From 8a9704b35a224b918e2e050bfcf9ae940c9f976d Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Sun, 18 Aug 2013 15:46:47 +0530 Subject: [PATCH] find closest node bug fix --- pdex/Todo, GSoC 2013.txt | 1 + .../mode/experimental/ASTGenerator.java | 16 +++-- .../experimental/ErrorCheckerService.java | 5 +- .../mode/experimental/TextArea.java | 62 +------------------ 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/pdex/Todo, GSoC 2013.txt b/pdex/Todo, GSoC 2013.txt index 8bee7b5f4..3866a19b4 100644 --- a/pdex/Todo, GSoC 2013.txt +++ b/pdex/Todo, GSoC 2013.txt @@ -15,6 +15,7 @@ The big stuff: - Making very good progress here. The elegance of recurion - Hats off! - Many of the cases seem to have been covered, and I'm achieving more and more code unification as I'm working through the problem step by step - Looks almost complete now, nearly all cases covered(July 13th) +* Ensure that a compilation unit is created at startup! * Scope handling? Static/non static scope? * Disable completions on comment line * Trie implementation would be lower priority, "premature optimisation is pure evil". Get all features of CC working good enough and then plan this. diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index adfd923d1..9302e910e 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -264,9 +264,9 @@ public class ASTGenerator { return; jtree.setModel(new DefaultTreeModel(codeTree)); ((DefaultTreeModel) jtree.getModel()).reload(); -// if (!frame2.isVisible()) { -// frame2.setVisible(true); -// } + if (!frame2.isVisible()) { + frame2.setVisible(true); + } // if (!frameAutoComp.isVisible()) { // // frameAutoComp.setVisible(true); @@ -1389,7 +1389,9 @@ public class ASTGenerator { if (nodes.size() > 0) { ASTNode retNode = nodes.get(0); for (ASTNode cNode : nodes) { - if (getLineNumber(cNode) <= lineNumber) + if (getLineNumber(cNode) <= lineNumber + && lineNumber <= getLineNumber(cNode, cNode.getStartPosition() + + cNode.getLength())) retNode = cNode; else break; @@ -1397,7 +1399,7 @@ public class ASTGenerator { return retNode; } - return null; + return parent; } public DefaultMutableTreeNode getAST() { @@ -1657,6 +1659,10 @@ public class ASTGenerator { return ((CompilationUnit) node.getRoot()).getLineNumber(node .getStartPosition()); } + + public static int getLineNumber(ASTNode node, int pos) { + return ((CompilationUnit) node.getRoot()).getLineNumber(pos); + } public static void main(String[] args) { //traversal2(); diff --git a/pdex/src/processing/mode/experimental/ErrorCheckerService.java b/pdex/src/processing/mode/experimental/ErrorCheckerService.java index e565b11c4..6d5d24e36 100644 --- a/pdex/src/processing/mode/experimental/ErrorCheckerService.java +++ b/pdex/src/processing/mode/experimental/ErrorCheckerService.java @@ -248,6 +248,8 @@ public class ErrorCheckerService implements Runnable{ stopThread = false; checkCode(); + if(!hasSyntaxErrors()) + editor.showProblemListView(XQConsoleToggle.CONSOLE); while (!stopThread) { try { // Take a nap. @@ -778,6 +780,7 @@ public class ErrorCheckerService implements Runnable{ // editor.statusNotice("Position: " + // editor.getTextArea().getCaretLine()); boolean notFound = true; + //if(notFound) return; for (ErrorMarker emarker : editor.errorBar.errorPoints) { if (emarker.problem.lineNumber == editor.getTextArea() .getCaretLine() + 1) { @@ -794,7 +797,7 @@ public class ErrorCheckerService implements Runnable{ } } if (notFound) { - editor.statusEmpty(); + //editor.statusEmpty(); } } diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 39282d3ef..35c3378ae 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -169,27 +169,6 @@ public class TextArea extends JEditTextArea { return; } break; -// case KeyEvent.VK_ENTER: -// if (suggestion != null) { -// if (suggestion.isVisible()) { -// if (suggestion.insertSelection()) { -// hideSuggestion(); // Kill it! -// //final int position = getCaretPosition(); -// SwingUtilities.invokeLater(new Runnable() { -// @Override -// public void run() { -// try { -// //getDocument().remove(position - 1, 1); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } -// }); -// return; -// } -// } -// } -// break; case KeyEvent.VK_BACK_SPACE: log("BK Key"); break; @@ -199,45 +178,6 @@ public class TextArea extends JEditTextArea { } super.processKeyEvent(evt); - /* - if (evt.getKeyCode() == KeyEvent.VK_DOWN && suggestion != null) { - if (suggestion.isVisible()) { - //log("KeyDown"); - suggestion.moveDown(); - return; - } - } else if (evt.getKeyCode() == KeyEvent.VK_UP && suggestion != null) { - if (suggestion.isVisible()) { - //log("KeyUp"); - suggestion.moveUp(); - return; - } - } - if (evt.getKeyChar() == KeyEvent.VK_ENTER) { - if (suggestion != null) { - if (suggestion.isVisible()){ - if (suggestion.insertSelection()) { - final int position = getCaretPosition(); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - try { - //getDocument().remove(position - 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - return; - } - } - } - } else if (evt.getKeyChar() == KeyEvent.VK_BACK_SPACE) { - log("BK Key"); - } - - }*/ - if (evt.getID() == KeyEvent.KEY_TYPED) { errorCheckerService.runManualErrorCheck(); log(" Typing: " + fetchPhrase(evt) + " " @@ -321,7 +261,7 @@ public class TextArea extends JEditTextArea { else if (keyChar == KeyEvent.VK_ESCAPE) { //log("ESC keypress. fetchPhrase()"); return null; - } else if (keyChar == KeyEvent.CHAR_UNDEFINED) { + } else if (keyChar == KeyEvent.VK_TAB || keyChar == KeyEvent.CHAR_UNDEFINED) { return null; } }