Home » Language IDEs » Java Development Tools (JDT) » problems with searching for references
problems with searching for references [message #247701] |
Sat, 08 September 2007 23:43 |
Eclipse User |
|
|
|
Originally posted by: Rudolf.Ziegaus.gmx.de
Hello,
I want to search for references for a class or a method. I do this via
getSearchEngine().search(pattern, getParticipants(), searchScope,
searchRequestor, monitor);
where the pattern has been created with
pattern = SearchPattern.createPattern(element,
JavaSearchConstants.REFERENCES);
and the searchScope has been created with
searchScope = SearchEngine.createJavaSearchScope(javaProjects);
javaProjects is a array of IJavaProject, that the user selects.
Now when I use this approach on classes I will find all references in java
source code, but I miss references in plugin.xml.
Eclipse itself however also finds the reference to plugin.xml when I search
the same projects via "references".
I thought that maybe the way I create my searchscope might be wrong, so I
tried SearchEngine.createWorkspaceScope(), but to no avail. I also tried
variations of the createPattern method, but again I had no success.
Can anybody give me a hint which approach I need to take in order to also
find references to a class in plugin.xml?
TIA,
Rudi
|
|
|
Re: problems with searching for references [message #247781 is a reply to message #247701] |
Tue, 18 September 2007 15:31 |
Frederic Fusier Messages: 147 Registered: July 2009 |
Senior Member |
|
|
You correctly use Search Engine, but it just cannot find references in
non-Java files...
When you said that Eclipse finds references in plugin.xml, I guess you
mean that using the 'File Search' of Eclipse, then you found matches...
But this kind of search is a text search inside file contents (like
Windows search in fact) which is different from Java Search...
Rudolf Ziegaus wrote:
> Hello,
>
> I want to search for references for a class or a method. I do this via
>
> getSearchEngine().search(pattern, getParticipants(), searchScope,
> searchRequestor, monitor);
>
> where the pattern has been created with
>
>
> pattern = SearchPattern.createPattern(element,
> JavaSearchConstants.REFERENCES);
>
> and the searchScope has been created with
>
> searchScope = SearchEngine.createJavaSearchScope(javaProjects);
>
> javaProjects is a array of IJavaProject, that the user selects.
>
> Now when I use this approach on classes I will find all references in java
> source code, but I miss references in plugin.xml.
> Eclipse itself however also finds the reference to plugin.xml when I search
> the same projects via "references".
>
> I thought that maybe the way I create my searchscope might be wrong, so I
> tried SearchEngine.createWorkspaceScope(), but to no avail. I also tried
> variations of the createPattern method, but again I had no success.
>
> Can anybody give me a hint which approach I need to take in order to also
> find references to a class in plugin.xml?
>
>
> TIA,
>
> Rudi
|
|
|
Re: problems with searching for references [message #247814 is a reply to message #247781] |
Tue, 18 September 2007 23:19 |
Eclipse User |
|
|
|
Originally posted by: Rudolf.Ziegaus.gmx.de
Am Tue, 18 Sep 2007 17:31:42 +0200 schrieb Frederic Fusier:
> You correctly use Search Engine, but it just cannot find references in
> non-Java files...
>
> When you said that Eclipse finds references in plugin.xml, I guess you
> mean that using the 'File Search' of Eclipse, then you found matches...
> But this kind of search is a text search inside file contents (like
> Windows search in fact) which is different from Java Search...
>
> Rudolf Ziegaus wrote:
Hello Frederic,
thanks for your reply. No, I did not mean the "File Search" in Eclipse. I
was talking about using "References" from the context menu. When I choose
the same working set as I do for my own search, I do get a match for a
class in "plugin.xml" that I don't get when I use my own search method.
Maybe Eclipse is doing additionally a search in all found "plugin.xml"
files?
Rudi
|
|
| |
Re: problems with searching for references [message #247959 is a reply to message #247855] |
Thu, 20 September 2007 21:57 |
Eclipse User |
|
|
|
Originally posted by: Rudolf.Ziegaus.gmx.de
Am Wed, 19 Sep 2007 12:36:35 +0200 schrieb Frederic Fusier:
> Rudolf Ziegaus wrote:
> > Hello Frederic,
>>
>> thanks for your reply. No, I did not mean the "File Search" in Eclipse. I
>> was talking about using "References" from the context menu. When I choose
>> the same working set as I do for my own search, I do get a match for a
>> class in "plugin.xml" that I don't get when I use my own search method.
>> Maybe Eclipse is doing additionally a search in all found "plugin.xml"
>> files?
>>
>> Rudi
>
> You're right, I never noticed that... and it seems to exist since 3.2!
> Thanks for the tip :-)
>
> However, this match is not reported by Search Engine, but by the "PDE Java
> Search Participant" which extends the org.eclipse.jdt.ui.queryParticipants
> extension point in MANIFEST.MF of org.eclipse.pde.ui plugin.
You're welcome;-)
I found the necessary classes. However I have a further question. I'd like
to implement this very functionality in my plugin. What's the best way to
do it? When I copy the class's source code I have to import many internal
packages and I get a "restricted access" message. Is there a better way to
implement this functionality? Or can I suppress the warnings? What does
this message mean btw?
Rudi
|
|
| |
Re: problems with searching for references [message #247993 is a reply to message #247974] |
Sat, 22 September 2007 21:03 |
Eclipse User |
|
|
|
Originally posted by: Rudolf.Ziegaus.gmx.de
Am Fri, 21 Sep 2007 10:57:35 +0200 schrieb Daniel Megert:
> Rudolf Ziegaus wrote:
>
>>Am Wed, 19 Sep 2007 12:36:35 +0200 schrieb Frederic Fusier:
>>
>>
>>
>>>Rudolf Ziegaus wrote:
>>> > Hello Frederic,
>>>
>>>
>>>>thanks for your reply. No, I did not mean the "File Search" in Eclipse. I
>>>>was talking about using "References" from the context menu. When I choose
>>>>the same working set as I do for my own search, I do get a match for a
>>>>class in "plugin.xml" that I don't get when I use my own search method.
>>>>Maybe Eclipse is doing additionally a search in all found "plugin.xml"
>>>>files?
>>>>
>>>>Rudi
>>>>
>>>>
>>>You're right, I never noticed that... and it seems to exist since 3.2!
>>>Thanks for the tip :-)
>>>
>>>However, this match is not reported by Search Engine, but by the "PDE Java
>>>Search Participant" which extends the org.eclipse.jdt.ui.queryParticipants
>>>extension point in MANIFEST.MF of org.eclipse.pde.ui plugin.
>>>
>>>
>>
>>You're welcome;-)
>>
>>I found the necessary classes. However I have a further question. I'd like
>>to implement this very functionality in my plugin. What's the best way to
>>do it? When I copy the class's source code I have to import many internal
>>packages and I get a "restricted access" message. Is there a better way to
>>implement this functionality? Or can I suppress the warnings? What does
>>this message mean btw?
>>
>>
> It means you are using internal code which can change anytime.
>
> Dani
>
>>Rudi
>>
>>
Yep, that what I thought. So, it's no good idea to use that code.
What alternatives do I have?
Since I have run into this problem with plugin.xml (that's where an
extension point is referenced) I thought I might as well parse the
plugin.xml for any mention of the class I am looking for.
Is there an "official way" to get the plugin.xml of a project? Of course I
could also look the members of the project and load the plugin.xml from
there. However, if there is an preferred way I would try to stick to that.
Thanks,
Rudi
|
|
|
Goto Forum:
Current Time: Sat Nov 09 03:23:00 GMT 2024
Powered by FUDForum. Page generated in 0.02919 seconds
|