Summary: | Code assist doesn't propose full method stub | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dirk Baeumer <dirk_baeumer> |
Component: | Core | Assignee: | David Audel <david_audel> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | martinae, mlists, philippe_mulet, tobias_widmer |
Version: | 3.1 | ||
Target Milestone: | 3.1 RC1 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Dirk Baeumer
2005-04-29 05:49:37 EDT
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. 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. |