diff --git a/pmd-ui/pom.xml b/pmd-ui/pom.xml
index c1a331ca7e..cc5829dbb8 100644
--- a/pmd-ui/pom.xml
+++ b/pmd-ui/pom.xml
@@ -36,5 +36,10 @@
pmd-apex
6.0.0-SNAPSHOT
+
+ junit
+ junit
+ test
+
diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowPresenter.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowPresenter.java
index 7c13d9b89e..2759736edc 100644
--- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowPresenter.java
+++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowPresenter.java
@@ -44,7 +44,7 @@ import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
/**
- * Presenter of the designer window.
+ * Presenter of the designer window. Subscribes to the events of the {@link DesignerWindow} that instantiates it.
*
* @author Clément Fournier
* @since 6.0.0
@@ -280,7 +280,7 @@ public class DesignerWindowPresenter {
XMLSettingsSaver saver = XMLSettingsSaver.forFile(SETTINGS_FILE_NAME);
for (DesignerWindowSettings setting : DesignerWindowSettings.values()) {
- saver.put(setting.keyName, setting.getValueFrom(this));
+ saver.put(setting.getKeyName(), setting.getValueFrom(this));
}
saver.save();
@@ -291,7 +291,7 @@ public class DesignerWindowPresenter {
private void loadSettings() throws IOException {
Set keyNames = Arrays.stream(DesignerWindowSettings.values())
- .map(e -> e.keyName)
+ .map(DesignerWindowSettings::getKeyName)
.collect(Collectors.toSet());
XMLSettingsLoader loader = new XMLSettingsLoader(SETTINGS_FILE_NAME, keyNames);
@@ -304,8 +304,6 @@ public class DesignerWindowPresenter {
/********************************/
/* SETTINGS LOAD/STORE ROUTINES */
-
-
/********************************/
diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettings.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettings.java
index 0239118700..b59c71459d 100644
--- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettings.java
+++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettings.java
@@ -47,7 +47,7 @@ enum DesignerWindowSettings {
DesignerWindowPresenter::setLeftToolbarDividerPosition);
- public final String keyName;
+ private final String keyName;
private final Function getValueFunction;
private final PresenterSettingSetter setValueFunction;
@@ -83,6 +83,11 @@ enum DesignerWindowSettings {
}
+ public String getKeyName() {
+ return keyName;
+ }
+
+
/** Get the setting from the name of its key. */
static DesignerWindowSettings ofKeyName(String key) {
return Arrays.stream(DesignerWindowSettings.values())
diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ASTManager.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ASTManager.java
index 2b73b80b99..9306e9af69 100644
--- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ASTManager.java
+++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ASTManager.java
@@ -20,7 +20,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
/**
- * Main class of the model.
+ * Main class of the model. Manages the compilation unit and evaluation logic.
*
* @author Clément Fournier
* @since 6.0.0
@@ -61,7 +61,7 @@ public class ASTManager {
public String getXPathVersion() {
- return xpathEvaluator.xpathVersionProperty().get();
+ return xpathEvaluator.getXpathVersion();
}
@@ -82,11 +82,11 @@ public class ASTManager {
/**
- * Evaluates an XPath request, returns the matching nodes.
+ * Evaluates an XPath query, returns the matching nodes.
*
* @param xpathQuery Query to execute
*
- * @return The matching nodes, or Optional.empty if the compilation unit is invalid.
+ * @return List of the matching nodes, never null.
*
* @throws XPathEvaluationException if there was an error during the evaluation. The cause is preserved.
*/
@@ -97,6 +97,13 @@ public class ASTManager {
}
+ /**
+ * Returns true if the source must be recompiled.
+ *
+ * @param source Source to test
+ *
+ * @return true if the current AST does not correspond to the parameter source
+ */
public boolean isRecompilationNeeded(String source) {
return !StringUtils.equals(source, lastValidSource)
|| !languageVersion.get().equals(lastLanguageVersion);
diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/XPathEvaluator.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/XPathEvaluator.java
index 0e35689ce9..24312cbf80 100644
--- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/XPathEvaluator.java
+++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/XPathEvaluator.java
@@ -33,7 +33,7 @@ class XPathEvaluator {
private final StringProperty xpathVersion = new SimpleStringProperty();
- public String getXpathVersion() {
+ String getXpathVersion() {
return xpathVersion.get();
}
diff --git a/pmd-ui/src/test/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettingsTest.java b/pmd-ui/src/test/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettingsTest.java
new file mode 100644
index 0000000000..e28233e485
--- /dev/null
+++ b/pmd-ui/src/test/java/net/sourceforge/pmd/util/fxdesigner/DesignerWindowSettingsTest.java
@@ -0,0 +1,28 @@
+package net.sourceforge.pmd.util.fxdesigner;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.junit.Test;
+
+/**
+ * @author Clément Fournier
+ * @since 6.0.0
+ */
+public class DesignerWindowSettingsTest {
+
+ @Test
+ public void testKeysNamesAreUnique() {
+ List keyNames = Arrays.stream(DesignerWindowSettings.values())
+ .map(DesignerWindowSettings::getKeyName)
+ .collect(Collectors.toList());
+
+ assertEquals(keyNames.size(), new HashSet<>(keyNames).size());
+
+ }
+
+}
\ No newline at end of file