diff options
19 files changed, 265 insertions, 189 deletions
diff --git a/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF b/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF index c132b017717..f18ce3f7b6b 100644 --- a/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.ui.genericeditor;singleton:=true -Bundle-Version: 1.1.300.qualifier +Bundle-Version: 1.1.400.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0", @@ -14,11 +14,13 @@ Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0", org.eclipse.jface;bundle-version="3.12.0", org.eclipse.ui.ide;bundle-version="3.12.0", org.eclipse.core.resources;bundle-version="3.11.0", - org.eclipse.core.expressions;bundle-version="3.6.0" + org.eclipse.core.expressions;bundle-version="3.6.0", + org.eclipse.compare;resolution:=optional Export-Package: org.eclipse.ui.internal.genericeditor;x-internal:=true, org.eclipse.ui.internal.genericeditor.hover;x-internal:=true, org.eclipse.ui.internal.genericeditor.markers;x-internal:=true, - org.eclipse.ui.internal.genericeditor.preferences;x-internal:=true + org.eclipse.ui.internal.genericeditor.preferences;x-internal:=true, + org.eclipse.ui.internal.genericeditor.compare;x-internal:=true Bundle-Activator: org.eclipse.ui.internal.genericeditor.GenericEditorPlugin Bundle-Localization: plugin Bundle-ActivationPolicy: lazy diff --git a/org.eclipse.ui.genericeditor/plugin.xml b/org.eclipse.ui.genericeditor/plugin.xml index c26db6af160..416f17b867f 100644 --- a/org.eclipse.ui.genericeditor/plugin.xml +++ b/org.eclipse.ui.genericeditor/plugin.xml @@ -209,4 +209,18 @@ <extension point="org.eclipse.core.runtime.preferences"> <initializer class="org.eclipse.ui.internal.genericeditor.preferences.GenericEditorPluginPreferenceInitializer"/> </extension> + <extension + point="org.eclipse.compare.contentViewers"> + <viewer + class="org.eclipse.ui.internal.genericeditor.compare.CompareViewerCreator" + id="org.eclipse.ui.genericeditor.compareViewer"> + </viewer> + </extension> + <extension + point="org.eclipse.compare.contentMergeViewers"> + <viewer + class="org.eclipse.ui.internal.genericeditor.compare.CompareViewerCreator" + id="org.eclipse.ui.genericeditor.compareViewer"> + </viewer> + </extension> </plugin> diff --git a/org.eclipse.ui.genericeditor/pom.xml b/org.eclipse.ui.genericeditor/pom.xml index f9cbe5676e1..d2026a60720 100644 --- a/org.eclipse.ui.genericeditor/pom.xml +++ b/org.eclipse.ui.genericeditor/pom.xml @@ -18,6 +18,6 @@ </parent> <groupId>org.eclipse.ui</groupId> <artifactId>org.eclipse.ui.genericeditor</artifactId> - <version>1.1.300-SNAPSHOT</version> + <version>1.1.400-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd b/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd index 2da6a4dd823..f5ac51c4ecd 100644 --- a/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd +++ b/org.eclipse.ui.genericeditor/schema/autoEditStrategies.exsd @@ -83,8 +83,9 @@ A core Expression that controls the enabled of the given auto edit strategies. The viewer, editor, and editor input are registered in the evaluation context as variable: * <with variable="viewer"/> : use it if your expression requires the viewer. - * <with variable="editor"/> : use it if your expression requires the editor. - * <with variable="editorInput"/> : use it if your expression requires the editor input. + * <with variable="document"/> : use it if your expression requires the document. + * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set). + * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set). </documentation> </annotation> <complexType> diff --git a/org.eclipse.ui.genericeditor/schema/characterPairMatchers.exsd b/org.eclipse.ui.genericeditor/schema/characterPairMatchers.exsd index 6890423431f..e9b444c46a5 100644 --- a/org.eclipse.ui.genericeditor/schema/characterPairMatchers.exsd +++ b/org.eclipse.ui.genericeditor/schema/characterPairMatchers.exsd @@ -83,8 +83,9 @@ A core Expression that controls the enabled of the given character pair matcher. The viewer, editor, and editor input are registered in the evaluation context as variable:
* <with variable="viewer"/> : use it if your expression requires the viewer.
- * <with variable="editor"/> : use it if your expression requires the editor.
- * <with variable="editorInput"/> : use it if your expression requires the editor input.
+ * <with variable="document"/> : use it if your expression requires the document.
+ * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set).
+ * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set).
</documentation>
</annotation>
<complexType>
diff --git a/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd b/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd index 53cf18b0189..2637a3f8673 100644 --- a/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd +++ b/org.eclipse.ui.genericeditor/schema/contentAssistProcessors.exsd @@ -83,8 +83,9 @@ A core Expression that controls the enabled of the given content assist processor. The viewer, editor, and editor input are registered in the evaluation context as variable: * <with variable="viewer"/> : use it if your expression requires the viewer. - * <with variable="editor"/> : use it if your expression requires the editor. - * <with variable="editorInput"/> : use it if your expression requires the editor input. + * <with variable="document"/> : use it if your expression requires the document. + * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set). + * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set). </documentation> </annotation> <complexType> diff --git a/org.eclipse.ui.genericeditor/schema/foldingReconcilers.exsd b/org.eclipse.ui.genericeditor/schema/foldingReconcilers.exsd index aeab7b5dfa0..1e15e42f466 100644 --- a/org.eclipse.ui.genericeditor/schema/foldingReconcilers.exsd +++ b/org.eclipse.ui.genericeditor/schema/foldingReconcilers.exsd @@ -85,8 +85,9 @@ A core Expression that controls the enabled of the given folding reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable:
* <with variable="viewer"/> : use it if your expression requires the viewer.
- * <with variable="editor"/> : use it if your expression requires the editor.
- * <with variable="editorInput"/> : use it if your expression requires the editor input.
+ * <with variable="document"/> : use it if your expression requires the document.
+ * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set).
+ * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set).
</documentation>
</annotation>
<complexType>
diff --git a/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd b/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd index 5a387667d95..a457bcf9a4e 100644 --- a/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd +++ b/org.eclipse.ui.genericeditor/schema/highlightReconcilers.exsd @@ -83,8 +83,9 @@ A core Expression that controls the enabled of the given highlight reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable: * <with variable="viewer"/> : use it if your expression requires the viewer. - * <with variable="editor"/> : use it if your expression requires the editor. - * <with variable="editorInput"/> : use it if your expression requires the editor input. + * <with variable="document"/> : use it if your expression requires the document. + * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set). + * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set). </documentation> </annotation> <complexType> diff --git a/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd b/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd index 42aed9045e6..8df8c7584ff 100644 --- a/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd +++ b/org.eclipse.ui.genericeditor/schema/hoverProviders.exsd @@ -112,8 +112,9 @@ Plan is to have contributions are sorted according to that value and to have onl A core Expression that controls the enabled of the given hover provider. The viewer, editor, and editor input are registered in the evaluation context as variable: * <with variable="viewer"/> : use it if your expression requires the viewer. - * <with variable="editor"/> : use it if your expression requires the editor. - * <with variable="editorInput"/> : use it if your expression requires the editor input. + * <with variable="document"/> : use it if your expression requires the document. + * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set). + * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set). </documentation> </annotation> <complexType> diff --git a/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd b/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd index 175f24bd130..6ff6fa7e966 100644 --- a/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd +++ b/org.eclipse.ui.genericeditor/schema/presentationReconcilers.exsd @@ -83,8 +83,9 @@ A core Expression that controls the enabled of the given presentation reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable: * <with variable="viewer"/> : use it if your expression requires the viewer. - * <with variable="editor"/> : use it if your expression requires the editor. - * <with variable="editorInput"/> : use it if your expression requires the editor input. + * <with variable="document"/> : use it if your expression requires the document. + * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set). + * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set). </documentation> </annotation> <complexType> diff --git a/org.eclipse.ui.genericeditor/schema/reconcilers.exsd b/org.eclipse.ui.genericeditor/schema/reconcilers.exsd index 604632ab06f..508cf6c6d07 100644 --- a/org.eclipse.ui.genericeditor/schema/reconcilers.exsd +++ b/org.eclipse.ui.genericeditor/schema/reconcilers.exsd @@ -83,8 +83,9 @@ A core Expression that controls the enabled of the given reconciler. The viewer, editor, and editor input are registered in the evaluation context as variable: * <with variable="viewer"/> : use it if your expression requires the viewer. - * <with variable="editor"/> : use it if your expression requires the editor. - * <with variable="editorInput"/> : use it if your expression requires the editor input. + * <with variable="document"/> : use it if your expression requires the document. + * <with variable="editor"/> : use it if your expression requires the editor (deprecated, not always set). + * <with variable="editorInput"/> : use it if your expression requires the editor input (deprecated, not always set). </documentation> </annotation> <complexType> diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java index 052982693a3..d5bdcbadd8b 100644 --- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java @@ -46,18 +46,13 @@ import org.eclipse.osgi.util.NLS; /** * - * This Reconciler Strategy is a default stategy which will be present if no - * other highlightReconcilers are registered for a given content-type. It splits - * the text into 'words' (which are defined as anything in-between - * non-alphanumeric characters) and searches the document highlighting all like - * words. + * This Reconciler Strategy is a default stategy which will be present if no other highlightReconcilers are registered for a given content-type. It splits the text into 'words' (which are defined as + * anything in-between non-alphanumeric characters) and searches the document highlighting all like words. * - * E.g. if your file contains "t^he dog in the bog" and you leave your caret at - * ^ you will get both instances of 'the' highlighted. + * E.g. if your file contains "t^he dog in the bog" and you leave your caret at ^ you will get both instances of 'the' highlighted. * */ -public class DefaultWordHighlightStrategy - implements IReconcilingStrategy, IReconcilingStrategyExtension, IPreferenceChangeListener { +public class DefaultWordHighlightStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension, IPreferenceChangeListener { private static final String ANNOTATION_TYPE = "org.eclipse.ui.genericeditor.text"; //$NON-NLS-1$ @@ -85,7 +80,10 @@ public class DefaultWordHighlightStrategy } String text = document.get(); - int offset = ((ITextViewerExtension5) sourceViewer).widgetOffset2ModelOffset(textSelection.getOffset()); + int offset = textSelection.getOffset(); + if (sourceViewer instanceof ITextViewerExtension5) { + offset = ((ITextViewerExtension5) sourceViewer).widgetOffset2ModelOffset(textSelection.getOffset()); + } String word = findCurrentWord(text, offset); if (word == null) { @@ -97,10 +95,7 @@ public class DefaultWordHighlightStrategy Map<Annotation, Position> annotationMap = new HashMap<>(); while (m.find()) { if (m.group().equals(word)) { - annotationMap.put( - new Annotation(ANNOTATION_TYPE, false, - NLS.bind(Messages.DefaultWordHighlightStrategy_OccurrencesOf, word)), - new Position(m.start(), m.end() - m.start())); + annotationMap.put(new Annotation(ANNOTATION_TYPE, false, NLS.bind(Messages.DefaultWordHighlightStrategy_OccurrencesOf, word)), new Position(m.start(), m.end() - m.start())); } } @@ -154,21 +149,18 @@ public class DefaultWordHighlightStrategy preferences.addPreferenceChangeListener(this); this.enabled = preferences.getBoolean(ToggleHighlight.TOGGLE_HIGHLIGHT_PREFERENCE, true); this.sourceViewer = (ISourceViewer) viewer; - ((IPostSelectionProvider) sourceViewer.getSelectionProvider()) - .addPostSelectionChangedListener(editorSelectionChangedListener); + ((IPostSelectionProvider) sourceViewer.getSelectionProvider()).addPostSelectionChangedListener(editorSelectionChangedListener); } public void uninstall() { if (sourceViewer != null) { - ((IPostSelectionProvider) sourceViewer.getSelectionProvider()) - .removePostSelectionChangedListener(editorSelectionChangedListener); + ((IPostSelectionProvider) sourceViewer.getSelectionProvider()).removePostSelectionChangedListener(editorSelectionChangedListener); } IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(GenericEditorPlugin.BUNDLE_ID); preferences.removePreferenceChangeListener(this); } - @Override - public void preferenceChange(PreferenceChangeEvent event) { + @Override public void preferenceChange(PreferenceChangeEvent event) { if (event.getKey().equals(ToggleHighlight.TOGGLE_HIGHLIGHT_PREFERENCE)) { this.enabled = Boolean.parseBoolean(event.getNewValue().toString()); if (enabled) { @@ -179,8 +171,7 @@ public class DefaultWordHighlightStrategy } } - @Override - public void initialReconcile() { + @Override public void initialReconcile() { if (sourceViewer != null) { sourceViewer.getTextWidget().getDisplay().asyncExec(() -> { if (sourceViewer != null && sourceViewer.getTextWidget() != null) { @@ -218,23 +209,19 @@ public class DefaultWordHighlightStrategy return annotationModel; } - @Override - public void setDocument(IDocument document) { + @Override public void setDocument(IDocument document) { this.document = document; } - @Override - public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { + @Override public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { // Do nothing } - @Override - public void reconcile(IRegion partition) { + @Override public void reconcile(IRegion partition) { // Do nothing } - @Override - public void setProgressMonitor(IProgressMonitor monitor) { + @Override public void setProgressMonitor(IProgressMonitor monitor) { // Not used } } diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java index 2de082dcec3..f1f2c4bfbb1 100644 --- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextEditor.java @@ -34,8 +34,7 @@ import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; /** - * A generic code editor that is aimed at being extended by contributions. - * Behavior is supposed to be added via extensions, not by inheritance. + * A generic code editor that is aimed at being extended by contributions. Behavior is supposed to be added via extensions, not by inheritance. * * @since 1.0 */ @@ -61,31 +60,26 @@ public class ExtensionBasedTextEditor extends TextEditor { /** * Initializes the key binding scopes of this generic code editor. */ - @Override - protected void initializeKeyBindingScopes() { + @Override protected void initializeKeyBindingScopes() { setKeyBindingScopes(new String[] { CONTEXT_ID }); } - @Override - protected void doSetInput(IEditorInput input) throws CoreException { + @Override protected void doSetInput(IEditorInput input) throws CoreException { super.doSetInput(input); configuration.watchDocument(getDocumentProvider().getDocument(input)); } - @Override - protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { + @Override protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { fAnnotationAccess = getAnnotationAccess(); fOverviewRuler = createOverviewRuler(getSharedColors()); - ProjectionViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), - styles); + ProjectionViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles); SourceViewerDecorationSupport support = getSourceViewerDecorationSupport(viewer); configureCharacterPairMatcher(viewer, support); return viewer; } - @Override - public void createPartControl(Composite parent) { + @Override public void createPartControl(Composite parent) { super.createPartControl(parent); ProjectionViewer viewer = (ProjectionViewer) getSourceViewer(); @@ -93,29 +87,26 @@ public class ExtensionBasedTextEditor extends TextEditor { viewer.doOperation(ProjectionViewer.TOGGLE); } - @Override - protected void initializeEditor() { + @Override protected void initializeEditor() { super.initializeEditor(); - setPreferenceStore(new ChainedPreferenceStore(new IPreferenceStore[] { - GenericEditorPreferenceConstants.getPreferenceStore(), EditorsUI.getPreferenceStore() })); + setPreferenceStore(new ChainedPreferenceStore(new IPreferenceStore[] { GenericEditorPreferenceConstants.getPreferenceStore(), EditorsUI.getPreferenceStore() })); } /** - * Configure the {@link ICharacterPairMatcher} from the - * "org.eclipse.ui.genericeditor.characterPairMatchers" extension point. + * Configure the {@link ICharacterPairMatcher} from the "org.eclipse.ui.genericeditor.characterPairMatchers" extension point. * - * @param viewer the source viewer. + * @param viewer + * the source viewer. * - * @param support the source viewer decoration support. + * @param support + * the source viewer decoration support. */ private void configureCharacterPairMatcher(ISourceViewer viewer, SourceViewerDecorationSupport support) { - List<ICharacterPairMatcher> matchers = GenericEditorPlugin.getDefault().getCharacterPairMatcherRegistry() - .getCharacterPairMatchers(viewer, this, configuration.getContentTypes()); + List<ICharacterPairMatcher> matchers = GenericEditorPlugin.getDefault().getCharacterPairMatcherRegistry().getCharacterPairMatchers(viewer, this, configuration.getContentTypes(viewer)); if (!matchers.isEmpty()) { ICharacterPairMatcher matcher = matchers.get(0); support.setCharacterPairMatcher(matcher); - support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR, - HIGHLIGHT_BRACKET_AT_CARET_LOCATION, ENCLOSING_BRACKETS); + support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR, HIGHLIGHT_BRACKET_AT_CARET_LOCATION, ENCLOSING_BRACKETS); } } } diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java index 28a2c64a6c0..f35d79b4f81 100644 --- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java @@ -18,6 +18,7 @@ package org.eclipse.ui.internal.genericeditor; import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; @@ -25,6 +26,8 @@ import java.util.Map; import java.util.Queue; import java.util.Set; +import org.eclipse.core.filebuffers.FileBuffers; +import org.eclipse.core.filebuffers.ITextFileBuffer; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; @@ -45,7 +48,6 @@ import org.eclipse.jface.text.quickassist.QuickAssistAssistant; import org.eclipse.jface.text.reconciler.IReconciler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorPart; import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; import org.eclipse.ui.internal.editors.text.EditorsPlugin; import org.eclipse.ui.internal.genericeditor.folding.DefaultFoldingReconciler; @@ -55,15 +57,13 @@ import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.spelling.SpellingCorrectionProcessor; /** - * The configuration of the {@link ExtensionBasedTextEditor}. It registers the - * proxy composite for hover, completion, syntax highlighting, and then those - * proxy take care of resolving to the right extensions on-demand. + * The configuration of the {@link ExtensionBasedTextEditor}. It registers the proxy composite for hover, completion, syntax highlighting, and then those proxy take care of resolving to the right + * extensions on-demand. * * @since 1.0 */ @SuppressWarnings("restriction") -public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewerConfiguration - implements IDocumentPartitioningListener { +public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewerConfiguration implements IDocumentPartitioningListener { private ITextEditor editor; private Set<IContentType> contentTypes; @@ -74,24 +74,35 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe /** * - * @param editor the editor we're creating. - * @param preferenceStore the preference store. + * @param editor + * the editor we're creating. + * @param preferenceStore + * the preference store. */ public ExtensionBasedTextViewerConfiguration(ITextEditor editor, IPreferenceStore preferenceStore) { super(preferenceStore); this.editor = editor; - this.editor.addPropertyListener((source, propId) -> { - if (propId == IEditorPart.PROP_INPUT) { - watchDocument(editor.getDocumentProvider().getDocument(editor.getEditorInput())); - } - }); } - Set<IContentType> getContentTypes() { + Set<IContentType> getContentTypes(ISourceViewer viewer) { if (this.contentTypes == null) { this.contentTypes = new LinkedHashSet<>(); - Queue<IContentType> types = new LinkedList<>(Arrays - .asList(Platform.getContentTypeManager().findContentTypesFor(editor.getEditorInput().getName()))); + String fileName = null; + if (this.editor != null) { + fileName = editor.getEditorInput().getName(); + } else { + IDocument document = viewer.getDocument(); + if (document != null) { + ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(document); + if (buffer != null) { + fileName = buffer.getLocation().lastSegment(); + } + } + } + if (fileName == null) { + return Collections.emptySet(); + } + Queue<IContentType> types = new LinkedList<>(Arrays.asList(Platform.getContentTypeManager().findContentTypesFor(fileName))); while (!types.isEmpty()) { IContentType type = types.poll(); this.contentTypes.add(type); @@ -104,10 +115,8 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe return this.contentTypes; } - @Override - public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { - List<ITextHover> hovers = GenericEditorPlugin.getDefault().getHoverRegistry().getAvailableHovers(sourceViewer, - editor, getContentTypes()); + @Override public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { + List<ITextHover> hovers = GenericEditorPlugin.getDefault().getHoverRegistry().getAvailableHovers(sourceViewer, editor, getContentTypes(sourceViewer)); if (hovers == null || hovers.isEmpty()) { return null; } else if (hovers.size() == 1) { @@ -117,8 +126,7 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe } } - @Override - public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { + @Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistProcessorRegistry registry = GenericEditorPlugin.getDefault().getContentAssistProcessorRegistry(); contentAssistant = new ContentAssistant(true); contentAssistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW); @@ -126,7 +134,7 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe contentAssistant.setAutoActivationDelay(0); contentAssistant.enableColoredLabels(true); contentAssistant.enableAutoActivation(true); - this.processors = registry.getContentAssistProcessors(sourceViewer, editor, getContentTypes()); + this.processors = registry.getContentAssistProcessors(sourceViewer, editor, getContentTypes(sourceViewer)); if (this.processors.isEmpty()) { this.processors.add(new DefaultContentAssistProcessor()); } @@ -137,19 +145,17 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe associateTokenContentTypes(this.document); } contentAssistant.setInformationControlCreator(new AbstractReusableInformationControlCreator() { - @Override - protected IInformationControl doCreateInformationControl(Shell parent) { + @Override protected IInformationControl doCreateInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); + watchDocument(sourceViewer.getDocument()); return contentAssistant; } - @Override - public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { + @Override public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { PresentationReconcilerRegistry registry = GenericEditorPlugin.getDefault().getPresentationReconcilerRegistry(); - List<IPresentationReconciler> reconciliers = registry.getPresentationReconcilers(sourceViewer, editor, - getContentTypes()); + List<IPresentationReconciler> reconciliers = registry.getPresentationReconcilers(sourceViewer, editor, getContentTypes(sourceViewer)); if (!reconciliers.isEmpty()) { return reconciliers.get(0); } @@ -163,13 +169,14 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe if (this.document != null) { this.document.removeDocumentPartitioningListener(this); } - this.document = document; - associateTokenContentTypes(document); - document.addDocumentPartitioningListener(this); + if (document != null) { + this.document = document; + associateTokenContentTypes(document); + document.addDocumentPartitioningListener(this); + } } - @Override - public void documentPartitioningChanged(IDocument document) { + @Override public void documentPartitioningChanged(IDocument document) { associateTokenContentTypes(document); } @@ -184,33 +191,27 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe } } - @Override - public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) { + @Override public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) { QuickAssistAssistant quickAssistAssistant = new QuickAssistAssistant(); - CompositeQuickAssistProcessor processor = new CompositeQuickAssistProcessor( - Arrays.asList(new MarkerResoltionQuickAssistProcessor(), new SpellingCorrectionProcessor())); + CompositeQuickAssistProcessor processor = new CompositeQuickAssistProcessor(Arrays.asList(new MarkerResoltionQuickAssistProcessor(), new SpellingCorrectionProcessor())); quickAssistAssistant.setQuickAssistProcessor(processor); - quickAssistAssistant.setRestoreCompletionProposalSize( - EditorsPlugin.getDefault().getDialogSettingsSection("quick_assist_proposal_size")); //$NON-NLS-1$ - quickAssistAssistant.setInformationControlCreator( - parent -> new DefaultInformationControl(parent, EditorsPlugin.getAdditionalInfoAffordanceString())); + quickAssistAssistant.setRestoreCompletionProposalSize(EditorsPlugin.getDefault().getDialogSettingsSection("quick_assist_proposal_size")); //$NON-NLS-1$ + quickAssistAssistant.setInformationControlCreator(parent -> new DefaultInformationControl(parent, EditorsPlugin.getAdditionalInfoAffordanceString())); return quickAssistAssistant; } - @Override - public IReconciler getReconciler(ISourceViewer sourceViewer) { + @Override public IReconciler getReconciler(ISourceViewer sourceViewer) { ReconcilerRegistry registry = GenericEditorPlugin.getDefault().getReconcilerRegistry(); - List<IReconciler> reconcilers = registry.getReconcilers(sourceViewer, editor, getContentTypes()); + List<IReconciler> reconcilers = registry.getReconcilers(sourceViewer, editor, getContentTypes(sourceViewer)); // Fill with highlight reconcilers - List<IReconciler> highlightReconcilers = registry.getHighlightReconcilers(sourceViewer, editor, - getContentTypes()); + List<IReconciler> highlightReconcilers = registry.getHighlightReconcilers(sourceViewer, editor, getContentTypes(sourceViewer)); if (!highlightReconcilers.isEmpty()) { reconcilers.addAll(highlightReconcilers); } else { reconcilers.add(new DefaultWordHighlightReconciler()); } // Fill with folding reconcilers - List<IReconciler> foldingReconcilers = registry.getFoldingReconcilers(sourceViewer, editor, getContentTypes()); + List<IReconciler> foldingReconcilers = registry.getFoldingReconcilers(sourceViewer, editor, getContentTypes(sourceViewer)); if (!foldingReconcilers.isEmpty()) { reconcilers.addAll(foldingReconcilers); } else { @@ -223,19 +224,16 @@ public final class ExtensionBasedTextViewerConfiguration extends TextSourceViewe return null; } - @Override - public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { + @Override public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) { AutoEditStrategyRegistry registry = GenericEditorPlugin.getDefault().getAutoEditStrategyRegistry(); - List<IAutoEditStrategy> editStrategies = registry.getAutoEditStrategies(sourceViewer, editor, - getContentTypes()); + List<IAutoEditStrategy> editStrategies = registry.getAutoEditStrategies(sourceViewer, editor, getContentTypes(sourceViewer)); if (!editStrategies.isEmpty()) { return editStrategies.toArray(new IAutoEditStrategy[editStrategies.size()]); } return super.getAutoEditStrategies(sourceViewer, contentType); } - @Override - protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { + @Override protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { Map<String, IAdaptable> targets = super.getHyperlinkDetectorTargets(sourceViewer); targets.put("org.eclipse.ui.genericeditor.GenericEditor", editor); //$NON-NLS-1$ return targets; diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java index b707112fbe7..7159e378c2c 100644 --- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java @@ -28,11 +28,10 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.ui.texteditor.ITextEditor; /** - * This class wraps and proxies an instance of T provided through extensions - * and loads it lazily when it can contribute to the editor, then delegates all operations to - * actual instance. + * This class wraps and proxies an instance of T provided through extensions and loads it lazily when it can contribute to the editor, then delegates all operations to actual instance. * - * @param <T> the actual type to proxy, typically the one defined on the extension point. + * @param <T> + * the actual type to proxy, typically the one defined on the extension point. */ public class GenericContentTypeRelatedExtension<T> { private static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$ @@ -46,13 +45,11 @@ public class GenericContentTypeRelatedExtension<T> { public GenericContentTypeRelatedExtension(IConfigurationElement element) throws Exception { this.extension = element; - this.targetContentType = Platform.getContentTypeManager() - .getContentType(element.getAttribute(CONTENT_TYPE_ATTRIBUTE)); + this.targetContentType = Platform.getContentTypeManager().getContentType(element.getAttribute(CONTENT_TYPE_ATTRIBUTE)); this.enabledWhen = buildEnabledWhen(element); } - @SuppressWarnings("unchecked") - public T createDelegate() { + @SuppressWarnings("unchecked") public T createDelegate() { try { return (T) extension.createExecutableExtension(CLASS_ATTRIBUTE); } catch (CoreException e) { @@ -62,22 +59,21 @@ public class GenericContentTypeRelatedExtension<T> { } /** - * Returns the expression {@link Expression} declared in the - * <code>enabledWhen</code> element. + * Returns the expression {@link Expression} declared in the <code>enabledWhen</code> element. * - * @param configElement the configuration element - * @return the expression {@link Expression} declared in the enabledWhen - * element. - * @throws CoreException when enabledWhen expression is not valid. + * @param configElement + * the configuration element + * @return the expression {@link Expression} declared in the enabledWhen element. + * @throws CoreException + * when enabledWhen expression is not valid. */ private static Expression buildEnabledWhen(IConfigurationElement configElement) throws CoreException { final IConfigurationElement[] children = configElement.getChildren(ENABLED_WHEN_ATTRIBUTE); if (children.length > 0) { IConfigurationElement[] subChildren = children[0].getChildren(); if (subChildren.length != 1) { - throw new CoreException(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, - "One <enabledWhen> element is accepted. Disabling " //$NON-NLS-1$ - + configElement.getAttribute(ID_ATTRIBUTE))); + throw new CoreException(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, "One <enabledWhen> element is accepted. Disabling " //$NON-NLS-1$ + + configElement.getAttribute(ID_ATTRIBUTE))); } final ElementHandler elementHandler = ElementHandler.getDefault(); final ExpressionConverter converter = ExpressionConverter.getDefault(); @@ -87,28 +83,32 @@ public class GenericContentTypeRelatedExtension<T> { } /** - * Returns true if the given viewer, editor matches the enabledWhen expression - * and false otherwise. + * Returns true if the given viewer, editor matches the enabledWhen expression and false otherwise. * - * @param viewer the viewer - * @param editor the editor - * @return true if the given viewer, editor matches the enabledWhen expression - * and false otherwise. + * @param viewer + * the viewer + * @param editor + * the editor + * @return true if the given viewer, editor matches the enabledWhen expression and false otherwise. */ public boolean matches(ISourceViewer viewer, ITextEditor editor) { if (enabledWhen == null) { return true; } - EvaluationContext context = new EvaluationContext(null, editor); + EvaluationContext context = new EvaluationContext(null, editor != null ? editor : viewer); context.setAllowPluginActivation(true); context.addVariable("viewer", viewer); //$NON-NLS-1$ - context.addVariable("editor", editor); //$NON-NLS-1$ - context.addVariable("editorInput", editor.getEditorInput()); //$NON-NLS-1$ + if (viewer.getDocument() != null) { + context.addVariable("document", viewer.getDocument()); //$NON-NLS-1$ + } + if (editor != null) { + context.addVariable("editor", editor); //$NON-NLS-1$ + context.addVariable("editorInput", editor.getEditorInput()); //$NON-NLS-1$ + } try { return enabledWhen.evaluate(context) == EvaluationResult.TRUE; } catch (CoreException e) { - GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, - "Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$ + GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, "Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$ return false; } } diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/compare/CompareViewerCreator.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/compare/CompareViewerCreator.java new file mode 100644 index 00000000000..22e9a96a549 --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/compare/CompareViewerCreator.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2019 Red Hat Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * - Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor.compare; + +import org.eclipse.compare.CompareConfiguration; +import org.eclipse.compare.IViewerCreator; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.widgets.Composite; + +public class CompareViewerCreator implements IViewerCreator { + + @Override public Viewer createViewer(Composite parent, CompareConfiguration compareConfiguration) { + return new GenericEditorMergeViewer(parent, compareConfiguration); + } + +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/compare/GenericEditorMergeViewer.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/compare/GenericEditorMergeViewer.java new file mode 100644 index 00000000000..296876cbd8d --- /dev/null +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/compare/GenericEditorMergeViewer.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2019 Red Hat Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * - Mickael Istria (Red Hat Inc.) + *******************************************************************************/ +package org.eclipse.ui.internal.genericeditor.compare; + +import org.eclipse.compare.CompareConfiguration; +import org.eclipse.compare.contentmergeviewer.TextMergeViewer; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.ITextInputListener; +import org.eclipse.jface.text.TextViewer; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.jface.text.source.SourceViewer; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.internal.genericeditor.ExtensionBasedTextViewerConfiguration; +import org.eclipse.ui.internal.genericeditor.GenericEditorPlugin; + +public class GenericEditorMergeViewer extends TextMergeViewer { + + public GenericEditorMergeViewer(Composite parent, CompareConfiguration configuration) { + super(parent, configuration); + } + + @Override protected SourceViewer createSourceViewer(Composite parent, int textOrientation) { + SourceViewer res = super.createSourceViewer(parent, textOrientation); + res.addTextInputListener(new ITextInputListener() { + @Override public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { + configureTextViewer(res); + } + + @Override public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { + // Nothing to do + } + }); + return res; + } + + @Override protected void configureTextViewer(TextViewer textViewer) { + if (textViewer.getDocument() != null && textViewer instanceof ISourceViewer) { + ((ISourceViewer) textViewer).configure(new ExtensionBasedTextViewerConfiguration(null, GenericEditorPlugin.getDefault().getPreferenceStore())); + } + } + +} diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/DefaultFoldingReconciler.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/DefaultFoldingReconciler.java index 694f5ff6157..cb88382f27a 100644 --- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/DefaultFoldingReconciler.java +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/DefaultFoldingReconciler.java @@ -29,42 +29,39 @@ public class DefaultFoldingReconciler extends AbstractReconciler { this.foldingStrategy = new IndentFoldingStrategy(); } - @Override - public void install(ITextViewer textViewer) { + @Override public void install(ITextViewer textViewer) { super.install(textViewer); - ProjectionViewer viewer = (ProjectionViewer) textViewer; - foldingStrategy.setViewer(viewer); + if (textViewer instanceof ProjectionViewer) { + ProjectionViewer viewer = (ProjectionViewer) textViewer; + foldingStrategy.setViewer(viewer); + } } - @Override - public void uninstall() { + @Override public void uninstall() { super.uninstall(); - foldingStrategy.uninstall(); + if (foldingStrategy != null) { + foldingStrategy.uninstall(); + } } - @Override - protected void process(DirtyRegion dirtyRegion) { + @Override protected void process(DirtyRegion dirtyRegion) { foldingStrategy.reconcile(dirtyRegion, null); } - @Override - protected void reconcilerDocumentChanged(IDocument newDocument) { + @Override protected void reconcilerDocumentChanged(IDocument newDocument) { foldingStrategy.setDocument(newDocument); } - @Override - public IReconcilingStrategy getReconcilingStrategy(String contentType) { + @Override public IReconcilingStrategy getReconcilingStrategy(String contentType) { return foldingStrategy; } - @Override - public void setProgressMonitor(IProgressMonitor monitor) { + @Override public void setProgressMonitor(IProgressMonitor monitor) { super.setProgressMonitor(monitor); foldingStrategy.setProgressMonitor(monitor); } - @Override - protected void initialProcess() { + @Override protected void initialProcess() { super.initialProcess(); foldingStrategy.initialReconcile(); } diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/markers/MarkerAnnotationHover.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/markers/MarkerAnnotationHover.java index 867d548e023..a5ba82e56ae 100644 --- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/markers/MarkerAnnotationHover.java +++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/markers/MarkerAnnotationHover.java @@ -14,6 +14,7 @@ package org.eclipse.ui.internal.genericeditor.markers; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.core.resources.IMarker; @@ -38,25 +39,23 @@ public class MarkerAnnotationHover implements ITextHoverExtension, ITextHoverExt if (!(annotation instanceof MarkerAnnotation)) { return false; } - AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation); + AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation); if (preference == null) { return false; } - String key= preference.getTextPreferenceKey(); + String key = preference.getTextPreferenceKey(); if (key != null) { if (!EditorsUI.getPreferenceStore().getBoolean(key)) return false; } else { - key= preference.getHighlightPreferenceKey(); + key = preference.getHighlightPreferenceKey(); if (key == null || !EditorsUI.getPreferenceStore().getBoolean(key)) return false; } return true; } - - @Override - public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { + @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { Object hoverInfo = getHoverInfo2(textViewer, hoverRegion); if (hoverInfo == null) { return null; @@ -64,12 +63,11 @@ public class MarkerAnnotationHover implements ITextHoverExtension, ITextHoverExt return hoverInfo.toString(); } - @Override - public IRegion getHoverRegion(ITextViewer textViewer, int offset) { + @Override public IRegion getHoverRegion(ITextViewer textViewer, int offset) { if (!(textViewer instanceof ISourceViewerExtension2)) { return null; } - ISourceViewerExtension2 viewer = (ISourceViewerExtension2)textViewer; + ISourceViewerExtension2 viewer = (ISourceViewerExtension2) textViewer; List<MarkerAnnotation> annotations = findMarkerAnnotations(viewer, new Region(offset, 0)); if (annotations.isEmpty()) { return null; @@ -86,12 +84,11 @@ public class MarkerAnnotationHover implements ITextHoverExtension, ITextHoverExt return new Region(highestOffsetStart, Math.max(0, lowestOffsetEnd - highestOffsetStart)); } - @Override - public List<IMarker> getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { + @Override public List<IMarker> getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (!(textViewer instanceof ISourceViewerExtension2)) { return null; } - List<MarkerAnnotation> annotations = findMarkerAnnotations((ISourceViewerExtension2)textViewer, hoverRegion); + List<MarkerAnnotation> annotations = findMarkerAnnotations((ISourceViewerExtension2) textViewer, hoverRegion); if (annotations.isEmpty()) { return null; } @@ -101,23 +98,25 @@ public class MarkerAnnotationHover implements ITextHoverExtension, ITextHoverExt } return markers; } - + private static List<MarkerAnnotation> findMarkerAnnotations(ISourceViewerExtension2 viewer, IRegion region) { List<MarkerAnnotation> res = new ArrayList<>(); IAnnotationModel annotationModel = viewer.getVisualAnnotationModel(); + if (annotationModel == null) { + return Collections.emptyList(); + } annotationModel.getAnnotationIterator().forEachRemaining(annotation -> { if (isIncluded(annotation)) { Position position = annotationModel.getPosition(annotation); if (region.getOffset() >= position.getOffset() && region.getOffset() + region.getLength() <= position.getOffset() + position.getLength()) { - res.add((MarkerAnnotation)annotation); + res.add((MarkerAnnotation) annotation); } } }); return res; } - @Override - public IInformationControlCreator getHoverControlCreator() { + @Override public IInformationControlCreator getHoverControlCreator() { return new MarkerHoverControlCreator(); } |