[Qt-creator] C++ Plugin: Check word against C++ Code Model

Sergey Shambir sergey.shambir.auto at gmail.com
Fri May 10 15:45:55 CEST 2013

CppModelManager class is a singleton. Use CppModelManager::document to 
get target Document instance, than use iteration over global symbols 
with globalSymbolCount/globalSymbolAt or scopeaAt(line, column) to get 

Scopes form a chain, you can get enclosing scope with 
Symbol::enclosingScope, and Scope is subclass of Symbol. Probably exact 
position of comment is in global or namespace scope, so use some 
heuristic like scanning until non-comment token appear.

10.05.13, 17:27, Carel Combrink ?????:
> Hi,
> I am busy with a Qt Creator plugin for the C++ Editor.
> How do I use the C++ code model to check if a word is a function, 
> class, etc or 'just a word'? The plugin parses the comment tokens in a 
> C++ Editor.
> For an example: I have the following code:
> /* This is function myFunction */
> void myFunction(int arg1);
> Parsing the comment gives me 4 words ("This", "is", "function" and 
> "myFunction"). How do I know that "This" is just a word while 
> "myFunction" is a token (part of the code model) in the scope of the 
> comment?
> My current, initial implementation checks a word against all tokens in 
> the file that the comment appears in. I would like to make use of the 
> code model instead, if possible.
> Regards,
> Carel
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20130510/8d415ea3/attachment.html>

More information about the Qt-creator mailing list