Bug 66271 - No need to resolve type names when selecting declaration
Summary: No need to resolve type names when selecting declaration
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 RC3   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 65260 65948 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-06-09 06:51 EDT by Philipe Mulet CLA
Modified: 2004-06-18 11:11 EDT (History)
3 users (show)

See Also:


Attachments
patch proposal (28.42 KB, text/plain)
2004-06-11 06:10 EDT, David Audel CLA
no flags Details
java model test update (20.35 KB, text/plain)
2004-06-11 06:11 EDT, David Audel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2004-06-09 06:51:39 EDT
Build 3.0RC1

Any selection occurring inside a declaration (type, field or method) is 
currently relying on the resolved binding for these, so as to match them in 
the source element in the end.

It should only infer the nature of the selection, and then based on its source 
location find out the proper corresponding element.
Comment 1 Philipe Mulet CLA 2004-06-09 06:52:26 EDT
David - pls investigate how much work this would be, and assess feasibility 
for RC2. If too risky we should defer it.
Comment 2 David Audel CLA 2004-06-11 06:10:43 EDT
Created attachment 11926 [details]
patch proposal
Comment 3 David Audel CLA 2004-06-11 06:11:32 EDT
Created attachment 11927 [details]
java model test update
Comment 4 David Audel CLA 2004-06-11 06:15:28 EDT
This patch: 
- avoid to resolve binding when a declaration is selected.
- select the correct duplicate type declaration, method declaration or field 
declaration
Comment 5 David Audel CLA 2004-06-15 07:18:16 EDT
This patch fix also
  bug 65948
  bug 65260

New supported cases are
- selection of duplicate method declaration with paramater
  class X {
    void foo(X x){}
    void foo(X x){}
  }
- selection of duplicate field declaration
  class X {
    int bar;
    int bar;
  }
- selection of duplicate type declaration
  public class X {
  }
  class X {
  }
- selection of a declaration inside a duplicate type declaration
  public class X {
  }
  class X {
    void foo(){}
  }
- selection of a method method declaration with unresolved parameters
  class X {
    void foo(Unresolved x) {}
  }
- selection of a method method declaration with syntax error inside parameters
  class X {
    void foo(X a, X){}
  }
Comment 6 Philipe Mulet CLA 2004-06-15 09:08:58 EDT
CodeSelect is used intensively. Performance wise this is significantly 
speeding up resolution of declaration selections.
In addition, it addresses elegantly issues where types could not be resolved 
(we don't care any longer as selection is matching with source model anyway).

I would vote to get it addressed for RC3.

Dirk - what is your take ?
Comment 7 Dirk Baeumer CLA 2004-06-15 09:37:16 EDT
Philippe, what are the side effects of this? 

- do we get more/less resolved declarations or is this simply a performace 
  optimization
- what happens if the element doesn't exist?. Will we now get a IJavaElement
  handle which doesn't exist, whereas in the past we got nothing (e.g an
  empty array from code resolve).
Comment 8 David Audel CLA 2004-06-15 10:14:53 EDT
It's not only a performance fix. We get more declarations. All cases in 
comment 5 did not work before (nothing returned or enclosing type returned 
instead of method declaration). These new results are only existing elements.
Comment 9 David Audel CLA 2004-06-15 10:51:32 EDT
This patch also fix a part of bug 65936
public class A {
  public static A show( int i ) {
    return new A();
  }
  public void show( int i ) {
  }
}

If you rename the first method 'show' with Refactor->Rename (or Alt+Shift+R) 
the result is good. But if you rename the second method instead, there is an 
org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: assertion 
failed; second condition.

There is another problem with the following test case.
public class A {
  public void show( int i ) {
  }
  public void show( int i ) {
  }
}
If you rename the first method with Refactor->Rename then the second method 
and the first method will be renamed.
Comment 10 David Audel CLA 2004-06-15 11:13:30 EDT
The AssertionFailedException can occur without this patch and with another 
test case.

see bug 67260.
Comment 11 Philipe Mulet CLA 2004-06-15 12:49:46 EDT
David: pls provide perf stats on this fix.
Comment 12 David Audel CLA 2004-06-15 13:02:41 EDT
With a small test case (a class with one method declaration) codeSelect is 18% 
faster (without patch 0,97 ms and with patch 0,79 ms)
With a more complex test case (Parser.java) codeSelect is 50% faster (without 
patch 26,2 ms and with patch 13,1 ms)
Comment 13 Dirk Baeumer CLA 2004-06-16 12:23:36 EDT
Approved by Dirk
Comment 14 Philipe Mulet CLA 2004-06-16 12:24:20 EDT
Reviewed the change. Pls release it.
Comment 15 David Audel CLA 2004-06-16 13:14:14 EDT
Fixed and regression tests added.
Comment 16 David Audel CLA 2004-06-16 13:15:03 EDT
*** Bug 65948 has been marked as a duplicate of this bug. ***
Comment 17 David Audel CLA 2004-06-16 13:15:31 EDT
*** Bug 65260 has been marked as a duplicate of this bug. ***
Comment 18 David Audel CLA 2004-06-18 11:11:36 EDT
Verified for 3.0RC3 I200406180800