Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 editor/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function checkWorkspaceSyntax(ctx: Ctx): Cmd {
);

const response = await client.sendRequest(ext.checkWorkspaceSyntax, params);
const diagnosticCollection = ctx.workspaceDiagnostic;
const diagnosticCollection = ctx.client.diagnostics;
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing ctx.client.diagnostics without null checking could cause runtime errors if the client is not initialized. The ctx.client property can be null as defined in the constructor.

Copilot uses AI. Check for mistakes.
diagnosticCollection.clear();
response.items.forEach(diagWorkspace => {
const diagnostics: vscode.Diagnostic[] = [];
Expand Down
24 changes: 8 additions & 16 deletions editor/src/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { ResultUpdate, ToolPreparator } from "./toolPreparator";
import {
LanguageClient,
LanguageClientOptions,
StreamInfo
StreamInfo,
Diagnostic
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Diagnostic import is added but appears unused after removing the custom diagnostic middleware. Consider removing this unused import.

Suggested change
StreamInfo,
Diagnostic
StreamInfo

Copilot uses AI. Check for mistakes.
} from 'vscode-languageclient/node';

import { workspace } from 'vscode';
Expand All @@ -15,6 +16,7 @@ import * as net from 'net';
import { Logger } from "./logger";
import { existsSync, readdirSync, rmdirSync, rm } from "fs";
import * as path from "path";
import { DiagnosticFeature } from 'vscode-languageclient/lib/common/diagnostic';
Copy link

Copilot AI Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DiagnosticFeature import appears unused after removing the diagnostic middleware. Consider removing this unused import.

Suggested change
import { DiagnosticFeature } from 'vscode-languageclient/lib/common/diagnostic';

Copilot uses AI. Check for mistakes.

export type CommandCallback = {
call: (ctx: Ctx) => Commands.Cmd;
Expand All @@ -25,24 +27,18 @@ export class Ctx {
private _extensionContext: vscode.ExtensionContext;
private _commands: Record<string, CommandCallback>;
private _config: Config;
private _workspaceDiagnostic: vscode.DiagnosticCollection;

constructor(ctx: vscode.ExtensionContext) {
this._client = null;
this._extensionContext = ctx;
this._commands = {};
this._config = null;
this._workspaceDiagnostic = vscode.languages.createDiagnosticCollection("4d_workspace");
}

public get config(): Config {
return this._config;
}

public get workspaceDiagnostic(): vscode.DiagnosticCollection {
return this._workspaceDiagnostic;
}

public get extensionContext(): vscode.ExtensionContext {
return this._extensionContext;
}
Expand Down Expand Up @@ -213,22 +209,17 @@ export class Ctx {
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [
{ scheme: 'file', language: '4d' },
{ scheme: 'file', language: '4d' },
{ scheme: 'file', language: '4qs' }
],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: workspace.createFileSystemWatcher('**/.4DSettings')
fileEvents: workspace.createFileSystemWatcher('**/.4DSettings'),
// Configure textDocument sync options to include save notifications
configurationSection: '4D-Analyzer'
},
initializationOptions: this._config.cfg,
diagnosticCollectionName: "4d",
middleware: {
provideDiagnostics: (document, previousResultId, token, next) => {
if (this._config.diagnosticEnabled)
this._workspaceDiagnostic.set(document instanceof vscode.Uri ? document : document.uri, undefined);
return next(document, previousResultId, token);
}
}
};
// Create the language client and start the client.
this._client = new LanguageClient(
Expand All @@ -243,6 +234,7 @@ export class Ctx {

public start() {
this._config = new Config(this._extensionContext);

if (this._config.IsTool4DEnabled()) {
this.prepareTool4D(this._config.tool4DWanted(), this._config.tool4DLocation(), this._config.tool4DDownloadChannel())
.then(result => {
Expand Down