Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Finding packages with same name in different source folders
Finding packages with same name in different source folders [message #257930] Mon, 05 January 2009 09:46 Go to next message
Eclipse UserFriend
Hi,
Suppose I have the following project structure:

MyProject
src
com.my.models
......
src-test
com.my.models
........

now given the project name, is their any efficient way to find out these
packages i..e packages with the same name that occur in different source
folders..

thanks
Re: Finding packages with same name in different source folders [message #257937 is a reply to message #257930] Mon, 05 January 2009 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Raheel Ashraf wrote:
> Suppose I have the following project structure:
>
> MyProject
> src
> com.my.models
> ......
> src-test
> com.my.models
> ........
>
> now given the project name, is their any efficient way to find out these
> packages i..e packages with the same name that occur in different source
> folders..

Hello,

You can try the following:
1. Select your project in the Project Explorer.
2. Select "Search" -> "Java" from the menu.
3. Put your package name (for example com.my.models) as search string.
4. Select the following options:
- "Search For" as "Package"
- "Limit To" as "All occurences"
- "Scope" as "Enclosing projects"
5. Submit your search.

Regards,
Radoslaw Jozwik
Re: Finding packages with same name in different source folders [message #257940 is a reply to message #257937] Mon, 05 January 2009 10:19 Go to previous messageGo to next message
Eclipse UserFriend
Thanks but I meant from the api....
also I am looking for an efficient way.
One not so efficient would to:

1. Call "getAllPackageFragmentRoots" on IJavaProject (sadly this method
returns all fragments including the one on classpath)
2. Go through the list and check if the kind is K_SOURCE
3. If that is the case, get its children i.e the package fragments
4. Use some kind of the map or something to detect the packages with the
same name

but this is not efficient in terms of memory and time...any other ideas or
apis?
Re: Finding packages with same name in different source folders [message #257945 is a reply to message #257940] Mon, 05 January 2009 10:51 Go to previous messageGo to next message
Eclipse UserFriend
Raheel Ashraf wrote:
> Thanks but I meant from the api....

Oh, sorry. I can't help you then, but you can always see how it is done
in the Eclipse search source code.

Regards,
Radoslaw Jozwik
Re: Finding packages with same name in different source folders [message #257949 is a reply to message #257940] Tue, 06 January 2009 03:17 Go to previous messageGo to next message
Eclipse UserFriend
Raheel Ashraf wrote:
> Thanks but I meant from the api....
> also I am looking for an efficient way. One not so efficient would to:
>
> 1. Call "getAllPackageFragmentRoots" on IJavaProject (sadly this
> method returns all fragments including the one on classpath)
> 2. Go through the list and check if the kind is K_SOURCE
> 3. If that is the case, get its children i.e the package fragments
> 4. Use some kind of the map or something to detect the packages with
> the same name
>
> but this is not efficient in terms of memory and time...any other
> ideas or apis?
Use Java search (see: org.eclipse.jdt.core.search.SearchEngine).

Dani
Re: Finding packages with same name in different source folders [message #257987 is a reply to message #257949] Thu, 08 January 2009 09:09 Go to previous message
Eclipse UserFriend
thanks..i think this will have better performance however i have to find
all the "duplicate packages": in a given project i.e. packages with same
name but in different source folders..
Previous Topic:javadoc formatter with {@code ...}
Next Topic:How to use IAnnotation.getMemberValuePairs()?
Goto Forum:
  


Current Time: Sat Apr 19 15:00:19 EDT 2025

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

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

Back to the top