mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Remove unneeded local variables and instanceof checks (#1087)
new AdaptedSourceViewer was unnecessarily upcast to ISourceViewer leaving a bunch of null checks and instanceof checks in the rest of the method. This commit removes the unneeded code. This extra complication was a result of CDT following JDT, but the JDT case has much more configurability which meant the extra instanceof and null checks are needed for JDT case.
This commit is contained in:
parent
6fd372066e
commit
ca5dabc3a3
1 changed files with 7 additions and 15 deletions
|
@ -2787,25 +2787,17 @@ public class CEditor extends TextEditor
|
|||
@Override
|
||||
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
|
||||
IPreferenceStore store = getPreferenceStore();
|
||||
ISourceViewer sourceViewer = new AdaptedSourceViewer(parent, ruler, getOverviewRuler(),
|
||||
AdaptedSourceViewer cSourceViewer = new AdaptedSourceViewer(parent, ruler, getOverviewRuler(),
|
||||
isOverviewRulerVisible(), styles, store);
|
||||
|
||||
CSourceViewer cSourceViewer = null;
|
||||
if (sourceViewer instanceof CSourceViewer) {
|
||||
cSourceViewer = (CSourceViewer) sourceViewer;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a performance optimization to reduce the computation of
|
||||
* the text presentation triggered by {@link #setVisibleDocument(IDocument)}
|
||||
*/
|
||||
if (cSourceViewer != null && isFoldingEnabled()
|
||||
&& (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
|
||||
if (isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
|
||||
cSourceViewer.prepareDelayedProjection();
|
||||
|
||||
ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
|
||||
|
||||
fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
|
||||
fProjectionSupport = new ProjectionSupport(cSourceViewer, getAnnotationAccess(), getSharedColors());
|
||||
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
|
||||
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
|
||||
fProjectionSupport.addSummarizableAnnotationType("org.eclipse.search.results"); //$NON-NLS-1$
|
||||
|
@ -2816,14 +2808,14 @@ public class CEditor extends TextEditor
|
|||
fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry()
|
||||
.getCurrentFoldingProvider();
|
||||
if (fProjectionModelUpdater != null)
|
||||
fProjectionModelUpdater.install(this, projectionViewer);
|
||||
fProjectionModelUpdater.install(this, cSourceViewer);
|
||||
|
||||
if (isFoldingEnabled())
|
||||
projectionViewer.doOperation(ProjectionViewer.TOGGLE);
|
||||
cSourceViewer.doOperation(ProjectionViewer.TOGGLE);
|
||||
|
||||
getSourceViewerDecorationSupport(sourceViewer);
|
||||
getSourceViewerDecorationSupport(cSourceViewer);
|
||||
|
||||
return sourceViewer;
|
||||
return cSourceViewer;
|
||||
}
|
||||
|
||||
/** Outliner context menu Id */
|
||||
|
|
Loading…
Add table
Reference in a new issue