Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/expandMacro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function configureExpandMacro(
}

const command =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: server capabilities guarantee this command exists
client.initializeResult.capabilities.executeCommandProvider?.commands.find(
(c) => c.startsWith("expandMacro:"),
)!;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/manipulatePipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function configureManipulatePipes(
}

const command =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: server capabilities guarantee this command exists
client.initializeResult.capabilities.executeCommandProvider?.commands.find(
(c: string) => c.startsWith("manipulatePipes:"),
)!;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/mixClean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function configureMixClean(
return;
}
const command =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: server capabilities guarantee this command exists
client.initializeResult.capabilities.executeCommandProvider?.commands.find(
(c) => c.startsWith("mixClean:"),
)!;
Expand Down
2 changes: 1 addition & 1 deletion src/debugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class DebugAdapterTrackerFactory

if (event.event === "initialized") {
const elapsed =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: start time exists for active sessions
performance.now() - this.startTimes.get(session.id)!;
reporter.sendTelemetryEvent(
"debug_session_initialized",
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const languageClientManager = new LanguageClientManager(
);

const startClientsForOpenDocuments = (context: vscode.ExtensionContext) => {
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: iterating with forEach keeps the initialization straightforward
vscode.workspace.textDocuments.forEach((value) => {
languageClientManager.handleDidOpenTextDocument(value, context);
});
Expand Down
28 changes: 14 additions & 14 deletions src/languageClientManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from "vscode";
import {
type Disposable,
type DocumentSelector,
type Executable,
LanguageClient,
type LanguageClientOptions,
Expand Down Expand Up @@ -69,8 +70,7 @@ function startClient(
debug: serverOpts,
};

// biome-ignore lint/suspicious/noImplicitAnyLet: <explanation>
let displayName;
let displayName: string;
if (clientOptions.workspaceFolder) {
console.log(
`ElixirLS: starting LSP client for ${clientOptions.workspaceFolder.uri.fsPath} with server options`,
Expand Down Expand Up @@ -320,15 +320,15 @@ export class LanguageClientManager {
folder = vscode.workspace.workspaceFolders[0];
} else {
// no folders - use default client
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: a default client is always started when no workspace folders exist
return this.defaultClientPromise!;
}
}

// If we have nested workspace folders we only start a server on the outer most workspace folder.
folder = this._workspaceTracker.getOuterMostWorkspaceFolder(folder);

// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: the client promise is set when the workspace folder's client is started
return this.clientsPromises.get(folder.uri.toString())!;
}

Expand Down Expand Up @@ -399,8 +399,8 @@ export class LanguageClientManager {
folder = this._workspaceTracker.getOuterMostWorkspaceFolder(folder);

if (!this.clients.has(folder.uri.toString())) {
// biome-ignore lint/suspicious/noImplicitAnyLet: <explanation>
let documentSelector;
// The document selector will be assigned based on workspace mode
let documentSelector: DocumentSelector = defaultDocumentSelector;
if (this._workspaceTracker.mode === WorkspaceMode.MULTI_ROOT) {
// multi-root workspace
// create document selector with glob pattern that will match files
Expand Down Expand Up @@ -450,9 +450,9 @@ export class LanguageClientManager {
const clientsToDispose: LanguageClient[] = [];
let changed = false;
if (this.defaultClient) {
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach
this.defaultClientDisposables?.forEach((d) => d.dispose());
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: defaultClientPromise is defined whenever defaultClient is
clientStartPromises.push(this.defaultClientPromise!);
clientsToDispose.push(this.defaultClient);
this.defaultClient = null;
Expand All @@ -462,9 +462,9 @@ export class LanguageClientManager {
}

for (const [uri, client] of this.clients.entries()) {
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach
this.clientsDisposables.get(uri)?.forEach((d) => d.dispose());
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: a promise exists for every started client
clientStartPromises.push(this.clientsPromises.get(uri)!);
clientsToDispose.push(client);
changed = true;
Expand Down Expand Up @@ -498,9 +498,9 @@ export class LanguageClientManager {
const client = this.clients.get(uri);
if (client) {
console.log("ElixirLS: Stopping LSP client for", folder.uri.fsPath);
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: disposing all registered disposables is easier with forEach
this.clientsDisposables.get(uri)?.forEach((d) => d.dispose());
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: a promise exists for every started client
const clientPromise = this.clientsPromises.get(uri)!;

this.clients.delete(uri);
Expand All @@ -520,7 +520,7 @@ export class LanguageClientManager {
);
reporter.sendTelemetryErrorEvent("language_client_stop_error", {
"elixir_ls.language_client_stop_error": String(e),
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: error may not be typed, cast to access stack trace
"elixir_ls.language_client_start_error_stack": (<any>e)?.stack ?? "",
});
}
Expand All @@ -531,7 +531,7 @@ export class LanguageClientManager {
console.warn("ElixirLS: error during LSP client dispose", e);
reporter.sendTelemetryErrorEvent("language_client_stop_error", {
"elixir_ls.language_client_stop_error": String(e),
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: error may not be typed, cast to access stack trace
"elixir_ls.language_client_start_error_stack": (<any>e)?.stack ?? "",
});
}
Expand Down
14 changes: 7 additions & 7 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,21 @@ class EnvironmentReporter extends TelemetryReporter {
const label = `elixir_ls.${eventName}_count`;
if (!measurements) {
const measurementsWithCount: TelemetryEventMeasurements = {};
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: dynamic property access requires an explicit any cast
(<any>measurementsWithCount)[label] = 1 / samplingFactor;
return measurementsWithCount;
}
let countFound = false;
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: forEach provides a concise way to modify the object in place
Object.keys(measurements).forEach((key) => {
if (key.endsWith("_count")) {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: dynamic property access requires an explicit any cast
(<any>measurements)[key] /= samplingFactor;
countFound = true;
}
});
if (!countFound) {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: dynamic property access requires an explicit any cast
(<any>measurements)[label] = 1 / samplingFactor;
}
return measurements;
Expand Down Expand Up @@ -373,7 +373,7 @@ export function preprocessStacktrace(originalStack: string) {
"pwd",
"android:value",
];
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: forEach simplifies keyword replacement logic
sensitiveKeywords.forEach((keyword) => {
const regex = new RegExp(`(${keyword})[^a-zA-Z0-9]`, "gi");
const encodeKeyword = `${keyword[0]}_${keyword.slice(1)}`;
Expand All @@ -393,9 +393,9 @@ export function preprocessStacktraceInProperties(
return properties;
}

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: properties may contain arbitrary values
for (const key in <any>properties) {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: values may be of unknown type
(<any>properties)[key] = preprocessStacktrace((<any>properties)[key]);
}
return properties;
Expand Down
2 changes: 1 addition & 1 deletion src/terminalLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function configureTerminalLinkProvider(

return [
{
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: matches is defined because we return early when the regex does not match
startIndex: matches.index!,
length: matches[0].length,
data: {
Expand Down
4 changes: 2 additions & 2 deletions src/test/multiRoot/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ suite("Multi root workspace tests", () => {
assert.equal(extension.exports.languageClientManager.clients.size, 3);

const addedWorkspaceFolder =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: the workspace folder exists because it was added above
vscode.workspace.getWorkspaceFolder(addedFolderUri)!;

await waitForLanguageClientManagerUpdate(extension, async () => {
Expand Down Expand Up @@ -189,7 +189,7 @@ suite("Multi root workspace tests", () => {
assert.equal(extension.exports.languageClientManager.clients.size, 2);

const addedWorkspaceFolder =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: the workspace folder exists because it was added above
vscode.workspace.getWorkspaceFolder(addedFolderUri)!;

await waitForWorkspaceUpdate(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/multiRoot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function run(
try {
const files = await glob("**/**.test.js", { cwd: testsRoot });
// Add files to the test suite
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/noWorkspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function run(
try {
const files = await glob("**/**.test.js", { cwd: testsRoot });
// Add files to the test suite
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/noWorkspaceElixirFile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function run(
try {
const files = await glob("**/**.test.js", { cwd: testsRoot });
// Add files to the test suite
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/singleFolderMix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function run(
try {
const files = await glob("**/**.test.js", { cwd: testsRoot });
// Add files to the test suite
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
Expand Down
2 changes: 1 addition & 1 deletion src/test/singleFolderNoMix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function run(
try {
const files = await glob("**/**.test.js", { cwd: testsRoot });
// Add files to the test suite
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach keeps the setup concise when adding test files
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));

try {
Expand Down
18 changes: 9 additions & 9 deletions src/testController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function configureTestController(
reporter.sendTelemetryErrorEvent("test_controller_resolve_error", {
"elixir_ls.test_controller_resolve_error": String(e),
"elixir_ls.test_controller_resolve_error_stack":
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: error may be of an unknown type
(<any>e)?.stack ?? "",
});
}
Expand All @@ -51,7 +51,7 @@ export function configureTestController(
reporter.sendTelemetryErrorEvent("test_controller_resolve_error", {
"elixir_ls.test_controller_resolve_error": String(e),
"elixir_ls.test_controller_resolve_error_stack":
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: error may be of an unknown type
(<any>e)?.stack ?? "",
});
}
Expand Down Expand Up @@ -207,7 +207,7 @@ export function configureTestController(
}

const command =
// biome-ignore lint/style/noNonNullAssertion: <explanation>
// biome-ignore lint/style/noNonNullAssertion: the command is guaranteed by the language server
client.initializeResult.capabilities.executeCommandProvider?.commands.find(
(c) => c.startsWith("getExUnitTestsInFile:"),
)!;
Expand All @@ -219,7 +219,7 @@ export function configureTestController(
arguments: [file.uri?.toString()],
};

// biome-ignore lint/suspicious/noExplicitAny: <explanation>
// biome-ignore lint/suspicious/noExplicitAny: response structure is defined by the server
let res: any[] = [];
try {
res = await client.sendRequest(ExecuteCommandRequest.type, params);
Expand Down Expand Up @@ -407,7 +407,7 @@ export function configureTestController(
): vscode.TestItem | undefined {
if (type === "doctest") {
let foundDoctest: vscode.TestItem | undefined;
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach allows iterating over the children collection directly
describeTest.children.forEach((doctestGroupItem) => {
if (getType(doctestGroupItem) === ItemType.Doctest) {
const candidate = doctestGroupItem.children.get(name);
Expand Down Expand Up @@ -474,13 +474,13 @@ export function configureTestController(

// Loop through all included tests, or all known tests, and add them to our queue
if (request.include) {
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach simplifies queuing requested tests
request.include.forEach((test) => {
queue.push(test);
run.enqueued(test);
});
} else {
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach simplifies queuing all known tests
controller.items.forEach((test) => {
queue.push(test);
run.enqueued(test);
Expand Down Expand Up @@ -522,7 +522,7 @@ export function configureTestController(
// If we're running a workspace and any of the files is not parsed yet, parse them now
{
const childrenToCheck: Array<Promise<void>> = [];
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: using forEach is convenient for iterating over the children set
test.children.forEach((fileTest) => {
if (fileTest.children.size === 0) {
childrenToCheck.push(parseTestsInFileContents(fileTest));
Expand Down Expand Up @@ -705,7 +705,7 @@ export function configureTestController(
}

if (includeChildren) {
// biome-ignore lint/complexity/noForEach: <explanation>
// biome-ignore lint/complexity/noForEach: forEach makes enqueueing child tests straightforward
test.children.forEach((test) => {
queue.push(test);
run.enqueued(test);
Expand Down
Loading