Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » findPackageFragment path issues
findPackageFragment path issues [message #240943] Wed, 21 February 2007 12:38 Go to next message
Larry Edelstein is currently offline Larry EdelsteinFriend
Messages: 25
Registered: July 2009
Junior Member
Hi all -

I've got an absolute file system path like
C:/Projects/bigthing/src/java/com/nowanswers/Perforator.java

and I have a Java project, and I want to find either the IJavaElement
corresponding to the file, or, failing that, the IPackageFragment
containing it.

I've had a lot of trouble with getting everything to work correctly
w/r/t to paths.

What's the canonical way to find the model elements I've described,
within a specific project, given an OS full path?

Larry Edelstein
Chris Richardson Consulting
San Francisco, CA
Re: findPackageFragment path issues [message #240994 is a reply to message #240943] Thu, 22 February 2007 10:20 Go to previous message
Eclipse UserFriend
Originally posted by: mehmet.sbox.tugraz.at

IJavaProject myJavaProject = ...
IPath filePath = Path.fromPortableString("com/noanswers/Perforator.java");
IJavaElement element = myJavaProject.findElement(filePath);
// when com.noanswers is the package name
if(element == null){ // file not in my project
} else{ // file in my project
}

hope helps.

Larry Edelstein schrieb:
> Hi all -
>
> I've got an absolute file system path like
> C:/Projects/bigthing/src/java/com/nowanswers/Perforator.java
>
> and I have a Java project, and I want to find either the IJavaElement
> corresponding to the file, or, failing that, the IPackageFragment
> containing it.
>
> I've had a lot of trouble with getting everything to work correctly
> w/r/t to paths.
>
> What's the canonical way to find the model elements I've described,
> within a specific project, given an OS full path?
>
> Larry Edelstein
> Chris Richardson Consulting
> San Francisco, CA
Previous Topic:getPackageFragmentRoots() and resolution
Next Topic:How can I add my own "new plug-in template"?
Goto Forum:
  


Current Time: Fri Apr 26 20:23:13 GMT 2024

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

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

Back to the top