|
41 | 41 | import org.eclipse.jface.text.source.IAnnotationModel; |
42 | 42 | import org.eclipse.jface.text.source.ISourceViewer; |
43 | 43 | import org.eclipse.jface.text.source.SourceViewer; |
44 | | -import org.eclipse.jface.text.source.SourceViewerConfiguration; |
45 | 44 | import org.eclipse.jface.text.source.inlined.LineFooterAnnotation; |
46 | 45 | import org.eclipse.jface.text.source.inlined.LineHeaderAnnotation; |
47 | 46 | import org.eclipse.swt.SWT; |
|
58 | 57 | import org.eclipse.swt.graphics.RGB; |
59 | 58 | import org.eclipse.swt.graphics.Rectangle; |
60 | 59 | import org.eclipse.swt.widgets.Display; |
61 | | -import org.eclipse.ui.IEditorPart; |
62 | | -import org.eclipse.ui.IWorkbench; |
63 | | -import org.eclipse.ui.IWorkbenchPage; |
64 | | -import org.eclipse.ui.IWorkbenchWindow; |
65 | | -import org.eclipse.ui.PlatformUI; |
66 | 60 | import org.eclipse.ui.editors.text.EditorsUI; |
67 | 61 | import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; |
68 | | -import org.eclipse.ui.texteditor.AbstractTextEditor; |
69 | 62 |
|
70 | 63 | public class UnifiedDiffCodeMiningProvider extends AbstractCodeMiningProvider { |
71 | 64 |
|
@@ -151,48 +144,13 @@ private int getTabWidth(ITextViewer viewer) { |
151 | 144 | return tabWidth; |
152 | 145 | } |
153 | 146 | } |
154 | | - AbstractTextEditor ate = getAbstractTextEditor(); |
155 | | - if (viewer != null && ate != null) { |
156 | | - ITextViewer a = ate.getAdapter(ITextViewer.class); |
157 | | - if (a == viewer && viewer instanceof ISourceViewer sv) { |
158 | | - try { |
159 | | - Field f = AbstractTextEditor.class.getDeclaredField("fConfiguration"); //$NON-NLS-1$ |
160 | | - f.setAccessible(true); |
161 | | - var config = (SourceViewerConfiguration) f.get(ate); |
162 | | - tabWidth = config.getTabWidth(sv); |
163 | | - } catch (IllegalAccessException | IllegalArgumentException | NoSuchFieldException |
164 | | - | SecurityException e) { |
165 | | - error(e); |
166 | | - } |
167 | | - } |
168 | | - } |
169 | 147 | if (tabWidth == -1) { |
170 | 148 | IPreferenceStore store = EditorsUI.getPreferenceStore(); |
171 | 149 | tabWidth = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); |
172 | 150 | } |
173 | 151 | return tabWidth; |
174 | 152 | } |
175 | 153 |
|
176 | | - private AbstractTextEditor getAbstractTextEditor() { |
177 | | - IWorkbench wb = PlatformUI.getWorkbench(); |
178 | | - if (wb == null) { |
179 | | - return null; |
180 | | - } |
181 | | - IWorkbenchWindow aww = wb.getActiveWorkbenchWindow(); |
182 | | - if (aww == null) { |
183 | | - return null; |
184 | | - } |
185 | | - IWorkbenchPage ap = aww.getActivePage(); |
186 | | - if (ap == null) { |
187 | | - return null; |
188 | | - } |
189 | | - IEditorPart ae = ap.getActiveEditor(); |
190 | | - if (ae instanceof AbstractTextEditor ate) { |
191 | | - return ate; |
192 | | - } |
193 | | - return null; |
194 | | - } |
195 | | - |
196 | 154 | private void createLineHeaderCodeMinings(List<UnifiedDiff> diffs, List<ICodeMining> minings, ITextViewer tv, |
197 | 155 | int tabWidth) { |
198 | 156 | if (diffs == null) { |
|
0 commit comments