Skip to content

Commit

Permalink
Use new ILog.of(...) method instead of Platform.getLog(...) (#645)
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Jul 14, 2023
1 parent 47689a8 commit 0be5972
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.manipulation/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bundle-Version: 1.19.100.qualifier
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.jdt.internal.core.manipulation.JavaManipulationPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.6.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.34.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import java.util.List;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;

Expand Down Expand Up @@ -302,7 +302,7 @@ public void run() {
@Override
public void handleException(Throwable ex) {
IStatus status= new Status(IStatus.ERROR, JavaManipulation.ID_PLUGIN, IStatus.OK, "Error in JDT Core during AST creation", ex); //$NON-NLS-1$
Platform.getLog(CoreASTProvider.class).log(status);
ILog.of(CoreASTProvider.class).log(status);
}
});
return root[0];
Expand Down Expand Up @@ -393,7 +393,7 @@ private static boolean hasSource(ITypeRoot je) {
return je.getBuffer() != null;
} catch (JavaModelException ex) {
IStatus status= new Status(IStatus.ERROR, JavaManipulation.ID_PLUGIN, IStatus.OK, "Error in JDT Core during AST creation", ex); //$NON-NLS-1$
Platform.getLog(CoreASTProvider.class).log(status);
ILog.of(CoreASTProvider.class).log(status);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import org.eclipse.osgi.util.NLS;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
Expand Down Expand Up @@ -466,7 +466,7 @@ public void appendMethodLabel(IMethod method, long flags) {
// don't care, we are decorating already removed element
return;
}
Platform.getLog(this.getClass()).error("Error rendering method label", e); //$NON-NLS-1$ // NotExistsException will not reach this point
ILog.of(this.getClass()).error("Error rendering method label", e); //$NON-NLS-1$ // NotExistsException will not reach this point
}
}

Expand Down Expand Up @@ -681,7 +681,7 @@ public void appendTypeParameterLabel(ITypeParameter typeParameter, long flags) {
}

} catch (JavaModelException e) {
Platform.getLog(this.getClass()).error("Error rendering type parameters", e); //$NON-NLS-1$ // NotExistsException will not reach this point
ILog.of(this.getClass()).error("Error rendering type parameters", e); //$NON-NLS-1$ // NotExistsException will not reach this point
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugOptionsListener;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;

Expand Down Expand Up @@ -99,11 +99,11 @@ public void setMembersOrderPreferenceCacheCommon(MembersOrderPreferenceCacheComm
}

public static void log(Throwable e) {
Platform.getLog(JavaManipulationPlugin.class).log(new Status(IStatus.ERROR, JavaManipulation.ID_PLUGIN, IStatusConstants.INTERNAL_ERROR, JavaManipulationMessages.JavaManipulationMessages_internalError, e));
ILog.of(JavaManipulationPlugin.class).log(new Status(IStatus.ERROR, JavaManipulation.ID_PLUGIN, IStatusConstants.INTERNAL_ERROR, JavaManipulationMessages.JavaManipulationMessages_internalError, e));
}

public static void log(IStatus status) {
Platform.getLog(JavaManipulationPlugin.class).log(status);
ILog.of(JavaManipulationPlugin.class).log(status);
}

public static String getPluginId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Arrays;
import java.util.List;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.ILog;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
Expand Down Expand Up @@ -262,7 +262,7 @@ protected void addPositionForEvent(DocumentEvent event, String category, int off
try {
event.fDocument.addPosition(category, highlightedPosition);
} catch (BadLocationException | BadPositionCategoryException e) {
Platform.getLog(this.getClass()).error("Error when adding new highlighting position to the document", e); //$NON-NLS-1$
ILog.of(this.getClass()).error("Error when adding new highlighting position to the document", e); //$NON-NLS-1$
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.ILog;

public class SerialVersionHashOperationDisplayCore {

Expand All @@ -24,7 +24,7 @@ public class SerialVersionHashOperationDisplayCore {
* The message to display
*/
public void displayErrorMessage(final String message) {
Platform.getLog(this.getClass()).error(message);
ILog.of(this.getClass()).error(message);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import java.util.Map;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;

import org.eclipse.core.resources.IResource;
Expand Down Expand Up @@ -303,7 +303,7 @@ public Refactoring createRefactoring(final RefactoringStatus status) throws Core
JavaRefactoringContribution javaContribution= (JavaRefactoringContribution) contribution;
refactoring= javaContribution.createRefactoring(this, status);
} else
Platform.getLog(this.getClass()).log(new Status(IStatus.ERROR, JavaManipulation.ID_PLUGIN, 0, MessageFormat.format(DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor, id), null));
ILog.of(this.getClass()).log(new Status(IStatus.ERROR, JavaManipulation.ID_PLUGIN, 0, MessageFormat.format(DescriptorMessages.JavaRefactoringDescriptor_no_resulting_descriptor, id), null));
}
return refactoring;
}
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.junit/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Require-Bundle:
org.eclipse.debug.ui;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.34.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.29.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
org.eclipse.jdt.debug.ui;bundle-version="[3.3.0,4.0.0)",
org.eclipse.jdt.junit.runtime;bundle-version="[3.5.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
Expand Down Expand Up @@ -1545,7 +1546,7 @@ private void handleStopped() {
private void logMessageIfNoTests() {
if (fTestRunSession != null && TestKindRegistry.JUNIT5_TEST_KIND_ID.equals(fTestRunSession.getTestRunnerKind().getId()) && fTestRunSession.getTotalCount() == 0) {
String msg= Messages.format(JUnitMessages.TestRunnerViewPart_error_notests_kind, fTestRunSession.getTestRunnerKind().getDisplayName());
Platform.getLog(getClass()).error(msg);
ILog.of(getClass()).error(msg);
}
}

Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.text.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Export-Package:
org.eclipse.jdt.text.tests.spelling,
org.eclipse.jdt.text.tests.templates
Require-Bundle:
org.eclipse.core.runtime,
org.eclipse.core.runtime;bundle-version="[3.28.0,4.0.0)",
org.eclipse.compare.core,
org.eclipse.core.filesystem,
org.eclipse.core.resources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.core.expressions.PropertyTester;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
Expand Down Expand Up @@ -181,7 +182,7 @@ protected boolean condition() {
}
}
} catch (Exception e) {
Platform.getLog(Platform.getBundle("org.eclipse.jdt.text.tests")).log(
ILog.of(Platform.getBundle("org.eclipse.jdt.text.tests")).log(
new Status(IStatus.ERROR, "org.eclipse.jdt.text.tests", e.getMessage(), e)
);
return false;
Expand Down

0 comments on commit 0be5972

Please sign in to comment.