Skip to content

Commit b1db4f4

Browse files
remove accessing sourceviewer config via reflection to get tab width
1 parent 900a124 commit b1db4f4

1 file changed

Lines changed: 0 additions & 42 deletions

File tree

team/bundles/org.eclipse.compare/compare/org/eclipse/compare/unifieddiff/internal/UnifiedDiffCodeMiningProvider.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.eclipse.jface.text.source.IAnnotationModel;
4242
import org.eclipse.jface.text.source.ISourceViewer;
4343
import org.eclipse.jface.text.source.SourceViewer;
44-
import org.eclipse.jface.text.source.SourceViewerConfiguration;
4544
import org.eclipse.jface.text.source.inlined.LineFooterAnnotation;
4645
import org.eclipse.jface.text.source.inlined.LineHeaderAnnotation;
4746
import org.eclipse.swt.SWT;
@@ -58,14 +57,8 @@
5857
import org.eclipse.swt.graphics.RGB;
5958
import org.eclipse.swt.graphics.Rectangle;
6059
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;
6660
import org.eclipse.ui.editors.text.EditorsUI;
6761
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
68-
import org.eclipse.ui.texteditor.AbstractTextEditor;
6962

7063
public class UnifiedDiffCodeMiningProvider extends AbstractCodeMiningProvider {
7164

@@ -151,48 +144,13 @@ private int getTabWidth(ITextViewer viewer) {
151144
return tabWidth;
152145
}
153146
}
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-
}
169147
if (tabWidth == -1) {
170148
IPreferenceStore store = EditorsUI.getPreferenceStore();
171149
tabWidth = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
172150
}
173151
return tabWidth;
174152
}
175153

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-
196154
private void createLineHeaderCodeMinings(List<UnifiedDiff> diffs, List<ICodeMining> minings, ITextViewer tv,
197155
int tabWidth) {
198156
if (diffs == null) {

0 commit comments

Comments
 (0)