Community
Participate
Working Groups
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.
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.