Skip to content

Commit

Permalink
style: auto format and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GreasySlug committed May 21, 2024
1 parent c8863ca commit 0d155ee
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 36 deletions.
28 changes: 14 additions & 14 deletions extension/src/commands.ts
Original file line number Diff line number Diff line change
@@ -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),
);
}
}
20 changes: 6 additions & 14 deletions extension/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
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;

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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/runTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";

import { runTests } from "@vscode/test-electron";

Expand Down
2 changes: 1 addition & 1 deletion extension/src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions extension/src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions extension/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//@ts-check

"use strict";

const path = require("path");
const path = require("node:path");

//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/
Expand Down

0 comments on commit 0d155ee

Please sign in to comment.