com.sun.source.doctree.StartElementTree Java Examples

The following examples show how to use com.sun.source.doctree.StartElementTree. 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: netbeans   Author: apache   File: VeryPretty.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source Project: netbeans   Author: apache   File: Analyzer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Void visitDocComment(DocCommentTree node, List<ErrorDescription> errors) {
    DocTreePath currentDocPath = getCurrentPath();
    Void value = super.visitDocComment(node, errors);
    DocSourcePositions sp = (DocSourcePositions) javac.getTrees().getSourcePositions();

    while (!tagStack.isEmpty()) {
        StartElementTree startTree = tagStack.pop();
        Name tagName = startTree.getName();
        HtmlTag tag = HtmlTag.get(tagName);
        if (tag.endKind == HtmlTag.EndKind.REQUIRED) {
            int s = (int) sp.getStartPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), startTree);
            int e = (int) sp.getEndPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), startTree);
            errors.add(ErrorDescriptionFactory.forSpan(ctx, s, e, TAG_START_UNMATCHED(tagName)));
        }
    }
    return value;
}
 
Example #3
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: HtmlDocletWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
boolean ignoreNonInlineTag(DocTree dtree) {
    Name name = null;
    if (dtree.getKind() == Kind.START_ELEMENT) {
        StartElementTree setree = (StartElementTree)dtree;
        name = setree.getName();
    } else if (dtree.getKind() == Kind.END_ELEMENT) {
        EndElementTree eetree = (EndElementTree)dtree;
        name = eetree.getName();
    }

    if (name != null) {
        com.sun.tools.doclint.HtmlTag htmlTag = com.sun.tools.doclint.HtmlTag.get(name);
        if (htmlTag != null &&
                htmlTag.blockType != com.sun.tools.doclint.HtmlTag.BlockType.INLINE) {
            return true;
        }
    }
    return false;
}
 
Example #4
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 visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #5
Source Project: TencentKona-8   Author: Tencent   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #6
Source Project: TencentKona-8   Author: Tencent   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #7
Source Project: jdk8u60   Author: chenghanpeng   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #8
Source Project: jdk8u60   Author: chenghanpeng   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #9
Source Project: jdk8u60   Author: chenghanpeng   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #10
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 visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #11
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #12
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #13
Source Project: lua-for-android   Author: qtiuto   File: DocTreeMaker.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean isSentenceBreak(DocTree dt, boolean isFirstDocTree) {
    switch (dt.getKind()) {
        case START_ELEMENT:
                StartElementTree set = (StartElementTree)dt;
                return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(set.getName());
        case END_ELEMENT:
                EndElementTree eet = (EndElementTree)dt;
                return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(eet.getName());
        default:
            return false;
    }
}
 
Example #14
Source Project: netbeans   Author: apache   File: ImmutableDocTreeTranslator.java    License: Apache License 2.0 5 votes vote down vote up
protected final StartElementTree rewriteChildren(StartElementTree tree) {
    StartElementTree value = tree;
    List<? extends DocTree> attributes = translateDoc(tree.getAttributes());
    if (attributes != tree.getAttributes()) {
        value = make.StartElement((Name) tree.getName(), attributes, tree.isSelfClosing());
    }
    return value;
}
 
Example #15
Source Project: netbeans   Author: apache   File: Analyzer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Messages({"# {0} - Tag name",
           "TAG_UNKNOWN=Unknown HTML Tag: <{0}>",
           "# {0} - Tag name",
           "TAG_END_UNKNOWN=Unknown HTML End Tag: </{0}>",
           "TAG_SELF_CLOSING=Self-closing element not allowed"})
public Void visitStartElement(StartElementTree node, List<ErrorDescription> errors) {
    DocTreePath currentDocPath = getCurrentPath();
    DocTreePathHandle dtph = DocTreePathHandle.create(currentDocPath, javac);
    if(dtph == null) {
        return null;
    }
    DocSourcePositions sp = (DocSourcePositions) javac.getTrees().getSourcePositions();
    int start = (int) sp.getStartPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), node);
    int end = (int) sp.getEndPosition(javac.getCompilationUnit(), currentDocPath.getDocComment(), node);


    final Name treeName = node.getName();
    final HtmlTag t = HtmlTag.get(treeName);
    if (t == null) {
        errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, TAG_UNKNOWN(treeName)));
    } else {
        if(t.endKind != HtmlTag.EndKind.NONE) {
            tagStack.push(node);
        }
    }
    
    if (node.isSelfClosing()) {
        errors.add(ErrorDescriptionFactory.forSpan(ctx, start, end, TAG_SELF_CLOSING()));
    }
    
    return super.visitStartElement(node, errors);
}
 
Example #16
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 visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #17
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #18
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #19
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 visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #20
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #21
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #22
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: DocTreeMaker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private boolean isSentenceBreak(DocTree dt, boolean isFirstDocTree) {
    switch (dt.getKind()) {
        case START_ELEMENT:
                StartElementTree set = (StartElementTree)dt;
                return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(set.getName());
        case END_ELEMENT:
                EndElementTree eet = (EndElementTree)dt;
                return !isFirstDocTree && ((DCTree) dt).pos > 1 && isSentenceBreak(eet.getName());
        default:
            return false;
    }
}
 
Example #23
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: JavaScriptScanner.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitStartElement(StartElementTree tree, Consumer<DocTreePath> f) {
    String name = tree.getName().toString();
    if (name.equalsIgnoreCase("script"))
        f.accept(getCurrentPath());
    return super.visitStartElement(tree, f);
}
 
Example #24
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 visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #25
Source Project: hottub   Author: dsrg-uoft   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #26
Source Project: hottub   Author: dsrg-uoft   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #27
Source Project: openjdk-8-source   Author: keerath   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}
 
Example #28
Source Project: openjdk-8-source   Author: keerath   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
void checkAllowsText(DocTree tree) {
    TagStackItem top = tagStack.peek();
    if (top != null
            && top.tree.getKind() == DocTree.Kind.START_ELEMENT
            && !top.tag.acceptsText()) {
        if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
            env.messages.error(HTML, tree, "dc.text.not.allowed",
                    ((StartElementTree) top.tree).getName());
        }
    }
}
 
Example #29
Source Project: openjdk-8-source   Author: keerath   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void checkHeader(StartElementTree tree, HtmlTag tag) {
    // verify the new tag
    if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
        if (currHeaderTag == null) {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.1", tag);
        } else {
            env.messages.error(ACCESSIBILITY, tree, "dc.tag.header.sequence.2",
                tag, currHeaderTag);
        }
    }

    currHeaderTag = tag;
}
 
Example #30
Source Project: openjdk-8   Author: bpupadhyaya   File: Checker.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public Void visitDocComment(DocCommentTree tree, Void ignore) {
    super.visitDocComment(tree, ignore);
    for (TagStackItem tsi: tagStack) {
        warnIfEmpty(tsi, null);
        if (tsi.tree.getKind() == DocTree.Kind.START_ELEMENT
                && tsi.tag.endKind == HtmlTag.EndKind.REQUIRED) {
            StartElementTree t = (StartElementTree) tsi.tree;
            env.messages.error(HTML, t, "dc.tag.not.closed", t.getName());
        }
    }
    return null;
}