当前位置: 首页>>代码示例>>Java>>正文


Java MemberSelectTree.getIdentifier方法代码示例

本文整理汇总了Java中com.sun.source.tree.MemberSelectTree.getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java MemberSelectTree.getIdentifier方法的具体用法?Java MemberSelectTree.getIdentifier怎么用?Java MemberSelectTree.getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.source.tree.MemberSelectTree的用法示例。


在下文中一共展示了MemberSelectTree.getIdentifier方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
@Override
public Object visitMemberSelect(MemberSelectTree node, Object p) {
    String s = node.getExpression().toString();
    Name id = node.getIdentifier();
    if (id.contentEquals("this") || id.contentEquals("super")) {
        // this.sym || super.sym
        return Boolean.TRUE;
    }
    if (s.endsWith("this") || s.endsWith("super")) {
        return Boolean.TRUE;
    }
    return node;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:SideEffectVisitor.java

示例2: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
@Override
public Symbol visitMemberSelect(MemberSelectTree node, Env<AttrContext> env) {
    Symbol site = visit(node.getExpression(), env);
    if (site.kind == ERR)
        return site;
    Name name = (Name)node.getIdentifier();
    if (site.kind == PCK) {
        env.toplevel.packge = (PackageSymbol)site;
        return rs.findIdentInPackage(env, (TypeSymbol)site, name, TYP | PCK);
    } else {
        env.enclClass.sym = (ClassSymbol)site;
        return rs.findMemberType(env, site.asType(), name, (TypeSymbol)site);
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:Attr.java

示例3: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
@Override
public Symbol visitMemberSelect(MemberSelectTree node, Env<AttrContext> env) {
    Symbol site = visit(node.getExpression(), env);
    if (site.kind == ERR || site.kind == ABSENT_TYP)
        return site;
    Name name = (Name)node.getIdentifier();
    if (site.kind == PCK) {
        env.toplevel.packge = (PackageSymbol)site;
        return rs.findIdentInPackage(env, (TypeSymbol)site, name, TYP | PCK);
    } else {
        env.enclClass.sym = (ClassSymbol)site;
        return rs.findMemberType(env, site.asType(), name, (TypeSymbol)site);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Attr.java

示例4: visitMemberSelect

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Symbol visitMemberSelect(MemberSelectTree node, Env<AttrContext> env) {
    Symbol site = visit(node.getExpression(), env);
    if (site.kind == ERR || site.kind == ABSENT_TYP || site.kind == HIDDEN)
        return site;
    Name name = (Name)node.getIdentifier();
    if (site.kind == PCK) {
        env.toplevel.packge = (PackageSymbol)site;
        return rs.findIdentInPackage(env, (TypeSymbol)site, name,
                KindSelector.TYP_PCK);
    } else {
        env.enclClass.sym = (ClassSymbol)site;
        return rs.findMemberType(env, site.asType(), name, (TypeSymbol)site);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Attr.java

示例5: getStaticallyImportedElement

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
/**
 * special handling of static imports
 * see #196685
 * 
 */
private Element getStaticallyImportedElement(TreePath treePath, CompilationInfo info) {
    if (treePath.getLeaf().getKind() != Tree.Kind.MEMBER_SELECT) 
        return null;
        
    MemberSelectTree memberSelectTree = (MemberSelectTree) treePath.getLeaf();
    TreePath tp = treePath; 
    while (tp!=null) {
        Kind treeKind = tp.getLeaf().getKind();
        if (treeKind == Tree.Kind.IMPORT) {
            if (!((ImportTree) tp.getLeaf()).isStatic()) {
                return null;
            }
            break;    
        } else if (treeKind == Tree.Kind.MEMBER_SELECT || treeKind == Tree.Kind.IDENTIFIER) {
            tp = tp.getParentPath();
            continue;
        }
        return null;
    }
    
    Name simpleName = memberSelectTree.getIdentifier();
    if (simpleName == null) {
        return null;
    }
    TreePath declPath  = new TreePath(new TreePath(treePath, memberSelectTree), memberSelectTree.getExpression());
    TypeElement decl = (TypeElement) info.getTrees().getElement(declPath);
    if (decl==null) {
        return null;
    }
    
    for (Element e : info.getElements().getAllMembers((TypeElement) decl)) {
        if (!e.getModifiers().contains(Modifier.STATIC)) {
            continue;
        }
        if (!e.getSimpleName().equals(simpleName)) {
            continue;
        }
        return e;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:TreePathHandle.java

示例6: visitImport

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
@Override
public Void visitImport(ImportTree tree, Void d) {
    if (parseErrorInImport(tree)) {
        return super.visitImport(tree, null);
    }
    if (tree.getQualifiedIdentifier() == null ||
        tree.getQualifiedIdentifier().getKind() != Tree.Kind.MEMBER_SELECT) {
        return super.visitImport(tree, null);
    }
    MemberSelectTree qualIdent = (MemberSelectTree) tree.getQualifiedIdentifier();
    boolean assign = false;
    
    // static imports and star imports only use the qualifier part
    boolean star = isStar(tree);
    TreePath tp = tree.isStatic() || star ?
            new TreePath(new TreePath(getCurrentPath(), qualIdent), qualIdent.getExpression()) :
            new TreePath(getCurrentPath(), tree.getQualifiedIdentifier());
    Element decl = info.getTrees().getElement(tp);
    
    import2Highlight.put(tree, getCurrentPath());
    if (decl != null && !isErroneous(decl)) {
        if (!tree.isStatic()) {
            if (star) {
                List<TypeElement> types = ElementFilter.typesIn(decl.getEnclosedElements());
                for (TypeElement te : types) {
                    assign = true;
                    if (!element2Import.containsKey(te)) {
                        element2Import.put(te, tree);
                    }
                }
            } else {
                element2Import.put(decl, tree);
                importedBySingleImport.add(decl);
            }
        } else if (decl.getKind().isClass() || decl.getKind().isInterface()) {
            Name simpleName = star ? null : qualIdent.getIdentifier();

            for (Element e : info.getElements().getAllMembers((TypeElement) decl)) {
                if (!e.getModifiers().contains(Modifier.STATIC)) continue;
                if (simpleName != null && !e.getSimpleName().equals(simpleName)) {
                    continue;
                }
                if (!star || !element2Import.containsKey(e)) {
                    element2Import.put(e, tree);
                }
                assign = true;
            }
        }
    }
    if (!assign) {
        if (!tree.isStatic() && star) {
            unresolvablePackageImports.add(tree);
        } else {
            addUnresolvableImport(qualIdent.getIdentifier(), tree);
        }
    }
    super.visitImport(tree, null);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:60,代码来源:UnusedImports.java

示例7: computeFixes

import com.sun.source.tree.MemberSelectTree; //导入方法依赖的package包/类
protected static Fix computeFixes(CompilationInfo info, TreePath treePath, int[] bounds, int[] kind, String[] simpleName) {
    if (treePath.getLeaf().getKind() != Kind.MEMBER_SELECT) {
        return null;
    }
    MemberSelectTree mst = (MemberSelectTree)treePath.getLeaf();
    Tree expression = mst.getExpression();
    TreePath expr = new TreePath(treePath, expression);
    
    TypeMirror tm = info.getTrees().getTypeMirror(expr);
    if (!Utilities.isValidType(tm)) {
        return null;
    }
    Element el = info.getTypes().asElement(tm);
    if (el == null || (!el.getKind().isClass() && !el.getKind().isInterface())) {
        return null;
    }
    
    TypeElement type = (TypeElement)el;
    
    if (isError(type)) {
        return null;
    }
    
    Name idName = null;
    
    if (expression.getKind() == Kind.MEMBER_SELECT) {
        MemberSelectTree exprSelect = (MemberSelectTree)expression;
        idName = exprSelect.getIdentifier();
    }
    
    if (expression.getKind() == Kind.IDENTIFIER) {
        IdentifierTree idt = (IdentifierTree)expression;
        idName = idt.getName();
    }
    
    if (idName != null) {
        if (idName.equals(type.getSimpleName())) {
            return null;
        }
        if (idName.equals(type.getQualifiedName())) {
            return null;
        }
    }
    
    Element used = info.getTrees().getElement(treePath);
    
    if (used == null || !used.getModifiers().contains(Modifier.STATIC)) {
        return null;
    }
    
    if (isError(used)) {
        return null;
    }
    
    if (used.getKind().isField()) {
        kind[0] = 0;
    } else {
        if (used.getKind() == ElementKind.METHOD) {
            kind[0] = 1;
        } else {
            kind[0] = 2;
        }
    }
    
    simpleName[0] = used.getSimpleName().toString();
    
    return new FixImpl(info, expr, type).toEditorFix();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:69,代码来源:StaticAccess.java


注:本文中的com.sun.source.tree.MemberSelectTree.getIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。