Bug 93249 - Code assist doesn't propose full method stub
Summary: Code assist doesn't propose full method stub
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-29 05:49 EDT by Dirk Baeumer CLA
Modified: 2005-05-27 09:06 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2005-04-29 05:49:37 EDT
- 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
Comment 1 Tobias Widmer CLA 2005-04-29 06:47:52 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
Comment 2 Tobias Widmer CLA 2005-04-29 08:14:24 EDT
We need to have at least the corresponding AST node to insert the method by 
AST rewriting.
Comment 3 Tobias Widmer CLA 2005-04-29 10:14:52 EDT
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.
Comment 4 Dirk Baeumer CLA 2005-04-29 13:23:36 EDT
Philippe, can you please have a look. We have to solve this for 3.1 since it
gives a bad user experience.
Comment 5 Philipe Mulet CLA 2005-05-10 17:57:32 EDT
David - is this a regression ?
Comment 6 David Audel CLA 2005-05-17 09:55:35 EDT
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>
    };
  }
}
Comment 7 Dirk Baeumer CLA 2005-05-19 04:27:54 EDT
Tobias, can you please comment on whether we still need something from core here ?
Comment 8 David Audel CLA 2005-05-19 04:41:57 EDT
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".
Comment 9 Tobias Widmer CLA 2005-05-19 05:07:10 EDT
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.
Comment 10 Tobias Widmer CLA 2005-05-19 06:15:40 EDT
See also bug 95911 for a possible explanation for the failure of snippet in 
comment 3
Comment 11 David Audel CLA 2005-05-24 10:08:27 EDT
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).
Comment 12 Maxime Daniel CLA 2005-05-27 04:13:15 EDT
Verified on build I20050526-2000-win32.