[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Determine if a method has source?

Michael Desmond wrote:
Hi,

Does anyone know how to determine if an IMethod has source or source attachment without calling getSource()..at the moment i use the getSource() method and check if the result != null... but this seems to cause pretty bad performance problems for large files...

Thanks
Mike
To know is there is a source attachment for the corresponding root, you
can use the following:

IMethod method = ...
IPackageFragmentRoot root = (IPackageFragmentRoot ) method.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
return root.getSourceAttachmentPath() != null;

Jerome