本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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();
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}