Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Getting the right IBinding for multiple types with the same name faster

Suppose I have multiple class definitions with the same name in my project, when I see an instance of that class, let’s say as a local variable in my case, I’d like to be able to resolve it to the right class type (and IBinding). Of course, only one class is visible in that scope where that variable is declared. I use IASTName#resolveBinding that returns IVariable for which getType returns the ICPPClassType that correspond to the wrong class.  I found that the reason is in how AST was created. When I use


IASTTranslationUnit ast = tu.getAST(index,ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);

it started to work, but is quite expensive.


Before I used IASTTranslationUnit ast = tu.getAST(index,ITranslationUnit.AST_SKIP_INDEXED_HEADERS);

but it didn’t work.


Do you see any other (less expensive) way to achieve what I want? Index doesn’t seem to be of help as I am dealing with function local variables. However, the type itself should be in the index, but it will show two types if I just search for it by name.  I thought I’d be able to skip all the function bodies (using ITranslationUnit.AST_SKIP_FUNCTION_BODIES) to speed AST construction up, but then it will skip my function as well K


Thank you,


Back to the top