Skip to content

Commit ba308b7

Browse files
committed
Use ILog.of(Class) in texteditor, editors, navigator.resources, genericeditor
Replace Activator-coupled Plugin.getDefault().getLog().log(...) call sites across four bundles with ILog.of(Class).error/warn/log(...), dropping the round-trip through the plug-in singleton and collapsing redundant Status allocations into the ILog convenience methods. Bundles touched: - org.eclipse.ui.workbench.texteditor (20 files) - org.eclipse.ui.genericeditor (13 files) - org.eclipse.ui.editors (4 files) - org.eclipse.ui.navigator.resources (2 files) Two sites intentionally preserve the explicit Status construction because they attribute the log to the contributor bundle via element.getNamespaceIdentifier() (CodeMiningProviderRegistry, StickyLinesProviderRegistry): only the ILog instance is swapped to avoid changing the logged pluginId. Activator internal log helpers are left unchanged; modernizing those is a separate concern.
1 parent b51da6b commit ba308b7

39 files changed

Lines changed: 91 additions & 165 deletions

File tree

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/codemining/annotation/AnnotationCodeMiningProvider.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
import org.eclipse.swt.events.MouseEvent;
2929

3030
import org.eclipse.core.runtime.Assert;
31+
import org.eclipse.core.runtime.ILog;
3132
import org.eclipse.core.runtime.IProgressMonitor;
32-
import org.eclipse.core.runtime.IStatus;
33-
import org.eclipse.core.runtime.Status;
3433

3534
import org.eclipse.jface.preference.IPreferenceStore;
3635
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -56,10 +55,6 @@
5655
import org.eclipse.jface.text.source.ISourceViewerExtension3;
5756
import org.eclipse.jface.text.source.ISourceViewerExtension5;
5857

59-
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
60-
61-
import org.eclipse.ui.editors.text.EditorsUI;
62-
6358
/**
6459
* Shows <i>info</i>, <i>warning</i>, and <i>error</i> Annotations as line header code minings.
6560
*
@@ -320,7 +315,7 @@ private List<AbstractCodeMining> createCodeMinings(Stream<Annotation> annotation
320315
final String message= quickAssistAssistant.showPossibleQuickAssists();
321316

322317
if (message != null) {
323-
EditorsPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, message));
318+
ILog.of(AnnotationCodeMiningProvider.class).error(message);
324319
}
325320

326321
});

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyLinesProviderDescriptor.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@
2222
import org.eclipse.core.runtime.Assert;
2323
import org.eclipse.core.runtime.CoreException;
2424
import org.eclipse.core.runtime.IConfigurationElement;
25+
import org.eclipse.core.runtime.ILog;
2526
import org.eclipse.core.runtime.IStatus;
2627
import org.eclipse.core.runtime.Status;
2728

2829
import org.eclipse.jface.text.source.ISourceViewer;
2930

30-
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
31-
3231
import org.eclipse.ui.texteditor.ITextEditor;
3332
import org.eclipse.ui.texteditor.stickyscroll.IStickyLinesProvider;
3433

@@ -122,13 +121,11 @@ public IStickyLinesProvider createStickyLinesProvider() {
122121
} else {
123122
String message= "Invalid extension to stickyLinesProvider. Must extends IStickyLinesProvider: " //$NON-NLS-1$
124123
+ getId();
125-
EditorsPlugin.getDefault().getLog()
126-
.log(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, message));
124+
ILog.of(StickyLinesProviderDescriptor.class).error(message);
127125
return null;
128126
}
129127
} catch (CoreException e) {
130-
EditorsPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID,
131-
"Error while creating stickyLinesProvider: " + getId(), e)); //$NON-NLS-1$
128+
ILog.of(StickyLinesProviderDescriptor.class).error("Error while creating stickyLinesProvider: " + getId(), e); //$NON-NLS-1$
132129
return null;
133130
}
134131
}
@@ -154,8 +151,7 @@ public boolean matches(ISourceViewer viewer, ITextEditor editor) {
154151
try {
155152
return enabledWhen.evaluate(context) == EvaluationResult.TRUE;
156153
} catch (CoreException e) {
157-
EditorsPlugin.getDefault().getLog().log(
158-
new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, "Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$
154+
ILog.of(StickyLinesProviderDescriptor.class).error("Error while 'enabledWhen' evaluation", e); //$NON-NLS-1$
159155
return false;
160156
}
161157
}

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/stickyscroll/StickyLinesProviderRegistry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
import org.eclipse.core.runtime.CoreException;
2222
import org.eclipse.core.runtime.IConfigurationElement;
2323
import org.eclipse.core.runtime.IExtensionRegistry;
24+
import org.eclipse.core.runtime.ILog;
2425
import org.eclipse.core.runtime.IStatus;
2526
import org.eclipse.core.runtime.Platform;
2627
import org.eclipse.core.runtime.Status;
2728

2829
import org.eclipse.jface.text.source.ISourceViewer;
2930

30-
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
31-
3231
import org.eclipse.ui.texteditor.ITextEditor;
3332
import org.eclipse.ui.texteditor.stickyscroll.IStickyLinesProvider;
3433

@@ -109,7 +108,7 @@ public synchronized void reloadExtensions() {
109108
StickyLinesProviderDescriptor descriptor = descriptorFactory.create(element);
110109
descriptors.add(descriptor);
111110
} catch (CoreException e) {
112-
EditorsPlugin.getDefault().getLog()
111+
ILog.of(StickyLinesProviderRegistry.class)
113112
.log(new Status(IStatus.ERROR, element.getNamespaceIdentifier(), e.getMessage()));
114113
}
115114
}

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/AutoEditStrategyRegistry.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.util.stream.Collectors;
2222

2323
import org.eclipse.core.runtime.IConfigurationElement;
24-
import org.eclipse.core.runtime.IStatus;
24+
import org.eclipse.core.runtime.ILog;
2525
import org.eclipse.core.runtime.Platform;
26-
import org.eclipse.core.runtime.Status;
2726
import org.eclipse.core.runtime.content.IContentType;
2827
import org.eclipse.jface.text.IAutoEditStrategy;
2928
import org.eclipse.jface.text.source.ISourceViewer;
@@ -83,8 +82,7 @@ private void sync() {
8382
try {
8483
this.extensions.put(extension, new GenericContentTypeRelatedExtension<>(extension));
8584
} catch (Exception ex) {
86-
GenericEditorPlugin.getDefault().getLog()
87-
.log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
85+
ILog.of(AutoEditStrategyRegistry.class).error(ex.getMessage(), ex);
8886
}
8987
}
9088
}

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/CharacterPairMatcherRegistry.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
import java.util.stream.Collectors;
1919

2020
import org.eclipse.core.runtime.IConfigurationElement;
21-
import org.eclipse.core.runtime.IStatus;
21+
import org.eclipse.core.runtime.ILog;
2222
import org.eclipse.core.runtime.Platform;
23-
import org.eclipse.core.runtime.Status;
2423
import org.eclipse.core.runtime.content.IContentType;
2524
import org.eclipse.jface.text.source.ICharacterPairMatcher;
2625
import org.eclipse.jface.text.source.ISourceViewer;
@@ -79,8 +78,7 @@ private void sync() {
7978
this.extensions.put(extension,
8079
new GenericContentTypeRelatedExtension<>(extension));
8180
} catch (Exception ex) {
82-
GenericEditorPlugin.getDefault().getLog()
83-
.log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
81+
ILog.of(CharacterPairMatcherRegistry.class).error(ex.getMessage(), ex);
8482
}
8583
}
8684
}

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ContentAssistProcessorRegistry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
import org.eclipse.core.filebuffers.FileBuffers;
2424
import org.eclipse.core.runtime.IConfigurationElement;
25+
import org.eclipse.core.runtime.ILog;
2526
import org.eclipse.core.runtime.IPath;
26-
import org.eclipse.core.runtime.IStatus;
2727
import org.eclipse.core.runtime.Platform;
28-
import org.eclipse.core.runtime.Status;
2928
import org.eclipse.core.runtime.content.IContentType;
3029
import org.eclipse.core.runtime.content.IContentTypeManager;
3130
import org.eclipse.jface.text.ITextViewer;
@@ -166,7 +165,7 @@ private void sync() {
166165
try {
167166
this.extensions.put(extension, new GenericContentTypeRelatedExtension<>(extension));
168167
} catch (Exception ex) {
169-
GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
168+
ILog.of(ContentAssistProcessorRegistry.class).error(ex.getMessage(), ex);
170169
}
171170
}
172171
}

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/ExtensionBasedTextViewerConfiguration.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141
import org.eclipse.core.runtime.Adapters;
4242
import org.eclipse.core.runtime.CoreException;
4343
import org.eclipse.core.runtime.IAdaptable;
44+
import org.eclipse.core.runtime.ILog;
4445
import org.eclipse.core.runtime.IPath;
45-
import org.eclipse.core.runtime.IStatus;
4646
import org.eclipse.core.runtime.Platform;
47-
import org.eclipse.core.runtime.Status;
4847
import org.eclipse.core.runtime.content.IContentType;
4948
import org.eclipse.jface.preference.IPreferenceStore;
5049
import org.eclipse.jface.text.AbstractReusableInformationControlCreator;
@@ -127,8 +126,7 @@ public Set<IContentType> getContentTypes(IDocument documentParam) {
127126
this.resolvedContentTypes.add(contentType);
128127
}
129128
} catch (CoreException ex) {
130-
GenericEditorPlugin.getDefault().getLog()
131-
.log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
129+
ILog.of(ExtensionBasedTextViewerConfiguration.class).error(ex.getMessage(), ex);
132130
}
133131
}
134132
String fileName = getCurrentFileName(documentParam);

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericContentTypeRelatedExtension.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.eclipse.core.expressions.IEvaluationContext;
2222
import org.eclipse.core.runtime.CoreException;
2323
import org.eclipse.core.runtime.IConfigurationElement;
24+
import org.eclipse.core.runtime.ILog;
2425
import org.eclipse.core.runtime.IStatus;
2526
import org.eclipse.core.runtime.Platform;
2627
import org.eclipse.core.runtime.Status;
@@ -63,8 +64,7 @@ public <E> E createDelegateWithoutTypeCheck() {
6364
try {
6465
return (E) extension.createExecutableExtension(CLASS_ATTRIBUTE);
6566
} catch (CoreException e) {
66-
GenericEditorPlugin.getDefault().getLog()
67-
.log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, e.getMessage(), e));
67+
ILog.of(GenericContentTypeRelatedExtension.class).error(e.getMessage(), e);
6868
}
6969
return null;
7070
}
@@ -121,8 +121,7 @@ public boolean matches(ISourceViewer viewer, ITextEditor editor) {
121121
try {
122122
return enabledWhen.evaluate(context) == EvaluationResult.TRUE;
123123
} catch (CoreException e) {
124-
GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID,
125-
"Error while 'enabledWhen' evaluation", e)); //$NON-NLS-1$
124+
ILog.of(GenericContentTypeRelatedExtension.class).error("Error while 'enabledWhen' evaluation", e); //$NON-NLS-1$
126125
return false;
127126
}
128127
}

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/GenericEditorWithContentTypeIcon.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
package org.eclipse.ui.internal.genericeditor;
1414

1515
import org.eclipse.core.runtime.Assert;
16-
import org.eclipse.core.runtime.IStatus;
16+
import org.eclipse.core.runtime.ILog;
1717
import org.eclipse.core.runtime.Platform;
18-
import org.eclipse.core.runtime.Status;
1918
import org.eclipse.jface.resource.ImageDescriptor;
2019
import org.eclipse.ui.IEditorDescriptor;
2120
import org.eclipse.ui.IEditorMatchingStrategy;
@@ -49,8 +48,7 @@ public ImageDescriptor getImageDescriptor() {
4948
return image;
5049
}
5150
} catch (Exception e) {
52-
GenericEditorPlugin.getDefault().getLog()
53-
.log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, e.getMessage(), e));
51+
ILog.of(GenericEditorWithContentTypeIcon.class).error(e.getMessage(), e);
5452
}
5553
return this.editorDescriptor.getImageDescriptor();
5654
}

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/IconsRegistry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
import java.util.Set;
2323

2424
import org.eclipse.core.runtime.IConfigurationElement;
25-
import org.eclipse.core.runtime.IStatus;
25+
import org.eclipse.core.runtime.ILog;
2626
import org.eclipse.core.runtime.Platform;
27-
import org.eclipse.core.runtime.Status;
2827
import org.eclipse.core.runtime.content.IContentType;
2928
import org.eclipse.jface.resource.ImageDescriptor;
3029
import org.eclipse.jface.resource.ResourceLocator;
@@ -68,7 +67,7 @@ private void sync() {
6867
ResourceLocator.imageDescriptorFromBundle(extension.getNamespaceIdentifier(), icon).ifPresent(imageDescriptor -> this.extensions.put(contentType, imageDescriptor));
6968
}
7069
} catch (Exception ex) {
71-
GenericEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, GenericEditorPlugin.BUNDLE_ID, ex.getMessage(), ex));
70+
ILog.of(IconsRegistry.class).error(ex.getMessage(), ex);
7271
}
7372
}
7473

0 commit comments

Comments
 (0)