Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370286 - Rethink plugin-contributed highlight API
Summary: Rethink plugin-contributed highlight API
Status: RESOLVED WONTFIX
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: 0.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Mark Macdonald CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-31 18:07 EST by Mark Macdonald CLA
Modified: 2015-05-05 16:00 EDT (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 Mark Macdonald CLA 2012-01-31 18:07:28 EST
Highlight information can currently be contributed from a plugin.

This is done using a combination of two services: 
 - 'orion.edit.model' allows the plugin to receive text change events from a TextView.
 - 'orion.edit.highlighter' allows the plugin to send styling information that will be applied to a TextView.

The API here implicitly assumes that a plugin will deal with a single TextView. This assumption doesn't hold when (for example) you have 3 diff viewers that all want to be styled by the orion-codemirror plugin.
Comment 1 Mark Macdonald CLA 2012-03-15 17:48:43 EDT
One way to fix this, in our current architecture, is to assign IDs to objects that a plugin is interested in, but that it cannot access directly.

So we'd give a unique ID to every TextView, and then any API call that contains data from a TextView would include the TextView ID.

For example, if you were writing a plugin that listened to a selection event, you would implement:
 onSelection(textViewId, selection)

Rather than:
 onSelection(selection)

The plugin would need to include this TextView ID in any data it sends back to Orion. If the plugin maintains any state between calls, it needs to store it per-TextView-instance so that one TextView cannot interfere with another.

But this feels like a cumbersome workaround for not being able to pass a reference to the actual 'TextView' object to a plugin. I am worried that forcing this onto clients will make our APIs unpleasant to use.
Comment 2 Mark Macdonald CLA 2012-03-15 18:50:03 EDT
I guess I'm searching for the equivalent of an executable extension from Eclipse desktop. A plugin wants to contribute an implementation of some interface. When the core needs the contribution, it magically instantiates it into a first-class object, and then interacts with it like any other object.

This allows more encapsulation because there may be many instances of a contribution, each with its own separate internal state.

By contrast, in our current architecture, Orion plugins are singletons. The services they contribute are also singletons. The core talks to these singletons to get work done, but every API call must carry all the parameters necessary to disambiguate one (would-be) instance of a contribution from another.

Not sure if I'm explaining this very well, but hopefully the example in Comment 1 made it clear.
Comment 3 John Arthorne CLA 2012-03-16 10:03:49 EDT
Yes it makes complete sense. Just to clarify though, on the "Coding" page there is only one text view so this isn't an issue right? I guess the problem would be compare pages, or git commit page, or any page showing multiple text views at once?
Comment 4 Mark Macdonald CLA 2012-03-16 10:39:59 EDT
(In reply to comment #3)
> Yes it makes complete sense. Just to clarify though, on the "Coding" page there
> is only one text view so this isn't an issue right? I guess the problem would
> be compare pages, or git commit page, or any page showing multiple text views
> at once?

Yes, that's right. If a service knows it will never apply to more than one thing on a page, there's no problem. But I can see a lot of the "coding-page only" services eventually being useful in compare & git-commit pages too -- for example, something like "mark occurrences".
Comment 5 John Arthorne CLA 2015-05-05 15:46:56 EDT
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:


https://dev.eclipse.org/mhonarc/lists/orion-dev/msg03444.html
Comment 6 John Arthorne CLA 2015-05-05 16:00:40 EDT
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:


https://dev.eclipse.org/mhonarc/lists/orion-dev/msg03444.html