Bug 489786 - "Real" enums in string attributes in extension points
Summary: "Real" enums in string attributes in extension points
Status: RESOLVED WONTFIX
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2016-03-16 15:49 EDT by Stephan Druskat CLA
Modified: 2021-04-07 04:23 EDT (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 Stephan Druskat CLA 2016-03-16 15:49:31 EDT
It'd be great to be able to use real enums for restrictions on string attributes in extension points. E.g., instead of

    <restriction base="string">
      <enumeration value="something">
      </enumeration>
    </restriction>

one could do something like

    <restriction base="string">
      <enumeration value="org.myproduct.myplugin.enums.MyEnumClass">
      </enumeration>
    </restriction>

which would restrict the allowed values to all enums in org.myproduct.myplugin.enums.MyEnumClass.

I'd be happy to investigate if this is possible at all but as I've never contributed to Eclipse and don't know that part of the API at all, I'd be thankful for any pointers on where to start (or a hint if this isn't possible at all).
Comment 1 Brian de Alwis CLA 2016-03-16 20:58:00 EDT
It's a neat idea, but I see some problems with this approach:

- the Eclipse Platform generally tries to be lazy and avoid loading classes as they consume memory
- the enum class or its containing bundle may not be able to be loaded (e.g., missing dependencies, failing activator)
- the enum may not have a proper stringification
- extension points are supposed to be declarative

An alternative approach could be to add an action to the 'restrictions' section to generate the values from an enum.  That action would use JDT to parse the source and populate the appropriate values based on the enum definition.  Virtually identical results, but a safer approach.

It looks like the relevant code is in the org.eclipse.pde.ui bundle in the org.eclipse.pde.internal.ui.editor.schema.SchemaStringAttributeDetails class.

Moving to PDE.
Comment 2 Stephan Druskat CLA 2016-03-17 04:01:00 EDT
Thanks, Brian, for the insights on the nature of extension points. Makes sense. Thanks also for moving the bug and the idea for enum generation. I'll have a look at the code and give it a shot :).
Comment 3 Eclipse Genie CLA 2019-03-23 11:40:26 EDT
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.

If you have further information on the current state of the bug, please add it. 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 Lars Vogel CLA 2019-10-08 10:45:39 EDT
This bug was marked as stalebug a while ago. Marking as wontfix.

If this report is still relevant for the current release, please
reopen and remove the stalebug whiteboard tag.
Comment 5 Stanisław Florczyk CLA 2021-04-07 04:23:10 EDT
Perhaps instead of string with restrictions better idea would be java type attribute but instead of "implements" or "extends" add 3rd option - enum value