當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。