PDA

View Full Version : Use Code Model in QT creator plugin



AngeloFrancabandiera
15th January 2020, 14:16
Hi,
I'm trying to write a plugin for Qt creator that lists the functions that are declarated in a '.c' or '.h' file. I'm doing this to speed up the useless practise required by my company to list in the header of each file the list of exported and internal functions.
I have written several plugin for Qt creator, but this is the first time I need the code model. I'd rather NOT to use CLang code model.

I have tried calling in a loop the function "CPlusPlus::Document::functionAt" but this only finds implemented functions; for me it's required to also include function prototypes of header files.

Then I have tried with CPlusPlus::Document::scopeAt, looping the member of the full file scope. Here the problem is that CPlusPlus::Symbol::asDeclaration does not make any difference between functions declaration and file scope variable declarations.

Any idea about how to isolate function declarations?

Thank you

d_stranz
15th January 2020, 18:40
Any idea about how to isolate function declarations?

If CPlusPlus:: Symbol:: asDeclaration returns all declarations in a header file, then you should be able to distinguish between variables and functions by looking for a pair of parentheses, no?

AngeloFrancabandiera
16th January 2020, 08:25
If CPlusPlus:: Symbol:: asDeclaration returns all declarations in a header file, then you should be able to distinguish between variables and functions by looking for a pair of parentheses, no?

Actually CPlusPlus:: Symbol is an object from which I can extract the 'nameId' (which never contains parentheses), but I can't retrieve the full signature.