|
74 | 74 | import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation;
|
75 | 75 | import org.eclipse.cdt.internal.ui.search.OccurrencesFinder;
|
76 | 76 | import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
| 77 | +import org.eclipse.cdt.internal.ui.switchtolsp.ISwitchToLsp; |
77 | 78 | import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
|
78 | 79 | import org.eclipse.cdt.internal.ui.text.CPairMatcher;
|
79 | 80 | import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
|
|
111 | 112 | import org.eclipse.core.runtime.ListenerList;
|
112 | 113 | import org.eclipse.core.runtime.NullProgressMonitor;
|
113 | 114 | import org.eclipse.core.runtime.Platform;
|
| 115 | +import org.eclipse.core.runtime.SafeRunner; |
114 | 116 | import org.eclipse.core.runtime.Status;
|
115 | 117 | import org.eclipse.core.runtime.content.IContentType;
|
116 | 118 | import org.eclipse.core.runtime.jobs.Job;
|
@@ -2786,8 +2788,10 @@ public final ISourceViewer getViewer() {
|
2786 | 2788 |
|
2787 | 2789 | @Override
|
2788 | 2790 | protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
|
| 2791 | + Composite editorComposite = createTryLspBanner(parent); |
| 2792 | + |
2789 | 2793 | IPreferenceStore store = getPreferenceStore();
|
2790 |
| - AdaptedSourceViewer cSourceViewer = new AdaptedSourceViewer(parent, ruler, getOverviewRuler(), |
| 2794 | + AdaptedSourceViewer cSourceViewer = new AdaptedSourceViewer(editorComposite, ruler, getOverviewRuler(), |
2791 | 2795 | isOverviewRulerVisible(), styles, store);
|
2792 | 2796 |
|
2793 | 2797 | /*
|
@@ -2818,6 +2822,29 @@ protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler rule
|
2818 | 2822 | return cSourceViewer;
|
2819 | 2823 | }
|
2820 | 2824 |
|
| 2825 | + /** |
| 2826 | + * Wraps {@link ISwitchToLsp#createTryLspEditor(org.eclipse.ui.texteditor.ITextEditor, Composite)} |
| 2827 | + * with the needed service access + fallback checks. |
| 2828 | + * |
| 2829 | + * If the {@link ISwitchToLsp} service doesn't exist, or fails, this method |
| 2830 | + * is a no-op that simply returns its input. |
| 2831 | + * |
| 2832 | + * @see ISwitchToLsp#createTryLspEditor(org.eclipse.ui.texteditor.ITextEditor, Composite) |
| 2833 | + */ |
| 2834 | + private Composite createTryLspBanner(Composite parent) { |
| 2835 | + Composite editorComposite = SafeRunner.run(() -> { |
| 2836 | + ISwitchToLsp switchToLsp = PlatformUI.getWorkbench().getService(ISwitchToLsp.class); |
| 2837 | + if (switchToLsp != null) { |
| 2838 | + return switchToLsp.createTryLspEditor(CEditor.this, parent); |
| 2839 | + } |
| 2840 | + return null; |
| 2841 | + }); |
| 2842 | + if (editorComposite == null) { |
| 2843 | + editorComposite = parent; |
| 2844 | + } |
| 2845 | + return editorComposite; |
| 2846 | + } |
| 2847 | + |
2821 | 2848 | /** Outliner context menu Id */
|
2822 | 2849 | protected String fOutlinerContextMenuId;
|
2823 | 2850 |
|
|
0 commit comments