本文整理汇总了Java中com.sun.source.doctree.TextTree类的典型用法代码示例。如果您正苦于以下问题:Java TextTree类的具体用法?Java TextTree怎么用?Java TextTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextTree类属于com.sun.source.doctree包,在下文中一共展示了TextTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkReference
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
void checkReference(ReferenceTree tree, List<? extends DocTree> label) {
String sig = tree.getSignature();
Element found = trees.getElement(new DocTreePath(getCurrentPath(), tree));
if (found == null) {
System.err.println(sig + " NOT FOUND");
} else {
System.err.println(sig + " found " + found.getKind() + " " + found);
}
String expect = "UNKNOWN";
if (label.size() > 0 && label.get(0) instanceof TextTree)
expect = ((TextTree) label.get(0)).getBody();
if (!expect.equalsIgnoreCase(found == null ? "bad" : found.getKind().name())) {
error(tree, "Unexpected value found: " + found +", expected: " + expect);
}
}
示例2: rewriteChildren
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
protected final LiteralTree rewriteChildren(LiteralTree tree) {
LiteralTree value = tree;
TextTree body = (TextTree) translate(tree.getBody());
if (body != tree.getBody()) {
if(tree.getKind() == DocTree.Kind.CODE) {
value = make.Code(body);
} else {
value = make.Literal(body);
}
}
return value;
}
示例3: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override
public DocTree visitText(TextTree node, Element p) {
if(renameInComments && refactoring.getContext().lookup(RenamePropertyRefactoringPlugin.class) == null) {
DocTreePath currentDocPath = getCurrentDocPath();
if(p.getKind() == ElementKind.PARAMETER) {
VariableElement var = (VariableElement) p;
Element method = workingCopy.getTrees().getElement(currentDocPath.getTreePath());
if(!var.getEnclosingElement().equals(method)) {
return super.visitText(node, p);
}
}
String originalName = getOldSimpleName(p);
if(node.getBody().contains(originalName)) {
StringBuilder text = new StringBuilder(node.getBody());
for (int index = text.indexOf(originalName); index != -1; index = text.indexOf(originalName, index + 1)) {
if (index > 0 && Character.isJavaIdentifierPart(text.charAt(index - 1))) {
continue;
}
if ((index + originalName.length() < text.length()) && Character.isJavaIdentifierPart(text.charAt(index + originalName.length()))) {
continue;
}
text.delete(index, index + originalName.length());
text.insert(index, newName);
}
if(!node.getBody().contentEquals(text)) {
TextTree newText = make.Text(text.toString());
rewrite(currentDocPath.getTreePath().getLeaf(), node, newText);
}
}
}
return super.visitText(node, p);
}
示例4: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override
public DocTree visitText(TextTree node, Element p) {
if(searchComment) {
DocTrees trees = info.getDocTrees();
DocSourcePositions sourcePositions = trees.getSourcePositions();
DocTreePath currentDocPath = getCurrentPath();
if(toFind.getKind() == ElementKind.PARAMETER) {
VariableElement var = (VariableElement) toFind;
Element method = trees.getElement(currentDocPath);
if(!var.getEnclosingElement().equals(method)) {
return super.visitText(node, p);
}
}
String text = node.getBody();
String name = toFind.getSimpleName().toString();
if(text.contains(name)) {
int start = (int) sourcePositions.getStartPosition(info.getCompilationUnit(), currentDocPath.getDocComment(), node);
int length = name.length();
int offset = -1;
do {
offset = text.indexOf(name, ++offset);
if(offset != -1) {
try {
MutablePositionRegion region = createRegion(doc, start + offset, start + offset + length);
comments.add(region);
} catch(BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
} while (offset != -1);
}
}
return super.visitText(node, p);
}
示例5: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override
public Void visitText(TextTree tree, Void ignore) {
if (hasNonWhitespace(tree)) {
checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
}
return null;
}
示例6: warnIfEmpty
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
void warnIfEmpty(DocTree tree, List<? extends DocTree> list) {
for (DocTree d: list) {
switch (d.getKind()) {
case TEXT:
if (hasNonWhitespace((TextTree) d))
return;
break;
default:
return;
}
}
env.messages.warning(SYNTAX, tree, "dc.empty", tree.getKind().tagName);
}
示例7: hasNonWhitespace
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
boolean hasNonWhitespace(TextTree tree) {
String s = tree.getBody();
for (int i = 0; i < s.length(); i++) {
if (!Character.isWhitespace(s.charAt(i)))
return true;
}
return false;
}
示例8: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Object visitText(TextTree node, Object p) {
String text = node.getBody();
if (!pre) {
text = text.replaceAll("[ \t\r\n]+", " ").trim();
if (text.isEmpty()) {
text = " ";
}
} else {
text = text.replaceAll("\n", "\n" + indentString(indent));
}
result.append(text);
return null;
}
示例9: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitText(TextTree tree, Void ignore) {
hasNonWhitespaceText = hasNonWhitespace(tree);
if (hasNonWhitespaceText) {
checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
}
return null;
}
示例10: hasNonWhitespace
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
boolean hasNonWhitespace(TextTree tree) {
String s = tree.getBody();
for (int i = 0; i < s.length(); i++) {
Character c = s.charAt(i);
if (!Character.isWhitespace(s.charAt(i)))
return true;
}
return false;
}
示例11: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitText(TextTree tree, Void ignore) {
if (hasNonWhitespace(tree)) {
checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
}
return null;
}
示例12: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override
public DocTree visitText(TextTree tree, Object p) {
return rewriteChildren(tree);
}
示例13: visitText
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
@Override
public Void visitText(TextTree node, Void p) {
print(node.getBody());
return null;
}
示例14: Literal
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
public com.sun.source.doctree.LiteralTree Literal(com.sun.source.doctree.TextTree text) {
return docMake.at(NOPOS).newLiteralTree(text);
}
示例15: Text
import com.sun.source.doctree.TextTree; //导入依赖的package包/类
public TextTree Text(String text) {
return docMake.at(NOPOS).newTextTree(text);
}