本文整理汇总了Java中com.sun.tools.javac.tree.DCTree类的典型用法代码示例。如果您正苦于以下问题:Java DCTree类的具体用法?Java DCTree怎么用?Java DCTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DCTree类属于com.sun.tools.javac.tree包,在下文中一共展示了DCTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doAccept
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
private void doAccept(DCTree t) {
// int start = toString().length();
// if (!handlePossibleOldTrees(Collections.singletonList(t), false)) {
t.accept(this, null);
// }
// int end = toString().length();
// System.err.println("t: " + t);
// System.err.println("thr=" + System.identityHashCode(t));
// Object tag = tree2Tag != null ? tree2Tag.get(t) : null;
//
// if (tag != null) {
// tag2Span.put(tag, new int[]{start + initialOffset, end + initialOffset});
// }
}
示例2: visitStartElement
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitStartElement(StartElementTree node, Void p) {
print("<");
print(node.getName());
java.util.List<? extends DocTree> attrs = node.getAttributes();
if (!attrs.isEmpty()) {
print(" ");
for (DocTree docTree : attrs) {
doAccept((DCTree)docTree);
}
DocTree last = attrs.get(attrs.size() - 1);
if (node.isSelfClosing() && last instanceof AttributeTree
&& ((AttributeTree) last).getValueKind() == ValueKind.UNQUOTED)
print(" ");
}
if (node.isSelfClosing())
print("/");
print(">");
return null;
}
示例3: visitParam
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitParam(ParamTree node, Void p) {
printTagName(node);
needSpace();
if(node.isTypeParameter()) {
print('<');
}
doAccept((DCTree)node.getName());
if(node.isTypeParameter()) {
print('>');
}
if(!node.getDescription().isEmpty()) {
needSpace();
}
for (DocTree docTree : node.getDescription()) {
doAccept((DCTree)docTree);
}
return null;
}
示例4: parse
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
public DCDocComment parse() {
String c = comment.getText();
buf = new char[c.length() + 1];
c.getChars(0, c.length(), buf, 0);
buf[buf.length - 1] = EOI;
buflen = buf.length - 1;
bp = -1;
nextChar();
List<DCTree> body = blockContent();
List<DCTree> tags = blockTags();
int pos = !body.isEmpty()
? body.head.pos
: !tags.isEmpty() ? tags.head.pos : Position.NOPOS;
DCDocComment dc = m.at(pos).newDocCommentTree(comment, body, tags);
return dc;
}
示例5: qualifyDocReference
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
/**
* Fully qualifies a javadoc reference, e.g. for replacing {@code {@link List}} with {@code {@link
* java.util.List}}
*
* @param fix the fix builder to add to
* @param docPath the path to a {@link DCTree.DCReference} element
*/
public static void qualifyDocReference(
SuggestedFix.Builder fix, DocTreePath docPath, VisitorState state) {
DocTree leaf = docPath.getLeaf();
checkArgument(
leaf.getKind() == DocTree.Kind.REFERENCE,
"expected a path to a reference, got %s instead",
leaf.getKind());
DCTree.DCReference reference = (DCTree.DCReference) leaf;
Symbol sym = (Symbol) JavacTrees.instance(state.context).getElement(docPath);
if (sym == null) {
return;
}
String refString = reference.toString();
String qualifiedName;
int idx = refString.indexOf('#');
if (idx >= 0) {
qualifiedName = sym.owner.getQualifiedName() + refString.substring(idx, refString.length());
} else {
qualifiedName = sym.getQualifiedName().toString();
}
replaceDocTree(fix, docPath, qualifiedName);
}
示例6: matchClass
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Description matchClass(ClassTree tree, final VisitorState state) {
final DCTree.DCDocComment comment =
((JCTree.JCCompilationUnit) state.getPath().getCompilationUnit())
.docComments.getCommentTree((JCTree) tree);
if (comment == null) {
return Description.NO_MATCH;
}
final SuggestedFix.Builder fix = SuggestedFix.builder();
new DocTreePathScanner<Void, Void>() {
@Override
public Void visitLink(LinkTree node, Void aVoid) {
SuggestedFixes.qualifyDocReference(
fix, new DocTreePath(getCurrentPath(), node.getReference()), state);
return null;
}
}.scan(new DocTreePath(state.getPath(), comment), null);
if (fix.isEmpty()) {
return Description.NO_MATCH;
}
return describeMatch(tree, fix.build());
}
示例7: rewriteChildren
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
protected final UnknownBlockTagTree rewriteChildren(UnknownBlockTagTree tree) {
UnknownBlockTagTree value = tree;
List<? extends DocTree> content = translateDoc(tree.getContent());
if (content != tree.getContent()) {
value = make.UnknownBlockTag(((DCTree.DCUnknownBlockTag) tree).name, tree.getContent());
}
return value;
}
示例8: print
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
public void print(DCTree t, boolean noMarginAfter) {
if (t == null) return;
blankLines(t, true, false);
toLeftMargin();
doAccept(t);
blankLines(t, false, noMarginAfter);
}
示例9: blankLines
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
/**
* The following tags are block-tags
* <ul>
* <li>@author (classes and interfaces only, required)</li>
* <li>@version (classes and interfaces only, required. See footnote 1)</li>
* <li>@param (methods and constructors only)</li>
* <li>@return (methods only)</li>
* <li>@exception (</li>
* <li>@throws is a synonym added in Javadoc 1.2)</li>
* <li>@see</li>
* <li>@since</li>
* <li>@serial (or @serialField or @serialData)</li>
* <li>@deprecated (see How and When To Deprecate APIs)</li>
* </ul>
*/
private void blankLines(DCTree tree, boolean before, boolean suppressMarginAfter) {
if (tree == null) {
return;
}
switch (tree.getKind()) {
case AUTHOR:
case DEPRECATED:
case EXCEPTION:
case PARAM:
case RETURN:
case SEE:
case SERIAL:
case SERIAL_DATA:
case SERIAL_FIELD:
case SINCE:
case THROWS:
case UNKNOWN_BLOCK_TAG:
case VERSION:
if(before) {
newline();
toLeftMargin();
print(" * ");
}
break;
case DOC_COMMENT:
if(before) {
blankline();
} else {
newline();
}
if (!suppressMarginAfter) {
toLeftMargin();
}
break;
default:
break;
}
}
示例10: visitAttribute
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitAttribute(AttributeTree node, Void p) {
print(node.getName());
String quote;
switch (node.getValueKind()) {
case EMPTY:
return null;
case UNQUOTED:
quote = "";
break;
case SINGLE:
quote = "'";
break;
case DOUBLE:
quote = "\"";
break;
default:
throw new AssertionError();
}
print("=");
print(quote);
for (DocTree docTree : node.getValue()) {
doAccept((DCTree)docTree);
}
print(quote);
return null;
}
示例11: visitAuthor
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitAuthor(AuthorTree node, Void p) {
printTagName(node);
print(" ");
for (DocTree docTree : node.getName()) {
doAccept((DCTree)docTree);
}
return null;
}
示例12: visitDeprecated
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitDeprecated(DeprecatedTree node, Void p) {
printTagName(node);
if (!node.getBody().isEmpty()) {
needSpace();
for (DocTree docTree : node.getBody()) {
doAccept((DCTree)docTree);
}
}
return null;
}
示例13: visitHidden
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitHidden(HiddenTree node, Void p) {
printTagName(node);
if (!node.getBody().isEmpty()) {
print(" ");
for (DocTree docTree : node.getBody()) {
doAccept((DCTree)docTree);
}
}
return null;
}
示例14: visitIndex
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitIndex(IndexTree node, Void p) {
print("{");
printTagName(node);
print(" ");
doAccept((DCTree)node.getSearchTerm());
if (!node.getDescription().isEmpty()) {
print(" ");
for (DocTree docTree : node.getDescription()) {
doAccept((DCTree)docTree);
}
}
print("}");
return null;
}
示例15: visitLink
import com.sun.tools.javac.tree.DCTree; //导入依赖的package包/类
@Override
public Void visitLink(LinkTree node, Void p) {
print("{");
printTagName(node);
print(" ");
doAccept((DCTree)node.getReference());
if (!node.getLabel().isEmpty()) {
print(" ");
for (DocTree docTree : node.getLabel()) {
doAccept((DCTree)docTree);
}
}
print("}");
return null;
}