From 61a5d1494be669f4dd4b1b0212bae20f6581ae6f Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Wed, 30 May 2018 15:21:37 +0530 Subject: [PATCH 01/17] auxClassPath UI --- .../fxdesigner/MainDesignerController.java | 16 ++++ .../util/AuxClassPathController.java | 83 +++++++++++++++++++ .../util/fxdesigner/fxml/aux-controller.fxml | 57 +++++++++++++ .../pmd/util/fxdesigner/fxml/designer.fxml | 14 +++- 4 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/AuxClassPathController.java create mode 100644 pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/aux-controller.fxml 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 3eb6133f0a0..02dcc659647 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 @@ -23,6 +23,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.symboltable.NameDeclaration; import net.sourceforge.pmd.lang.symboltable.NameOccurrence; +import net.sourceforge.pmd.util.fxdesigner.util.AuxClassPathController; import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; import net.sourceforge.pmd.util.fxdesigner.util.LimitedSizeStack; import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsOwner; @@ -73,8 +74,11 @@ public class MainDesignerController implements Initializable, SettingsOwner { */ private final DesignerRoot designerRoot; + /* Menu bar */ @FXML + private MenuItem pmdconfig; + @FXML private MenuItem openFileMenuItem; @FXML private MenuItem licenseMenuItem; @@ -111,6 +115,8 @@ public class MainDesignerController implements Initializable, SettingsOwner { private SourceEditorController sourceEditorController; @FXML private EventLogController eventLogPanelController; + @FXML + private AuxClassPathController auxClassPathController; // Other fields private Stack recentFiles = new LimitedSizeStack<>(5); @@ -161,6 +167,16 @@ public void initialize(URL location, ResourceBundle resources) { } }); + pmdconfig.setOnAction(e -> { + try { + auxClassPathController.showAuxPathWizard(); + } catch (Exception e1) { + e1.printStackTrace(); + } + }); + + + sourceEditorController.refreshAST(); xpathPanelController.evaluateXPath(sourceEditorController.getCompilationUnit(), getLanguageVersion()); diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/AuxClassPathController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/AuxClassPathController.java new file mode 100644 index 00000000000..79dd157ac58 --- /dev/null +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/AuxClassPathController.java @@ -0,0 +1,83 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + + +package net.sourceforge.pmd.util.fxdesigner.util; + +import java.io.File; +import java.net.URL; +import java.util.ResourceBundle; + +import net.sourceforge.pmd.util.fxdesigner.DesignerRoot; +import net.sourceforge.pmd.util.fxdesigner.MainDesignerController; +import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsOwner; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +public class AuxClassPathController implements Initializable, SettingsOwner { + + private final DesignerRoot designerRoot; + + @FXML + private Button removeFiles; + + @FXML + private TableView fileTable; + + @FXML + private Button selectFile; + + @FXML + private TableColumn fileList; + + @FXML + private TableColumn fileAdd; + + @FXML + private final MainDesignerController parent; + + + public AuxClassPathController(DesignerRoot designerRoot, MainDesignerController parent) { + this.designerRoot = designerRoot; + this.parent = parent; + } + + + @Override + public void initialize(URL location, ResourceBundle resources) { + + selectFile.setOnAction(e -> fileSeleced()); + + } + + + private void fileSeleced() { + FileChooser chooser = new FileChooser(); + chooser.setTitle("Load source from file"); + File file = chooser.showOpenDialog(designerRoot.getMainStage()); + + } + + + public void showAuxPathWizard() throws Exception { + + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("fxml/aux-controller.fxml")); + Parent root1 = (Parent) fxmlLoader.load(); + Stage stage = new Stage(); + stage.setScene(new Scene(root1)); + stage.show(); + + } + + +} diff --git a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/aux-controller.fxml b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/aux-controller.fxml new file mode 100644 index 00000000000..b3c2b2adc5b --- /dev/null +++ b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/aux-controller.fxml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + From 30f63266fe3fdc93f1001c685a0a322adb38f24d Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Tue, 5 Jun 2018 21:56:57 +0530 Subject: [PATCH 08/17] added the Cancel button the list needs to be updated in the popup to make the data flow as required working on validation and left out a couple of changes due to some reasons --- .../fxdesigner/AuxClassPathController.java | 39 ++++++++++++++----- .../fxdesigner/MainDesignerController.java | 5 +-- .../fxdesigner/SourceEditorController.java | 23 +++++++++++ .../fxml/auxclasspath-setup-popup.fxml | 9 ++++- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java index 741888f9b26..d6d2c916d3e 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java @@ -11,11 +11,14 @@ import java.util.List; import java.util.ResourceBundle; +import org.controlsfx.validation.ValidationSupport; + import net.sourceforge.pmd.PMDConfiguration; import net.sourceforge.pmd.util.ClasspathClassLoader; import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsOwner; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; @@ -31,7 +34,7 @@ public class AuxClassPathController implements Initializable, SettingsOwner { private final DesignerRoot designerRoot; private ClassLoader classLoader = getClass().getClassLoader(); - + private ValidationSupport validationSupport = new ValidationSupport(); @FXML @@ -39,19 +42,31 @@ public class AuxClassPathController implements Initializable, SettingsOwner { @FXML private Button selectFilesButton; @FXML - private ListView fileListView; + private ListView fileListView = new ListView<>(); @FXML private Button moveItemUpButton; @FXML private Button moveItemDownButton; @FXML private Button setClassPathButton; + @FXML + private Button cancelButton; - public AuxClassPathController(DesignerRoot designerRoot) { + public AuxClassPathController(ObservableList auxClassPathFiles, DesignerRoot designerRoot) { this.designerRoot = designerRoot; - } + if (auxClassPathFiles != null) { + fileListView.setItems(auxClassPathFiles); + } + + try { + showAuxPathWizard(); + } catch (Exception e) { + e.printStackTrace(); + } + + } @Override public void initialize(URL location, ResourceBundle resources) { @@ -65,8 +80,11 @@ public void initialize(URL location, ResourceBundle resources) { e1.printStackTrace(); } }); + + moveItemUpButton.setOnAction(e -> moveUp()); moveItemDownButton.setOnAction(e -> moveDown()); + cancelButton.setOnAction(e -> closePopup()); } @@ -79,10 +97,8 @@ private void onSelectFileClicked() { new FileChooser.ExtensionFilter("Java EARs", "*.ear"), new FileChooser.ExtensionFilter("Java class files", "*.class") ); - List file = chooser.showOpenMultipleDialog(designerRoot.getMainStage()); - for (File f : file) { - fileListView.getItems().add(f); - } + List files = chooser.showOpenMultipleDialog(designerRoot.getMainStage()); + fileListView.getItems().addAll(files); } @@ -128,12 +144,16 @@ public void moveItem(int direction) { } + private void setValidationSupport() { + + } + private String classPathGenerator() throws IOException { String classPath = ""; for (File f : fileListView.getItems()) { - classPath = classPath + ";" + f.getAbsolutePath(); + classPath = classPath + File.pathSeparator + f.getAbsolutePath(); } setClassPath(classPath); @@ -149,6 +169,7 @@ public void setClassPath(String classPath) throws IOException { if (classPath != null) { classLoader = new ClasspathClassLoader(classPath, classLoader); } + SourceEditorController.auxclasspathFiles = fileListView.getItems(); closePopup(); } 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 5cb52540f37..8d5e4a14cf2 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 @@ -115,8 +115,6 @@ public class MainDesignerController implements Initializable, SettingsOwner { @FXML private EventLogController eventLogPanelController; - private final AuxClassPathController auxClassPathController; - // Other fields private Stack recentFiles = new LimitedSizeStack<>(5); // Properties @@ -126,7 +124,6 @@ public class MainDesignerController implements Initializable, SettingsOwner { public MainDesignerController(DesignerRoot owner) { this.designerRoot = owner; - this.auxClassPathController = new AuxClassPathController(designerRoot); } @@ -169,7 +166,7 @@ public void initialize(URL location, ResourceBundle resources) { setupAuxclasspathMenuItem.setOnAction(e -> { try { - auxClassPathController.showAuxPathWizard(); + sourceEditorController.showAuxClassPathController(designerRoot); } catch (Exception e1) { e1.printStackTrace(); } 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 891ac4eb874..d583c1fab80 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 @@ -4,6 +4,7 @@ package net.sourceforge.pmd.util.fxdesigner; +import java.io.File; import java.net.URL; import java.time.Duration; import java.util.Collection; @@ -33,6 +34,7 @@ import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeItem; import net.sourceforge.pmd.util.fxdesigner.util.controls.TreeViewWrapper; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.Label; @@ -62,6 +64,9 @@ public class SourceEditorController implements Initializable, SettingsOwner { private ASTTreeItem selectedTreeItem; private static final Duration AST_REFRESH_DELAY = Duration.ofMillis(100); + public static ObservableList auxclasspathFiles; + private Var auxclasspathClassLoader; + public SourceEditorController(DesignerRoot owner, MainDesignerController mainController) { parent = mainController; astManager = new ASTManager(owner); @@ -126,6 +131,24 @@ public void refreshAST() { } + public void showAuxClassPathController(DesignerRoot root) { + AuxClassPathController auxClassPathController = new AuxClassPathController(auxclasspathFiles, root); + + + } + + + @PersistentProperty + public ObservableList getAuxclasspathFiles() { + return auxclasspathFiles; + } + + + public void setAuxClassPathFiles(ObservableList auxclasspathFiles) { + this.auxclasspathFiles = auxclasspathFiles; + } + + private void setUpToDateCompilationUnit(Node node) { astTitleLabel.setText("Abstract Syntax Tree"); ASTTreeItem root = ASTTreeItem.getRoot(node); diff --git a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml index ddd317d8a6e..f66299513c2 100644 --- a/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml +++ b/pmd-ui/src/main/resources/net/sourceforge/pmd/util/fxdesigner/fxml/auxclasspath-setup-popup.fxml @@ -7,7 +7,7 @@ - @@ -53,6 +53,13 @@ + + From 5ae8e7293016bba79445d33a746ca7bf0bb19c41 Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Thu, 7 Jun 2018 04:24:19 +0530 Subject: [PATCH 09/17] Data flow is working properly thanks to @oowekyala for helping me out. UI is upgraded to make sure buttons are active only when needed (will make a small addition to moveitem up and moveitem down button as discussed) About the ClassLoader I am a bit confused about how to use `ClasspathClassLoader` I think will be able to merge it today before evening IST. --- .../fxdesigner/AuxClassPathController.java | 120 +++++------------- .../fxdesigner/SourceEditorController.java | 69 ++++++++-- 2 files changed, 90 insertions(+), 99 deletions(-) diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java index d6d2c916d3e..2cd955509a2 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java @@ -6,35 +6,28 @@ package net.sourceforge.pmd.util.fxdesigner; import java.io.File; -import java.io.IOException; import java.net.URL; import java.util.List; import java.util.ResourceBundle; +import java.util.function.Consumer; -import org.controlsfx.validation.ValidationSupport; +import org.reactfx.value.Var; -import net.sourceforge.pmd.PMDConfiguration; -import net.sourceforge.pmd.util.ClasspathClassLoader; -import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsOwner; -import javafx.collections.ObservableList; +import javafx.collections.FXCollections; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; -import javafx.scene.Parent; -import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ListView; import javafx.stage.FileChooser; -import javafx.stage.Modality; -import javafx.stage.Stage; public class AuxClassPathController implements Initializable, SettingsOwner { private final DesignerRoot designerRoot; - private ClassLoader classLoader = getClass().getClassLoader(); - private ValidationSupport validationSupport = new ValidationSupport(); + + private final Var onCancel = Var.newSimpleVar(() -> {}); + private final Var>> onApply = Var.newSimpleVar(l -> {}); @FXML @@ -53,38 +46,27 @@ public class AuxClassPathController implements Initializable, SettingsOwner { private Button cancelButton; - public AuxClassPathController(ObservableList auxClassPathFiles, DesignerRoot designerRoot) { + public AuxClassPathController(DesignerRoot designerRoot) { this.designerRoot = designerRoot; - - if (auxClassPathFiles != null) { - fileListView.setItems(auxClassPathFiles); - } - - try { - showAuxPathWizard(); - } catch (Exception e) { - e.printStackTrace(); - } - } @Override public void initialize(URL location, ResourceBundle resources) { - selectFilesButton.setOnAction(e -> onSelectFileClicked()); - removeFileButton.setOnAction(e -> onRemoveFileClicked()); - setClassPathButton.setOnAction(e -> { - try { - setClassPath(classPathGenerator()); - } catch (IOException e1) { - e1.printStackTrace(); - } - }); + + removeFileButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); + moveItemUpButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); + moveItemDownButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); + setClassPathButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); + selectFilesButton.setOnAction(e -> onSelectFileClicked()); + removeFileButton.setOnAction(e -> onRemoveFileClicked()); + setClassPathButton.setOnAction(e -> onApply.ifPresent(f -> f.accept(fileListView.getItems()))); moveItemUpButton.setOnAction(e -> moveUp()); moveItemDownButton.setOnAction(e -> moveDown()); - cancelButton.setOnAction(e -> closePopup()); + cancelButton.setOnAction(e -> onCancel.ifPresent(Runnable::run)); + } @@ -108,6 +90,21 @@ private void onRemoveFileClicked() { } + public void setAuxclasspathFiles(List lst) { + fileListView.setItems(FXCollections.observableArrayList(lst)); + } + + + public void setOnCancel(Runnable run) { + onCancel.setValue(run); + } + + + public void setOnApply(Consumer> onApply) { + this.onApply.setValue(onApply); + } + + private void moveUp() { moveItem(-1); } @@ -144,61 +141,8 @@ public void moveItem(int direction) { } - private void setValidationSupport() { - } - - private String classPathGenerator() throws IOException { - - String classPath = ""; - for (File f : fileListView.getItems()) { - classPath = classPath + File.pathSeparator + f.getAbsolutePath(); - } - - setClassPath(classPath); - return classPath; - } - - - public void setClassPath(String classPath) throws IOException { - - if (classLoader == null) { - classLoader = PMDConfiguration.class.getClassLoader(); - } - if (classPath != null) { - classLoader = new ClasspathClassLoader(classPath, classLoader); - } - SourceEditorController.auxclasspathFiles = fileListView.getItems(); - - closePopup(); - } - - - private void closePopup() { - Stage stage = (Stage) setClassPathButton.getScene().getWindow(); - stage.close(); - } - - public void showAuxPathWizard() throws Exception { - - FXMLLoader fxmlLoader = new FXMLLoader(DesignerUtil.getFxml("auxclasspath-setup-popup.fxml")); - - fxmlLoader.setControllerFactory(type -> { - if (type == AuxClassPathController.class) { - return this; - } else { - throw new IllegalStateException("Wrong controller!"); - } - }); - - Parent root1 = fxmlLoader.load(); - Stage stage = new Stage(); - stage.initOwner(designerRoot.getMainStage()); - stage.initModality(Modality.WINDOW_MODAL); - stage.setScene(new Scene(root1)); - stage.show(); - } } 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 d583c1fab80..f2b7dc408c4 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 @@ -5,14 +5,18 @@ package net.sourceforge.pmd.util.fxdesigner; import java.io.File; +import java.io.IOException; import java.net.URL; import java.time.Duration; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.ResourceBundle; import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.fxmisc.richtext.LineNumberFactory; @@ -25,6 +29,7 @@ import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.util.fxdesigner.model.ASTManager; import net.sourceforge.pmd.util.fxdesigner.model.ParseAbortedException; +import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsOwner; import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsPersistenceUtil.PersistentProperty; import net.sourceforge.pmd.util.fxdesigner.util.codearea.AvailableSyntaxHighlighters; @@ -34,13 +39,17 @@ import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeItem; import net.sourceforge.pmd.util.fxdesigner.util.controls.TreeViewWrapper; -import javafx.collections.ObservableList; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.SelectionModel; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; +import javafx.stage.Modality; +import javafx.stage.Stage; /** @@ -52,6 +61,7 @@ public class SourceEditorController implements Initializable, SettingsOwner { private final MainDesignerController parent; + @FXML private Label astTitleLabel; @FXML @@ -64,8 +74,8 @@ public class SourceEditorController implements Initializable, SettingsOwner { private ASTTreeItem selectedTreeItem; private static final Duration AST_REFRESH_DELAY = Duration.ofMillis(100); - public static ObservableList auxclasspathFiles; - private Var auxclasspathClassLoader; + private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); + private Val auxclasspathClassLoader; public SourceEditorController(DesignerRoot owner, MainDesignerController mainController) { parent = mainController; @@ -73,8 +83,6 @@ public SourceEditorController(DesignerRoot owner, MainDesignerController mainCon } - - @Override public void initialize(URL location, ResourceBundle resources) { @@ -132,20 +140,59 @@ public void refreshAST() { public void showAuxClassPathController(DesignerRoot root) { - AuxClassPathController auxClassPathController = new AuxClassPathController(auxclasspathFiles, root); + AuxClassPathController auxClassPathController = new AuxClassPathController(root); + + FXMLLoader fxmlLoader = new FXMLLoader(DesignerUtil.getFxml("auxclasspath-setup-popup.fxml")); + + fxmlLoader.setControllerFactory(type -> { + if (type == AuxClassPathController.class) { + return auxClassPathController; + } else { + throw new IllegalStateException("Wrong controller!"); + } + }); + try { + Parent root1 = fxmlLoader.load(); + + auxClassPathController.setAuxclasspathFiles(auxclasspathFiles.getValue()); + + Stage stage = new Stage(); + stage.initOwner(root.getMainStage()); + stage.initModality(Modality.WINDOW_MODAL); + stage.setScene(new Scene(root1)); + stage.show(); + + auxClassPathController.setOnApply(files -> { + stage.close(); + auxclasspathFiles.setValue(files); + }); + + auxClassPathController.setOnCancel(stage::close); + + + } catch (IOException e) { + e.printStackTrace(); + } } @PersistentProperty - public ObservableList getAuxclasspathFiles() { - return auxclasspathFiles; + public String getAuxclasspathFiles() { + + StringBuilder sb = new StringBuilder(); + + for (File f : auxclasspathFiles.getValue()) { + sb.append(';').append(f.getAbsolutePath()); + } + return sb.length() > 0 ? sb.substring(1) : ""; } - public void setAuxClassPathFiles(ObservableList auxclasspathFiles) { - this.auxclasspathFiles = auxclasspathFiles; + public void setAuxClassPathFiles(String files) { + List newVal = Arrays.asList(files.split(";")).stream().map(File::new).collect(Collectors.toList()); + auxclasspathFiles.setValue(newVal); } @@ -205,7 +252,7 @@ public void focusNodeInTreeView(Node node) { // node is different from the old one if (selectedTreeItem == null && node != null - || selectedTreeItem != null && !Objects.equals(node, selectedTreeItem.getValue())) { + || selectedTreeItem != null && !Objects.equals(node, selectedTreeItem.getValue())) { ASTTreeItem found = ((ASTTreeItem) astTreeView.getRoot()).findItem(node); if (found != null) { selectionModel.select(found); From c61fb73d7b088e87e8d949177c2f558d0f020550 Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Thu, 7 Jun 2018 16:24:31 +0530 Subject: [PATCH 10/17] Classloader is completed. --- .../pmd/util/ClasspathClassLoader.java | 16 ++++++++++++ .../fxdesigner/AuxClassPathController.java | 5 ---- .../fxdesigner/SourceEditorController.java | 25 +++++++++++-------- .../pmd/util/fxdesigner/model/ASTManager.java | 9 ++++--- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java index d9adf73bc5f..3360d9258ce 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java @@ -38,6 +38,22 @@ public ClasspathClassLoader(String classpath, ClassLoader parent) throws IOExcep super(initURLs(classpath), parent); } + + public ClasspathClassLoader(List files, ClassLoader parent) throws IOException { + super(fileToURL(files), parent); + } + + + private static URL[] fileToURL(List files) throws IOException { + + List urlList = new ArrayList<>(); + + for (File f : files) { + addFileURLs(urlList, f.toURI().toURL()); + } + return urlList.toArray(new URL[urlList.size()]); + } + private static URL[] initURLs(String classpath) throws IOException { if (classpath == null) { throw new IllegalArgumentException("classpath argument cannot be null"); diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java index 2cd955509a2..3b3ba5aef6e 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java @@ -140,9 +140,4 @@ public void moveItem(int direction) { } - - - - - } 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 f2b7dc408c4..88a8d129d6d 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 @@ -27,6 +27,7 @@ import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.Node; +import net.sourceforge.pmd.util.ClasspathClassLoader; import net.sourceforge.pmd.util.fxdesigner.model.ASTManager; import net.sourceforge.pmd.util.fxdesigner.model.ParseAbortedException; import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; @@ -75,7 +76,15 @@ public class SourceEditorController implements Initializable, SettingsOwner { private static final Duration AST_REFRESH_DELAY = Duration.ofMillis(100); private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); - private Val auxclasspathClassLoader; + private final Val auxclasspathClassLoader + = auxclasspathFiles.map(files -> { + try { + new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); + } catch (IOException e) { + e.printStackTrace(); + } + return SourceEditorController.class.getClassLoader(); + }); public SourceEditorController(DesignerRoot owner, MainDesignerController mainController) { parent = mainController; @@ -127,7 +136,7 @@ public void refreshAST() { } try { - current = astManager.updateCompilationUnit(source); + current = astManager.updateCompilationUnit(source, auxclasspathClassLoader); } catch (ParseAbortedException e) { invalidateAST(true); return; @@ -180,18 +189,14 @@ public void showAuxClassPathController(DesignerRoot root) { @PersistentProperty public String getAuxclasspathFiles() { - - StringBuilder sb = new StringBuilder(); - - for (File f : auxclasspathFiles.getValue()) { - sb.append(';').append(f.getAbsolutePath()); - } - return sb.length() > 0 ? sb.substring(1) : ""; + String files = auxclasspathFiles.getValue().stream().map(p -> File.pathSeparator + p.getAbsolutePath()) + .collect(Collectors.joining("")); + return files; } public void setAuxClassPathFiles(String files) { - List newVal = Arrays.asList(files.split(";")).stream().map(File::new).collect(Collectors.toList()); + List newVal = Arrays.asList(files.split(File.pathSeparator)).stream().map(File::new).collect(Collectors.toList()); auxclasspathFiles.setValue(newVal); } 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 e9c7533e33f..9f7e74ca756 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 @@ -38,7 +38,8 @@ public class ASTManager { */ private LanguageVersion lastLanguageVersion; /** - * Latest computed compilation unit (only null before the first call to {@link #updateCompilationUnit(String)}) + * Latest computed compilation unit (only null before the first call to + * {@link #updateCompilationUnit(String, Val)}) */ private Var compilationUnit = Var.newSimpleVar(null); /** @@ -84,7 +85,7 @@ public Val compilationUnitProperty() { * * @throws ParseAbortedException if parsing fails and cannot recover */ - public Node updateCompilationUnit(String source) throws ParseAbortedException { + public Node updateCompilationUnit(String source, Val classLoader) throws ParseAbortedException { if (compilationUnit.isPresent() && getLanguageVersion().equals(lastLanguageVersion) && StringUtils.equals(source, lastValidSource)) { @@ -107,14 +108,14 @@ && getLanguageVersion().equals(lastLanguageVersion) } try { // TODO this should use the aux classpath - languageVersionHandler.getQualifiedNameResolutionFacade(ASTManager.class.getClassLoader()).start(node); + languageVersionHandler.getQualifiedNameResolutionFacade(classLoader.getValue()); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.QUALIFIED_NAME_RESOLUTION_EXCEPTION)); } try { // TODO this should use the aux classpath - languageVersionHandler.getTypeResolutionFacade(ASTManager.class.getClassLoader()).start(node); + languageVersionHandler.getTypeResolutionFacade(classLoader.getValue()); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.TYPERESOLUTION_EXCEPTION)); } From 6d2bbb0ede78ceedc37fd6c571b4e9a5b793acc3 Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Thu, 7 Jun 2018 16:25:41 +0530 Subject: [PATCH 11/17] Classloader is completed. --- .../util/fxdesigner/SourceEditorController.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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 88a8d129d6d..466625927f1 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 @@ -76,15 +76,14 @@ public class SourceEditorController implements Initializable, SettingsOwner { private static final Duration AST_REFRESH_DELAY = Duration.ofMillis(100); private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); - private final Val auxclasspathClassLoader - = auxclasspathFiles.map(files -> { - try { - new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); - } catch (IOException e) { - e.printStackTrace(); - } - return SourceEditorController.class.getClassLoader(); - }); + private final Val auxclasspathClassLoader = auxclasspathFiles.map(files -> { + try { + new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); + } catch (IOException e) { + e.printStackTrace(); + } + return SourceEditorController.class.getClassLoader(); + }); public SourceEditorController(DesignerRoot owner, MainDesignerController mainController) { parent = mainController; From 1de231347274db6302f7a068fe861f5434097a1a Mon Sep 17 00:00:00 2001 From: Akshat Bahety Date: Thu, 7 Jun 2018 16:54:29 +0530 Subject: [PATCH 12/17] Typo --- .../pmd/util/fxdesigner/SourceEditorController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 466625927f1..1c94e39a993 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 @@ -78,7 +78,7 @@ public class SourceEditorController implements Initializable, SettingsOwner { private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); private final Val auxclasspathClassLoader = auxclasspathFiles.map(files -> { try { - new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); + new ClasspathClassLoader(auxclasspathFiles.getValue(), SourceEditorController.class.getClassLoader()); } catch (IOException e) { e.printStackTrace(); } @@ -188,9 +188,7 @@ public void showAuxClassPathController(DesignerRoot root) { @PersistentProperty public String getAuxclasspathFiles() { - String files = auxclasspathFiles.getValue().stream().map(p -> File.pathSeparator + p.getAbsolutePath()) - .collect(Collectors.joining("")); - return files; + return auxclasspathFiles.getValue().stream().map(p -> File.pathSeparator + p.getAbsolutePath()).collect(Collectors.joining("")); } From 7fd3ba467964bf3011d379bb6a1e29c0a5f0fbdf Mon Sep 17 00:00:00 2001 From: akshatbahety Date: Thu, 7 Jun 2018 17:03:19 +0530 Subject: [PATCH 13/17] Updates --- .../pmd/util/fxdesigner/SourceEditorController.java | 6 +++--- .../sourceforge/pmd/util/fxdesigner/model/ASTManager.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) 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 1c94e39a993..b637438371f 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 @@ -78,7 +78,7 @@ public class SourceEditorController implements Initializable, SettingsOwner { private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); private final Val auxclasspathClassLoader = auxclasspathFiles.map(files -> { try { - new ClasspathClassLoader(auxclasspathFiles.getValue(), SourceEditorController.class.getClassLoader()); + new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); } catch (IOException e) { e.printStackTrace(); } @@ -135,7 +135,7 @@ public void refreshAST() { } try { - current = astManager.updateCompilationUnit(source, auxclasspathClassLoader); + current = astManager.updateCompilationUnit(source, auxclasspathClassLoader.getValue()); } catch (ParseAbortedException e) { invalidateAST(true); return; @@ -188,7 +188,7 @@ public void showAuxClassPathController(DesignerRoot root) { @PersistentProperty public String getAuxclasspathFiles() { - return auxclasspathFiles.getValue().stream().map(p -> File.pathSeparator + p.getAbsolutePath()).collect(Collectors.joining("")); + return auxclasspathFiles.getValue().stream().map(p -> p.getAbsolutePath()).collect(Collectors.joining(File.pathSeparator)); } 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 9f7e74ca756..42afe279f0f 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 @@ -39,7 +39,7 @@ public class ASTManager { private LanguageVersion lastLanguageVersion; /** * Latest computed compilation unit (only null before the first call to - * {@link #updateCompilationUnit(String, Val)}) + * {@link #updateCompilationUnit(String, ClassLoader)}) */ private Var compilationUnit = Var.newSimpleVar(null); /** @@ -85,7 +85,7 @@ public Val compilationUnitProperty() { * * @throws ParseAbortedException if parsing fails and cannot recover */ - public Node updateCompilationUnit(String source, Val classLoader) throws ParseAbortedException { + public Node updateCompilationUnit(String source, ClassLoader classLoader) throws ParseAbortedException { if (compilationUnit.isPresent() && getLanguageVersion().equals(lastLanguageVersion) && StringUtils.equals(source, lastValidSource)) { @@ -108,14 +108,14 @@ && getLanguageVersion().equals(lastLanguageVersion) } try { // TODO this should use the aux classpath - languageVersionHandler.getQualifiedNameResolutionFacade(classLoader.getValue()); + languageVersionHandler.getQualifiedNameResolutionFacade(classLoader); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.QUALIFIED_NAME_RESOLUTION_EXCEPTION)); } try { // TODO this should use the aux classpath - languageVersionHandler.getTypeResolutionFacade(classLoader.getValue()); + languageVersionHandler.getTypeResolutionFacade(classLoader); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.TYPERESOLUTION_EXCEPTION)); } From 84f9c9db3223f0169cc5f9aebbe2ef44c9738794 Mon Sep 17 00:00:00 2001 From: akshatbahety Date: Thu, 7 Jun 2018 17:58:57 +0530 Subject: [PATCH 14/17] Minor updates --- .../java/net/sourceforge/pmd/util/ClasspathClassLoader.java | 2 +- .../pmd/util/fxdesigner/SourceEditorController.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java index 3360d9258ce..d5324bcb509 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java @@ -49,7 +49,7 @@ private static URL[] fileToURL(List files) throws IOException { List urlList = new ArrayList<>(); for (File f : files) { - addFileURLs(urlList, f.toURI().toURL()); + urlList.add(f.toURI().toURL()); } return urlList.toArray(new URL[urlList.size()]); } 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 b637438371f..f63a20e5e26 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 @@ -78,7 +78,7 @@ public class SourceEditorController implements Initializable, SettingsOwner { private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); private final Val auxclasspathClassLoader = auxclasspathFiles.map(files -> { try { - new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); + return new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); } catch (IOException e) { e.printStackTrace(); } @@ -192,7 +192,7 @@ public String getAuxclasspathFiles() { } - public void setAuxClassPathFiles(String files) { + public void setAuxclasspathFiles(String files) { List newVal = Arrays.asList(files.split(File.pathSeparator)).stream().map(File::new).collect(Collectors.toList()); auxclasspathFiles.setValue(newVal); } From 6fe9459d1c9b60203772c5e84a59e0145aac7092 Mon Sep 17 00:00:00 2001 From: akshatbahety Date: Fri, 8 Jun 2018 14:30:19 +0530 Subject: [PATCH 15/17] Minor updates --- .../net/sourceforge/pmd/util/ClasspathClassLoader.java | 10 ++++------ .../pmd/util/fxdesigner/AuxClassPathController.java | 2 +- .../pmd/util/fxdesigner/SourceEditorController.java | 6 ++++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java index d5324bcb509..841baa81e5f 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/util/ClasspathClassLoader.java @@ -33,16 +33,14 @@ public class ClasspathClassLoader extends URLClassLoader { static { registerAsParallelCapable(); } - - public ClasspathClassLoader(String classpath, ClassLoader parent) throws IOException { - super(initURLs(classpath), parent); - } - public ClasspathClassLoader(List files, ClassLoader parent) throws IOException { super(fileToURL(files), parent); } + public ClasspathClassLoader(String classpath, ClassLoader parent) throws IOException { + super(initURLs(classpath), parent); + } private static URL[] fileToURL(List files) throws IOException { @@ -51,7 +49,7 @@ private static URL[] fileToURL(List files) throws IOException { for (File f : files) { urlList.add(f.toURI().toURL()); } - return urlList.toArray(new URL[urlList.size()]); + return urlList.toArray(new URL[0]); } private static URL[] initURLs(String classpath) throws IOException { diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java index 3b3ba5aef6e..059dc3b21a5 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/AuxClassPathController.java @@ -57,7 +57,7 @@ public void initialize(URL location, ResourceBundle resources) { removeFileButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); moveItemUpButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); moveItemDownButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); - setClassPathButton.disableProperty().bind(fileListView.getSelectionModel().selectedItemProperty().isNull()); + selectFilesButton.setOnAction(e -> onSelectFileClicked()); 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 f63a20e5e26..a390ba841b4 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 @@ -76,9 +76,9 @@ public class SourceEditorController implements Initializable, SettingsOwner { private static final Duration AST_REFRESH_DELAY = Duration.ofMillis(100); private Var> auxclasspathFiles = Var.newSimpleVar(Collections.emptyList()); - private final Val auxclasspathClassLoader = auxclasspathFiles.map(files -> { + private final Val auxclasspathClassLoader = auxclasspathFiles.map(fileList -> { try { - return new ClasspathClassLoader(files, SourceEditorController.class.getClassLoader()); + return new ClasspathClassLoader(fileList, SourceEditorController.class.getClassLoader()); } catch (IOException e) { e.printStackTrace(); } @@ -117,6 +117,8 @@ public void initialize(URL location, ResourceBundle resources) { parent.refreshAST(); }); + auxclasspathClassLoader.changes().subscribe(t -> parent.refreshAST()); + codeEditorArea.setParagraphGraphicFactory(LineNumberFactory.get(codeEditorArea)); } From 8380d3d5a95c7e1b8a0e3f3cca14442403f7ecf4 Mon Sep 17 00:00:00 2001 From: akshatbahety Date: Fri, 8 Jun 2018 15:07:54 +0530 Subject: [PATCH 16/17] Minor updates --- .../net/sourceforge/pmd/util/fxdesigner/model/ASTManager.java | 2 -- 1 file changed, 2 deletions(-) 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 42afe279f0f..671ef32f972 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 @@ -107,14 +107,12 @@ && getLanguageVersion().equals(lastLanguageVersion) designerRoot.getLogger().logEvent(new LogEntry(e, Category.SYMBOL_FACADE_EXCEPTION)); } try { - // TODO this should use the aux classpath languageVersionHandler.getQualifiedNameResolutionFacade(classLoader); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.QUALIFIED_NAME_RESOLUTION_EXCEPTION)); } try { - // TODO this should use the aux classpath languageVersionHandler.getTypeResolutionFacade(classLoader); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.TYPERESOLUTION_EXCEPTION)); From e533c54ffba5f2d3d6a5fd65a897dbd2eac1f4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Fri, 8 Jun 2018 19:43:23 +0200 Subject: [PATCH 17/17] Fix visitors not started --- .../pmd/util/fxdesigner/SourceEditorController.java | 5 ++--- .../sourceforge/pmd/util/fxdesigner/model/ASTManager.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) 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 a390ba841b4..86c434c4488 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 @@ -109,7 +109,8 @@ public void initialize(URL location, ResourceBundle resources) { codeEditorArea.richChanges() .filter(t -> !t.isIdentity()) .successionEnds(AST_REFRESH_DELAY) - // Refresh the AST anytime the text or the language version changes + // Refresh the AST anytime the text, classloader, or language version changes + .or(auxclasspathClassLoader.changes()) .or(languageVersionProperty().changes()) .subscribe(tick -> { // Discard the AST if the language version has changed @@ -117,8 +118,6 @@ public void initialize(URL location, ResourceBundle resources) { parent.refreshAST(); }); - auxclasspathClassLoader.changes().subscribe(t -> parent.refreshAST()); - codeEditorArea.setParagraphGraphicFactory(LineNumberFactory.get(codeEditorArea)); } 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 671ef32f972..f34fa372562 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 @@ -107,13 +107,13 @@ && getLanguageVersion().equals(lastLanguageVersion) designerRoot.getLogger().logEvent(new LogEntry(e, Category.SYMBOL_FACADE_EXCEPTION)); } try { - languageVersionHandler.getQualifiedNameResolutionFacade(classLoader); + languageVersionHandler.getQualifiedNameResolutionFacade(classLoader).start(node); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.QUALIFIED_NAME_RESOLUTION_EXCEPTION)); } try { - languageVersionHandler.getTypeResolutionFacade(classLoader); + languageVersionHandler.getTypeResolutionFacade(classLoader).start(node); } catch (Exception e) { designerRoot.getLogger().logEvent(new LogEntry(e, Category.TYPERESOLUTION_EXCEPTION)); }