Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bundles/org.eclipse.cdt.lsp/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jface.text,
org.eclipse.debug.ui,
org.eclipse.lsp4j,
org.eclipse.lsp4j.jsonrpc
org.eclipse.lsp4j.jsonrpc,
org.eclipse.cdt.codan.core
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: org.eclipse.cdt.lsp
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@

package org.eclipse.cdt.lsp.editor;

import org.eclipse.cdt.codan.core.model.IProblemReporter;
import org.eclipse.cdt.lsp.LspPlugin;
import org.eclipse.cdt.lsp.LspUtils;
import org.eclipse.cdt.lsp.server.ICLanguageServerProvider;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
Expand Down Expand Up @@ -80,12 +83,24 @@ private boolean isEnabledFor(IEditorInput editorInput) {
return false;
IResource resource = editorInput.getAdapter(IResource.class);
if (resource != null) {
return cLanguageServerProvider.isEnabledFor(resource.getProject());
boolean enabled = cLanguageServerProvider.isEnabledFor(resource.getProject());
if (enabled) {
deleteCodanMarkers(resource);
}
return enabled;
}
// When resource == null it's an external file: Check if the file is already opened, if not check the active editor:
return LspUtils.isFileOpenedInLspEditor(editorInput);
}

private void deleteCodanMarkers(IResource resource) {
try {
resource.deleteMarkers(IProblemReporter.GENERIC_CODE_ANALYSIS_MARKER_TYPE, true, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
Platform.getLog(CEditorAssociationOverride.class).error(e.getMessage(), e);
}
}

private boolean isNoCElement(IContentType contentType) {
if (contentType == null) {
return true;
Expand Down