Hello. This situation has been driving me (and others) crazy every minute(!) I am coding with eclipse since forever, so I finally took some time out to at least pinpoint the offending plugin and commit. Hope this helps!
This behaviour started back with eclipe 2021-06 while 2021-03 still behaved "well".
Code completion is behaving in an undesired manner in the following situation:
public class Demo {
public static void main(String[] args) {
System.out.println("hello");
if (true) {
System.out.print|cursor|ln("world");
}
}
}
Triggering code completion (ctrl+space) while the cursor is located as indicated gives a list of proposals, so far so good.
Now, after selecting the first proposal (in my case the "print" method), the code gets transformed as follows:
public class Demo {
public static void main(String[] args) {
System.out.println("hello");
if (true) {
System.out.print(false);
}
}
}
The expected behaviour would be that the existing parameter "world" remains in place and only the "ln" part of "println" gets removed, i.e. the method call is updated from "println" to "print", like so:
public class Demo {
public static void main(String[] args) {
System.out.println("hello");
if (true) {
System.out.print("world");
}
}
}
Note that I have enclosed the second println statement in an if block (the true doesnt matter). An empty block does not show the bad behaviour. Here is an (incomplete) overview:
public class Test {
public static void main (String[] args) {
// good behaviour
System.out.println("hello");
{ // good behaviour
System.out.println("world");
}
if (true) { // bad behaviour
System.out.println("world");
}
while (true) { // bad behaviour
System.out.println("world");
break;
}
for (int i = 0; i < 10; i++) { // bad behaviour
System.out.println("world");
}
Runnable a = () -> { // bad behaviour
System.out.println("world");
};
Nested n = new Nested();
// good behaviour for deeper1, bad behaviour for deeper2
n.deeper1(1, 2).deeper2(3, 4);
}
public static class Nested {
public Nested deeper;
public Nested deeper1 (int a, int b) {
return deeper;
}
public Nested deeper2 (int a, int b) {
return deeper;
}
}
}
My content assist settings:

I was able to pinpoint the issue to the jdt.core, specifically the following commit: e3517dd
To arrive at this commit I used a git bisect:
Due to the complexity of that specific commit, me looking into the eclipse source code for the first time, and my lack of time, I was hoping someone more experienced could pick it up from here.
There are some other completion issues I have been encountering which are possibly related to this, so looking into it is hopefully time well spent.
Additionally possibly related:
#1770
#1016
Thank you!
Hello. This situation has been driving me (and others) crazy every minute(!) I am coding with eclipse since forever, so I finally took some time out to at least pinpoint the offending plugin and commit. Hope this helps!
This behaviour started back with eclipe 2021-06 while 2021-03 still behaved "well".
Code completion is behaving in an undesired manner in the following situation:
Triggering code completion (ctrl+space) while the cursor is located as indicated gives a list of proposals, so far so good.
Now, after selecting the first proposal (in my case the "print" method), the code gets transformed as follows:
The expected behaviour would be that the existing parameter "world" remains in place and only the "ln" part of "println" gets removed, i.e. the method call is updated from "println" to "print", like so:
Note that I have enclosed the second println statement in an if block (the true doesnt matter). An empty block does not show the bad behaviour. Here is an (incomplete) overview:
My content assist settings:

I was able to pinpoint the issue to the jdt.core, specifically the following commit: e3517dd
To arrive at this commit I used a git bisect:
Due to the complexity of that specific commit, me looking into the eclipse source code for the first time, and my lack of time, I was hoping someone more experienced could pick it up from here.
There are some other completion issues I have been encountering which are possibly related to this, so looking into it is hopefully time well spent.
Additionally possibly related:
#1770
#1016
Thank you!