com.sun.source.doctree.TextTree Java Examples

The following examples show how to use com.sun.source.doctree.TextTree. 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 Project: TencentKona-8   Author: Tencent   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #2
Source Project: jdk8u60   Author: chenghanpeng   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #3
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #4
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #5
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #6
Source Project: hottub   Author: dsrg-uoft   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #7
Source Project: openjdk-8-source   Author: keerath   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #8
Source Project: openjdk-8   Author: bpupadhyaya   File: ReferenceTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
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);
    }
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitText(TextTree tree, Void ignore) {
    if (hasNonWhitespace(tree)) {
        checkAllowsText(tree);
        markEnclosingTag(Flag.HAS_TEXT);
    }
    return null;
}
 
Example #10
Source Project: TencentKona-8   Author: Tencent   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #11
Source Project: TencentKona-8   Author: Tencent   File: Checker.java    License: 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 Project: jdk8u60   Author: chenghanpeng   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitText(TextTree tree, Void ignore) {
    if (hasNonWhitespace(tree)) {
        checkAllowsText(tree);
        markEnclosingTag(Flag.HAS_TEXT);
    }
    return null;
}
 
Example #13
Source Project: jdk8u60   Author: chenghanpeng   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #14
Source Project: jdk8u60   Author: chenghanpeng   File: Checker.java    License: 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 #15
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitText(TextTree tree, Void ignore) {
    if (hasNonWhitespace(tree)) {
        checkAllowsText(tree);
        markEnclosingTag(Flag.HAS_TEXT);
    }
    return null;
}
 
Example #16
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #17
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Checker.java    License: 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 #18
Source Project: netbeans   Author: apache   File: ImmutableDocTreeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #19
Source Project: netbeans   Author: apache   File: RenameTransformer.java    License: 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 #20
Source Project: netbeans   Author: apache   File: FindLocalUsagesQuery.java    License: 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 #21
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitText(TextTree tree, Void ignore) {
    if (hasNonWhitespace(tree)) {
        checkAllowsText(tree);
        markEnclosingTag(Flag.HAS_TEXT);
    }
    return null;
}
 
Example #22
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #23
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Checker.java    License: 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 #24
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: JavadocFormatter.java    License: 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 #25
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitText(TextTree tree, Void ignore) {
    if (hasNonWhitespace(tree)) {
        checkAllowsText(tree);
        markEnclosingTag(Flag.HAS_TEXT);
    }
    return null;
}
 
Example #26
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #27
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Checker.java    License: 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 #28
Source Project: hottub   Author: dsrg-uoft   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitText(TextTree tree, Void ignore) {
    if (hasNonWhitespace(tree)) {
        checkAllowsText(tree);
        markEnclosingTag(Flag.HAS_TEXT);
    }
    return null;
}
 
Example #29
Source Project: hottub   Author: dsrg-uoft   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #30
Source Project: hottub   Author: dsrg-uoft   File: Checker.java    License: 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;
}