Java Code Examples for com.sun.source.doctree.TextTree#getBody()

The following examples show how to use com.sun.source.doctree.TextTree#getBody() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Checker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 2
Source File: Checker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: Checker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 4
Source File: RenameTransformer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: FindLocalUsagesQuery.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 6
Source File: Checker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: JavadocFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source File: Checker.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: Checker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: Checker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 11
Source File: Checker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 12
Source File: ApiDoclet.java    From uyuni with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String visitText(TextTree node, Void p) {
    return node.getBody();
}