本文整理汇总了Java中com.sun.tools.javac.tree.DCTree.DCReference类的典型用法代码示例。如果您正苦于以下问题:Java DCReference类的具体用法?Java DCReference怎么用?Java DCReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DCReference类属于com.sun.tools.javac.tree.DCTree包,在下文中一共展示了DCReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitReference
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override
public Void visitReference(ReferenceTree node, Void p) {
//TODO: should use formatting settings:
DCReference refNode = (DCReference) node;
if (refNode.qualifierExpression != null) {
print(refNode.qualifierExpression);
}
if (refNode.memberName != null) {
print("#");
print(refNode.memberName);
}
if (refNode.paramTypes != null) {
print("(");
boolean first = true;
for (Tree param : refNode.paramTypes) {
if (!first) print(", ");
print(param.toString());
first = false;
}
print(")");
}
return null;
}
示例2: rewriteChildren
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
protected final ReferenceTree rewriteChildren(ReferenceTree tree) {
DCReference refTree = (DCReference) tree;
ReferenceTree value = tree;
ExpressionTree classReference = (ExpressionTree) translate(refTree.qualifierExpression);
List<? extends Tree> methodParameters = translate(refTree.paramTypes);
if(classReference != refTree.qualifierExpression || methodParameters != refTree.paramTypes) {
value = make.Reference(classReference, refTree.memberName, methodParameters);
}
return value;
}
示例3: findNameSpan
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
/**Find span of the name in the DocTree's reference tree (see {@link #getReferenceName(com.sun.source.util.DocTreePath)}
* identifier in the source. Returns starting and ending offset of the name in
* the source code that was parsed (ie. {@link CompilationInfo.getText()}, which
* may differ from the positions in the source document if it has been already
* altered.
*
* @param ref reference for which the identifier should be found
* @return the span of the name, or null if cannot be found
* @since 0.124
*/
public int[] findNameSpan(DocCommentTree docTree, ReferenceTree ref) {
Name name = ((DCReference) ref).memberName;
if (name == null || !SourceVersion.isIdentifier(name)) {
//names like "<error>", etc.
return null;
}
int pos = (int) info.getDocTrees().getSourcePositions().getStartPosition(info.getCompilationUnit(), docTree, ref);
if (pos < 0)
return null;
TokenSequence<JavaTokenId> tokenSequence = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());
tokenSequence.move(pos);
if (!tokenSequence.moveNext() || tokenSequence.token().id() != JavaTokenId.JAVADOC_COMMENT) return null;
TokenSequence<JavadocTokenId> jdocTS = tokenSequence.embedded(JavadocTokenId.language());
jdocTS.move(pos);
boolean wasNext;
while ((wasNext = jdocTS.moveNext()) && jdocTS.token().id() != JavadocTokenId.HASH)
;
if (wasNext && jdocTS.moveNext()) {
if (jdocTS.token().id() == JavadocTokenId.IDENT &&
name.contentEquals(jdocTS.token().text())) {
return new int[] {
jdocTS.offset(),
jdocTS.offset() + jdocTS.token().length()
};
}
}
return null;
}
示例4: getReferenceClass
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
/**Find the type (the part before {@code #}) that is being referenced by the given {@link ReferenceTree}.
*
* @param path the leaf must be {@link ReferenceTree}
* @return the referred type, or {@code null} if none.
* @since 0.124
*/
public @CheckForNull ExpressionTree getReferenceClass(@NonNull DocTreePath path) {
TreePath tp = path.getTreePath();
DCReference ref = (DCReference) path.getLeaf();
((DocTrees) this.info.getTrees()).getElement(path);
// was:
// ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
return (ExpressionTree) ref.qualifierExpression;
}
示例5: getReferenceParameters
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
/**Find the parameters that are specified in the given {@link ReferenceTree}.
*
* @param path the leaf must be {@link ReferenceTree}
* @return the parameters for the referred method, or {@code null} if none.
* @since 0.124
*/
public @CheckForNull List<? extends Tree> getReferenceParameters(@NonNull DocTreePath path) {
TreePath tp = path.getTreePath();
DCReference ref = (DCReference) path.getLeaf();
((DocTrees) this.info.getTrees()).getElement(path);
// was:
// ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
return ref.paramTypes;
}
示例6: getElement
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override
public Element getElement(DocTreePath path) {
DocTree forTree = path.getLeaf();
if (forTree instanceof DCReference)
return attributeDocReference(path.getTreePath(), ((DCReference) forTree));
if (forTree instanceof DCIdentifier) {
if (path.getParentPath().getLeaf() instanceof DCParam) {
return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
}
}
return null;
}
示例7: newExceptionTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCThrows newExceptionTree(ReferenceTree name, List<? extends DocTree> description) {
// TODO: verify the reference is just to a type (not a field or method)
DCThrows tree = new DCThrows(Kind.EXCEPTION, (DCReference) name, cast(description));
tree.pos = pos;
return tree;
}
示例8: newReferenceTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCReference newReferenceTree(String signature) {
try {
ReferenceParser.Reference ref = referenceParser.parse(signature);
DCReference tree = new DCReference(signature, ref.qualExpr, ref.member, ref.paramTypes);
tree.pos = pos;
return tree;
} catch (ReferenceParser.ParseException e) {
throw new IllegalArgumentException("invalid signature", e);
}
}
示例9: newThrowsTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCThrows newThrowsTree(ReferenceTree name, List<? extends DocTree> description) {
// TODO: verify the reference is just to a type (not a field or method)
DCThrows tree = new DCThrows(Kind.THROWS, (DCReference) name, cast(description));
tree.pos = pos;
return tree;
}
示例10: newValueTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCValue newValueTree(ReferenceTree ref) {
// TODO: verify the reference is to a constant value
DCValue tree = new DCValue((DCReference) ref);
tree.pos = pos;
return tree;
}
示例11: getElement
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Element getElement(DocTreePath path) {
DocTree forTree = path.getLeaf();
if (forTree instanceof DCReference)
return attributeDocReference(path.getTreePath(), ((DCReference) forTree));
if (forTree instanceof DCIdentifier) {
if (path.getParentPath().getLeaf() instanceof DCParam) {
return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
}
}
return null;
}
示例12: diffReference
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
private int diffReference(DCDocComment doc, DCReference oldT, DCReference newT, int[] elementBounds) {
printer.print(newT);
return elementBounds[1];
}
示例13: newLinkTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCLink newLinkTree(ReferenceTree ref, List<? extends DocTree> label) {
DCLink tree = new DCLink(Kind.LINK, (DCReference) ref, cast(label));
tree.pos = pos;
return tree;
}
示例14: newLinkPlainTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCLink newLinkPlainTree(ReferenceTree ref, List<? extends DocTree> label) {
DCLink tree = new DCLink(Kind.LINK_PLAIN, (DCReference) ref, cast(label));
tree.pos = pos;
return tree;
}
示例15: newProvidesTree
import com.sun.tools.javac.tree.DCTree.DCReference; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public DCProvides newProvidesTree(ReferenceTree name, List<? extends DocTree> description) {
DCProvides tree = new DCProvides((DCReference) name, cast(description));
tree.pos = pos;
return tree;
}