Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Getting the IClassFile of ICompilationUnit
Getting the IClassFile of ICompilationUnit [message #185421] Fri, 12 November 2004 10:19 Go to next message
Eclipse UserFriend
Originally posted by: newaym.hotmail.com

hi,

i'm looking for a specific IClassFile, which is inside a selected IProject.
Finding the ICompilationUnit using the SearchEngin or iterating through
IPackageFragments seems to easy.

but how do you get the IClassFile?


many thanks in advance.

tanaysy
Re: Getting the IClassFile of ICompilationUnit [message #185445 is a reply to message #185421] Fri, 12 November 2004 12:36 Go to previous messageGo to next message
Eclipse UserFriend
use IPackageFragment.getClassFile

/adam
Re: Getting the IClassFile of ICompilationUnit [message #217230 is a reply to message #185421] Tue, 18 October 2005 12:41 Go to previous message
Eclipse UserFriend
Originally posted by: rotsch_mulla.yahoo.de

Hi!

Tanaysy wrote:
>> i'm looking for a specific IClassFile, which is inside a selected
IProject.
>> Finding the ICompilationUnit using the SearchEngin or iterating through
>> IPackageFragments seems to easy.
>> but how do you get the IClassFile?

Adam Kiezun wrote:
> use IPackageFragment.getClassFile

I have a follow-up question to this older thread.

What I want to do is to get the absolute path to a class file. However I
only have an IMethod retrieved from an ISelection. From what I
understand from several other posts and the Javadoc API I could now

* get the ICompilationUnit from the IMethod and retrieve the
IPackageFragment and the IJavaProject from it and then

* use the IPackageFragment.getClassFile method with the class name I get
from the ICompilationUnit (minus .java plus .class) to get the
IClassFile, which I can use in turn to get the relative path and then

* use the IJavaProject.geOutputLocation to get the output path and then

* combine both informations for a still relative link to the sought
class file.

I'm just wondering if that really is the easiest way to find the class
file corresponding to a source file, the solution I outlined seems to be
too complicated for such an everyday task ...

Any hints are appreciated!

-Rotsch
Previous Topic:APT for 3.1.1
Next Topic:IType and generics (determining the content of List<MyClass> given the IType)
Goto Forum:
  


Current Time: Sun Jun 22 17:09:13 EDT 2025

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

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

Back to the top