Bug 83693 - [search][javadoc] References to methods/constructors: range does not include parameter lists
Summary: [search][javadoc] References to methods/constructors: range does not include ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-26 04:36 EST by Markus Keller CLA
Modified: 2005-03-30 15:59 EST (History)
0 users

See Also:


Attachments
Patch which fixes this bug (3.15 KB, patch)
2005-03-07 11:24 EST, Frederic Fusier CLA
no flags Details | Diff
Patch which fixes JDT/UI refactoring failing tests (1.42 KB, patch)
2005-03-07 11:27 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-01-26 04:36:42 EST
I20050118-1015

Search for References to methods/constructors: The source ranges sometimes
include parameter lists (e.g. for MethodInvocations, ClassInstanceCreations),
and sometimes don't (e.g. for MethodRefs, EnumConstantDeclarations).

Is there a rationale behind these differences?
If not, could the ranges be made homegenous (and documented in SearchPattern)?
Comment 1 Frederic Fusier CLA 2005-02-27 18:03:42 EST
Fixed.

I've described selection behavior in complete document attached with bug 81377
and have to figure out how to put document it in eclipse...

[jdt-core-internal]
No test case added. Only existing ones modified to match described behavior.
Comment 2 Markus Keller CLA 2005-03-02 06:29:35 EST
Frederic, this bug was not about generic type parameters, but about the "old"
method parameters. For example, when searching for occurrences of method m in
the code below, some of the matches include the parameter list (in parentheses)
and others don't:

package p;
import static p.A.m;
/**
 * @see A#m(int)
 */
class A {
    static void m(int i) {
        p.A.m(i);
    }
}

For AST-based refactorings, we have to map search results back to ASTNodes. This
is e.g. done in ChangeSignatureRefactoring#createOccurrenceUpdate(..): the
ASTNode is the first node that encloses a SearchMatch's source range. The code
there is specially tailored to the current behavior of the search engine, but I
would like to have a more uniform mapping.

I think it's also strange for other users of the search engine, that the
parameter list is sometimes included and sometimes it's not.
Comment 3 Frederic Fusier CLA 2005-03-07 09:28:46 EST
Only happens for methods/constructors references in Javadoc (see your example)
Comment 4 Frederic Fusier CLA 2005-03-07 11:23:06 EST
Markus, fix is ready but have some impact on JDT-UI refactoring tests.
Following tests fail in ChangeSignatureTests:
  - testAll58
  - testAll59
  - testAll60
  - testEnum02
  - testVararg05

If I modify ChangeSignatureRefactoring.createOccurenceUpdate method (see patch
I'll attach later), then all these tests are OK.

Let me know when you'll be able to modify these tests then I'll release this
fix, thx
Comment 5 Frederic Fusier CLA 2005-03-07 11:24:37 EST
Created attachment 18487 [details]
Patch which fixes this bug

Apply this patch in HEAD stream on org.eclipse.jdt.core project...
Comment 6 Frederic Fusier CLA 2005-03-07 11:27:10 EST
Created attachment 18488 [details]
Patch which fixes JDT/UI refactoring failing tests

This patch was made on top of org.eclipse.jdt.ui project, version
v20050301-0800.
Comment 7 Markus Keller CLA 2005-03-08 04:11:51 EST
Frederic, I released a workaround, such that Change Method Signature doesn't
care about parameter inclusion. You can release your patch whenever you like.

Do I see that right, that method declarations and references to enum
constructors won't include the parameters list? E.g. search for references to
Color(int):

enum Color {
    RED, GREEN(), BLUE(17), PINK(1) {/*anon*/};
    Color() {}
    Color(int i) {}
}

-> the range is only "BLUE", not "BLUE(17)"
Comment 8 Frederic Fusier CLA 2005-03-08 07:30:05 EST
Fixed.

Now contructor/method references in javadoc also include parameters list.

[jdt-core-internal]
Changes done in JavadocParser.createMethodReference(...)
Existing tests modified + test case added in JavaSearchBugsTests
Comment 9 Olivier Thomann CLA 2005-03-30 15:55:13 EST
Verified in I20050330-0500
Comment 10 Frederic Fusier CLA 2005-03-30 15:59:14 EST
Unfortunately, I missed comment 7 and didn't fix this specific issue.
I've opened a new bug for it: bug 89686...