[Qt-creator] Multiple Symbols in Scope for same Namespace

Roberto Raggi roberto.raggi at trolltech.com
Thu Mar 12 11:55:46 CET 2009


On 12.03.2009, at 10:21, Marek Jasovsky wrote:

> Hi, would it be possible to help us with some small hints / code  
> snippets how we can fetch information about symbols / scope from  
> annotated ast?

for example, look at the declaration of FunctionDefinitionAST in  
AST.h. FunctionDefinitionAST has an attribute called "symbol", you can  
use that attribute to get the info you need from the symbol table  
(e.g. the function's scope, the function name, and so on..)

class MyVisitor: protected ASTVisitor {
  // ...

protected:
    virtual bool visit(FunctionDefinitionAST *ast) {
       Function *fun = ast->symbol->asFunction();
       qDebug() << "scope:" << fun->scope() << "name = " << fun->name();
       qDebug() << "coordinates:" << fun->line() << fun->column();
       return false;
    }
};


ciao robe


>
> or maybe point to some of your code within tests that does this



>
> Thanks & regards
>
> Marek
>
> 2009/3/12 Roberto Raggi <roberto.raggi at trolltech.com>
> Hi Bertjan,
>
> On 10.03.2009, at 20:43, Bertjan Broeksema wrote:
> > I wrote a simple Scope dumper to be able to have a quick look at the
> > result
> > and noticed a strange thing. It seems that there is no check to see
> > if a
> > namespace already is defined in the current scope and it is just
> > added without
>
> Yep, but this is a feature not a bug :-) The semantic pass in Creator
> is optimized for our use case (incremental updates of C++ documents),
> that's why we use a sort of forest of trees and not one "central"
> database of symbols. But I understand that in your case our design can
> be quite annoying. By the way, if you want you can write a simple pass
> that will merge the namespace symbols. Take a look at tests/manual/
> binding/ for an example of how to do it.
>
> http://labs.trolltech.com/gitweb?p=qt-creator;a=blob;f=tests/manual/binding/main.cpp;h=7165e3860755d4e1386da27076a371fa05dbe9ca;hb=refs/heads/master
>
> ciao robe
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-creator

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-creator-old/attachments/20090312/91258e56/attachment.html 


More information about the Qt-creator-old mailing list