diff options
author | Karsten Thoms | 2018-03-21 12:38:16 +0000 |
---|---|---|
committer | Mickael Istria | 2018-04-24 14:31:27 +0000 |
commit | 6e3500bbb912961be9724d506486bb4c65180477 (patch) | |
tree | 705e8696f12651396d52432e4ab100d31dde7551 | |
parent | 658a3ab665fa5ee7fbba7ddc6b235372fc46ff2f (diff) | |
download | eclipse.platform.text-6e3500bbb912961be9724d506486bb4c65180477.tar.gz eclipse.platform.text-6e3500bbb912961be9724d506486bb4c65180477.tar.xz eclipse.platform.text-6e3500bbb912961be9724d506486bb4c65180477.zip |
Bug 532706 - Update minings when code mining manager is initializedI20180425-1705I20180425-1650I20180425-1455I20180425-0910I20180425-0725I20180425-0505I20180425-0250I20180424-2000
After fCodeMiningManager is initialized in
ensureCodeMiningManagerInstalled, it is not assured that
updateCodeMinings() is called afterwards. The initial reconciling has
already called before an annotation painter is set. But only when this
has happened the code mining is properly installed and an initial mining
has to be shown. Thus ensureCodeMiningManagerInstalled calls
updateCodeMinings after initialization of the manager.
Also changed guard conditions since it is intended to check that the
code mining manager is set, but method hasCodeMiningProviders is from
its name not so clear that this is implied by calling it.
Change-Id: Ic79743178aa3302d38586770246ca7d749401e15
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java | 10 | ||||
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java | 9 |
2 files changed, 10 insertions, 9 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java index 27e645801aa..79f16fdf154 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/codemining/CodeMiningStrategy.java @@ -37,12 +37,10 @@ class CodeMiningStrategy implements IReconcilingStrategy, IReconcilingStrategyEx @Override
public void initialReconcile() {
- if (fViewer != null) {
- // FIXME: this update is done because minings is not updated on focus by AbstractTextEditor#setFocus
- // But I'm a little afraid to update minings each time editor will have focus
- // @Mickael what do you think about doing update minings on AbstractTextEditor#setFocus ?
- fViewer.updateCodeMinings();
- }
+ // Do nothing
+ // Initial reconcilation will happen when the SourceViewer
+ // has initialized the code mining provider
+ // see SourceViewer#ensureCodeMiningManagerInstalled
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java index c98d750c042..303b9c51163 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java @@ -1272,13 +1272,14 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi boolean enable= codeMiningProviders != null && codeMiningProviders.length > 0; fCodeMiningProviders= codeMiningProviders; if (enable) { - if (hasCodeMiningProviders()) { + if (fCodeMiningManager != null) { fCodeMiningManager.setCodeMiningProviders(fCodeMiningProviders); } ensureCodeMiningManagerInstalled(); } else { - if (hasCodeMiningProviders()) + if (fCodeMiningManager != null) { fCodeMiningManager.uninstall(); + } fCodeMiningManager= null; } } @@ -1296,12 +1297,14 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi fInlinedAnnotationSupport.install(this, fAnnotationPainter); } fCodeMiningManager= new CodeMiningManager(this, fInlinedAnnotationSupport, fCodeMiningProviders); + // now trigger an update + updateCodeMinings(); } } @Override public boolean hasCodeMiningProviders() { - return fCodeMiningManager != null; + return fCodeMiningManager != null; // manager always has at least one provider } @Override |