Bug 48435 - Java Search for OR-pattern finds too much in strange project setup
Summary: Java Search for OR-pattern finds too much in strange project setup
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M8   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-10 14:43 EST by Markus Keller CLA
Modified: 2004-03-26 05:09 EST (History)
0 users

See Also:


Attachments
3 projects for workspace (3.90 KB, application/zip)
2003-12-10 14:45 EST, Markus Keller CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2003-12-10 14:43:35 EST
2.1.2 + jdt.core from R2_1_maintenance branch.

This problem breaks a constructed corner case in our upcoming contribution to
bug 47509.

I'll attach a .zip with a valid but somewhat strange workspace consisting of
three projects. In that setup, I do the following search:

Pattern (IType<<xxx>> is a concrete JavaElement): 
SearchEngine.createOrSearchPattern(
  SearchEngine.createSearchPattern(IType<</project0/p/A>>, REFERENCES),
  SearchEngine.createSearchPattern(IType<</projectB/p/B>>, REFERENCES),
)

Scope:
JavaSearchScope on [
	/projectB/test/Ref.java
	/projectA/p
]

The search gives these results:
[
<Search Result
	start:49
	end:50
	resource:/projectB/test/Ref.java
	javaElement:A a [in Ref [in Ref.java [in test [in [project root] [in
projectB]]]]](instanceof class
org.eclipse.jdt.internal.core.SourceField)[offset=49, length=4]
	Accuracy:0/>, 
<Search Result
	start:56
	end:57
	resource:/projectB/test/Ref.java
	javaElement:B b [in Ref [in Ref.java [in test [in [project root] [in
projectB]]]]](instanceof class
org.eclipse.jdt.internal.core.SourceField)[offset=56, length=4]
	Accuracy:0/>]

The second result is fine, but the first one wrong: A in Ref is a reference to
/projectA/p/A, but not a reference to /project0/p/A as requested by the search
pattern. The search should only give the second search result.
Comment 1 Markus Keller CLA 2003-12-10 14:45:14 EST
Created attachment 7107 [details]
3 projects for workspace
Comment 2 Kent Johnson CLA 2004-02-20 15:38:55 EST
Marcus: is this a 2.1.x problem only? Or does it also happen in the 3.0 stream?

If its just a 2.1.x problem then we likely won't fix it.
Comment 3 Markus Keller CLA 2004-02-23 12:12:10 EST
Hi Cent ;-)

It's also a 3.0 "problem" (I don't think it's too severe): To look at it,
- set up the zipped workspace in a run-time eclipse
- set a breakpoint in
RenamePackageProcessor#getReferencesToTypesInNamesakes(..), in the third-to-last
line (before ... RefactoringSearchEngine.search(..) ...).
- select package p from projectA
- Refactor > Rename... to "asdf", with updating references to the renamed element
- click 'Preview >'
- when you hit the breakpoint, step into the search, and soon you'll hit
familiar jdt-core land ;-)
Comment 4 Kent Johnson CLA 2004-03-09 15:54:56 EST
The problem was with the TypeReferencePattern.

It didn't consult with the supplied focus.
Comment 5 Jerome Lanneluc CLA 2004-03-24 12:26:10 EST
I cannot reproduce in 3.0 M7. Kent which build did you use to reproduce it?
Comment 6 Kent Johnson CLA 2004-03-24 12:50:03 EST
Not sure exactly but I suspect it was M7 (or an integration build shortly 
after).
Comment 7 Jerome Lanneluc CLA 2004-03-26 05:09:52 EST
Kent can you please verify the bug is fixed in latest integration build?