Bug 164085 - [assist] offer method/variable declaration completion based on usages
Summary: [assist] offer method/variable declaration completion based on usages
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-10 05:21 EST by Martin Aeschlimann CLA
Modified: 2006-11-13 07:44 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2006-11-10 05:21:49 EST
20061110

Code assist already provides ways to create a method declaration
class A {
  foo|code assist here

}
This feature could be improved by looking at the code in the class for unresolved references:
class A {
  f|code assist

  void bar() {
    foo("Hello"); // unresoved method invocation
    fMyColor= new RGB(100, 100, 100); // unresolved field/variable reference
  }
}
Code assist can suggest
  public foo(String s) {
  }
and
  RGB fMyColor

This is very similar to using quick fix on the unresolved method/variable, but would allow you to position the new method where you want it and seems to be a natural way how developpers work. See bug 162868 as an example.

This could be implemented in JDT/UI if we get a callback for method declaration (alreay exists) and variable declarations. We would also require a code assist context that provides an AST where we get information about unresolved references and the resolved types of their arguments and expected type.
Comment 1 David Audel CLA 2006-11-13 07:44:21 EST
It would be an interesting feature. The implementation of this feature would need to preserve current performance of code assist.

Currently only 'diet' structure of the completed compilation unit is parsed and the content of one method if the completion is inside a method. The 'diet' AST is resolved and only a small subset of statements are resolved.

Implements this feature would require to parse the 'diet' structure and the content of <b>all</b> the methods of the compilation unit. Perhaps it would require to resolve more statements but we could do the same optimization as for unresolved local variable name completion.

If we decide to add this feature we need to be careful about performance issues.

About your last suggestion:
> This could be implemented in JDT/UI if we get a callback for method 
> declaration (alreay exists) and variable declarations. We would also
> require a code assist context that provides an AST where we get 
> information about unresolved references and the resolved types of
> their arguments and expected type.

The API already exists for method declaration and as field declaration can be added at same location as method, you could use the callback for method declaration for field declaration.
Provide the context is a more complicated issue. We would need to add a usable and implementable API (bug 110181) and we would need to preserve performance as explained before in this bug report.