From cb86f2a4b08ae80c1dc235daaabaeced038e0a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 8 Jun 2018 21:47:33 +0200 Subject: [PATCH] Take the chance to display attributes correctly in the designer --- .../pmd/util/fxdesigner/NodeInfoPanelController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/NodeInfoPanelController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/NodeInfoPanelController.java index f3fddaf9e8..ef594572fc 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/NodeInfoPanelController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/NodeInfoPanelController.java @@ -6,6 +6,7 @@ package net.sourceforge.pmd.util.fxdesigner; import java.net.URL; import java.util.Collections; +import java.util.Iterator; import java.util.Objects; import java.util.ResourceBundle; @@ -14,6 +15,7 @@ import org.reactfx.EventStreams; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.xpath.Attribute; import net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator; +import net.sourceforge.pmd.lang.ast.xpath.AttributeNode; import net.sourceforge.pmd.lang.java.ast.TypeNode; import net.sourceforge.pmd.lang.symboltable.NameDeclaration; import net.sourceforge.pmd.util.fxdesigner.model.MetricEvaluator; @@ -138,9 +140,10 @@ public class NodeInfoPanelController implements Initializable { */ private static ObservableList getAttributes(Node node) { ObservableList result = FXCollections.observableArrayList(); - AttributeAxisIterator attributeAxisIterator = new AttributeAxisIterator(node); + Iterator attributeAxisIterator = node instanceof AttributeNode ? ((AttributeNode) node).getAttributeIterator() : new AttributeAxisIterator(node); while (attributeAxisIterator.hasNext()) { Attribute attribute = attributeAxisIterator.next(); + // TODO the display should be handled in a ListCell result.add(attribute.getName() + " = " + ((attribute.getValue() != null) ? attribute.getStringValue() : "null")); }