RFR: 8278039: Code completion not woking after some statements such as "if" or "while"
Aggelos Biboudis
duke at openjdk.java.net
Tue May 3 08:05:19 UTC 2022
On Tue, 1 Feb 2022 15:44:53 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider these snippets with completion:
>
> String s = "";
> if (s.c<tab>
>
>
> The completion here proposes:
>
> char com.
>
>
> which is clearly wrong. The reason is that when the completion searches for the deepest `Tree` at the cursor's position, it finds a tree for the synthetic/error recovery ';' for the then section of the command, rather than a tree in the condition.
>
> The proposed patch is to tweak the search for the deepest `Tree`, so that the tree from the if's condition is found.
test/langtools/jdk/jshell/CompletionSuggestionTest.java line 779:
> 777: public void testStatements() {
> 778: assertEval("String s = \"\";");
> 779: assertCompletion("if (s.conta|", (Boolean) null, "contains(");
The `if (s.ch|` would return only one result, [chars](https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/String.html#chars())().
How about including that to show that `char` (as mentioned in the description) will not be included?
-------------
PR: https://git.openjdk.java.net/jdk/pull/7308
More information about the kulla-dev
mailing list