English 中文(简体)
为什么一些可声明的解决 具有约束力的回报无效,但其他权利则不在此限。
原标题:Why some VariableDeclaration resolveBinding returns null but others does not

我正在开发一种ec滴式pl滴,以分析 j源代码。 我verse倒整个AST树,并写一名访问者,访问每个变数的宣言,我注意到一些变数,“解除约束性”回报是可加固的事例,但其他情况并非如此。 我不能区分他们。 BTW:我设立了STParser.setKind(K_COMPILATION_UNIT)并设立了ResolveBelles(true)。 我的法典如下:

@Override
public boolean visit(VariableDeclarationStatement vStatement) {
    Type theType = vStatement.getType();
    for(Iterator iterator = vStatement.fragments().iterator();iterator.hasNext();){
        VariableDeclarationFragment fragment = (VariableDeclarationFragment)iterator.next();
        IVariableBinding binding = fragment.resolveBinding();           
        if(binding !=null){
            ITypeBinding tBinding =  binding.getType();
            if(tBinding !=null){
                // if there is ArrayType, get the root type
                while(tBinding.getComponentType()!=null){
                    tBinding = tBinding.getComponentType();
                }
                System.out.println("USING BINDING VARIABLE CLASS IS: " + tBinding.getQualifiedName());  
            }

        }                       
    }
}

我的问题是:我如何区分能够与不能解决约束性问题的可变宣言?

许多预告

问题回答

http://www.un.org/Depts/DGACM/index_french.htm

Variable declaration fragment AST node type, used in field declarations, local variable declarations, and ForStatement initializers. It contrast to SingleVariableDeclaration, fragments are missing the modifiers and the type; these are located in the fragment s parent node.

从<代码>获得约束的类型 缩略语





相关问题
Eclipse JDT API documentation, preferrably CHM format [closed]

I am going to need to do some development with Eclipse JDT while on holiday. I will be off-line for the most of the time and therefore I will not be able to access the [Eclipse JDT API documentation] (...

Weird JavaCore IType cache problem

I m developing a plugin that takes all enums in workspace that implements certain interface (IDomain) parses the code (Using AST) does some modification over the enum and marks it as processed with an ...

Runtime error using the Eclipse Abstract Syntax Tree

I m trying to use AST parser in a non-plugin environment. The code compiles, but I get the following runtime error: Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/...

How do i find the project of the contents of an ITextViewer?

I m trying to implement a HyperlinkDetector for an Eclipse plug-in and the callback method is giving me an ITextViewer to work with. How do i get the project, IPath or IFile of the viewer s IDocument?...

热门标签