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 File: ReferenceTest.java    From openjdk-8-source with 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 File: ReferenceTest.java    From openjdk-jdk9 with 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 File: ReferenceTest.java    From hottub with 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 File: ReferenceTest.java    From openjdk-jdk8u with 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 File: ReferenceTest.java    From openjdk-jdk8u-backup with 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 File: ReferenceTest.java    From jdk8u60 with 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 File: ReferenceTest.java    From openjdk-8 with 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 File: ReferenceTest.java    From TencentKona-8 with 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 File: Checker.java    From openjdk-jdk8u-backup with 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 File: Checker.java    From openjdk-jdk8u-backup with 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 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 #12
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 #13
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 #14
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 #15
Source File: Checker.java    From TencentKona-8 with 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 File: Checker.java    From openjdk-jdk9 with 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 #17
Source File: Checker.java    From openjdk-jdk9 with 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 #18
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 #19
Source File: Checker.java    From openjdk-jdk8u with 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 #20
Source File: Checker.java    From hottub with 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 #21
Source File: Checker.java    From hottub with 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 #22
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 #23
Source File: Checker.java    From openjdk-8-source with 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 #24
Source File: Checker.java    From openjdk-8-source with 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 #25
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 #26
Source File: Checker.java    From openjdk-8 with 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 #27
Source File: Checker.java    From openjdk-8 with 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 #28
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 #29
Source File: JavadocConverter.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitText(TextTree node, TagElement tag) {
  String[] lines = node.getBody().split("\n");
  int linePos = pos(node);
  for (String line : lines) {
    if (line.length() > 0) {
      linePos = source.indexOf(line, linePos);
      int endPos = linePos + line.length();
      TreeNode newNode = setPos(new TextElement().setText(line), linePos, endPos);
      tag.addFragment(newNode);
    }
  }
  return null;
}
 
Example #30
Source File: Taglet.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the text contained in the given inline tag.
 */
static String text(final DocTree tag) {
    for (final DocTree node : ((UnknownInlineTagTree) tag).getContent()) {
        if (node.getKind() == DocTree.Kind.TEXT) {
            return ((TextTree) node).getBody().trim();
        }
    }
    return "";
}