EasyClangComplete icon indicating copy to clipboard operation
EasyClangComplete copied to clipboard

No completion in if statement

Open rdlaner opened this issue 9 years ago • 9 comments

I ran into a strange issue where, within a member function, auto-complete correctly identifies a member variable except when in an "if" statement. See below:

Correct when not using "if" statement: screen shot 2017-05-14 at 10 44 19 pm

Failure to auto-complete member variable "m_list" when using "if" statement: screen shot 2017-05-14 at 10 44 50 pm

Any thoughts on why this is happening?

rdlaner avatar May 15 '17 05:05 rdlaner

I believe the reason is that the if statement is not valid yet, so the translation unit created from an unsaved file is not really fully valid, so libclang cannot properly create the AST.

niosus avatar May 15 '17 07:05 niosus

Works perfectly fine here. Maybe configuration issue? (I have autocomplete_all=true and hide_default_completions=true)

simia avatar May 15 '17 08:05 simia

@simia I think it supports what I said before. It highly depends on the code being completed and if libclang was able to create the correct tree.

niosus avatar May 15 '17 08:05 niosus

Yes :)

simia avatar May 15 '17 08:05 simia

Anyway, I think I will close this for now, but we can continue discussion here if needed. @rdlaner maybe try it with autocomplete_all setting on as @simia has suggested?

niosus avatar May 15 '17 08:05 niosus

Thanks for the feedback. I tried it with autocomplete_all set to true and it was able to successfully autocomplete while in the "if" statement. One thing of note, when autocomplete_all was false, it didn't matter if the "if" statement was fully completed or only partially completed, it still did not auto complete.

The only other issue I'm having with this is, even though the member variable m_list is now autocompleting correctly, it will not autocomplete when I try to dereference the pointer: screen shot 2017-05-15 at 9 12 10 am

rdlaner avatar May 15 '17 16:05 rdlaner

Ah, stupid me. The original issue is because the plugin searches for a valid trigger before the cursor and ( is not one for now. I am unsure whether to consider it a bug or not at this time. I will reopen this will I am better decided.

Your new issue might be because of template use. If the compiler cannot guess the type used with your list in the current translation unit, it will not autocomplete at all.

niosus avatar May 15 '17 16:05 niosus

Got it, thanks @niosus!

rdlaner avatar May 15 '17 16:05 rdlaner

Ok, just adding "(" to triggers in user settings solves this. I have added this by default to the new version. Just make sure your old settings do not override the default ones. I will close it now.

niosus avatar May 16 '17 22:05 niosus