diff --git a/pmd-ui/pom.xml b/pmd-ui/pom.xml index 84dc7cf9ff..7da4227cb6 100644 --- a/pmd-ui/pom.xml +++ b/pmd-ui/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 pmd-ui PMD UI Applications @@ -15,6 +16,40 @@ 8 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-toolchains-plugin + 1.1 + + + + toolchain + + + + + + + 1.8 + + + + + + + + net.sourceforge.pmd @@ -36,6 +71,36 @@ pmd-apex 6.0.0-SNAPSHOT + + net.sourceforge.pmd + pmd-jsp + 6.0.0-SNAPSHOT + + + net.sourceforge.pmd + pmd-plsql + 6.0.0-SNAPSHOT + + + net.sourceforge.pmd + pmd-visualforce + 6.0.0-SNAPSHOT + + + net.sourceforge.pmd + pmd-xml + 6.0.0-SNAPSHOT + + + net.sourceforge.pmd + pmd-vm + 6.0.0-SNAPSHOT + + + net.sourceforge.pmd + pmd-javascript + 6.0.0-SNAPSHOT + junit junit diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java index b11f11dddd..093d42c2e3 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/MainDesignerController.java @@ -424,4 +424,9 @@ public class MainDesignerController implements Initializable, SettingsOwner { } + public void invalidateAst() { + nodeInfoPanelController.invalidateInfo(); + xpathPanelController.invalidateResults(false); + sourceEditorController.clearNodeHighlight(); + } } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java index db771efac2..b0c1e85046 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/SourceEditorController.java @@ -127,6 +127,7 @@ public class SourceEditorController implements Initializable, SettingsOwner { */ public void refreshAST() { String source = codeEditorArea.getText(); + Node previous = astManager.compilationUnitProperty().get(); Node current; try { current = astManager.updateCompilationUnit(source); @@ -134,6 +135,9 @@ public class SourceEditorController implements Initializable, SettingsOwner { invalidateAST(true); return; } + if (previous != current) { + parent.invalidateAst(); + } setUpToDateCompilationUnit(current); codeEditorArea.clearPrimaryStyleLayer(); diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java index 7f4a7f5199..2ff1e3dfbe 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java @@ -34,6 +34,7 @@ import javafx.scene.control.ListView; import javafx.scene.control.TitledPane; import javafx.util.StringConverter; + /** * XPath panel controller. * @@ -123,7 +124,7 @@ public class XPathPanelController implements Initializable, SettingsOwner { xpathResultListView.setItems(results); violationsTitledPane.setText("Matched nodes\t(" + results.size() + ")"); } catch (XPathEvaluationException e) { - notifyXPathError(e); + invalidateResults(true); designerApp.getLogger().logEvent(new LogEntry(e, Category.XPATH_EVALUATION_EXCEPTION)); } @@ -132,8 +133,9 @@ public class XPathPanelController implements Initializable, SettingsOwner { } - public void invalidateResults() { + public void invalidateResults(boolean error) { xpathResultListView.getItems().clear(); + violationsTitledPane.setText("Matched nodes" + (error ? "\t(error)" : "")); } @@ -142,12 +144,6 @@ public class XPathPanelController implements Initializable, SettingsOwner { } - private void notifyXPathError(Throwable t) { - // Currently dismisses the exception - violationsTitledPane.setText("Matched nodes\t(error)"); - } - - public StringProperty xpathVersionProperty() { return xpathEvaluator.xpathVersionProperty(); } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/CustomCodeArea.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/CustomCodeArea.java index 2687122722..b3a30424a7 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/CustomCodeArea.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/CustomCodeArea.java @@ -121,7 +121,7 @@ public class CustomCodeArea extends CodeArea { public boolean isInRange(Node n) { return n.getEndLine() <= getParagraphs().size() && (n.getEndLine() != getParagraphs().size() - || n.getEndColumn() <= getParagraph(n.getEndLine() - 2).length()); + || n.getEndColumn() <= getParagraph(n.getEndLine() - 1).length()); } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/SimpleRegexSyntaxHighlighter.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/SimpleRegexSyntaxHighlighter.java index f4e89ca3ab..daefd5c01f 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/SimpleRegexSyntaxHighlighter.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/SimpleRegexSyntaxHighlighter.java @@ -62,6 +62,11 @@ public abstract class SimpleRegexSyntaxHighlighter implements SyntaxHighlighter } catch (StackOverflowError so) { // matcher.find overflowed, might happen when coloring ginormous files with incorrect language } + + if (lastKwEnd == 0) { // no spans found/ no text + builder.add(Collections.emptySet(), text.length()); + } + return builder.create(); } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/StyleContext.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/StyleContext.java index 1ad5c4cd0c..c17d7f3aa3 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/StyleContext.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/codearea/StyleContext.java @@ -86,6 +86,7 @@ class StyleContext implements Iterable { return allSpans.stream() .filter(spans -> spans != base) + .filter(spans -> spans.length() <= codeArea.getLength()) .reduce(allSpans.get(0), (accumulator, elt) -> accumulator.overlay(elt, (style1, style2) -> { Set styles = new HashSet<>(style1);