EasyClangComplete icon indicating copy to clipboard operation
EasyClangComplete copied to clipboard

Filter out constructors

Open Xecutor opened this issue 10 years ago • 9 comments

You definitely cannot call constructor with dot operator. MyObject obj; obj.MyObject(); have no sense. Completion proposal for classes with multiple overloaded constructors are cluttered with them.

Xecutor avatar Jun 20 '16 12:06 Xecutor

Yep, also the private members. This is a far reaching thing. Unfortunately, after a brief search I didn't find a way to control that with libclang or clang. At this stage I would like to refrain from parsing any code myself relying on the powers of clang for that.

niosus avatar Jun 24 '16 06:06 niosus

I don't think it is possible as of now. So will put it to backlog and if the time comes when I have not so much on my plate, I will try to look at it.

niosus avatar Sep 21 '16 23:09 niosus

I have found out, that I have not been using all the information that is given to me by libclang. It is definitely possible when using libclang and I will implement it at some point. Unfortunately, I still see no solution for this with binary completion.

niosus avatar Sep 25 '16 17:09 niosus

Care to elaborate on this a little bit? Maybe someone else might want to look into it.

merlinthered avatar Nov 16 '16 10:11 merlinthered

Yes, sure this sounds like a nice idea. It is fairly simple to have a hacked together version running. We would want to filter the completions by CursorKind, see Constructor for example.

This code has to go into this function where each c is actually a cursor and it has a CursorKind.

To make this sustainable, we need also to know which trigger triggered the completion, as we don't want to filter constructor when the user types :: and expects to see one, which needs subtle design changes. I do have this in mind for #130

It probably will land in a few coming weeks, when I am done with refactoring of the code (follow feature branches for progress).

niosus avatar Nov 16 '16 10:11 niosus

Hi, First of all - awesome plugin. Thanks a lot for it :) Disclaimer: Since my experience with libclang and this plugins code is about 2h I might be talking total rubish. I had a look at this yesterday. As far as I can tell c is not a cursor but CodeCompletionResult. It still has CursorKind available but it seems to be little limited (can't filter out private member functions, operators etc.). Maybe walking translation unit and getting cursors from it would be a suitable solution?

simia avatar Nov 28 '16 12:11 simia

@simia thanks a lot! Glad that you like it. As for what you say, it might be true, but at this point to check will take most of the time to actually implement it. I would expect that there is a (quite badly) specified way to get to AccessSpecifier from what we get as results. It would be so not logical it would be impossible :)

Let's see, maybe I will find some time to hack around with this. Also, everyone is free to fork and experiment with the how much info can we actually get from the completion results.

I am sorry, but at this point I really cannot elaborate more :(

niosus avatar Nov 28 '16 13:11 niosus

I will try to play with this a little and maybe make some pull requests if I succeed :)

simia avatar Nov 28 '16 13:11 simia

That would be awesome! :+1: Good luck and hope to see a pull request from you soon :)

niosus avatar Nov 28 '16 13:11 niosus