Community
Participate
Working Groups
Does not work. static class Clazz { public Clazz(Foo foo) { } } @FunctionalInterface public interface Foo extends Serializable { public void buttonClick(String event); } Somewhere in code we have: new Clazz(e -> e.chars()); Then we place the cursor after the arrow and insert a curly brace. Not possible. It is inserted at the end of the line.
Please provide a working example/snippet.
Minimally extended: //--- package n; import java.io.Serializable; class Clazz { public Clazz(Foo foo) { } static void test() { new Clazz(e -> e.chars()); } } @FunctionalInterface public interface Foo extends Serializable { public void buttonClick(String event); } //--- Indeed trying to create new Clazz(e -> { e.chars()); produces new Clazz(e -> e.chars()); { Similarly, I just tried to insert { into a string literal. Also broken: //--- class Page { void test(Page page) { page.setStatus(new Status( "Sources {0} and cannot patch different modules because both share the same output location")); } public void setStatus(Status status) { } } class Status { public Status(String string) { } } //--- Try to type {1} between "and" and "cannot". Not possible.
Thank you Stephan. What does Dani Megert mean with "provide a working example/snippet"? All he has to do is copy & paste 9 lines of code into a class :o
Once you type '{' which is moved to the end, you can press 'Backspace' key to bring it back to the original position where you typed. Or, you can disable it in the preferences. But pressing 'Enter' after that (if you wanted to insert the lambda body in braces) will result in bug 466723. The suggestion is to use the quick assist "Change body expression to block" at lambda expression until that bug is fixed.
(In reply to T3rm1 from comment #3) > Thank you Stephan. What does Dani Megert mean with "provide a working > example/snippet"? > All he has to do is copy & paste 9 lines of code into a class :o What I mean that one should be able to copy & paste without getting errors or having to do additional work. See the snippets from Stephan.
Oh, I see, you mean the missing import of java.io.Serializable. That's indeed reason enough to set the status to INVALID and RESOLVED. Pro tip: If your IDE is set up correctly, it can do the work for you!
(In reply to T3rm1 from comment #6) > Oh, I see, you mean the missing import of java.io.Serializable. That's > indeed reason enough to set the status to INVALID and RESOLVED. > > Pro tip: If your IDE is set up correctly, it can do the work for you! I do not need the pro tip ;-). The (missing) import was added by the IDE but the given snippet does not compile. In addition, the the mentioned code "new Clazz(e -> e.chars());" is not part of your snippet. Yes, I could have left the bug open and wait for the snippet, but many times, there's no further answer and the bug then remains open forever. There's no problem reopening the bug report once the complete example is provided.
(In reply to Noopur Gupta from comment #4) > Once you type '{' which is moved to the end, you can press 'Backspace' key > to bring it back to the original position where you typed. Or, you can > disable it in the preferences. I read this as a workaround, not an excuse for the current behavior, right? Dani, I had raised the severity since some of this business of "I know better where the brace should go" business left even me quite clueless (and angry :) ). Neither is the backspace workaround obvious, nor should the editor ever misplace any keystrokes sent into a string literal, never. Generally, this feature should probably be more careful to prefer erring on the side of not helping rather than breaking a perfectly valid workflow.
(In reply to Stephan Herrmann from comment #8) > (In reply to Noopur Gupta from comment #4) > > Once you type '{' which is moved to the end, you can press 'Backspace' key > > to bring it back to the original position where you typed. Or, you can > > disable it in the preferences. > > I read this as a workaround, not an excuse for the current behavior, right? Yes. > Dani, I had raised the severity since some of this business of "I know > better where the brace should go" business left even me quite clueless (and > angry :) ). Neither is the backspace workaround obvious, nor should the > editor ever misplace any keystrokes sent into a string literal, never. > > Generally, this feature should probably be more careful to prefer erring on > the side of not helping rather than breaking a perfectly valid workflow. Yes, but AFAIK we classified those under 'normal'. Feel free to raise the severity again if it is really major for you (compared to other major issues). I'd be fine with that.
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. If you have further information on the current state of the bug, please add it. 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.
This appears to have been fixed. I am using 4.20 M1 and both scenarios from Stephan work fine (i.e. the bracket is not added to the end of the line). Stephan can you confirm that we can close this bug?
(In reply to Jeff Johnston from comment #11) > This appears to have been fixed. I am using 4.20 M1 and both scenarios from > Stephan work fine (i.e. the bracket is not added to the end of the line). > > Stephan can you confirm that we can close this bug? Cool it works! :) Fixed apparently via bug 520081 and bug 560919. The latter is the one for the lambda case. *** This bug has been marked as a duplicate of bug 560919 ***