style: auto format and fix

This commit is contained in:
GreasySlug 2024-05-22 00:08:05 +09:00
parent c8863ca77c
commit 0d155ee0cd
6 changed files with 28 additions and 36 deletions

View File

@ -1,19 +1,19 @@
import { Uri, commands } from "vscode";
// copied and modified from https://github.com/rust-lang/rust-analyzer/blob/27239fbb58a115915ffc1ce65ededc951eb00fd2/editors/code/src/commands.ts
import { LanguageClient, Location, Position } from 'vscode-languageclient/node';
import { Uri, commands } from 'vscode';
import type { LanguageClient, Location, Position } from "vscode-languageclient/node";
export async function showReferences(
client: LanguageClient | undefined,
uri: string,
position: Position,
locations: Location[]
client: LanguageClient | undefined,
uri: string,
position: Position,
locations: Location[],
) {
if (client) {
await commands.executeCommand(
"editor.action.showReferences",
Uri.parse(uri),
client.protocol2CodeConverter.asPosition(position),
locations.map(client.protocol2CodeConverter.asLocation)
);
}
if (client) {
await commands.executeCommand(
"editor.action.showReferences",
Uri.parse(uri),
client.protocol2CodeConverter.asPosition(position),
locations.map(client.protocol2CodeConverter.asLocation),
);
}
}

View File

@ -1,9 +1,5 @@
import { ExtensionContext, commands, window, workspace } from "vscode";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
} from "vscode-languageclient/node";
import { type ExtensionContext, commands, window, workspace } from "vscode";
import { LanguageClient, type LanguageClientOptions, type ServerOptions } from "vscode-languageclient/node";
import { showReferences } from "./commands";
let client: LanguageClient | undefined;
@ -11,9 +7,7 @@ let client: LanguageClient | undefined;
async function startLanguageClient(context: ExtensionContext) {
try {
const executablePath = (() => {
const executablePath = workspace
.getConfiguration("pylyzer")
.get<string>("executablePath", "");
const executablePath = workspace.getConfiguration("pylyzer").get<string>("executablePath", "");
return executablePath === "" ? "pylyzer" : executablePath;
})();
const enableDiagnostics = workspace.getConfiguration("pylyzer").get<boolean>("diagnostics", true);
@ -84,13 +78,11 @@ async function restartLanguageClient() {
}
export async function activate(context: ExtensionContext) {
context.subscriptions.push(
commands.registerCommand("pylyzer.restartLanguageServer", () => restartLanguageClient())
);
context.subscriptions.push(commands.registerCommand("pylyzer.restartLanguageServer", () => restartLanguageClient()));
context.subscriptions.push(
commands.registerCommand("pylyzer.showReferences", async (uri, position, locations) => {
await showReferences(client, uri, position, locations)
})
await showReferences(client, uri, position, locations);
}),
);
await startLanguageClient(context);
}

View File

@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import { runTests } from "@vscode/test-electron";

View File

@ -1,4 +1,4 @@
import * as assert from "assert";
import * as assert from "node:assert";
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it

View File

@ -1,6 +1,6 @@
import * as path from "path";
import Mocha from "mocha";
import * as path from "node:path";
import glob from "glob";
import Mocha from "mocha";
export function run(): Promise<void> {
// Create the mocha test
@ -18,7 +18,9 @@ export function run(): Promise<void> {
}
// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
for (const f of files) {
mocha.addFile(path.resolve(testsRoot, f));
}
try {
// Run the mocha test

View File

@ -1,8 +1,6 @@
//@ts-check
"use strict";
const path = require("path");
const path = require("node:path");
//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/