本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.accept方法的典型用法代码示例。如果您正苦于以下问题:Java JCTree.accept方法的具体用法?Java JCTree.accept怎么用?Java JCTree.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.tree.JCTree
的用法示例。
在下文中一共展示了JCTree.accept方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseRClass
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private void parseRClass(String respectivePackageName, String rClass) {
Element element;
try {
element = elementUtils.getTypeElement(rClass);
} catch (MirroredTypeException mte) {
element = typeUtils.asElement(mte.getTypeMirror());
}
JCTree tree = (JCTree) trees.getTree(element);
if (tree != null) { // tree can be null if the references are compiled types and not source
IdScanner idScanner = new IdScanner(symbols, elementUtils.getPackageOf(element)
.getQualifiedName().toString(), respectivePackageName);
tree.accept(idScanner);
} else {
parseCompiledR(respectivePackageName, (TypeElement) element);
}
}
示例2: parseRClass
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private void parseRClass(String respectivePackageName, String rClass) {
Element element;
try {
element = elementUtils.getTypeElement(rClass);
} catch (MirroredTypeException mte) {
element = typeUtils.asElement(mte.getTypeMirror());
}
JCTree tree = (JCTree) trees.getTree(element);
if (tree != null) {
IdScanner idScanner = new IdScanner(symbols, elementUtils.getPackageOf(element)
.getQualifiedName().toString(), respectivePackageName);
tree.accept(idScanner);
} else {
parseCompiledR(respectivePackageName, (TypeElement) element);
}
}
示例3: scan
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public void scan(JCTree tree) {
if (tree == null ||
excludeTags.contains(treeUtil.nameFromTag(tree.getTag()))) {
return;
}
Info self = new Info(tree, endPosTable);
if (mandatoryType(tree)) {
check(tree.type != null,
"'null' field 'type' found in tree ", self);
if (tree.type==null)
Thread.dumpStack();
}
Field errField = checkFields(tree);
if (errField!=null) {
check(false,
"'null' field '" + errField.getName() + "' found in tree ", self);
}
Info prevEncl = encl;
encl = self;
tree.accept(this);
encl = prevEncl;
}
示例4: width
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private void width(JCTree tree, int prec) {
if (tree != null) {
int prevPrec = this.prec;
this.prec = prec;
tree.accept(this);
this.prec = prevPrec;
}
}
示例5: parseRClass
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
private void parseRClass(String respectivePackageName, String rClass) {
Element element;
try {
element = elementUtils.getTypeElement(rClass);
} catch (MirroredTypeException mte) {
element = typeUtils.asElement(mte.getTypeMirror());
}
JCTree tree = (JCTree) trees.getTree(element);
if (tree != null) { // tree can be null if the references are compiled types and not source
IdScanner idScanner = new IdScanner(symbols, elementUtils.getPackageOf(element).getQualifiedName().toString(), respectivePackageName, supportedTypes);
tree.accept(idScanner);
} else {
parseCompiledR(respectivePackageName, (TypeElement) element);
}
}
示例6: classEnter
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/** Visitor method: enter all classes in given tree, catching any
* completion failure exceptions. Return the tree's type.
*
* @param tree The tree to be visited.
* @param env The environment visitor argument.
*/
Type classEnter(JCTree tree, Env<AttrContext> env) {
Env<AttrContext> prevEnv = this.env;
try {
this.env = env;
tree.accept(this);
return result;
} catch (CompletionFailure ex) {
return chk.completionError(tree.pos(), ex);
} finally {
this.env = prevEnv;
}
}
示例7: attribArg
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
/**
* Main entry point for attributing an argument with given tree and attribution environment.
*/
Type attribArg(JCTree tree, Env<AttrContext> env) {
Env<AttrContext> prevEnv = this.env;
try {
this.env = env;
tree.accept(this);
return result;
} finally {
this.env = prevEnv;
}
}
示例8: printTree
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
protected void printTree(String label, JCTree tree) {
if (tree == null) {
printNull(label);
} else {
indent();
String ext;
try {
ext = tree.getKind().name();
} catch (Throwable t) {
ext = "n/a";
}
out.print(label + ": " + info(tree.getClass(), tree.getTag(), ext));
if (showPositions) {
// We can always get start position, but to get end position
// and/or line+offset, we would need a JCCompilationUnit
out.print(" pos:" + tree.pos);
}
if (showTreeTypes && tree.type != null)
out.print(" type:" + toString(tree.type));
Symbol sym;
if (showTreeSymbols && (sym = TreeInfo.symbolFor(tree)) != null)
out.print(" sym:" + toString(sym));
out.println();
indent(+1);
if (showSrc) {
indent();
out.println("src: " + Pretty.toSimpleString(tree, maxSrcLength));
}
tree.accept(treeVisitor);
indent(-1);
}
}
示例9: hasDanglingElse
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
public boolean hasDanglingElse(JCTree t) {
if(t==null) return false;
foundDanglingElse = false;
t.accept(this);
return foundDanglingElse;
}
示例10: estimateWidth
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
public int estimateWidth(JCTree t, int maxwidth) {
width = 0;
this.maxwidth = maxwidth;
t.accept(this);
return width;
}
示例11: scan
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
public void scan(JCTree tree) {
// short circuit scan when end result is definitely false
if (maybeConstantExpr && tree != null)
tree.accept(this);
}
示例12: visitTree
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public void visitTree(JCTree that) {
//delegates to Attr
that.accept(attr);
result = attr.result;
}
示例13: scan
import com.sun.tools.javac.tree.JCTree; //导入方法依赖的package包/类
@Override
public void scan(JCTree tree) {
if (tree == null)
return;
Info self = new Info(tree, endPosTable);
if (check(encl, self)) {
// Modifiers nodes are present throughout the tree even where
// there is no corresponding source text.
// Redundant semicolons in a class definition can cause empty
// initializer blocks with no positions.
if ((self.tag == MODIFIERS || self.tag == BLOCK)
&& self.pos == NOPOS) {
// If pos is NOPOS, so should be the start and end positions
check("start == NOPOS", encl, self, self.start == NOPOS);
check("end == NOPOS", encl, self, self.end == NOPOS);
} else {
// For this node, start , pos, and endpos should be all defined
check("start != NOPOS", encl, self, self.start != NOPOS);
check("pos != NOPOS", encl, self, self.pos != NOPOS);
check("end != NOPOS", encl, self, self.end != NOPOS);
// The following should normally be ordered
// encl.start <= start <= pos <= end <= encl.end
// In addition, the position of the enclosing node should be
// within this node.
// The primary exceptions are for array type nodes, because of the
// need to support legacy syntax:
// e.g. int a[]; int[] b[]; int f()[] { return null; }
// and because of inconsistent nesting of left and right of
// array declarations:
// e.g. int[][] a = new int[2][];
if (!(encl.tag == REFERENCE && self.tag == ANNOTATED_TYPE)) {
check("encl.start <= start", encl, self, encl.start <= self.start);
}
check("start <= pos", encl, self, self.start <= self.pos);
if (!( (self.tag == TYPEARRAY ||
isAnnotatedArray(self.tree))
&& (encl.tag == VARDEF ||
encl.tag == METHODDEF ||
encl.tag == TYPEARRAY ||
isAnnotatedArray(encl.tree))
||
encl.tag == ANNOTATED_TYPE && self.tag == SELECT
||
encl.tag == REFERENCE && self.tag == ANNOTATED_TYPE
)) {
check("encl.pos <= start || end <= encl.pos",
encl, self, encl.pos <= self.start || self.end <= encl.pos);
}
check("pos <= end", encl, self, self.pos <= self.end);
if (!( (self.tag == TYPEARRAY || isAnnotatedArray(self.tree)) &&
(encl.tag == TYPEARRAY || isAnnotatedArray(encl.tree))
||
encl.tag == MODIFIERS && self.tag == ANNOTATION
) ) {
check("end <= encl.end", encl, self, self.end <= encl.end);
}
}
}
Info prevEncl = encl;
encl = self;
tree.accept(this);
encl = prevEncl;
}