Bug 521326 - Provide IReconcilingStrategyExtension2 to handle IReconciler#install/uninstall
Summary: Provide IReconcilingStrategyExtension2 to handle IReconciler#install/uninstall
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2017-08-23 15:55 EDT by Angelo ZERR CLA
Modified: 2017-08-24 09:32 EDT (History)
1 user (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-08-23 15:55:22 EDT
All IReconcilingStrategy that I have developed and I have seen needs to work with ITextViewer (IDocument is not enough). Here some sample like JavaCompositeReconcilingStrategy, SpellingReconcileStrategy, XMLFoldingStrategy (from WTP), etc.

This viewer is setted in the constructor or with a setter. IMHO I think Platform should provide a new interface IReconcilingStrategyExtension2 like this:

----------------------------------------------------------
package org.eclipse.jface.text.reconciler;

public interface IReconcilingStrategyExtension2 {
    
  void install(ITextViewer textViewer);

  void uninstall();

}
----------------------------------------------------------

MonoReconciler should call the 2 methods of this API. This new interface will give 2 capabilities:

 * get the ITextViewer in the strategy with a standard mean.
 * detect when reconciler is unistalled and implement some dispose code if needed.

I think this new API should be welcome with Generic Editor and multiple reconciler strategy described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=520686
Comment 1 Dani Megert CLA 2017-08-24 06:19:12 EDT
Some strategies even need the editor, so, it would split the installation.

Having an uninstall was not needed so far.

We can take a closer look if there is a real need from a new strategy.
Comment 2 Angelo ZERR CLA 2017-08-24 06:40:50 EDT
> Some strategies even need the editor, so, it would split the installation.

I have not found those kinds of strategies? Have you a sample?

> Having an uninstall was not needed so far. We can take a closer look if there is a real need from a new strategy.

I have a sample with my PR for lsp4e https://git.eclipse.org/r/#/c/103579/3/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/highlight/HighlightReconcilingStrategy.java

This HighlightReconcilingStrategy adds caret listener on install and removes caret listener on uninstall of reconciler.

If MonoReconciler could takes care of this lifecycle of install/uninstall, I could remove the custom reconciler https://git.eclipse.org/r/#/c/103579/3/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/highlight/HighlightReconciler.java
Comment 3 Dani Megert CLA 2017-08-24 07:17:43 EDT
(In reply to Angelo ZERR from comment #2)
> > Some strategies even need the editor, so, it would split the installation.
> 
> I have not found those kinds of strategies? Have you a sample?

You listed it in comment 0: JavaCompositeReconcilingStrategy


> > Having an uninstall was not needed so far. We can take a closer look if there is a real need from a new strategy.
> 
> I have a sample with my PR for lsp4e
> https://git.eclipse.org/r/#/c/103579/3/org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/highlight/HighlightReconcilingStrategy.java

I'd prefer to have a usage of the new API inside the SDK. Maybe the Generic editor could start with it.
Comment 4 Angelo ZERR CLA 2017-08-24 07:27:52 EDT
> You listed it in comment 0: JavaCompositeReconcilingStrategy

Yes you are right, sorry. In this case constructor is a good idea.

> I'd prefer to have a usage of the new API inside the SDK. Maybe the Generic editor could start with it.

org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy could use it, to avoid to set the sourceViewer in the constructor, no?
Comment 5 Dani Megert CLA 2017-08-24 09:29:23 EDT
(In reply to Angelo ZERR from comment #4)
> > You listed it in comment 0: JavaCompositeReconcilingStrategy
> 
> Yes you are right, sorry. In this case constructor is a good idea.
> 
> > I'd prefer to have a usage of the new API inside the SDK. Maybe the Generic editor could start with it.
> 
> org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy could use it,
> to avoid to set the sourceViewer in the constructor, no?

Not really. In addition to the viewer it needs the spelling service. For me it makes no sense to set the spelling service in the constructor and then pass the viewer via #install.
Comment 6 Angelo ZERR CLA 2017-08-24 09:32:13 EDT
> Not really. In addition to the viewer it needs the spelling service. For me it makes no sense to set the spelling service in the constructor and then pass the viewer via #install.

Ok Dani thanks for your feedback!

I hope generic editor will provide  this kind of interface to implement clean IReconcilingStrategy.