Community
Participate
Working Groups
Created attachment 153523 [details] proposed fix I'm using the JDT search support in my static analysis application and noticed some unexpected search matches teh test case i'm using is: I have 2 classes that looks like that : public class Class1 { /** * @see Class2 */ private void m(){ } } public class Class2 { /** * @see Class1 */ private void m(){ } } If i run a search using engine.searchDeclarationsOfReferencedTypes for either Class1 or Class2, I get a match (becuase of the @see, the same happen with @link), which is fine but if I call teh method isInsideDocComment() on the match it returns false I did some invistigation, and found that the TypeReferenceLocator never calls setInsideDocComment opn the match Changing it to set the flag fixs the issue, attached a patch with the fix
Do not forget that while using using engine.searchDeclarationsOfReferencedTypes, the returned matches are declarations, not references... Hence, the javadoc flag is not set because a type declaration cannot be inside a javadoc comment!
(In reply to comment #1) > Do not forget that while using using > engine.searchDeclarationsOfReferencedTypes, the returned matches are > declarations, not references... Hence, the javadoc flag is not set because a > type declaration cannot be inside a javadoc comment! Sorry but i'm confused, if this is true why do i get the match then r u saying that in 3.6 M4, I will not get a match any more ?
Attaching sample code showing that i get a type reference runnign the search Steps to reproduce: Improt the source code for the JDTSearchPlugin in you dev enviroment, start a runtime and import the project called sample code, select Class1 right click and select search for references you will get a message tellingyou which class being searched, thena message for each reference it find
Created attachment 153614 [details] sample code to reproduce teh problem (import in teh dev enviroment)
Created attachment 153615 [details] sample project to import in the run time
Moving to M5.
I think you mixed the reference found in the selected java element and the returned declaration match. A reference can be inside a javadoc comment but a declaration cannot. As its name clearly tells us, the searchDeclarationsOfReferencedTypes method returns declarations and not references. You can verify this by setting a breakpoint in your JDTSearch plugin line 82, you'll see that the match is a TypeDeclarationMatch which does not overridde isInsideJavadocComment which returns false by default... This behavior hasn't changed since day 1, so it's normal that you get the same results using 3.4...
Created attachment 155087 [details] Modified SearchAction If this is references of types that you're looking for, then use the SearchEngine.search(...) method instead with the corresponding pattern as shown in the modified SearchAction attached here...
Verified for 3.6M5
Verified.