Bug 535510 - file patterns for content-types not prioritized
Summary: file patterns for content-types not prioritized
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Resources-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-04 05:44 EDT by Martin Lippert CLA
Modified: 2021-03-06 15:20 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Lippert CLA 2018-06-04 05:44:42 EDT
This is a follow-up entry from Bug #263316.

I defined a content-type via file-patterns, but it doesn't seem to be taken into account in the correct way. The extension looks like:

   <extension
         point="org.eclipse.core.contenttype.contentTypes">
      <content-type
            id="org.springframework.boot.ide.properties.application.properties"
            base-type="org.eclipse.jdt.core.javaProperties"
            name="Spring Properties File"
            priority="high">
      </content-type>
      <file-association
            content-type="org.springframework.boot.ide.properties.application.properties"
            file-patterns="*application*.properties">
      </file-association>
   </extension>

There is also an associated editor defined for that content-type. But having a file called "application.properties" the editor doesn't show up for this.

When I change the definition to

            file-names="application.properties">

Everything works as expected.
Looks like a bug to be, the file pattern based content-type definition should work as well.
Comment 1 Mickael Istria CLA 2018-06-04 05:50:49 EDT
What do you mean by work? Just opening the right editor, or did you also checked the behavior of some API?

Can you please add a test to IContentTypeManagerTest about it, mimicking what was done in https://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=28cac80c5be28e7e7ba0f45222e89c94a53fb902 but with your specific case?
This will help to establish which layer is wrong: if ContentTypeManager behaves well, then it is most likely an issue in how the UI uses the API to take some decision about what to show.
Comment 2 Martin Lippert CLA 2018-06-15 05:06:29 EDT
Mickael and I debugged this at EclipseCon France a bit and we thing the culprit is:

ContentTypeCatalog.internalFindContentTypesFor(..) prioritizes an extension-based content-type definition over a pattern-based definition. It looks like whenever there is a content-type associated via a file extension like ".properties", an additional pattern-based definition like "*application*.properties" isn't prioritized over the extension-based one.

We think it would make sense to change this and take this specific case into account:

===
Whenever there is a file-patterns definition that includes the file-extension (like in the example above), prioritize the file-pattern-based one, since it is more specific.
===
Comment 3 Eclipse Genie CLA 2021-03-06 15:04:05 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Mickael Istria CLA 2021-03-06 15:20:14 EST
This is still relevant.