diff --git a/actions-languageserver/src/commands.ts b/actions-languageserver/src/commands.ts new file mode 100644 index 0000000..cf2fc01 --- /dev/null +++ b/actions-languageserver/src/commands.ts @@ -0,0 +1,3 @@ +export enum Commands { + ClearCache = "cacheClear" +} diff --git a/actions-languageserver/src/connection.ts b/actions-languageserver/src/connection.ts index ef3114d..af1bcad 100644 --- a/actions-languageserver/src/connection.ts +++ b/actions-languageserver/src/connection.ts @@ -6,6 +6,7 @@ import { Connection, DocumentLink, DocumentLinkParams, + ExecuteCommandParams, Hover, HoverParams, InitializeParams, @@ -21,6 +22,7 @@ import {onCompletion} from "./on-completion"; import {TTLCache} from "./utils/cache"; import {valueProviders} from "./value-providers"; import {getActionInputs} from "./value-providers/action-inputs"; +import {Commands} from "./commands"; export function initConnection(connection: Connection) { const documents: TextDocuments = new TextDocuments(TextDocument); @@ -121,6 +123,13 @@ export function initConnection(connection: Connection) { return hover(documents.get(textDocument.uri)!, position); }); + connection.onRequest("workspace/executeCommand", (params: ExecuteCommandParams) => { + if (params.command === Commands.ClearCache) { + cache.clear(); + documents.all().forEach(validateTextDocument); + } + }); + connection.onDocumentLinks(async ({textDocument}: DocumentLinkParams): Promise => { return documentLinks(documents.get(textDocument.uri)!); }); diff --git a/actions-languageserver/src/utils/cache.ts b/actions-languageserver/src/utils/cache.ts index 1e4de37..323c064 100644 --- a/actions-languageserver/src/utils/cache.ts +++ b/actions-languageserver/src/utils/cache.ts @@ -36,4 +36,8 @@ export class TTLCache { throw e; } } + + clear(): void { + this.cache.clear(); + } }