Use cache when validating with value providers

This commit is contained in:
Christopher Schleiden
2022-11-28 16:08:47 -08:00
parent a495432d40
commit 71619bee95
3 changed files with 12 additions and 2 deletions
+5 -1
View File
@@ -93,7 +93,11 @@ documents.onDidChangeContent((change) => {
async function validateTextDocument(textDocument: TextDocument): Promise<void> {
const result = await validate(
textDocument,
valueProviders(sessionToken, repoWorkspaceMap)
valueProviders(
sessionToken,
repos.find((repo) => textDocument.uri.startsWith(repo.workspaceUri)),
cache
)
);
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: result });
@@ -9,9 +9,13 @@ import { getRunnerLabels } from "./value-providers/runs-on";
export function valueProviders(
sessionToken: string | undefined,
repoContext: RepositoryContext,
repoContext: RepositoryContext | undefined,
cache: TTLCache
): ValueProviderConfig {
if (!repoContext) {
return {};
}
return {
"job-environment": passOctoKit(
sessionToken,
@@ -29,9 +29,11 @@ export async function getRunnerLabels(
undefined,
() => fetchRunnerLabels(client, owner, name)
);
for (const label of defaultLabels) {
repoLabels.add(label);
}
return Array.from(repoLabels).map((label) => ({ label }));
}