Community
Participate
Working Groups
- take revision 1.8 of BuildPathAction. - in run method add the following IRunnableWithProgress runnable= new IRunnableWithProgress() { }; - inside the runnable type run<code assist> and select run observe: only the following method signature gets inserted. No method body. Additionally IProgressMonitor is fully qualified. public void run(org.eclipse.core.runtime.IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
The problem is that the completion offset there is not covered by an AnonymousClassDeclaration or AbstractTypeDeclaration node. As it seems to me, this is a regression. Here is a simpler test case: import org.eclipse.jface.operation.IRunnableWithProgress; public class Test { IRunnableWithProgress progress= new IRunnableWithProgress() { run<Ctrl+Space> }; } Moving to JDT Core for comments
We need to have at least the corresponding AST node to insert the method by AST rewriting.
In order to generate proposals for generic anonymous classes like in: Map<String, Number> map= new Map<String, Number>() { putAll<Ctrl+Space> } we currently depend on the binding of the anonymous class declaration to generate the override proposal. The completion proposal from JDT Core offers as parameter type only the raw type 'Map' in 'putAll(Map)', where 'putAll (Map<? extends String, ? extends Map>) would be correct. To fix this, we either need correct parameter proposals or an AnonymousTypeDeclaration node with bindings. However the AST node is needed in both cases for the rewriting.
Philippe, can you please have a look. We have to solve this for 3.1 since it gives a bad user experience.
David - is this a regression ?
This is not a regression. There is no recovery for anynomous type inside a field declaration. This recovery can be easily added but it would solve the problem only partially because there is no statement recovery. The completion would not work for the following test case. public class Test { void foo() { new IRunnableWithProgress() { run<Ctrl+Space> }; } }
Tobias, can you please comment on whether we still need something from core here ?
Jdtcore could generate a more complete completion string. e.g. "public <T extends AType> AnotherType foo(Map<? extends String, ? extends Map> arg0) throws Exception" instead of just "public AnotherType foo(Map arg0) throws Exception".
We are now deleting the partial identifier left to the completion offset in order to get a complete AST containing the AnonymousClassDeclaration node and the necessary bindings to let the StubUtility generate the method stub. This seems to work reliably. Although we are not dependent on the information from the proposal, the completion string is still incorrect.
See also bug 95911 for a possible explanation for the failure of snippet in comment 3
Fixed and tests added CompletionTests_1_5#test214() -> test0216 CompletionTests updated The complete method header is created (e.g. public <T extends AType> AnotherType foo(Map<? extends String, ? extends Map> arg0) throws Exception).
Verified on build I20050526-2000-win32.