AutoComplete-Clang is Non Sequitur


#1

Using a small c++ example

struct test
{
	int a, b, c, d;
}

test t;

Typing t. produces a huge list of gibberish. Starting with __amd64 and going on to list a lot of items that have nothing to do with my test struct. Members a, b, c, d are not even shown.

This happens wether I use geany or atom.

Any ideas of how to troubleshoot?


(url)


#2

Here’s the disconnect. You’re expecting Atom to be able to parse your code and know that t.a and company have meaning. Atom has no means of doing this built into it. It is a code editor, not an IDE, and all of the autocomplete packages I know of are nothing more than lists of keywords. Atom does have the capability to complete words that are found in the document you’re working in, but in order for it to do that, you have to start typing a word.

It sounds like you’re expecting Atom to be a drop-in replacement for Netbeans or Visual Studio, but with more flexibility. It is not. It has different strengths and being “dumber” regarding specific languages is a weakness.

I’m 90% sure that a package could solve this, but I don’t have any idea how it would go about doing that. You’d probably need for a compiler tool to not fully compile the code, but just spit out assigned variables into a list that could be referenced by the autocomplete dropdown.


#3

Thank you for taking the time to reply, DamnedScholar. I’m afraid that you aren’t understanding my problem.
As per the thread title this is about AutoComplete-Clang, an Atom plugin.


#4

Is clang capable of the behavior you’re looking for? If so, then you should take it up with the package authors.

And as I said, every autocomplete provider I’ve looked at is a list of keywords.


#5

This is the plugin home:


I have attempted to contact the author but have not heard back yet.
Clang is commonly used as a backend for code completion and delinting.
It’s very useful when learning a library a complex library with little documentation.


#6

The solution was simple. It’s only going to work with valid c++ code.
Adding a main function and putting my class instance inside fixed this issue.