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


Java JCTree.hasTag方法代码示例

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


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

示例1: getElement

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
public Symbol getElement(TreePath path) {
    JCTree tree = (JCTree) path.getLeaf();
    Symbol sym = TreeInfo.symbolFor(tree);
    if (sym == null) {
        if (TreeInfo.isDeclaration(tree)) {
            for (TreePath p = path; p != null; p = p.getParentPath()) {
                JCTree t = (JCTree) p.getLeaf();
                if (t.hasTag(JCTree.Tag.CLASSDEF)) {
                    JCClassDecl ct = (JCClassDecl) t;
                    if (ct.sym != null) {
                        if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
                            attr.attribClass(ct.pos(), ct.sym);
                            sym = TreeInfo.symbolFor(tree);
                        }
                        break;
                    }
                }
            }
        }
    }
    return sym;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:JavacTrees.java

示例2: getElement

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Symbol getElement(TreePath path) {
    JCTree tree = (JCTree) path.getLeaf();
    Symbol sym = TreeInfo.symbolFor(tree);
    if (sym == null) {
        for (TreePath p = path; p != null; p = p.getParentPath()) {
            JCTree t = (JCTree) p.getLeaf();
            if (t.hasTag(JCTree.Tag.CLASSDEF)) {
                JCClassDecl ct = (JCClassDecl) t;
                if (ct.sym != null) {
                    if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
                        attr.attribClass(ct.pos(), ct.sym);
                        sym = TreeInfo.symbolFor(tree);
                    }
                    break;
                }
            }
        }
    }
    return sym;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:JavacTrees.java

示例3: copyEnvIfNeeded

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/**
 * Create a copy of Env if needed.
 */
Env<AttrContext> copyEnvIfNeeded(JCTree tree, Env<AttrContext> env) {
    if (!analyzerModes.isEmpty() &&
            !env.info.isSpeculative &&
            TreeInfo.isStatement(tree) &&
            !tree.hasTag(LABELLED)) {
        Env<AttrContext> analyzeEnv =
                env.dup(env.tree, env.info.dup(env.info.scope.dupUnshared(env.info.scope.owner)));
        analyzeEnv.info.returnResult = analyzeEnv.info.returnResult != null ?
                attr.new ResultInfo(analyzeEnv.info.returnResult.pkind,
                                    analyzeEnv.info.returnResult.pt) : null;
        return analyzeEnv;
    } else {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Analyzer.java

示例4: listClasses

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/**
 * From a list of top level trees, return the list of contained class definitions
 */
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
    ListBuffer<JCClassDecl> result = new ListBuffer<JCClassDecl>();
    for (JCCompilationUnit t : trees) {
        for (JCTree def : t.defs) {
            if (def.hasTag(JCTree.Tag.CLASSDEF))
                result.append((JCClassDecl)def);
        }
    }
    return result.toList();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:JavadocTool.java

示例5: collect

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private List<JCTree> collect(JCTree tree, List<JCTree> res) {
    tree = TreeInfo.skipParens(tree);
    if (tree.hasTag(PLUS) && tree.type.constValue() == null) {
        JCTree.JCBinary op = (JCTree.JCBinary) tree;
        if (op.operator.kind == MTH && op.operator.opcode == string_add) {
            return res
                    .appendList(collect(op.lhs, res))
                    .appendList(collect(op.rhs, res));
        }
    }
    return res.append(tree);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:StringConcat.java

示例6: AnalysisContext

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
AnalysisContext(JCTree tree, Env<AttrContext> env) {
    this.tree = tree;
    this.env = attr.copyEnv(env);
    /*  this is a temporary workaround that should be removed once we have a truly independent
     *  clone operation
     */
    if (tree.hasTag(VARDEF)) {
        // avoid redefinition clashes
        this.env.info.scope.remove(((JCVariableDecl)tree).sym);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:Analyzer.java

示例7: scan

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void scan(JCTree tree) {
    if (tree != null) {
        for (StatementAnalyzer<JCTree, JCTree> analyzer : analyzers) {
            if (analyzer.isEnabled() &&
                    tree.hasTag(analyzer.tag) &&
                    analyzer.match(tree)) {
                context.treesToAnalyzer.put(tree, analyzer);
                break; //TODO: cover cases where multiple matching analyzers are found
            }
        }
    }
    super.scan(tree);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Analyzer.java

示例8: listClasses

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/**
 * From a list of top level trees, return the list of contained class definitions
 */
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
    List<JCClassDecl> result = new ArrayList<>();
    for (JCCompilationUnit t : trees) {
        for (JCTree def : t.defs) {
            if (def.hasTag(JCTree.Tag.CLASSDEF))
                result.add((JCClassDecl)def);
        }
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JavadocTool.java

示例9: listClasses

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/**
 * From a list of top level trees, return the list of contained class definitions
 */
List<JCClassDecl> listClasses(List<JCCompilationUnit> trees) {
    ListBuffer<JCClassDecl> result = new ListBuffer<>();
    for (JCCompilationUnit t : trees) {
        for (JCTree def : t.defs) {
            if (def.hasTag(JCTree.Tag.CLASSDEF))
                result.append((JCClassDecl)def);
        }
    }
    return result.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JavadocTool.java

示例10: attribStat

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
    com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
    if (tree.hasTag(TRY)) {
        JCTry tryTree = (JCTry)tree;
        lineNumber = env.toplevel.lineMap.getLineNumber(tryTree.finalizer.endpos);
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:MissingLNTEntryForFinalizerTest.java

示例11: attribStat

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
    com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
    if (tree.hasTag(BREAK) || tree.hasTag(CONTINUE)) {
        lineNumber = env.toplevel.lineMap.getLineNumber(tree.pos);
    }
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:MissingLNTEntryForBreakContinueTest.java

示例12: isAnnotatedArray

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private boolean isAnnotatedArray(JCTree tree) {
    return tree.hasTag(ANNOTATED_TYPE) &&
                    ((JCAnnotatedType)tree).underlyingType.hasTag(TYPEARRAY);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:TreePosTest.java

示例13: mandatoryType

import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private boolean mandatoryType(JCTree that) {
    return that instanceof JCTree.JCExpression ||
            that.hasTag(VARDEF) ||
            that.hasTag(METHODDEF) ||
            that.hasTag(CLASSDEF);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:CheckAttributedTree.java


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