tags:

views:

16

answers:

1

I have an IJavaElement and I wish to know which one of the IClasspathEntrys of an IJavaProject the element belongs to.

I have a feeling that I'm missing something obvious, but I just couldn't find a simple solution to that.

Thanks in advance for any forthcoming tips and answers.

A: 

Maybe this will help:

IPackageFragmentRoot root = (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
IClasspathEntry entry = root.getRawClasspathEntry();

Note, that this is not a one-to-one relation between a Java element and class-path entry, this code only returns the first entry.

spektom
Only checking for the first entry is exactly what I am trying to avoid. I guess I will just have get all the entries and iterate over them searching for a match.Thanks for you reply.