no completions in single line comments

This commit is contained in:
Manindra Moharana
2013-07-26 20:13:59 +05:30
parent 704395f886
commit d871c18710
2 changed files with 41 additions and 4 deletions

View File

@@ -37,11 +37,11 @@ x Completion for array access, strings[0].
Finer details
* printStuff(int,float,String) - completion endings have to be appropriate. Right now it's just printStuff(,,). Cursor positioning also needs to be taken care of(done). Argument list as tooltip if possible?
* Show declaring class for completions
*! p5 enhanced stuff in java, how does it fit in with everything else, and edge cases. Possibly add support for them. Offset handling improvements should help here.
* Diamond operator isn't supported for now. Bummer.
* Icons for completions? Or overkill right now?
x Show declaring class for completions
x! Ignore String case while finding completion candidates
x Multiple 3rd party classes found in various packages. Not a chance no more.
x Obj a1; a1.-> completion doesn't work before it is instantiated. Look into that. Began working again by itself. Yay!

View File

@@ -238,7 +238,7 @@ public class ASTGenerator {
}
// OutlineVisitor visitor = new OutlineVisitor();
// compilationUnit.accept(visitor);
calculateComments();
getCodeComments();
codeTree = new DefaultMutableTreeNode(
getNodeAsString((ASTNode) compilationUnit
.types().get(0)));
@@ -757,6 +757,10 @@ public class ASTGenerator {
private String lastPredictedWord = " ";
public void preparePredictions(final String word, final int line, final int lineStartNonWSOffset) {
if(caretWithinLineComment()){
System.out.println("No predictions.");
return;
}
SwingWorker worker = new SwingWorker() {
@Override
@@ -807,6 +811,21 @@ public class ASTGenerator {
}
}
// Ensure that we're not inside a comment. TODO: Binary search
/*for (Comment comm : getCodeComments()) {
int commLineNo = PdeToJavaLineNumber(compilationUnit
.getLineNumber(comm.getStartPosition()));
if(commLineNo == lineNumber){
System.out.println("Found a comment line " + comm);
System.out.println("Comment LSO "
+ javaCodeOffsetToLineStartOffset(compilationUnit
.getLineNumber(comm.getStartPosition()),
comm.getStartPosition()));
break;
}
}*/
// Now parse the expression into an ASTNode object
ASTNode nearestNode = null;
@@ -2580,15 +2599,33 @@ public class ASTGenerator {
}
private void calculateComments(){
private List<Comment> getCodeComments(){
List<Comment> commentList = compilationUnit.getCommentList();
System.out.println("Total comments: " + commentList.size());
// System.out.println("Total comments: " + commentList.size());
// int i = 0;
// for (Comment comment : commentList) {
// System.out.println(++i + ": "+comment + " Line:"
// + compilationUnit.getLineNumber(comment.getStartPosition()) + ", "
// + comment.getLength());
// }
return commentList;
}
protected boolean caretWithinLineComment(){
String pdeLine = editor.getLineText(editor.textArea().getCaretLine()).trim();
int caretPos = editor.textArea().getCaretPosition()
- editor.textArea()
.getLineStartNonWhiteSpaceOffset(editor.textArea().getCaretLine());
int x = pdeLine.indexOf("//");
System.out.println(x + " , " + caretPos + ", Checking line for comment " + pdeLine);
//lineStartOffset = editor.textArea().
if (x >= 0 && caretPos > x) {
System.out.println("INSIDE a comment");
return true;
}
System.out.println("not within comment");
return false;
}
/**