Bug 61013 - [plan][model] Minimal support for editing units outside workspace
Summary: [plan][model] Minimal support for editing units outside workspace
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-05 07:03 EDT by Philipe Mulet CLA
Modified: 2006-02-14 08:56 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2004-05-05 07:03:34 EDT
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.
Comment 1 Philipe Mulet CLA 2004-05-05 07:04:06 EDT
Likely something to consider post 3.0
Comment 2 Philipe Mulet CLA 2004-05-18 07:52:05 EDT
Deferred
Comment 3 Jerome Lanneluc CLA 2004-09-23 07:17:55 EDT
Reconsidering for 3.1
Comment 4 Philipe Mulet CLA 2005-04-07 09:26:17 EDT
Deferring post 3.1
Comment 5 Jerome Lanneluc CLA 2005-09-21 11:51:32 EDT
Considering for 3.2
Comment 6 Jerome Lanneluc CLA 2005-11-23 10:41:18 EST
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
Comment 7 Dani Megert CLA 2005-12-08 10:06:05 EST
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.
Comment 8 Jerome Lanneluc CLA 2005-12-08 10:29:16 EST
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 ?
Comment 9 Dani Megert CLA 2005-12-08 10:31:18 EST
In addition it breaks client code like JDT Debug, over which we have no control.
Comment 10 Jerome Lanneluc CLA 2005-12-09 09:29:33 EST
Dani, I just noticed you were not on the CC list. Can you please comment on comment 7 ?
Also what breaks in JDT Debug ?
Comment 11 Dani Megert CLA 2005-12-09 09:43:09 EST
e.g. actions via object contributions which also call getProject() and assume that it's never null.
Comment 12 Jerome Lanneluc CLA 2005-12-09 09:49:53 EST
You meant getJavaProject(), right ? What kind of questions do you need to ask to this IJavaProject ?
Comment 13 Dani Megert CLA 2005-12-09 09:57:40 EST
Yes, I mean getJavaProject().
A very prominent question is isOnClasspath().
Comment 14 Dani Megert CLA 2005-12-09 09:58:14 EST
But basically we have no idea. Clients can call any API that's there.
Comment 15 Jerome Lanneluc CLA 2005-12-09 10:36:45 EST
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.
Comment 16 Dani Megert CLA 2005-12-12 05:45:53 EST
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.
Comment 17 Jerome Lanneluc CLA 2005-12-14 07:53:01 EST
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)
Comment 18 Dani Megert CLA 2005-12-14 09:03:52 EST
If setting the classpath results in isOnClasspath() to return true then this won't help.
Comment 19 Jerome Lanneluc CLA 2005-12-14 09:07:40 EST
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.
Comment 20 Dani Megert CLA 2005-12-14 09:17:03 EST
That sounds good. We could give this a try.
Comment 21 Jerome Lanneluc CLA 2006-01-24 11:38:58 EST
Added WorkingCopyOwner#newWorkingCopy(String, IClasspathEntry[], IProblemRequestor, IProgressMonitor).
Added tests ReconcilerTests#testExternal() and ASTConvertTest2#test0578().
Comment 22 Dani Megert CLA 2006-01-25 12:07:51 EST
Looks like this is not yet in this weeks I-build, right?
Comment 23 Jerome Lanneluc CLA 2006-01-25 12:11:10 EST
Right, this was released after our weekly contribution.
Comment 24 Dani Megert CLA 2006-01-26 08:54:57 EST
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.
Comment 25 Jerome Lanneluc CLA 2006-01-26 08:59:23 EST
Always good to hear from a happy customer :-)
Comment 26 Frederic Fusier CLA 2006-02-14 08:56:42 EST
Code verified for 3.2 M5 using build I20060214-0010.