Skip to content
Open
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
12 changes: 11 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,17 @@ export async function activate(context: ExtensionContext) {
}
);

context.subscriptions.push(previewDisposable);
let clearAllDiagnostics = commands.registerCommand(
"extension.clearAllDiagnostics",
() => {
languageClient.sendNotification("cfn/clearAllDiagnostics");
}
);

context.subscriptions.push(
previewDisposable,
clearAllDiagnostics
);
}

function reloadSidePreview(file: string, languageClient: LanguageClient) {
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
"main": "./client/out/extension",
"activationEvents": [
"onLanguage:yaml",
"onLanguage:json",
"onCommand:extension.sidePreview"
"onLanguage:json"
],
"extensionDependencies": [],
"homepage": "https://github.com/awslabs/aws-cfn-lint-visual-studio-code/blob/main/README.md",
Expand Down Expand Up @@ -85,6 +84,10 @@
"dark": "./resources/open-preview-dark.svg",
"light": "./resources/open-preview-light.svg"
}
},
{
"command": "extension.clearAllDiagnostics",
"title": "Clear CloudFormation template issues"
}
],
"menus": {
Expand Down
6 changes: 6 additions & 0 deletions server/src/requestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ export namespace ValidateCfnLintVersion {
"cfn/validateCfnLintVersion"
);
}

export namespace ClearAllDiagnostics {
export const type: NotificationType<{}> = new NotificationType(
"cfn/clearAllDiagnostics"
);
}
6 changes: 6 additions & 0 deletions server/src/server/handlers/notificationHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
RequestPreview,
PreviewClosed,
ValidateCfnLintVersion,
ClearAllDiagnostics,
} from "../../requestTypes";
import { SettingsState } from "../../cfnSettings";
import { ValidationHandler } from "./validationHandler";
Expand Down Expand Up @@ -49,6 +50,11 @@ export class NotificationHandler {
this.connection.onNotification(ValidateCfnLintVersion.type, () =>
this.validateCfnLintVersion()
);
this.connection.onNotification(ClearAllDiagnostics.type, () => {
this.cfnSettings.documents.all().forEach((document) => {
this.connection.sendDiagnostics({ uri: document.uri, diagnostics: [] });
});
});
}

private requestPreview(uri: string): void {
Expand Down