Merge branch 'main' into joshmgross/read-file-request-types

This commit is contained in:
Josh Gross
2023-02-08 13:10:20 -05:00
committed by GitHub
27 changed files with 535 additions and 269 deletions
+1
View File
@@ -120,6 +120,7 @@ export function initConnection(connection: Connection) {
connection.onCompletion(async ({position, textDocument}: TextDocumentPositionParams): Promise<CompletionItem[]> => {
return await onCompletion(
connection,
position,
documents.get(textDocument.uri)!,
client,
+10 -7
View File
@@ -1,23 +1,26 @@
import {complete} from "@github/actions-languageservice/complete";
import {Octokit} from "@octokit/rest";
import {CompletionItem, Position} from "vscode-languageserver";
import {CompletionItem, Connection, Position} from "vscode-languageserver";
import {TextDocument} from "vscode-languageserver-textdocument";
import {contextProviders} from "./context-providers";
import {getFileProvider} from "./file-provider";
import {RepositoryContext} from "./initializationOptions";
import {TTLCache} from "./utils/cache";
import {valueProviders} from "./value-providers";
export async function onCompletion(
connection: Connection,
position: Position,
document: TextDocument,
client: Octokit | undefined,
repoContext: RepositoryContext | undefined,
cache: TTLCache
): Promise<CompletionItem[]> {
return await complete(
document,
position,
repoContext && valueProviders(client, repoContext, cache),
repoContext && contextProviders(client, repoContext, cache)
);
return await complete(document, position, {
valueProviderConfig: repoContext && valueProviders(client, repoContext, cache),
contextProviderConfig: repoContext && contextProviders(client, repoContext, cache),
fileProvider: getFileProvider(client, cache, repoContext?.workspaceUri, async path => {
return await connection.sendRequest("actions/readFile", {path});
})
});
}
@@ -1,31 +1,16 @@
import {Value} from "@github/actions-languageservice/value-providers/config";
import {DEFAULT_RUNNER_LABELS} from "@github/actions-languageservice/value-providers/default";
import {Octokit} from "@octokit/rest";
import {TTLCache} from "../utils/cache";
// Limitation: getRunnerLabels returns default hosted labels and labels for repository self-hosted runners.
// It doesn't return labels for organization runners visible to the repository.
export async function getRunnerLabels(client: Octokit, cache: TTLCache, owner: string, name: string): Promise<Value[]> {
const defaultLabels = [
"ubuntu-latest",
"ubuntu-22.04",
"ubuntu-20.04",
"ubuntu-18.04",
"windows-latest",
"windows-2022",
"windows-2019",
"windows-2016",
"macos-latest",
"macos-12",
"macos-11",
"macos-10.15",
"self-hosted"
];
const repoLabels = await cache.get(`${owner}/${name}/runner-labels`, undefined, () =>
fetchRunnerLabels(client, owner, name)
);
for (const label of defaultLabels) {
for (const label of DEFAULT_RUNNER_LABELS) {
repoLabels.add(label);
}