Community
Participate
Working Groups
Build 20040504 As we do support minimal behavior for units outside the classpath (or in non Java projects), we could better support units outside the workspace. These are now available through Open External File menu. 2 options: - allow to create some special fake project (as we do with special fake pkg roots when outside classpath). Need to filter this special project out from standard model. - enrish the working copy owner to allow it to define its classpath and compiler settings to use (when none is available by default). Either option have the nice advantage that existing APIs would not need to be modified.
Likely something to consider post 3.0
Deferred
Reconsidering for 3.1
Deferring post 3.1
Considering for 3.2
Added WorkingCopyOwner#newWorkingCopy(String,IProgressMonitor) to create a new working copy without an underlying resource. Changed CompilationUnit, BecomeWorkingCopyOperation, CommitWorkingCopyOperation, JavaModelOperation and Openable to support this kind of working copy. Added tests WorkingCopyOwnerTests#testNewWorkingCopy01/08
I have to reopen this one: I've tested the support and it can't be used: all UI code (e.g. label providers, decorators, actions,...) fails appart since the getProject() returns null. Changing that code is out of scope for us.
Are you talking about getJavaProject() that returns an IJavaProject ? If we were to return a non-null IJavaProject, what kind of question would you need to ask this IJavaProject ?
In addition it breaks client code like JDT Debug, over which we have no control.
Dani, I just noticed you were not on the CC list. Can you please comment on comment 7 ? Also what breaks in JDT Debug ?
e.g. actions via object contributions which also call getProject() and assume that it's never null.
You meant getJavaProject(), right ? What kind of questions do you need to ask to this IJavaProject ?
Yes, I mean getJavaProject(). A very prominent question is isOnClasspath().
But basically we have no idea. Clients can call any API that's there.
That was supposed to be *minimal* support. We cannot possibly implement all functionalities on a dummy IJavaProject. So if you're passing this dummy project to other clients, they will surely be broken.
I have written my own code to create a fake CU, see CompilationUnitDocumentProvider.createFakeCompiltationUnit(...). This allowed me to enable Java Outline and Quick Outline for repository and external *.java files, including reconciling the fake CU if it is editable and getting a minimal AST. In order to provide more functionality we need to get a fake CU with minimal support for - problem reporting - code assist - resolving of referenced members - return fake elements if asked for parent or Java project - but not being on the build path i.e. IJavaProject.isOnClasspath(...) -> false This last point is crucial because otherwise most of our actions would be enabled and fail apart when run. Same applies for clients that contribute actions to editors and views or make object contributions. Each of those actions would have to assess whether it can handle the new kind of Java element and if not, be disabled and/or protected.
So would you be able to provide a classpath (IClasspathEntry[]) when creating such working copy ? API would look like: WorkingCopyOwner#newWorkingCopy(String,IClasspathEntry[],IProblemRequestor,IProgressMonitor)
If setting the classpath results in isOnClasspath() to return true then this won't help.
No, the classpath would only be used to compute problems, code assist, etc. The IJavaProject of this working copy would still consider that the working copy is not on the classpath.
That sounds good. We could give this a try.
Added WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProblemRequestor, IProgressMonitor). Added tests ReconcilerTests#testExternal() and ASTConvertTest2#test0578().
Looks like this is not yet in this weeks I-build, right?
Right, this was released after our weekly contribution.
This API is great! I now do a fuzzy search for a matching Java project and use its classpath and the default installed JRE container if no project can be found. This will enable hovers, linking, F3 and even occurrence marking for external CUs and CUs from the repository.
Always good to hear from a happy customer :-)
Code verified for 3.2 M5 using build I20060214-0010.