Summary: | Invalid check in the isConstructor() method of the IMethod implementation. | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Dietrich M. <dietrich.mostowoj> | ||||||
Component: | Core | Assignee: | Jay Arthanareeswaran <jarthana> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | amj87.iitr, Olivier_Thomann, satyam.kandula | ||||||
Version: | 3.7 | Flags: | satyam.kandula:
review+
|
||||||
Target Milestone: | 3.7 M4 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Dietrich M.
2010-11-09 02:53:02 EST
Jay, please follow up. Thanks! I am unable to reproduce this with the build I20101028-1441. Could you try with a newer build and if you still find the problem, could you please provide a test case that I can use to reproduce? (In reply to comment #2) > I am unable to reproduce this with the build I20101028-1441. > Could you try with a newer build and if you still find the problem, could you > please provide a test case that I can use to reproduce? I created a simple PDE application with an action that is performing this peace of code: final String txtPattern = "Snapsho*"; SearchPattern pattern = SearchPattern.createPattern(txtPattern, IJavaSearchConstants.CONSTRUCTOR, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_PATTERN_MATCH); SearchParticipant[] participants = new SearchParticipant[1]; participants[0] = SearchEngine.getDefaultSearchParticipant(); SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { // assert method assert match.getElement() instanceof IMethod; // assert constructor assert ((IMethod) match.getElement()).isConstructor(); } }; try { SearchEngine engine = new SearchEngine(); IJavaSearchScope scope = engine.createWorkspaceScope(); engine.search(pattern, participants, scope, requestor, new NullProgressMonitor()); } catch (CoreException e) { e.printStackTrace(); } The search engine finds the constructor of the following class : com.sun.xml.internal.bind.v2.runtime.unmarshaller.LocatorEx$Snapshot But the getElementName() method of the returnd IMethod provides "LocatorEx$Snapshot" and the parent.getElementName()method provides "Snapshot", so the isConstructor() method returns false and the second assert in the requestor fails. Last version I used. Version: 3.6.1 Build id: M20100909-0800 Thanks for the code, Dietrich! I am able to reproduce the problem now. The problem occurs only with binary types. I will investigate why we remove the enclosing type name from the inner type name (ClassFile#getType) where as the method name is untouched. Created attachment 182893 [details]
Proposed patch
While constructing a BinaryMethod in ClassFileMatchLocator#locateMatches(), the constructor is allowed to keep the enclosing name as part of it's element name. It causes problem since the type name itself doesn't have the enclosing name.
This has been fixed in the patch and tests added.
Satyam, can you please review the patch?
I was wondering if info.getSourceName() could be called instead of calling info.getName() and then processing. The search bug tests generally go in JavaSearchBugsTests.java - So, please move the test there. Created attachment 183365 [details]
updated patch
Indeed, info.getSourceName() will work very well. Thanks, Satyam. The patch has been updated accordingly. And I have moved the tests to JavaSearchBugsTests.
(In reply to comment #8) > Created an attachment (id=183365) [details] > updated patch > > Indeed, info.getSourceName() will work very well. Thanks, Satyam. The patch has > been updated accordingly. And I have moved the tests to JavaSearchBugsTests. The Patch looks good. +1 Released in HEAD for 3.7 M4. Verified for 3.7M4 using build I20101205-2000 |