Bug 528418 - [code mining] Support for action CodeMining
Summary: [code mining] Support for action CodeMining
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.8 M5   Edit
Assignee: Angelo ZERR CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on: 527720 529087
Blocks: 529316 526969
  Show dependency tree
 
Reported: 2017-12-11 08:29 EST by Angelo ZERR CLA
Modified: 2018-04-05 17:32 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Angelo ZERR CLA 2017-12-11 08:29:58 EST
CodeMining provides the capability to draw content before a line. It should be cool if user could execute an action on click on mining.

Here some examples of action mining with Java Editor:

 * click on "n references" mining executes the JDT search references (like Ctrl+Shift+G) 
 * click on "n implementation" mining open the JDT Implementation dialog (like Ctrl+T)kind of events?)
 * click on "Run/Debug" icons (before a main method or @Test methods) execute the Java class.

To support this feature, ICodeMining should support:

 * hover mining: when mining is hovered, the label mining (or icons) must be displayed as hovered (like an hyperlink for label)
 * gives the capability to add an action with a new API like 

------------------------------------------
ICodeMining#addSelectionListener(CodeMiningSelectionListener listener)

ICodeMining#removeSelectionListener(CodeMiningSelectionListener listener)
------------------------------------------

Question: if we have addSelectionListener, it means that we have several actions to execute, is it a good idea? Perhaps we should provide an hover which displays list of available actions to execute (like Hyperlink)?
Comment 1 Mickael Istria CLA 2017-12-12 03:31:22 EST
+1.
Note that these workflows can already be implemented by placing MouseListeners in the `draw` method. It's not extremely straightforward, but it works ;)

(In reply to Angelo ZERR from comment #0)
>  * hover mining: when mining is hovered, the label mining (or icons) must be
> displayed as hovered (like an hyperlink for label)

I don't think we should give user the opportunity to tweak it. If they use an AbstractCodeMining, hover should just underline the label or icon for instance. Users shouldn't be requested to implement it manually.

>  * gives the capability to add an action with a new API like 
> ------------------------------------------
> ICodeMining#addSelectionListener(CodeMiningSelectionListener listener)
> ICodeMining#removeSelectionListener(CodeMiningSelectionListener listener)
> ------------------------------------------
> Question: if we have addSelectionListener, it means that we have several
> actions to execute, is it a good idea? Perhaps we should provide an hover
> which displays list of available actions to execute (like Hyperlink)?

Let's start smaller and minimize APIs there. The 'codeMiningSelected' action could simply be an (optional) method to implement in the ICodeMining implementation. Let's avoid creating specific listener, and start by assuming the provider of the CodeMining has the full control over the action, before implementing some extensibility we may not need.
For example, the `N implementations` codemining would implement a `codeMiningSelected()` method that would show the search result.
Comment 2 Angelo ZERR CLA 2017-12-30 06:47:10 EST
@Mickael, once you will accept https://bugs.eclipse.org/bugs/show_bug.cgi?id=529087 I will create a gerrit patch to support action. It will help more to discuss about this feature.

Please note that, I'm using this action support for:

 * inside the InlinedAnnotationDemo (now you can click on the colorized square to open the ColorDialog).
 * to Run/Debug Junit test 

See demo at https://bugs.eclipse.org/bugs/show_bug.cgi?id=529316
Comment 3 Eclipse Genie CLA 2018-01-08 17:15:23 EST
New Gerrit change created: https://git.eclipse.org/r/115075
Comment 5 Eclipse Genie CLA 2018-01-22 09:06:24 EST
New Gerrit change created: https://git.eclipse.org/r/115809
Comment 6 Angelo ZERR CLA 2018-01-22 09:10:42 EST
@Mickael, please review my N&N. Thanks!
Comment 8 Angelo ZERR CLA 2018-01-22 09:45:30 EST
Thanks @Lars, @Mickael for your review!