Skip to content

Commit

Permalink
Use new ILog.of(...) method instead of Platform.getLog(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Jun 27, 2023
1 parent a07ba74 commit ff43419
Show file tree
Hide file tree
Showing 33 changed files with 53 additions and 49 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.core.filebuffers.tests;x-internal:=true
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.core.filebuffers;bundle-version="[3.5.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static class TestFailReporter extends TestWatcher {

private static final String BUNDLE_ID= "org.eclipse.core.filebuffers.tests";

ILog log= Platform.getLog(Platform.getBundle(BUNDLE_ID));
ILog log= ILog.of(Platform.getBundle(BUNDLE_ID));

@Override
protected void failed(Throwable e, Description description) {
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.core.filebuffers/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Export-Package:
org.eclipse.core.filebuffers.manipulation,
org.eclipse.core.internal.filebuffers;x-internal:=true
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)";resolution:=optional,
org.eclipse.text;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
Expand Down Expand Up @@ -175,7 +176,7 @@ private void readContentType(String attributeName, IConfigurationElement element
* @param status the status to log
*/
private void log(IStatus status) {
Platform.getLog(ExtensionsRegistry.class).log(status);
ILog.of(ExtensionsRegistry.class).log(status);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import org.eclipse.core.filesystem.IFileInfo;

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;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
Expand Down Expand Up @@ -85,7 +85,7 @@ public void run() {
try {
execute();
} catch (Exception x) {
Platform.getLog(ResourceFileBuffer.class).error("Exception when synchronizing", x); //$NON-NLS-1$
ILog.of(ResourceFileBuffer.class).error("Exception when synchronizing", x); //$NON-NLS-1$
fManager.fireStateChangeFailed(ResourceFileBuffer.this);
}
}
Expand Down Expand Up @@ -451,7 +451,7 @@ protected void refreshFile(IProgressMonitor monitor) {
* @param exception the exception to be logged
*/
protected void handleCoreException(CoreException exception) {
Platform.getLog(ResourceFileBuffer.class).log(exception.getStatus());
ILog.of(ResourceFileBuffer.class).log(exception.getStatus());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.eclipse.core.runtime.Assert;
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.ISafeRunnable;
Expand Down Expand Up @@ -152,13 +153,13 @@ public void run() throws Exception {
if (document.getDocumentPartitioner() != null) {
String message= NLSUtility.format(FileBuffersMessages.TextFileBufferManager_warning_documentSetupInstallsDefaultPartitioner, participant.getClass());
IStatus status= new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null);
Platform.getLog(ResourceTextFileBufferManager.class).log(status);
ILog.of(ResourceTextFileBufferManager.class).log(status);
}
}
@Override
public void handleException(Throwable t) {
IStatus status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.TextFileBufferManager_error_documentSetupFailed, t);
Platform.getLog(ResourceTextFileBufferManager.class).log(status);
ILog.of(ResourceTextFileBufferManager.class).log(status);
}
};
SafeRunner.run(runnable);
Expand Down Expand Up @@ -189,7 +190,7 @@ public void run() throws Exception {
@Override
public void handleException(Throwable t) {
IStatus status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.TextFileBufferManager_error_documentFactoryFailed, t);
Platform.getLog(ResourceTextFileBufferManager.class).log(status);
ILog.of(ResourceTextFileBufferManager.class).log(status);
}
};
SafeRunner.run(runnable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.eclipse.core.runtime.Assert;
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.ISafeRunnable;
Expand Down Expand Up @@ -463,13 +464,13 @@ public void run() throws Exception {
if (document.getDocumentPartitioner() != null) {
String message= NLSUtility.format(FileBuffersMessages.TextFileBufferManager_warning_documentSetupInstallsDefaultPartitioner, participant.getClass());
IStatus status= new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null);
Platform.getLog(ResourceTextFileBufferManager.class).log(status);
ILog.of(ResourceTextFileBufferManager.class).log(status);
}
}
@Override
public void handleException(Throwable t) {
IStatus status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.TextFileBufferManager_error_documentSetupFailed, t);
Platform.getLog(ResourceTextFileBufferManager.class).log(status);
ILog.of(ResourceTextFileBufferManager.class).log(status);
}
};
SafeRunner.run(runnable);
Expand Down Expand Up @@ -502,7 +503,7 @@ public void run() throws Exception {
@Override
public void handleException(Throwable t) {
IStatus status= new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.TextFileBufferManager_error_documentFactoryFailed, t);
Platform.getLog(ResourceTextFileBufferManager.class).log(status);
ILog.of(ResourceTextFileBufferManager.class).log(status);
}
};
SafeRunner.run(runnable);
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.jface.text.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.jface.text.tests
Bundle-Version: 3.13.100.qualifier
Bundle-Version: 3.13.200.qualifier
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package:
Expand All @@ -20,7 +20,7 @@ Require-Bundle:
org.eclipse.jface;bundle-version="[3.5.0,4.0.0)",
org.junit;bundle-version="4.12.0",
org.eclipse.text.tests;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.ui.workbench.texteditor,
org.eclipse.test.performance;bundle-version="3.13.0"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void testCollapse() throws Exception {
logError.set(status);
};
if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
log = Platform.getLog(bundle);
log = ILog.of(bundle);
log.addLogListener(logListener);
}
try {
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jface.text/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Export-Package:
org.eclipse.jface.text.templates,
org.eclipse.jface.text.templates.persistence
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.text;bundle-version="[3.8.0,4.0.0)";visibility:=reexport,
org.eclipse.swt;bundle-version="[3.117.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.19.0,4.0.0)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private static void logCodeMiningProviderException(Throwable e) {
Bundle plugin= Platform.getBundle(PLUGIN_ID);
if (plugin != null) {
// In OSGi context, uses Platform Text log
ILog log= Platform.getLog(plugin);
ILog log= ILog.of(plugin);
log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, e.getMessage(), e));
} else {
// In java main context, print stack trace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void run() {
// Just swallow the exception if the operation was canceled
} catch (RuntimeException ex) {
String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$
ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID));
ILog log= ILog.of(Platform.getBundle(PLUGIN_ID));
log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Unexpected runtime error while computing a text hover", ex)); //$NON-NLS-1$
} finally {
synchronized (fMutex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ private void handleSetData(Event event) {
displayString= JFaceTextMessages.getString("CompletionProposalPopup.error_retrieving_proposal"); //$NON-NLS-1$

String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$
ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID));
ILog log= ILog.of(Platform.getBundle(PLUGIN_ID));
log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, JFaceTextMessages.getString("CompletionProposalPopup.unexpected_error"), e)); //$NON-NLS-1$
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.eclipse.core.commands.IHandler;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ListenerList;
Expand Down Expand Up @@ -874,7 +875,7 @@ public void handleException(Throwable exception) {
String message= JFaceTextMessages.getString(fMessageKey);

IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, message, exception);
Platform.getLog(Platform.getBundle(PLUGIN_ID)).log(status);
ILog.of(Platform.getBundle(PLUGIN_ID)).log(status);

fLastErrorMessage= message;
}
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.text/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.text
Bundle-Version: 3.13.0.qualifier
Bundle-Version: 3.13.100.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
Expand All @@ -18,6 +18,6 @@ Require-Bundle:
org.eclipse.core.commands;bundle-version="[3.5.0,4.0.0)",
org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)",
org.eclipse.equinox.preferences;bundle-version="[3.7.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.14.0,4.0.0)"
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: org.eclipse.text
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private TemplatePersistenceData[] read(InputSource source, ResourceBundle bundle
String id= getStringValue(attributes, ID_ATTRIBUTE, null);
if (id != null && ids.contains(id)) {
String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$
ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID));
ILog log= ILog.of(Platform.getBundle(PLUGIN_ID));
String message= NLS.bind(TextTemplateMessages.getString("TemplateReaderWriter.duplicate.id"), id); //$NON-NLS-1$
log.log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.OK, message, null));
} else {
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.ui.editors.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.ui.editors.tests
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.junit;bundle-version="4.12.0",
org.eclipse.jface;bundle-version="[3.5.0,4.0.0)",
org.eclipse.text;bundle-version="[3.5.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void makeSureResourceIsOutOfDate() throws Exception {

static void logError(String message, Exception ex) {
String PLUGIN_ID = "org.eclipse.jface.text"; //$NON-NLS-1$
ILog log = Platform.getLog(Platform.getBundle(PLUGIN_ID));
ILog log = ILog.of(Platform.getBundle(PLUGIN_ID));
log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, ex));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void tearDown() throws Exception {
public void testDirectDependency() {
final ArrayList<IStatus> list= new ArrayList<>(2);
Bundle bundle= Platform.getBundle(EditorsUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
log.addLogListener((status, plugin) -> list.add(status));

TestMarkerAnnotationModel t1= new TestMarkerAnnotationModel();
Expand Down Expand Up @@ -137,7 +137,7 @@ protected boolean isAcceptable(IMarker marker) {

private static void log(Exception ex) {
String PLUGIN_ID= "org.eclipse.jface.text"; //$NON-NLS-1$
ILog log= Platform.getLog(Platform.getBundle(PLUGIN_ID));
ILog log= ILog.of(Platform.getBundle(PLUGIN_ID));
log.log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, ex.getMessage(), ex));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void after() {
public void doNotThrowOnActivationInStale() throws Exception {
IEditorPart editor1 = openNonExistentFile(page, new URI("file:/1.txt"));
openNonExistentFile(page, new URI("file:/2.txt"));
ILog log = Platform.getLog(Platform.getBundle("org.eclipse.e4.ui.workbench"));
ILog log = ILog.of(Platform.getBundle("org.eclipse.e4.ui.workbench"));
List<String> logEvents = new ArrayList<>();
ILogListener listener = (status, plugin) -> logEvents.add(status.toString());
log.addLogListener(listener);
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.ui.editors/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Export-Package:
org.eclipse.ui.internal.texteditor;x-internal:=true,
org.eclipse.ui.texteditor
Require-Bundle:
org.eclipse.core.runtime;bundle-version="[3.27.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
org.eclipse.swt;bundle-version="[3.101.0,4.0.0)",
org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.8.0,4.0.0)",
org.eclipse.ui.workbench;bundle-version="[3.117.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.14.0,4.0.0)",
org.eclipse.core.filebuffers;visibility:=reexport;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.filebuffers;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)",
org.eclipse.jdt.annotation;bundle-version="2.2";resolution:=optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocumen
protected void handleCoreException(CoreException exception, String message) {

Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);

if (message != null)
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, exception));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ public IContentType getContentType(Object element) throws CoreException {
*/
protected void handleCoreException(CoreException exception, String message) {
Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
IStatus status= message != null ? new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, exception) : exception.getStatus();
log.log(status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
protected void handleCoreException(CoreException exception, String message) {

Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
if (message != null)
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, exception));
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public <T> T getAdapter(Class<T> adapter) {
operationHistory.execute(operation, null, context);
} catch (ExecutionException x) {
Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, x));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void initialize() {
if (extensionPoint == null) {
String msg= NLSUtility.format(TextEditorMessages.DocumentProviderRegistry_error_extension_point_not_found, PlatformUI.PLUGIN_ID);
Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, null));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ protected boolean includesRulerLine(Position position, IDocument document) {
*/
protected void handleCoreException(CoreException exception, String message) {
Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);

if (message != null)
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, exception));
Expand Down Expand Up @@ -535,7 +535,7 @@ public <T> T getAdapter(Class<T> adapter) {
operationHistory.execute(operation, null, context);
} catch (ExecutionException e) {
Bundle bundle= Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$
log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, msg, e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static int getSeverity(IMarker marker) {
*/
private static void handleCoreException(CoreException e) {
Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
ILog log= Platform.getLog(bundle);
ILog log= ILog.of(bundle);
log.log(e.getStatus());
}

Expand Down
Loading

0 comments on commit ff43419

Please sign in to comment.