Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 376269 - Editor Mapping Lookup in EditorRegistry assume file extension is not empty
Summary: Editor Mapping Lookup in EditorRegistry assume file extension is not empty
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Linux
: P1 major with 1 vote (vote)
Target Milestone: 4.2 M7   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-06 20:16 EDT by Alex Ruiz CLA
Modified: 2012-05-01 15:00 EDT (History)
3 users (show)

See Also:


Attachments
Suggested fix. (994 bytes, patch)
2012-04-06 20:17 EDT, Alex Ruiz CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Ruiz CLA 2012-04-06 20:16:04 EDT
Build Identifier: M20120208-0800

Some background:
We have an existing editor associated to the file names BUILD and BUILD.test. We are currently re-writing this editor. Until this new editor has all the features of the existing/old one, we are allowing our users to use both, for testing purposes. The problem is that when they install the new one, "BUILD" is not mapped to the new editor, even though the new editor is associated to the file names BUILD and BUILD.test.

BTW, the new editor is successfully mapped to BUILD.test (but not to BUILD).

Problem:
After doing some debugging, we found out that the method readResources(Map, Reader) in org.eclipse.ui.internal.registry.EditorRegistry assumes that the file extension is never empty:

FileEditorMapping mapping = getMappingFor(name + "." + extension); //$NON-NLS-1$

I'm submitting a patch that does the following, instead:

String key = name;
if (extension != null && extension.length() > 0) {
    key = key + "." + extension; //$NON-NLS-1$
}
FileEditorMapping mapping = getMappingFor(key);

This bug is present in 3.7.2, 3.8 and Juno. The same patch can be be applied to all the Eclipse versions.

Reproducible: Always

Steps to Reproduce:
1. Have an editor associated to a file name without extension (e.g. "BUILD")
2. Create a new plug-in that has an editor associated to the same extension
3. When the new editor is installed, it is not associated to the file name it is supposed to.
Comment 1 Alex Ruiz CLA 2012-04-06 20:17:04 EDT
Created attachment 213721 [details]
Suggested fix.
Comment 2 Paul Webster CLA 2012-04-10 09:03:31 EDT
I know we don't handle content types with no file extension gracefully, but a quick can through the code seems to indicate that having no extension/"" is handled.

John, I'm inclined to apply the patch ... do have have any reservations?

PW
Comment 3 John Arthorne CLA 2012-04-10 10:44:23 EDT
Looks quite reasonable to me.
Comment 4 Eric Moffatt CLA 2012-04-16 14:43:53 EDT
Alex, first off thanks for taking the time to track down the issue...

What version did you make the 'patch' with ? I've found what I think is the right place to put the code but in the current source it's at line 776, not line 763 as indicated by the patch.

I'm just trying to make sure I'm looking in the right place...
Comment 5 Alex Ruiz CLA 2012-04-16 15:23:44 EDT
Hi Eric,

I created the patch using Eclipse 3.7.2. 

I thought that when applying the patch Git will figure out the place based on surrounding code, instead of line numbers. I also successfully applied the patch to 3.8.

Please let me know if version-specific patches is a better approach.

Many thanks,
-Alex

(In reply to comment #4)
> Alex, first off thanks for taking the time to track down the issue...
> 
> What version did you make the 'patch' with ? I've found what I think is the
> right place to put the code but in the current source it's at line 776, not
> line 763 as indicated by the patch.
> 
> I'm just trying to make sure I'm looking in the right place...
Comment 7 Alex Ruiz CLA 2012-04-18 10:09:44 EDT
It was my pleasure! Thanks so much for fixing it :)

Cheers,
-Alex

(In reply to comment #6)
> Released:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=6a3c2870c4b77571115360602140a34d61cef2bf
> 
> Thanx Alex.
> 
> PW
Comment 8 Paul Webster CLA 2012-05-01 15:00:10 EDT
by inspection in I20120430-1800
PW