Simple caching for parsed workflow and template

This commit is contained in:
Jacob Wallraff
2023-03-02 16:43:23 -08:00
parent 4b8613da02
commit f2f377c21c
10 changed files with 58 additions and 12 deletions
+16
View File
@@ -91,9 +91,20 @@ export function initConnection(connection: Connection) {
return result;
});
connection.onInitialized(() => {
if (hasWorkspaceFolderCapability) {
connection.workspace.onDidChangeWorkspaceFolders(_event => {
// Invalidate caches? Not sure what to do here, but we should track
connection.console.log('Workspace folder change event received.');
});
}
})
// The content of a text document has changed. This event is emitted
// when the text document first opened or when its content has changed.
documents.onDidChangeContent(change => {
clearParsedCacheEntry(change.document.uri);
clearWorkflowTemplateCacheEntry(change.document.uri);
return timeOperation("validation", async () => await validateTextDocument(change.document));
});
@@ -119,6 +130,11 @@ export function initConnection(connection: Connection) {
await connection.sendDiagnostics({uri: textDocument.uri, diagnostics: result});
}
// connection.onDidChangeWatchedFiles(async change => {
// // Monitored files have change in VSCode
// connection.console.log('We received an file change event');
// });
connection.onCompletion(async ({position, textDocument}: TextDocumentPositionParams): Promise<CompletionItem[]> => {
return timeOperation(
"completion",
@@ -17,7 +17,7 @@ export async function createWorkflowContext(
if (!parsed.value) {
throw new Error("Failed to parse workflow");
}
const template = await convertWorkflowTemplate(parsed.context, parsed.value);
const template = await convertWorkflowTemplate("test.yaml", parsed.context, parsed.value);
const context: WorkflowContext = {uri: "test.yaml", template};
if (job) {