Bug 89426 - provide Java class file content type
Summary: provide Java class file content type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-29 17:18 EST by Rafael Chaves CLA
Modified: 2005-05-12 11:23 EDT (History)
1 user (show)

See Also:


Attachments
patch for org.eclipse.jdt.core (1.49 KB, patch)
2005-03-29 17:19 EST, Rafael Chaves CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Chaves CLA 2005-03-29 17:18:00 EST
Please provide Java class content type. I will attach a patch for
org.eclipse.jdt.core that does that. This will enable the Java class file viewer
to be bound to the content type instead of to the file name.

See bug 89232 and bug 89240 for more details.
Comment 1 Rafael Chaves CLA 2005-03-29 17:19:22 EST
Created attachment 19296 [details]
patch for org.eclipse.jdt.core

The only changes required are in plugin.xml and plugin.properties.
Comment 2 Philipe Mulet CLA 2005-03-29 18:18:49 EST
Is it making the classfile viewer any slower ?
Comment 3 Rafael Chaves CLA 2005-03-29 18:33:52 EST
Yes. For class files as files in the workspace, there will be an additional
(partial) file read (should be a one-time only hit though). For class files in
JAR files, it depends on how the client is implemented. I am not sure if the
regular editor association mechanism is used. Daniel, do you know how this is done?
Comment 4 Dani Megert CLA 2005-03-30 05:03:51 EST
For stuff in JARs we use IDE.getEditorDescriptor(input.getName()), e.g.
IDE.getEditorDescriptor("Test.class"). Will this still work if we (JDT UI) only
contribute the class file editor to the new Java class content type? As you
suggested we should remove the file-based contributions.
Comment 5 Philipe Mulet CLA 2005-03-30 06:38:36 EST
My reading of related issues is that this extension point is only meant to
provide hints to editors. Then its name sounds confusing as it is fairly
generic, and suggests all tools would use it over the file extensions.
If so, and it is slower as you said, this might be deadly for JDT/Core, and
simply prove inadequate.

Comment 6 Rafael Chaves CLA 2005-03-30 10:27:22 EST
DM: Just talked to Kim Horne about this and she confirmed it should work. Note
though that since contents are not being taken into account, you might end up
with an editor that is not the most appropriate. This would not be an issue for
class files though.

PM: the content type extension point *is* meant to be the single file name based
registry in Eclipse. See the summary for bug 37668. It is currently used for
encoding determination, compare merger/viewer selection, content-sensitive
object contributions, document setup participants (filebuffers) and recently
editor selection.

"If so, and it is slower as you said, this might be deadly for JDT/Core, and
simply prove inadequate."

I am not sure you are talking about issues in the context of of editor
selection, or you have other use cases in mind. For editor selection, it should
not be a big deal.

Re: my own comment 3 - since class files are frequently rewritten, the caching
scheme for files in the workspace would actually not be very helpful.
Comment 7 Jerome Lanneluc CLA 2005-04-28 09:33:44 EDT
Note that JDT Core will never rely on the content-type to find out if a file is
a Java class file. This would mean that every single .class file in the
workspace would need to be opened, and this would slow us down to a crawl. We
currently rely on the file extension and we have no plan to change this.

Now it might still make sense to have the Java class content-type defined in JDT
Core, as dependent plugins could benefit from this content-type.

First I would need to understand the implications. Since I'm not familiar with
this content-type notion, can you please tell me which Platform APIs use/return
the content-type ? TIA.
Comment 8 Rafael Chaves CLA 2005-04-28 11:26:21 EDT
We did not expect JDT/Core to use the content type. Still, as you mention,
jdt.core is the best place for defining any content types supported by the JDT
feature, because it is the only essential plug-in.

IContentTypeManager/IContentTypeMatcher in org.eclipse.core.runtime.content and
org.eclipse.core.resources.IFile.getContentDescription() are good starting
points. From there, you can find all clients. Also, in comment 6 I mention what
use cases are based on content types so far (you can add Team binary vs text
determination).

Maybe if I knew what kind of implications you are looking for, I may be able to
be more helpful.
Comment 9 Jerome Lanneluc CLA 2005-05-09 07:29:36 EDT
Thanks Rafael. I just wanted to make sure that we don't use any of the methods
that are affected by this change. So it looks like we're okay. I released your
patch.
Comment 10 Frederic Fusier CLA 2005-05-12 11:23:26 EDT
Verified for 3.1 M7 using build I20050509-2010 + jdt.core HEAD.