Community
Participate
Working Groups
I frequently use the Ctrl+2, L and end up with an syntax error. For example in Android: findViewByID(R.id.text1) Ctrl+2, L create the following: View view = findViewByID(R.id.text1); But I also need to trigger the organize import (of a save action) to also add the import statement. I think JDT should also add the import statement. If you agree and don't have the capacity to implement this, let me know, we (Simon or I) can look into this.
I cannot reproduce the issue. Example: import java.util.ArrayList; class Test extends BugExample { { (new ArrayList<String>()).stream(); } } Ctrl+2, L also adds the "import java.util.stream.Stream;" by default. Please provide a stand-alone example where it does not work.
Closing as WORKSFORME. Please re-open with a stand-alone example to reproduce the issue.
Noopur, I have a hard time reproducing this outside of an Android project and I guess you don't want to install the ADT tools. Could you tell me the class which is triggered by this shortcut? I can try to debug it, and see why it does not work in the Android example.
To find out what happens when you press a shortcut, set a breakpoint in KeyBindingDispatcher#executeCommand(..) and step through. I know this became a bit painful with E4, but maybe you could work on that? QuickAssistProcessor#getAssists(..) and ExtractTempRefactoring#checkInitialConditions(..) are potential entry points.
Created attachment 257542 [details] Animated Gif Here is a simple code example in a standard Java program: 1.) Create the following class public class Main { public static void main(String[] args) { } } 2.) Copy and paste new ArrayList<>() into it (do not type it) 3.) Use Ctrl+2, l to assign it to a local variable -> Import is not added. See animated Gif as example
See comment 5
*** Bug 479030 has been marked as a duplicate of this bug. ***
title and comment 0 should probably say "resolve error" instead of "syntax error", right? I would be weird if a quick assist really creates a syntax error.