| Summary: | [parser][dom ast] surprising recovery of 3 identifiers: would prefer ExpressionStatement over dropping a token | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Peter Platek <peterplatek> | ||||
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | marcel.bruch, markus.kell.r, noopur_gupta | ||||
| Version: | 4.4.1 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
|
Description
Peter Platek
would be surprising since there is no logic to remove quick fixes... Since this is an Eclipse built-in snippet, which version of Eclipse are you using? eclipse.buildId=4.4.1.M20140925-0400 Tested on Eclipse Standard/SDK Version: 4.4.1, 4.5 M3 and I don't see any problem with CTRL+1 on iterables.
Test snippet:
package test;
import java.util.List;
public class Test {
void s(List<String> ss){
ss|<ctrl+1, select the enhanced for each loop>
}
}
Closing as invalid. Please reopen if there is anything in the logs that makes you certain that Code Recommenders actually prevents you from having this snippet. I yet don't know anything in Code Recommenders that can have that side effect - but I'd be happy if you could prove me wrong and found a bug.
Created attachment 249452 [details]
What happens when you have something after the interable
Looks like when you have a something after the iterable and it gets underlined it will show you the selection in the attachment.
I used this code to test:
package test;
import java.util.List;
public class Test {
void s(List<String> ss){
ss
String something;
}
}
However this shows what is expected:
package test;
import java.util.List;
public class Test {
void s(List<String> ss){
ss
int i;
}
}
(In reply to Peter Platek from comment #5) > Looks like when you have a something after the iterable and it gets > underlined it will show you the selection in the attachment. I can confirm that the above example does not work while the second one works as announced in an IDE where code recommenders is installed. However, I also tested this scenario with the JEE package (where Code Recommenders is not included) and got the same behavior. Thus, I don't see how Code Recommenders can cause this yet. Are you still convinced Code Recommenders causes this? You are correct and I just double checked as well. The same behaviour happens in eclipse jee without Code Recommenders installed. I guess this bug should be moved to JDT. Hey committers, is this something your AST parser can recover from (I guess it wouldn't be easy)? It's a (small) surprise that completion works when the next type is a primitive like int but will fail with a type name, but you know your internals better. (In reply to Marcel Bruch from comment #8) > Hey committers, is this something your AST parser can recover from (I guess > it wouldn't be easy)? It's a (small) surprise that completion works when the > next type is a primitive like int but will fail with a type name, but you > know your internals better. Moving to JDT Core for analysis. (In reply to Marcel Bruch from comment #8) > Hey committers, is this something your AST parser can recover from (I guess > it wouldn't be easy)? Yeah, I fear your guess is correct. The AST parser actually does recover ss String something; ... but not as we would expect. It assumes this is a variable declaration and recommends removing "something". The parser neither knows about line breaks nor about the upper/lowercase conventions for types and names. > It's a (small) surprise that completion works when the > next type is a primitive like int but will fail with a type name, but you > know your internals better. If you replace "String" by "int", then that token can't be a variable name any more, and the recovery goes a more favorable path. A workaround is to add a ";" after the collection name, e.g.: void s(List<String> ss){ ss; // <- semicolon forces the compiler to recover "ss" separately String something; } This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |