Search in sources :

Example 1 with AttributeAxisIterator

use of net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator in project pmd by pmd.

the class NodeInfoPanelController method getAttributes.

/**
 * Gets the XPath attributes of the node for display within a listview.
 */
private static ObservableList<String> getAttributes(Node node) {
    ObservableList<String> result = FXCollections.observableArrayList();
    AttributeAxisIterator attributeAxisIterator = new AttributeAxisIterator(node);
    while (attributeAxisIterator.hasNext()) {
        Attribute attribute = attributeAxisIterator.next();
        result.add(attribute.getName() + " = " + ((attribute.getValue() != null) ? attribute.getStringValue() : "null"));
    }
    if (node instanceof TypeNode) {
        result.add("typeof() = " + ((TypeNode) node).getType());
    }
    Collections.sort(result);
    return result;
}
Also used : Attribute(net.sourceforge.pmd.lang.ast.xpath.Attribute) TypeNode(net.sourceforge.pmd.lang.java.ast.TypeNode) AttributeAxisIterator(net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator)

Example 2 with AttributeAxisIterator

use of net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator in project pmd by pmd.

the class AttributeAxisIteratorTest method testRemove.

@Test(expected = UnsupportedOperationException.class)
public void testRemove() {
    DummyNode n = new DummyNode(0);
    n.testingOnlySetBeginColumn(1);
    n.testingOnlySetBeginLine(1);
    AttributeAxisIterator iter = new AttributeAxisIterator(n);
    iter.remove();
}
Also used : DummyNode(net.sourceforge.pmd.lang.ast.DummyNode) AttributeAxisIterator(net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator) Test(org.junit.Test)

Example 3 with AttributeAxisIterator

use of net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator in project pmd by pmd.

the class AttributesSubMenu method init.

private void init() {
    AttributeAxisIterator i = new AttributeAxisIterator(node);
    while (i.hasNext()) {
        Attribute attribute = i.next();
        add(new XPathFragmentAddingItem(attribute.getName() + " = " + attribute.getValue(), model, AttributeToolkit.constructPredicate(attribute)));
    }
}
Also used : Attribute(net.sourceforge.pmd.lang.ast.xpath.Attribute) AttributeAxisIterator(net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator)

Aggregations

AttributeAxisIterator (net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator)3 Attribute (net.sourceforge.pmd.lang.ast.xpath.Attribute)2 DummyNode (net.sourceforge.pmd.lang.ast.DummyNode)1 TypeNode (net.sourceforge.pmd.lang.java.ast.TypeNode)1 Test (org.junit.Test)1