Search in sources :

Example 1 with JavadocElement

use of net.sourceforge.pmd.lang.java.ast.JavadocElement in project pmd-eclipse-plugin by pmd.

the class ASTPainterHelper method layoutFor.

public TextLayout layoutFor(TreeItem item) {
    Object data = item.getData();
    if (data instanceof Comment) {
        return layoutFor((Comment) data);
    }
    if (data instanceof JavadocElement) {
        return layoutFor((JavadocElement) data);
    }
    AbstractNode node = (AbstractNode) data;
    String label = node.toString();
    TextStyle extraStyle = imageStyle;
    String extra = NodeImageDeriver.derivedTextFor(node);
    if (extra != null) {
        extraStyle = derivedStyle;
    } else {
        extra = textFor(node);
    }
    textLayout.setText(label + (extra == null ? "" : " " + extra));
    int labelLength = label.length();
    textLayout.setStyle(labelStyle, 0, labelLength);
    if (extra != null) {
        textLayout.setStyle(extraStyle, labelLength, labelLength + extra.length() + 1);
    }
    return textLayout;
}
Also used : Comment(net.sourceforge.pmd.lang.java.ast.Comment) AbstractNode(net.sourceforge.pmd.lang.ast.AbstractNode) TextStyle(org.eclipse.swt.graphics.TextStyle) JavadocElement(net.sourceforge.pmd.lang.java.ast.JavadocElement)

Aggregations

AbstractNode (net.sourceforge.pmd.lang.ast.AbstractNode)1 Comment (net.sourceforge.pmd.lang.java.ast.Comment)1 JavadocElement (net.sourceforge.pmd.lang.java.ast.JavadocElement)1 TextStyle (org.eclipse.swt.graphics.TextStyle)1