jostillmanns / javacomplete

java completion daemon
31 stars 0 forks source link

No completion inside for-each parens #1

Open dgutov opened 9 years ago

dgutov commented 9 years ago

With example (context):

ArrayList<String> fullyqualified = new ArrayList();
for(String s:f|) {
  sb.append(s+"\n");
}

there's no completion after f. The backtrace from the server output looks like this:

TRACE: japa.parser.ParseException: Encountered " <IDENTIFIER> "out "" at line 114, column 13.
Was expecting one of:
    "catch" ...
    "finally" ...

    at japa.parser.ASTParser.generateParseException(ASTParser.java:10074)
    at japa.parser.ASTParser.jj_consume_token(ASTParser.java:9920)
    at japa.parser.ASTParser.TryStatement(ASTParser.java:4308)
    at japa.parser.ASTParser.Statement(ASTParser.java:3391)
    at japa.parser.ASTParser.BlockStatement(ASTParser.java:3527)
    at japa.parser.ASTParser.Statements(ASTParser.java:1657)
    at japa.parser.ASTParser.Block(ASTParser.java:3460)
    at japa.parser.ASTParser.MethodDeclaration(ASTParser.java:1333)
    at japa.parser.ASTParser.ClassOrInterfaceBodyDeclaration(ASTParser.java:1042)
    at japa.parser.ASTParser.ClassOrInterfaceBody(ASTParser.java:961)
    at japa.parser.ASTParser.ClassOrInterfaceDeclaration(ASTParser.java:604)
    at japa.parser.ASTParser.TypeDeclaration(ASTParser.java:524)
    at japa.parser.ASTParser.CompilationUnit(ASTParser.java:269)
    at japa.parser.JavaParser.parse(JavaParser.java:81)
    at japa.parser.JavaParser.parse(JavaParser.java:94)
    at me.tillmanns.javacomplete.JavaCompleteCompilationUnit.<init>(JavaCompleteCompilationUnit.java:43)
    at me.tillmanns.javacomplete.Complete.complete(Complete.java:111)
    at me.tillmanns.javacomplete.Complete.<init>(Complete.java:55)
    at me.tillmanns.javacomplete.JavaComplete.acceptRequest(JavaComplete.java:145)
    at me.tillmanns.javacomplete.JavaComplete.initCompleteLoop(JavaComplete.java:100)
    at me.tillmanns.javacomplete.JavaComplete.main(JavaComplete.java:51)
DEBUG: could not complete at point: java.lang.NullPointerException
jostillmanns commented 9 years ago

Thanks for the notice. I know about this issue and I am going to fix this by switching to the eclipse ASTParser (which will allow me to read incomplete / incorrect code). Sadly I have been sick the last few days, so I didn't really had the chance to look into this.

dgutov commented 9 years ago

I see. I thought the parser shouldn't be the problem here, since for-each was added in Java 1.5, and that's the version javaparser claims to support.

There's no hurry, though, as far as I'm concerned. Thanks for bringing a new option to the community. :)

jostillmanns commented 9 years ago

It's not a matter of parser support. The client implementation sends an incorrect buffer (syntax wise) to the server, thus leaving the current parser with incomplete code. One could easily fix this specific error by refining the elisp client, but I think it will be better to just use the eclipse ASTParser, which will (as I said) allow to parse incomplete code.