Bug 38873 - Compilation Units which aren't any.
Summary: Compilation Units which aren't any.
Status: RESOLVED INVALID
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.0 M2   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 38853
  Show dependency tree
 
Reported: 2003-06-13 04:30 EDT by Dirk Baeumer CLA
Modified: 2003-06-13 12:51 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2003-06-13 04:30:52 EDT
To be able open a Java editor on a Java file outside of a build path JDT/Core 
creates a working copy / compilation unit which isn't connected to a real Java 
project. As a result all our actions have to contain some check code if the CU 
we have in hand is a real or a fake CU. Since calling most of the API on a 
fake CU ends in a JavaModelException. And as usual this check code is 
sometimes forgotten.

Is there a change to get a different type for this kind of files in 3.0. This 
woulld really ease our code.
Comment 1 Philipe Mulet CLA 2003-06-13 05:00:09 EDT
I don't see how it would make any difference on your end.
Comment 2 Dirk Baeumer CLA 2003-06-13 05:10:13 EDT
If we have a separate type then the action would be disabled since it wouldn't 
be a compilation unit. And this is something we can currently spec in XML and 
in code. Having the same type enables the action even if it should be 
disabled. So we have some check code in run to test if it is a fake or a real 
CU. 
Comment 3 Philipe Mulet CLA 2003-06-13 06:02:42 EDT
A .java file outside the classpath isn't a compilation unit, however we 
tolerate opening a working copy on it, so that editors can be opened onto them. 
This was a special request from JDT/UI which induces rather inelegant hacks on 
our end to support. 

Now, are you asking back that we shouldn't support this any longer for you ? 
Legitimally, we shouldn't allow you to create working copies on them, period.
Comment 4 Philipe Mulet CLA 2003-06-13 06:03:59 EDT
FYI these are already of different type, since they are listed amongst non-java 
resources.
Comment 5 Dirk Baeumer CLA 2003-06-13 06:18:08 EDT
I know that we have asked for this support and at that point in time it was 
the right thing to do. I am not asking back to not support this anymore. 

Since the current solution seems to be a hack on your and on our side I am 
asking for a better solution than the one we have right now. I thought about 
something like a IJavaFile which isn't a ICompilationUnit ?
Comment 6 Philipe Mulet CLA 2003-06-13 06:31:40 EDT
How do you expect all Java tooling to function on these entities ? We would 
pretty much have to provide new elements for these, and new support accordingly.

Maybe we could reuse working copies under the cover, but this feels a nasty 
request since all resolution should step back from the working copies back to 
this IJavaFile element... 

Very unlikely to occur.

Why aren't your actions registered onto a different object than the fake unit ? 
It seems to me you are missing a generic 'enable' check for actions (they would 
all check whether or not the unit is on a classpath).
Comment 7 Dirk Baeumer CLA 2003-06-13 06:47:46 EDT
Currently our actions do exactly this. They check if the element they try to 
working on is on the class path and if not the pop-up a dialog. But since this 
is something the developer has to do manually it gets forgotten.
Comment 8 Philipe Mulet CLA 2003-06-13 07:12:10 EDT
I think this is an implementation detail on your end. You should better 
structure these actions so that you implicitly get this behavior (by 
inheritance or whatever suits the best your needs).
Comment 9 Dirk Baeumer CLA 2003-06-13 08:13:32 EDT
Yes and No, since another plug-in can contribute action to a compilation unit 
as well. So all plug-ins have to be aware of that issue as well. 

But I agree that doubling the Java element tree isn't an option either.
Comment 10 Olivier Thomann CLA 2003-06-13 09:58:03 EDT
As an end user I don't care if I have a Java editor when I open a file (ending 
with .java) that is located in a simple project (not a java project). All 
actions like Open on selection won't work anyway. So why would this be a fake 
compilation unit? Open it as a text file and this is good enough. Then I won't 
be tempted to use action that will fail. See bug 38853.
Note that I am not talking about a compilation unit outside of the classpath, 
but about a file (name ending with .java) located in a simple project.
Comment 11 Dirk Baeumer CLA 2003-06-13 10:43:59 EDT
We had PRs that users wanted to get an Outline for normal *.java files even if 
they don't reside in a Java Project. 
Comment 12 Olivier Thomann CLA 2003-06-13 12:23:21 EDT
Enabling the outliner should not interfere with different actions like open on 
selection. The actual behavior is not acceptable. The check has to be done on 
the UI side.
Comment 13 Dirk Baeumer CLA 2003-06-13 12:51:29 EDT
I am not saying that we don't intend to fix 38853. It is already assigned to 
me. I justed wanted to find a better solution than always putting the "is a 
fake" check into all our actions.