From 2a986ffa3ac7071cb2f31b3e66fcf5303bbc676c Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Mon, 20 Apr 2026 17:13:44 +0200 Subject: [PATCH] Use ILog.of(Class) in org.eclipse.ui.ide Replace Activator-coupled `getDefault().getLog().log(...)` call sites in org.eclipse.ui.ide 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. Skipped for a separate pass: - IDEWorkbenchPlugin internal log helpers (activator self-reference) - ProjectEncodingMarkerResolutionGenerator logs via UIPlugin from an IDE-bundle class (bundle-id mismatch needs per-site judgement) --- .../ui/actions/CopyFilesAndFoldersOperation.java | 8 ++++---- .../ide/EditorAssociationOverrideDescriptor.java | 3 ++- .../ui/internal/ide/dialogs/ProjectNaturesPage.java | 11 +++++------ .../ide/filesystem/FileSystemSupportRegistry.java | 3 ++- .../views/markers/MarkerContentGenerator.java | 3 ++- .../views/markers/internal/MarkerSupportRegistry.java | 10 +++------- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java index af7766ff48c..82504e776a5 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java @@ -45,6 +45,7 @@ import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -644,10 +645,9 @@ protected boolean isMove() { private void display(InvocationTargetException e) { // CoreExceptions are collected above, but unexpected runtime // exceptions and errors may still occur. - IDEWorkbenchPlugin.getDefault().getLog().log( - Status.error(MessageFormat.format( - "Exception in {0}.performCopy(): {1}", //$NON-NLS-1$ - getClass().getName(), e.getTargetException()))); + ILog.of(CopyFilesAndFoldersOperation.class).error(MessageFormat.format( + "Exception in {0}.performCopy(): {1}", //$NON-NLS-1$ + getClass().getName(), e.getTargetException())); displayError(NLS .bind( IDEWorkbenchMessages.CopyFilesAndFoldersOperation_internalError, diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java index 9d5288740c4..9768dc73a9d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; @@ -160,7 +161,7 @@ private static EditorAssociationOverrideDescriptor[] createDescriptors(IConfigur } else { String message= MessageFormat.format(IDEWorkbenchMessages.editorAssociationOverride_error_invalidElementName_message, configElement.getContributor().getName(), configElement.getName()); - IDEWorkbenchPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.OK, message, null)); + ILog.of(EditorAssociationOverrideDescriptor.class).error(message); } } return result.toArray(new EditorAssociationOverrideDescriptor[result.size()]); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java index d3d33020f4d..2d18728e86b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java @@ -29,6 +29,7 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; @@ -128,10 +129,9 @@ protected Control createContents(final Composite parent) { this.naturesIdsWorkingCopy = new ArrayList<>(); this.naturesIdsWorkingCopy.addAll(Arrays.asList(project.getDescription().getNatureIds())); } catch (CoreException ex) { - IDEWorkbenchPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, - IDEWorkbenchPlugin.getDefault().getBundle().getSymbolicName(), + ILog.of(ProjectNaturesPage.class).warn( "Error while loading project description for " + this.project.getName(), //$NON-NLS-1$ - ex)); + ex); } this.activeNaturesList.setInput(this.naturesIdsWorkingCopy); @@ -313,10 +313,9 @@ public boolean performOk() { try { originalNatureIds = Arrays.asList(this.project.getDescription().getNatureIds()); } catch (CoreException ex) { - IDEWorkbenchPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, - IDEWorkbenchPlugin.getDefault().getBundle().getSymbolicName(), + ILog.of(ProjectNaturesPage.class).warn( "Error while loading project description for " + this.project.getName(), //$NON-NLS-1$ - ex)); + ex); originalNatureIds = new ArrayList<>(); } if (this.naturesIdsWorkingCopy.size() == originalNatureIds.size() diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java index 0a23c81fe2c..43cd1781518 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java @@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SafeRunner; @@ -161,7 +162,7 @@ public void run() { } catch (CoreException exception) { exceptions[0] = exception; - IDEWorkbenchPlugin.getDefault().getLog().log(exception.getStatus()); + ILog.of(FileSystemSupportRegistry.class).log(exception.getStatus()); } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java index 40bfc63f496..48a910f3d67 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java @@ -33,6 +33,7 @@ import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.IPropertyChangeListener; @@ -526,7 +527,7 @@ private void writeFiltersPreference() { try { memento.save(writer); } catch (IOException e) { - IDEWorkbenchPlugin.getDefault().getLog().log(Util.errorStatus(e)); + ILog.of(MarkerContentGenerator.class).log(Util.errorStatus(e)); } // TODO: We need to migrate this the current class IDEWorkbenchPlugin.getDefault().getPreferenceStore().putValue( diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java index 72a1823598a..9b2d045b651 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java @@ -28,9 +28,8 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker; import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler; import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker; @@ -572,11 +571,8 @@ private ProblemFilter newFilter(IConfigurationElement element) { if (markerId != null) { MarkerType markerType = filter.getMarkerType(markerId); if (markerType == null) { - IStatus status = new Status(IStatus.WARNING, IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.WARNING, - NLS.bind(MarkerMessages.ProblemFilterRegistry_nullType, - new Object[] { markerId, filter.getName() }), - null); - IDEWorkbenchPlugin.getDefault().getLog().log(status); + ILog.of(MarkerSupportRegistry.class).warn(NLS.bind(MarkerMessages.ProblemFilterRegistry_nullType, + new Object[] { markerId, filter.getName() })); } else { selectedTypes.add(markerType); }