From 4f9d96f207bdf510d8a5bc28e22ec7ba0bfab06e Mon Sep 17 00:00:00 2001 From: Alexander Fedorov Date: Sun, 23 Aug 2020 13:03:13 +0300 Subject: [PATCH] Bug 566286 - Rework CDT LSP Activator Switch logging code to platform facilities Change-Id: Iff6654ab6a55af898be8360ec0208ec7a0ddf977 Signed-off-by: Alexander Fedorov --- .../org/eclipse/cdt/lsp/core/Activator.java | 31 ------------------- .../ui/PublishSemanticHighlighting.java | 8 ++--- .../ui/text/LineBackgroundListenerCPP.java | 6 ++-- .../ui/text/PresentationReconcilerCPP.java | 4 +-- .../internal/ui/text/SetInactiveRegions.java | 8 ++--- 5 files changed, 13 insertions(+), 44 deletions(-) diff --git a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java index 82e3149a670..1574abc8cea 100644 --- a/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java +++ b/lsp/org.eclipse.cdt.lsp.core/src/org/eclipse/cdt/lsp/core/Activator.java @@ -11,8 +11,6 @@ package org.eclipse.cdt.lsp.core; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -41,33 +39,4 @@ public class Activator extends AbstractUIPlugin { return plugin; } - /** - * Creates an error status. - * - * @noreference This method is not intended to be referenced by clients. - */ - public static Status createErrorStatus(String message, Throwable e) { - return new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e); - } - - /** - * @noreference This method is not intended to be referenced by clients. - */ - public static void log(Throwable e) { - log("Error", e); //$NON-NLS-1$ - } - - /** - * @noreference This method is not intended to be referenced by clients. - */ - public static void log(String message, Throwable e) { - log(createErrorStatus(message, e)); - } - - /** - * @noreference This method is not intended to be referenced by clients. - */ - public static void log(IStatus status) { - getDefault().getLog().log(status); - } } diff --git a/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java b/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java index 83c72f1f3e3..061552c2582 100644 --- a/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java +++ b/lsp/org.eclipse.cdt.lsp.cquery/src/org/eclipse/cdt/lsp/internal/cquery/ui/PublishSemanticHighlighting.java @@ -17,13 +17,13 @@ import java.util.function.Consumer; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle; -import org.eclipse.cdt.lsp.core.Activator; import org.eclipse.cdt.lsp.internal.cquery.CquerySemanticHighlights; import org.eclipse.cdt.lsp.internal.cquery.HighlightSymbol; import org.eclipse.cdt.lsp.internal.text.ResolveDocumentUri; import org.eclipse.cdt.lsp.internal.ui.text.PresentationReconcilerCPP; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.BadLocationException; @@ -78,7 +78,7 @@ public class PublishSemanticHighlighting implements Consumer, Suppl try { doc.removePositionCategory(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY); } catch (BadPositionCategoryException e) { - Activator.log(e); + Platform.getLog(getClass()).error(e.getMessage(), e); } // Again add Inactive Code Position Category to the document. doc.addPositionCategory(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY); @@ -68,7 +68,7 @@ public final class SetInactiveRegions implements BiConsumer, Suppl offset = doc.getLineOffset(region.getStart().getLine()); length = doc.getLineOffset(region.getEnd().getLine()) - offset; } catch (BadLocationException e) { - Activator.log(e); + Platform.getLog(getClass()).error(e.getMessage(), e); } Position inactivePosition = new Position(offset, length); @@ -76,7 +76,7 @@ public final class SetInactiveRegions implements BiConsumer, Suppl doc.addPosition(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY, inactivePosition); } catch (BadLocationException | BadPositionCategoryException e) { - Activator.log(e); + Platform.getLog(getClass()).error(e.getMessage(), e); } } }