| Summary: | [content assist] Wrong completion suggestion when method invocations are nested | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Gayan Perera <gayanper> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | loskutov, manoj.palat, mauromol, stephan.herrmann |
| Version: | 4.20 | ||
| Target Milestone: | 4.20 M3 | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=539685 https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/180085 https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=1e898ec9c2f982e045bbb910f6d94f084cb5d545 |
||
| Whiteboard: | |||
Seems like the problem started after Bug 539685. (In reply to Gayan Perera from comment #1) > Seems like the problem started after Bug 539685. @Stephan, could you please check? I can confirm that recovered AST is wrong:
private void foo() {
String template;
this.list.(<CompleteOnMessageSendName:template.concat()>);
}
In a corresponding JUnit, however, I don't get any proposals, so I'm not seeing the exact same symptoms as Gayan.
@Stephan, the issue was reported based on what i get in JDT UI. Can it be that the suggestion i'm getting is from some other proposal computer based on the recovered information ? (In reply to Gayan Perera from comment #4) > @Stephan, the issue was reported based on what i get in JDT UI. Can it be > that the suggestion i'm getting is from some other proposal computer based > on the recovered information ? I don't think so, but meanwhile I found a significant difference between the junit and the real world case: by placing the test inside CompletionTest_1_5 it runs against the mock system library jclMin1.5.jar, which doesn't contain the type ArrayList :) I'm about to propose a fix, and then you can retest the result in real life, OK? BTW: severity "critical" is reserved for issues akin to data loss (e.g., eclipse crashing without any chance to save recent work) :) New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/180085 (In reply to Eclipse Genie from comment #6) > New Gerrit change created: > https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/180085 Indeed Bug 539685 introduced a new branch guarded by a condition that was not sufficiently precise. Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/180085 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=1e898ec9c2f982e045bbb910f6d94f084cb5d545 (In reply to Eclipse Genie from comment #8) > Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/180085 was > merged to [master]. > Commit: > http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/ > ?id=1e898ec9c2f982e045bbb910f6d94f084cb5d545 Released. Thanks, Gayan, for the report! (In reply to Stephan Herrmann from comment #5) > (In reply to Gayan Perera from comment #4) > > @Stephan, the issue was reported based on what i get in JDT UI. Can it be > > that the suggestion i'm getting is from some other proposal computer based > > on the recovered information ? > > I don't think so, but meanwhile I found a significant difference between the > junit and the real world case: by placing the test inside CompletionTest_1_5 > it runs against the mock system library jclMin1.5.jar, which doesn't contain > the type ArrayList :) > > I'm about to propose a fix, and then you can retest the result in real life, > OK? Sure @Staphan, > BTW: severity "critical" is reserved for issues akin to data loss (e.g., > eclipse crashing without any chance to save recent work) :) Sure i will use this info next time when i report a regression issue like this. Verified for 4.20 M3 Version: 2021-06 (4.20)Build id: I20210518-0850 |
Take the code package workbench; import java.util.ArrayList; public class App { ArrayList<String> list = new ArrayList<String>(); public static void main(String[] args) { } private void foo() { String template = "temp"; this.list.$add(template.concat("late")); } } Invoke completions at $ which will give you concat method suggestion from String class which is wrong from current position and even from the String class point of view. Change that like by removing "this." to list.$add(template.concat("late")); Now invoke the completions, you will get the correct method completions for ArrayList. Seems like when we have this qualifier the nested method which is String.concat is suggested as a completion, if you have a different method as the nested invocation, it will be suggested.