| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e469f2d commit ade288b
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1619,7 +1619,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 1619 | 1619 | item = Toolkit.newJMenuItem(Language.text("menu.debug.show_sketch_outline"), KeyEvent.VK_L); | |
| 1620 | 1620 | item.addActionListener(new ActionListener() { | |
| 1621 | 1621 | public void actionPerformed(ActionEvent e) { | |
| 1622 | - Base.log("Show Sketch Outline:"); | ||
| 1622 | + Messages.log("Show Sketch Outline:"); | ||
| 1623 | 1623 | errorCheckerService.getASTGenerator().showSketchOutline(); | |
| 1624 | 1624 | } | |
| 1625 | 1625 | }); | |
@@ -1628,7 +1628,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 1628 | 1628 | item = Toolkit.newJMenuItem(Language.text("menu.debug.show_tabs_list"), KeyEvent.VK_Y); | |
| 1629 | 1629 | item.addActionListener(new ActionListener() { | |
| 1630 | 1630 | public void actionPerformed(ActionEvent e) { | |
| 1631 | - Base.log("Show Tab Outline:"); | ||
| 1631 | + Messages.log("Show Tab Outline:"); | ||
| 1632 | 1632 | errorCheckerService.getASTGenerator().showTabOutline(); | |
| 1633 | 1633 | } | |
| 1634 | 1634 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,6 @@ | |||
| 28 | 28 | import java.awt.event.MouseEvent; | |
| 29 | 29 | import java.awt.event.MouseMotionAdapter; | |
| 30 | 30 | import java.util.ArrayList; | |
| 31 | - import java.util.Collections; | ||
| 32 | 31 | import java.util.List; | |
| 33 | 32 | ||
| 34 | 33 | import javax.swing.JPanel; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,7 +119,7 @@ | |||
| 119 | 119 | @SuppressWarnings({ "unchecked" }) | |
| 120 | 120 | public class ASTGenerator { | |
| 121 | 121 | protected final ErrorCheckerService errorCheckerService; | |
| 122 | - protected JavaEditor editor; | ||
| 122 | + protected final JavaEditor editor; | ||
| 123 | 123 | public DefaultMutableTreeNode codeTree = new DefaultMutableTreeNode(); | |
| 124 | 124 | ||
| 125 | 125 | protected JFrame frmASTView; | |
@@ -139,9 +139,9 @@ public class ASTGenerator { | |||
| 139 | 139 | protected JLabel lblRefactorOldName; | |
| 140 | 140 | ||
| 141 | 141 | ||
| 142 | - public ASTGenerator(ErrorCheckerService ecs) { | ||
| 142 | + public ASTGenerator(JavaEditor editor, ErrorCheckerService ecs) { | ||
| 143 | + this.editor = editor; | ||
| 143 | 144 | this.errorCheckerService = ecs; | |
| 144 | - this.editor = ecs.getEditor(); | ||
| 145 | 145 | setupGUI(); | |
| 146 | 146 | //addCompletionPopupListner(); | |
| 147 | 147 | addListeners(); | |
@@ -809,7 +809,6 @@ protected static List<CompletionCandidate> trimCandidates(String newWord, List<C | |||
| 809 | 809 | */ | |
| 810 | 810 | public List<CompletionCandidate> preparePredictions(final String pdePhrase, | |
| 811 | 811 | final int line) { | |
| 812 | - ErrorCheckerService errorCheckerService = editor.getErrorChecker(); | ||
| 813 | 812 | ASTNode astRootNode = (ASTNode) errorCheckerService.getLatestCU().types().get(0); | |
| 814 | 813 | ||
| 815 | 814 | // If the parsed code contains pde enhancements, take 'em out. | |
@@ -1650,7 +1649,6 @@ public ASTNodeWrapper getASTNodeAt(int lineNumber, String name, int offset, | |||
| 1650 | 1649 | int pdeLineNumber = lineNumber + errorCheckerService.mainClassOffset; | |
| 1651 | 1650 | // log("----getASTNodeAt---- CU State: " | |
| 1652 | 1651 | // + errorCheckerService.compilationUnitState); | |
| 1653 | - editor = errorCheckerService.getEditor(); | ||
| 1654 | 1652 | int codeIndex = editor.getSketch().getCodeIndex(editor.getCurrentTab()); | |
| 1655 | 1653 | if (codeIndex > 0) { | |
| 1656 | 1654 | for (int i = 0; i < codeIndex; i++) { | |
@@ -2349,15 +2347,15 @@ public ASTNode dfsLookForASTNode(ASTNode root, String name, int startOffset, | |||
| 2349 | 2347 | public void showSketchOutline() { | |
| 2350 | 2348 | if (editor.hasJavaTabs()) return; | |
| 2351 | 2349 | ||
| 2352 | - sketchOutline = new SketchOutline(codeTree, errorCheckerService); | ||
| 2350 | + sketchOutline = new SketchOutline(editor, codeTree); | ||
| 2353 | 2351 | sketchOutline.show(); | |
| 2354 | 2352 | } | |
| 2355 | - */ | ||
| 2356 | 2353 | ||
| 2357 | 2354 | ||
| 2358 | 2355 | public void showTabOutline() { | |
| 2359 | - new TabOutline(errorCheckerService).show(); | ||
| 2356 | + new TabOutline(editor).show(); | ||
| 2360 | 2357 | } | |
| 2358 | + */ | ||
| 2361 | 2359 | ||
| 2362 | 2360 | ||
| 2363 | 2361 | public int javaCodeOffsetToLineStartOffset(int line, int jOffset){ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,10 +176,11 @@ public class ErrorCheckerService { | |||
| 176 | 176 | public static final String IMPORT_REGEX = | |
| 177 | 177 | "(?:^|;)\\s*(import\\s+)((?:static\\s+)?\\S+)(\\s*;)"; | |
| 178 | 178 | ||
| 179 | - public ErrorCheckerService(JavaEditor debugEditor) { | ||
| 180 | - this.editor = debugEditor; | ||
| 181 | - xqpreproc = new XQPreprocessor(this); | ||
| 182 | - astGenerator = new ASTGenerator(this); | ||
| 179 | + | ||
| 180 | + public ErrorCheckerService(JavaEditor editor) { | ||
| 181 | + this.editor = editor; | ||
| 182 | + xqpreproc = new XQPreprocessor(editor); | ||
| 183 | + astGenerator = new ASTGenerator(editor, this); | ||
| 183 | 184 | loadCompClass = true; | |
| 184 | 185 | } | |
| 185 | 186 | ||
@@ -318,7 +319,7 @@ public void request() { | |||
| 318 | 319 | ||
| 319 | 320 | ||
| 320 | 321 | public void addListener(Document doc) { | |
| 321 | - doc.addDocumentListener(sketchChangedListener); | ||
| 322 | + if (doc != null) doc.addDocumentListener(sketchChangedListener); | ||
| 322 | 323 | } | |
| 323 | 324 | ||
| 324 | 325 | ||
@@ -1516,10 +1517,6 @@ public void handleErrorCheckingToggle() { | |||
| 1516 | 1517 | } | |
| 1517 | 1518 | ||
| 1518 | 1519 | ||
| 1519 | - public JavaEditor getEditor() { | ||
| 1520 | - return editor; | ||
| 1521 | - } | ||
| 1522 | - | ||
| 1523 | 1520 | public ArrayList<ImportStatement> getProgramImports() { | |
| 1524 | 1521 | return programImports; | |
| 1525 | 1522 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,21 +61,20 @@ | |||
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | 63 | public class SketchOutline { | |
| 64 | + protected final JavaEditor editor; | ||
| 65 | + | ||
| 64 | 66 | protected JFrame frmOutlineView; | |
| 65 | - protected ErrorCheckerService errorCheckerService; | ||
| 66 | 67 | protected JScrollPane jsp; | |
| 67 | 68 | protected DefaultMutableTreeNode soNode, tempNode; | |
| 68 | 69 | protected final JTree soTree; | |
| 69 | 70 | protected JTextField searchField; | |
| 70 | - protected JavaEditor editor; | ||
| 71 | 71 | protected boolean internalSelection = false; | |
| 72 | 72 | ||
| 73 | 73 | ImageIcon classIcon, fieldIcon, methodIcon; | |
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | - public SketchOutline(DefaultMutableTreeNode codeTree, ErrorCheckerService ecs) { | ||
| 77 | - errorCheckerService = ecs; | ||
| 78 | - editor = ecs.getEditor(); | ||
| 76 | + public SketchOutline(JavaEditor editor, DefaultMutableTreeNode codeTree) { | ||
| 77 | + this.editor = editor; | ||
| 79 | 78 | soNode = new DefaultMutableTreeNode(); | |
| 80 | 79 | generateSketchOutlineTree(soNode, codeTree); | |
| 81 | 80 | soNode = (DefaultMutableTreeNode) soNode.getChildAt(0); | |
@@ -95,7 +94,7 @@ private void createGUI(){ | |||
| 95 | 94 | frmOutlineView = new JFrame(); | |
| 96 | 95 | frmOutlineView.setAlwaysOnTop(true); | |
| 97 | 96 | frmOutlineView.setUndecorated(true); | |
| 98 | - Point tp = errorCheckerService.getEditor().getTextArea().getLocationOnScreen(); | ||
| 97 | + Point tp = editor.getTextArea().getLocationOnScreen(); | ||
| 99 | 98 | ||
| 100 | 99 | int minWidth = (int) (editor.getMinimumSize().width * 0.7f); | |
| 101 | 100 | int maxWidth = (int) (editor.getMinimumSize().width * 0.9f); | |
@@ -130,10 +129,10 @@ private void createGUI(){ | |||
| 130 | 129 | frmOutlineView.add(panelBottom); | |
| 131 | 130 | frmOutlineView.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | |
| 132 | 131 | frmOutlineView.pack(); | |
| 133 | - frmOutlineView.setBounds(tp.x + errorCheckerService.getEditor().getTextArea().getWidth() - minWidth, tp.y, minWidth, | ||
| 132 | + frmOutlineView.setBounds(tp.x + editor.getTextArea().getWidth() - minWidth, tp.y, minWidth, | ||
| 134 | 133 | Math.min(editor.getTextArea().getHeight(), frmOutlineView.getHeight())); | |
| 135 | - frmOutlineView.setMinimumSize(new Dimension(minWidth, Math.min(errorCheckerService.getEditor().getTextArea().getHeight(), frmOutlineView.getHeight()))); | ||
| 136 | - frmOutlineView.setLocation(tp.x + errorCheckerService.getEditor().getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2, | ||
| 134 | + frmOutlineView.setMinimumSize(new Dimension(minWidth, Math.min(editor.getTextArea().getHeight(), frmOutlineView.getHeight()))); | ||
| 135 | + frmOutlineView.setLocation(tp.x + editor.getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2, | ||
| 137 | 136 | frmOutlineView.getY() + (editor.getTextArea().getHeight() - frmOutlineView.getHeight()) / 2); | |
| 138 | 137 | addListeners(); | |
| 139 | 138 | } | |
@@ -221,7 +220,7 @@ private void updateSelection(){ | |||
| 221 | 220 | protected Object doInBackground() throws Exception { | |
| 222 | 221 | String text = searchField.getText().toLowerCase(); | |
| 223 | 222 | tempNode = new DefaultMutableTreeNode(); | |
| 224 | - filterTree(text, tempNode, soNode); | ||
| 223 | + filterTree(text, tempNode, soNode); // TODO: is using soNode thread-safe? [jv] | ||
| 225 | 224 | return null; | |
| 226 | 225 | } | |
| 227 | 226 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,13 +63,11 @@ public class TabOutline { | |||
| 63 | 63 | protected JTextField searchField; | |
| 64 | 64 | protected JLabel lblCaption; | |
| 65 | 65 | protected JavaEditor editor; | |
| 66 | - protected ErrorCheckerService errorCheckerService; | ||
| 67 | 66 | protected boolean internalSelection = false; | |
| 68 | 67 | ||
| 69 | 68 | ||
| 70 | - public TabOutline(ErrorCheckerService ecs) { | ||
| 71 | - errorCheckerService = ecs; | ||
| 72 | - editor = ecs.getEditor(); | ||
| 69 | + public TabOutline(JavaEditor editor) { | ||
| 70 | + this.editor = editor; | ||
| 73 | 71 | createGUI(); | |
| 74 | 72 | } | |
| 75 | 73 | ||
@@ -78,7 +76,7 @@ private void createGUI() { | |||
| 78 | 76 | frmOutlineView = new JFrame(); | |
| 79 | 77 | frmOutlineView.setAlwaysOnTop(true); | |
| 80 | 78 | frmOutlineView.setUndecorated(true); | |
| 81 | - Point tp = errorCheckerService.getEditor().getTextArea().getLocationOnScreen(); | ||
| 79 | + Point tp = editor.getTextArea().getLocationOnScreen(); | ||
| 82 | 80 | lblCaption = new JLabel("Tabs List (type to filter)"); | |
| 83 | 81 | int minWidth = estimateFrameWidth(); | |
| 84 | 82 | int maxWidth = (int) (editor.getMinimumSize().width * 0.9f); | |
@@ -108,14 +106,14 @@ private void createGUI() { | |||
| 108 | 106 | frmOutlineView.add(panelBottom); | |
| 109 | 107 | frmOutlineView.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); | |
| 110 | 108 | frmOutlineView.pack(); | |
| 111 | - frmOutlineView.setBounds(tp.x + errorCheckerService.getEditor().getTextArea().getWidth() - minWidth, | ||
| 109 | + frmOutlineView.setBounds(tp.x + editor.getTextArea().getWidth() - minWidth, | ||
| 112 | 110 | tp.y, | |
| 113 | 111 | minWidth, | |
| 114 | 112 | estimateFrameHeight()); | |
| 115 | 113 | frmOutlineView.setMinimumSize(new Dimension(minWidth, Math | |
| 116 | - .min(errorCheckerService.getEditor().getTextArea().getHeight(), | ||
| 114 | + .min(editor.getTextArea().getHeight(), | ||
| 117 | 115 | frmOutlineView.getHeight()))); | |
| 118 | - frmOutlineView.setLocation(tp.x + errorCheckerService.getEditor().getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2, | ||
| 116 | + frmOutlineView.setLocation(tp.x + editor.getTextArea().getWidth()/2 - frmOutlineView.getWidth()/2, | ||
| 119 | 117 | frmOutlineView.getY() + (editor.getTextArea().getHeight() - frmOutlineView.getHeight()) / 2); | |
| 120 | 118 | DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tabTree.getCellRenderer(); | |
| 121 | 119 | renderer.setLeafIcon(null); | |
@@ -202,7 +200,7 @@ private void updateSelection() { | |||
| 202 | 200 | protected Object doInBackground() throws Exception { | |
| 203 | 201 | String text = searchField.getText().toLowerCase(); | |
| 204 | 202 | tempNode = new DefaultMutableTreeNode(); | |
| 205 | - filterTree(text, tempNode, tabNode); | ||
| 203 | + filterTree(text, tempNode, tabNode); // TODO: is using tabNode thread-safe? [jv] | ||
| 206 | 204 | return null; | |
| 207 | 205 | } | |
| 208 | 206 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,6 +37,7 @@ | |||
| 37 | 37 | ||
| 38 | 38 | import processing.app.Util; | |
| 39 | 39 | import processing.data.StringList; | |
| 40 | + import processing.mode.java.JavaEditor; | ||
| 40 | 41 | import processing.mode.java.preproc.PdePreprocessor; | |
| 41 | 42 | ||
| 42 | 43 | ||
@@ -47,17 +48,17 @@ | |||
| 47 | 48 | public class XQPreprocessor { | |
| 48 | 49 | private ASTRewrite rewrite = null; | |
| 49 | 50 | private List<ImportStatement> extraImports; | |
| 50 | - private ErrorCheckerService ecs; | ||
| 51 | + private final JavaEditor editor; | ||
| 51 | 52 | private String[] coreImports; | |
| 52 | 53 | private String[] defaultImports; | |
| 53 | 54 | ||
| 54 | 55 | ||
| 55 | - public XQPreprocessor(ErrorCheckerService ecs) { | ||
| 56 | - this.ecs = ecs; | ||
| 56 | + public XQPreprocessor(JavaEditor editor) { | ||
| 57 | + this.editor = editor; | ||
| 57 | 58 | ||
| 58 | 59 | // get parameters from the main preproc | |
| 59 | 60 | // PdePreprocessor p = new PdePreprocessor(null); | |
| 60 | - PdePreprocessor p = ecs.editor.createPreprocessor(null); | ||
| 61 | + PdePreprocessor p = editor.createPreprocessor(null); | ||
| 61 | 62 | defaultImports = p.getDefaultImports(); | |
| 62 | 63 | coreImports = p.getCoreImports(); | |
| 63 | 64 | } | |
@@ -105,16 +106,16 @@ protected String prepareImports(List<ImportStatement> programImports) { | |||
| 105 | 106 | for (String imp : defaultImports) { | |
| 106 | 107 | imports.append("import " + imp + ";"); | |
| 107 | 108 | } | |
| 108 | - if (ecs.getEditor().getSketch().getCodeFolder().exists()) { | ||
| 109 | + if (editor.getSketch().getCodeFolder().exists()) { | ||
| 109 | 110 | StringList codeFolderPackages = null; | |
| 110 | - String codeFolderClassPath = Util.contentsToClassPath(ecs.getEditor().getSketch().getCodeFolder()); | ||
| 111 | + String codeFolderClassPath = Util.contentsToClassPath(editor.getSketch().getCodeFolder()); | ||
| 111 | 112 | codeFolderPackages = Util.packageListFromClassPath(codeFolderClassPath); | |
| 112 | 113 | if (codeFolderPackages != null) { | |
| 113 | - ecs.codeFolderImports.clear(); | ||
| 114 | + editor.getErrorChecker().codeFolderImports.clear(); | ||
| 114 | 115 | for (String item : codeFolderPackages) { | |
| 115 | 116 | // Messages.log("CF import " + item); | |
| 116 | 117 | imports.append("import " + item + ".*;"); | |
| 117 | - ecs.codeFolderImports.add(new ImportStatement("import " + item + ".*;",0,0)); | ||
| 118 | + editor.getErrorChecker().codeFolderImports.add(new ImportStatement("import " + item + ".*;",0,0)); | ||
| 118 | 119 | } | |
| 119 | 120 | } | |
| 120 | 121 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments