Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] converting a package definition to an instance of IResource

Hi,

 

What is the easiest way of converting a package name such as “com.comp.module.util” etc to an instance of IResource?

 

Currently, I am using this mechanism and it seems to be a very inefficient one as I get a list of packages not just from source but from all the packages available to the classloader

 

  1. Create IJavaProject from project name.
  2. Get all packages from IJavaProject.getPackageFragments.
  3. Loop thru the array returned above and break when done
  4. get an instance of IResource of the package using IPackageFragment.getResource()

 

Can someone please help me with a easier way of achieving the same.  I can’t seem to find anything that will find the required IPackageFragment with a single method call on IJavaProject.  I IJavaProject.findPackageFragment needs a IPath and IPath needs the absolute path from project root which is not available to me.  I cannot assume my package is available in project/src as I could have more that one source folder configured in my build path.

 

Warm Regards

Ajaneesh

 

============================================================================================================================

Tech Mahindra, formerly Mahindra-British Telecom.

Disclaimer:

This message and the information contained herein is proprietary and confidential and subject to the Tech Mahindra policy statement, you may review at http://www.techmahindra.com/Disclaimer.html externally and http://tim.techmahindra.com/Disclaimer.html internally within Tech Mahindra.

============================================================================================================================

Back to the top