Bug 296617 - [search] TypeReferenceLocator does not update the java doc flag
Summary: [search] TypeReferenceLocator does not update the java doc flag
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-01 15:15 EST by Mohammed Mostafa CLA
Modified: 2010-01-25 05:22 EST (History)
5 users (show)

See Also:


Attachments
proposed fix (1.66 KB, text/plain)
2009-12-01 15:15 EST, Mohammed Mostafa CLA
no flags Details
sample code to reproduce teh problem (import in teh dev enviroment) (8.60 KB, application/zip)
2009-12-02 11:44 EST, Mohammed Mostafa CLA
no flags Details
sample project to import in the run time (2.33 KB, application/zip)
2009-12-02 11:45 EST, Mohammed Mostafa CLA
no flags Details
Modified SearchAction (3.63 KB, text/plain)
2009-12-28 09:59 EST, Frederic Fusier CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mohammed Mostafa CLA 2009-12-01 15:15:58 EST
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
Comment 1 Frederic Fusier CLA 2009-12-02 04:49:07 EST
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!
Comment 2 Mohammed Mostafa CLA 2009-12-02 10:35:01 EST
(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 ?
Comment 3 Mohammed Mostafa CLA 2009-12-02 11:42:57 EST
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
Comment 4 Mohammed Mostafa CLA 2009-12-02 11:44:57 EST
Created attachment 153614 [details]
sample code to reproduce teh problem (import in teh dev enviroment)
Comment 5 Mohammed Mostafa CLA 2009-12-02 11:45:48 EST
Created attachment 153615 [details]
sample project to import in the run time
Comment 6 Olivier Thomann CLA 2009-12-07 11:12:40 EST
Moving to M5.
Comment 7 Frederic Fusier CLA 2009-12-28 09:57:25 EST
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...
Comment 8 Frederic Fusier CLA 2009-12-28 09:59:58 EST
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...
Comment 9 Satyam Kandula CLA 2010-01-25 04:52:24 EST
Verified for 3.6M5
Comment 10 Srikanth Sankaran CLA 2010-01-25 05:22:48 EST
Verified.