1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 566286 - Rework CDT LSP Activator

Switch logging code to platform facilities

Change-Id: Iff6654ab6a55af898be8360ec0208ec7a0ddf977
Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
Alexander Fedorov 2020-08-23 13:03:13 +03:00
parent fbc117fd59
commit 4f9d96f207
5 changed files with 13 additions and 44 deletions

View file

@ -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);
}
}

View file

@ -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<CquerySemanticHighl
try {
doc.removePositionCategory(PresentationReconcilerCPP.SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
} catch (BadPositionCategoryException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
// Again add Semantic Highlighting Position Category to the document.
doc.addPositionCategory(PresentationReconcilerCPP.SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
@ -113,7 +113,7 @@ public class PublishSemanticHighlighting implements Consumer<CquerySemanticHighl
offset = doc.getLineOffset(range.getStart().getLine()) + range.getStart().getCharacter();
length = doc.getLineOffset(range.getEnd().getLine()) + range.getEnd().getCharacter() - offset;
} catch (BadLocationException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
int textStyle = SWT.NORMAL;
@ -139,7 +139,7 @@ public class PublishSemanticHighlighting implements Consumer<CquerySemanticHighl
doc.addPosition(PresentationReconcilerCPP.SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY,
highlightedPosition);
} catch (BadLocationException | BadPositionCategoryException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
}
}

View file

@ -12,8 +12,8 @@
package org.eclipse.cdt.lsp.internal.ui.text;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.lsp.core.Activator;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
@ -45,7 +45,7 @@ public class LineBackgroundListenerCPP implements LineBackgroundListener {
inactivePositions = currentDocument
.getPositions(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY);
} catch (BadPositionCategoryException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
if (inactivePositions == null) {
@ -64,7 +64,7 @@ public class LineBackgroundListenerCPP implements LineBackgroundListener {
}
}
} catch (BadLocationException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
}
}

View file

@ -40,7 +40,6 @@ import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
import org.eclipse.cdt.internal.ui.text.PartitionDamager;
import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
import org.eclipse.cdt.internal.ui.text.TokenStore;
import org.eclipse.cdt.lsp.core.Activator;
import org.eclipse.cdt.lsp.internal.text.ResolveDocumentUri;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.ILanguageUI;
@ -51,6 +50,7 @@ import org.eclipse.cdt.ui.text.ICTokenScanner;
import org.eclipse.cdt.ui.text.ITokenStoreFactory;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
@ -205,7 +205,7 @@ public class PresentationReconcilerCPP extends CPresentationReconciler {
try {
returnedPositions = doc.getPositions(SEMANTIC_HIGHLIGHTING_POSITION_CATEGORY);
} catch (BadPositionCategoryException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
if (returnedPositions == null) {

View file

@ -15,8 +15,8 @@ import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import org.eclipse.cdt.lsp.core.Activator;
import org.eclipse.cdt.lsp.internal.text.ResolveDocumentUri;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.IDocument;
@ -57,7 +57,7 @@ public final class SetInactiveRegions implements BiConsumer<Supplier<URI>, 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<Supplier<URI>, 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<Supplier<URI>, Suppl
doc.addPosition(PresentationReconcilerCPP.INACTIVE_CODE_HIGHLIGHTING_POSITION_CATEGORY,
inactivePosition);
} catch (BadLocationException | BadPositionCategoryException e) {
Activator.log(e);
Platform.getLog(getClass()).error(e.getMessage(), e);
}
}
}