mike-lischke / antlr4-c3

A grammar agnostic code completion engine for ANTLR4 based parsers
MIT License
396 stars 62 forks source link

hotfix[java-port]: Eliminate possible NPE #109

Closed rovo98 closed 5 months ago

rovo98 commented 5 months ago

This pr fix https://github.com/mike-lischke/antlr4-c3/issues/108 .

mike-lischke commented 5 months ago

@rovo98 Thanks for the patch! Can you also add a signature? (see the failed DCO and follow the Details link for help).

rovo98 commented 5 months ago

@rovo98 Thanks for the patch! Can you also add a signature? (see the failed DCO and follow the Details link for help).

@mike-lischke Thanks for the review! I have add the signature, the failed DCO turns green now.

rovo98 commented 5 months ago

Just FYI, the NPE might also occurs at the line 459, since the.candidates.tokens.get(symbol) can return null.(Same issue mentioned in the corresponding issue). https://github.com/mike-lischke/antlr4-c3/blob/60f62a4f4e39644280c8b666394bd8cf3cebb348/ports/java/src/main/java/com/vmware/antlr4c3/CodeCompletionCore.java#L458-L461 In this case, Objects.equals() is preferred. Never mind, the patch also fix the issue.