Bug 3205 - Problems with IJavaModel.findPackageFragment (1G456DO)
Summary: Problems with IJavaModel.findPackageFragment (1G456DO)
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All Windows NT
: P3 normal (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-10 22:51 EDT by Dirk Baeumer CLA
Modified: 2002-01-11 09:04 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2001-10-10 22:51:16 EDT
I try to find a package fragment using the Method IJavaProject.findPackageFragment(path). 
	Calling this method on a project that contains JUnit with the argument "/junit/framework"
	returns null. Calling the method with the argument "junit/framework" (path isn't absolute)
	throws an AssertFailedException. 

	How do I find a package fragment if I want to consider the project's class path.


NOTES:

	OT (11/24/00 2:31:11 PM)
		Try this:
			IPackageFragment fragment = project.getNameLookup().findPackageFragment("junit.frameworkpath", false);

DB (05.12.2000 10:31:39)
	The method getNameLookup isn't part of the IJavaProject interface so I am not able to use it.

	The implementation of JavaProject.findPackageFragement(path) does exactly what you propose so
	I think that this won't work either.

	public IPackageFragment findPackageFragment(IPath path) throws JavaModelException {
		return getNameLookup().findPackageFragment(path);
	}

	What is the path separator character I have to use? A '.' or a '/'? In general IPath is using '/'.
Comment 1 Philipe Mulet CLA 2001-10-12 06:11:53 EDT
The IJavaProject specs says to use '/'/

/**
 * Returns the first existing package fragment on this project's classpath
 * whose path matches the given (absolute) path, or <code>null</code> if none
 * exist.
 * The path can be:
 * 	- internal to the workbench: "/Project/src"
 *  - external to the workbench: "c:/jdk/classes.zip/java/lang"
 *
 * @exception JavaModelException if this element does not exist or if an
 *		exception occurs while accessing its corresponding resource
 */
IPackageFragment findPackageFragment(IPath path) throws JavaModelException;
Comment 2 Philipe Mulet CLA 2001-10-12 10:52:39 EDT
Closing
Comment 3 Dirk Baeumer CLA 2001-10-22 03:53:45 EDT
Why got this PR closed. Is it fixed now. The first comment states that
neither /junit/framework not junit/framework works as a path. So I am
already using the / character as a path separator.
Comment 4 Philipe Mulet CLA 2001-10-22 05:21:49 EDT
The specs says how to use the API. You have to use a '/'.
Looks in your case, you forgot the project prefix: '/JUnit/src/junit/framework'.

Do I miss something ?
Comment 5 Dirk Baeumer CLA 2001-10-23 04:38:42 EDT
Yup, forgot to add /JUnit/src to the path. It is a little bit confusing
that if I call the method on an IJavaProject which represents the JUnit
project that I have to prepend the path with the /JUnit/src.

PR can be closed.
Comment 6 Philipe Mulet CLA 2001-10-23 05:17:47 EDT
Closing