Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Specifying default (empty) package in a serach
Specifying default (empty) package in a serach [message #231047] Thu, 08 June 2006 23:06 Go to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 481
Registered: July 2009
Senior Member
Greetings,

When constructing a SearchPattern of the form:

final SearchPattern jdtSearchPattern =
SearchPattern.createPattern(pathStr,
IJavaSearchConstants.PACKAGE,

JavaSearchConstants.DECLARATIONS,

SearchPattern.R_EQUIVALENT_MATCH);

Is there a way to specify 'pathStr' so that it will find all default
package in particular scope? The createPattern factory method blocks
specifying null or "". I tried " " on a lark but it didn't seem to work.


Thanks,

Cameron
Re: Specifying default (empty) package in a serach [message #231283 is a reply to message #231047] Mon, 12 June 2006 23:30 Go to previous messageGo to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 481
Registered: July 2009
Senior Member
Any ideas?
Re: Specifying default (empty) package in a serach [message #231290 is a reply to message #231047] Tue, 13 June 2006 08:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benno_baumgartner.ch.ibm.com

"Cameron Bateman" <cameron.bateman@oracle.com> wrote in message
news:2c50f39bc7c93703455de6184dd9f7be$1@www.eclipse.org...
> Greetings,
>
> When constructing a SearchPattern of the form:
>
> final SearchPattern jdtSearchPattern =
> SearchPattern.createPattern(pathStr, IJavaSearchConstants.PACKAGE,
> JavaSearchConstants.DECLARATIONS, SearchPattern.R_EQUIVALENT_MATCH);
>
> Is there a way to specify 'pathStr' so that it will find all default
> package in particular scope? The createPattern factory method blocks
> specifying null or "". I tried " " on a lark but it didn't seem to work.
>
>
> Thanks,
>
> Cameron

Hi Cameron

I think this should work:

SearchPattern pattern= SearchPattern.createPattern("*",
IJavaSearchConstants.PACKAGE,
IJavaSearchConstants.DECLARATIONS,
SearchPattern.R_PATTERN_MATCH);

SearchRequestor requestor= new SearchRequestor() {
public void acceptSearchMatch(SearchMatch match) throws
CoreException {
IJavaElement enclosingElement= (IJavaElement)
match.getElement();
String name= enclosingElement.getElementName();
if (name.length() == 0) {
//default pack
}
}
};

But maybe there is a more efficient way?

HTH
Benno
Re: Specifying default (empty) package in a serach [message #231305 is a reply to message #231290] Tue, 13 June 2006 15:11 Go to previous messageGo to next message
Frederic Fusier is currently offline Frederic FusierFriend
Messages: 147
Registered: July 2009
Senior Member
Benno Baumgartner wrote:
> "Cameron Bateman" <cameron.bateman@oracle.com> wrote in message
> news:2c50f39bc7c93703455de6184dd9f7be$1@www.eclipse.org...
>> Greetings,
>>
>> When constructing a SearchPattern of the form:
>>
>> final SearchPattern jdtSearchPattern =
>> SearchPattern.createPattern(pathStr, IJavaSearchConstants.PACKAGE,
>> JavaSearchConstants.DECLARATIONS, SearchPattern.R_EQUIVALENT_MATCH);
>>
>> Is there a way to specify 'pathStr' so that it will find all default
>> package in particular scope? The createPattern factory method blocks
>> specifying null or "". I tried " " on a lark but it didn't seem to work.
>>
>>
>> Thanks,
>>
>> Cameron
>
> Hi Cameron
>
> I think this should work:
>
> SearchPattern pattern= SearchPattern.createPattern("*",
> IJavaSearchConstants.PACKAGE,
> IJavaSearchConstants.DECLARATIONS,
> SearchPattern.R_PATTERN_MATCH);
>
> SearchRequestor requestor= new SearchRequestor() {
> public void acceptSearchMatch(SearchMatch match) throws
> CoreException {
> IJavaElement enclosingElement= (IJavaElement)
> match.getElement();
> String name= enclosingElement.getElementName();
> if (name.length() == 0) {
> //default pack
> }
> }
> };
>
> But maybe there is a more efficient way?
>
> HTH
> Benno
>
>
Benno,
There's currently no more efficient way to do this.
Thanks for the answer

Cameron,
You can enter an enhancement bug against JDT/Core to have this specific
search request for default package declarations or references
Re: Specifying default (empty) package in a serach [message #641202 is a reply to message #231305] Wed, 24 November 2010 14:39 Go to previous message
alex  is currently offline alex Friend
Messages: 6
Registered: September 2010
Junior Member
Hi Cameron,

Just want to know how to run the application with the JDT search engine? I came across an issue as this url: http://www.eclipse.org/forums/index.php?t=msg&th=200356& amp;start=0&S=44cb0ef37935ec39063b0e36548e3ec8

thanks
Alexander
Previous Topic:Problem with editor screen.
Next Topic:Plugins for debug Websphere 7 apps?
Goto Forum:
  


Current Time: Thu Mar 28 13:37:55 GMT 2024

Powered by FUDForum. Page generated in 0.01988 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top