Merge branch 'main' into thyeggman/reusable-workflow-hover

This commit is contained in:
Jacob Wallraff
2023-02-17 12:27:50 -08:00
72 changed files with 466112 additions and 8640 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@github/actions-languageserver",
"version": "0.1.143",
"version": "0.1.145",
"description": "Language server for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -38,8 +38,8 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"dependencies": {
"@github/actions-languageservice": "^0.1.143",
"@github/actions-workflow-parser": "^0.1.143",
"@github/actions-languageservice": "^0.1.145",
"@github/actions-workflow-parser": "^0.1.145",
"@octokit/rest": "^19.0.7",
"vscode-languageserver": "^8.0.2",
"vscode-languageserver-textdocument": "^1.0.7",
+18 -12
View File
@@ -26,6 +26,7 @@ import {onCompletion} from "./on-completion";
import {ReadFileRequest, Requests} from "./request";
import {fetchActionMetadata} from "./utils/action-metadata";
import {TTLCache} from "./utils/cache";
import {timeOperation} from "./utils/timer";
import {valueProviders} from "./value-providers";
export function initConnection(connection: Connection) {
@@ -93,7 +94,7 @@ export function initConnection(connection: Connection) {
// 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 => {
validateTextDocument(change.document);
return timeOperation("validation", async () => await validateTextDocument(change.document));
});
async function validateTextDocument(textDocument: TextDocument): Promise<void> {
@@ -113,26 +114,31 @@ export function initConnection(connection: Connection) {
return await connection.sendRequest(Requests.ReadFile, {path} satisfies ReadFileRequest);
})
};
const result = await validate(textDocument, config);
connection.sendDiagnostics({uri: textDocument.uri, diagnostics: result});
const result = await validate(textDocument, config);
await connection.sendDiagnostics({uri: textDocument.uri, diagnostics: result});
}
connection.onCompletion(async ({position, textDocument}: TextDocumentPositionParams): Promise<CompletionItem[]> => {
return await onCompletion(
connection,
position,
documents.get(textDocument.uri)!,
client,
repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri)),
cache
return timeOperation(
"completion",
async () =>
await onCompletion(
connection,
position,
documents.get(textDocument.uri)!,
client,
repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri)),
cache
)
);
});
connection.onHover(async ({position, textDocument}: HoverParams): Promise<Hover | null> => {
const repoContext = repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri));
return timeOperation("hover", async () => {
const repoContext = repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri));
return hover(documents.get(textDocument.uri)!, position, {
return await hover(documents.get(textDocument.uri)!, position, {
descriptionProvider: descriptionProvider(client, cache),
contextProviderConfig: repoContext && contextProviders(client, repoContext, cache),
fileProvider: getFileProvider(client, cache, repoContext?.workspaceUri, async path => {
+10
View File
@@ -0,0 +1,10 @@
import {log} from "@github/actions-languageservice/log";
export function timeOperation<T>(name: string, f: () => T): T {
const start = Date.now();
const result = f();
const end = Date.now();
log(`${name} took ${end - start}ms`);
return result;
}