Map workspaces to the correct repository

This commit is contained in:
Josh Gross
2022-11-28 15:49:56 -05:00
parent bf5f06a90c
commit 6563b98333
2 changed files with 6 additions and 18 deletions
+5 -12
View File
@@ -2,7 +2,7 @@ import { complete } from "@github/actions-languageservice/complete";
import { WorkflowContext } from "@github/actions-languageservice/context/workflow-context";
import { ValueProviderConfig } from "@github/actions-languageservice/value-providers/config";
import { Octokit } from "@octokit/rest";
import { CompletionItem, DocumentUri, Position } from "vscode-languageserver";
import { CompletionItem, Position } from "vscode-languageserver";
import { TextDocument } from "vscode-languageserver-textdocument";
import { RepositoryContext } from "./initializationOptions";
import { getEnvironments } from "./value-providers/job-environment";
@@ -10,14 +10,13 @@ import { getRunnerLabels } from "./value-providers/runs-on";
export async function onCompletion(
position: Position,
uri: DocumentUri,
document: TextDocument,
sessionToken: string | undefined,
repoWorkflowMap: Map<string, RepositoryContext>
repoContext: RepositoryContext | undefined
): Promise<CompletionItem[]> {
const config: ValueProviderConfig = {
getCustomValues: async (key: string, context: WorkflowContext) =>
getCustomValues(key, context, sessionToken, repoWorkflowMap),
getCustomValues(key, context, sessionToken, repoContext),
};
return await complete(document, position, config);
}
@@ -26,15 +25,9 @@ async function getCustomValues(
key: string,
context: WorkflowContext,
sessionToken: string | undefined,
repoWorkspaceMap: Map<string, RepositoryContext>
repo: RepositoryContext | undefined,
) {
if (!sessionToken) {
return;
}
// TODO: Parse workflow URI and look up repo for workspace
const [repo] = repoWorkspaceMap.values();
if (!repo) {
if (!sessionToken || !repo) {
return;
}