find closest node bug fix

This commit is contained in:
Manindra Moharana
2013-08-18 15:46:47 +05:30
parent a5a9f1417b
commit 8a9704b35a
4 changed files with 17 additions and 67 deletions

View File

@@ -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.

View File

@@ -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();

View File

@@ -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();
}
}

View File

@@ -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;
}
}