Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
F4r3n committed Mar 6, 2024
1 parent 648a3e0 commit 9dea73b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
10 changes: 8 additions & 2 deletions editor/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,20 @@ export function checkWorkspaceSyntax(ctx: Ctx): Cmd {
vscode.window.activeTextEditor.document
);
const response = await client.sendRequest(ext.checkWorkspaceSyntax, params);
for(const diagWorkspace of response.items)
{
let currentItem = diagWorkspace as WorkspaceFullDocumentDiagnosticReport;
//client.diagnostics.set(vscode.Uri.parse(currentItem.uri), undefined);
let diagnostics = vscode.languages.getDiagnostics(vscode.Uri.parse(currentItem.uri))
}


let diagnosticCollection = client.diagnostics;
let diagnosticCollection = ctx.workspaceDiagnostic;

for(const diagWorkspace of response.items)
{
const diagnostics : vscode.Diagnostic[] = [];
let currentItem = diagWorkspace as WorkspaceFullDocumentDiagnosticReport;

for(const diag of currentItem.items)
{
const range : vscode.Range = new vscode.Range(diag.range.start.line, diag.range.start.character, diag.range.end.line, diag.range.end.character);
Expand Down
24 changes: 16 additions & 8 deletions editor/src/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as child_process from 'child_process';
import * as net from 'net';


import { ProvideDiagnosticSignature, DocumentDiagnosticRequest, DocumentDiagnosticReportKind, DocumentDiagnosticParams } from 'vscode-languageclient'
import { ProvideDiagnosticSignature, DocumentDiagnosticRequest, DocumentDiagnosticReportKind, DocumentDiagnosticParams, FullDocumentDiagnosticReport } from 'vscode-languageclient'
export type CommandCallback = {
call: (ctx: Ctx) => Commands.Cmd;
};
Expand All @@ -22,12 +22,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 workspaceDiagnostic(): vscode.DiagnosticCollection {
return this._workspaceDiagnostic;
}

public get extensionContext(): vscode.ExtensionContext {
Expand Down Expand Up @@ -159,22 +165,25 @@ export class Ctx {
console.log("handleDiagnostics", diagnostics)
next(uri, diagnostics);
},

provideDiagnostics: (document, previousResultId, token, next) => {

const next2: ProvideDiagnosticSignature = (document, previousResultId, token) => {
this._workspaceDiagnostic.set(document instanceof vscode.Uri ? document : document.uri, undefined)
return next(document, previousResultId, token);
const p: any = async (document, previousResultId, token) => {
const params: DocumentDiagnosticParams = {
identifier: "4d",
textDocument: { uri: this.client.code2ProtocolConverter.asUri(document instanceof vscode.Uri ? document : document.uri) },
previousResultId: previousResultId
};
if (/*this.isDisposed === true ||*/ !this.client.isRunning()) {
if (!this.client.isRunning()) {
return { kind: DocumentDiagnosticReportKind.Full, items: [] };
}
return this.client.sendRequest(DocumentDiagnosticRequest.type, params, token).then(async (result) => {
if (result === undefined || result === null /*|| this.isDisposed*/ || token.isCancellationRequested) {
if (result === undefined || result === null || token.isCancellationRequested) {
return { kind: DocumentDiagnosticReportKind.Full, items: [] };
}



if (result.kind === DocumentDiagnosticReportKind.Full) {
return { kind: DocumentDiagnosticReportKind.Full, resultId: result.resultId, items: await this.client.protocol2CodeConverter.asDiagnostics(result.items, token) };
} else {
Expand All @@ -185,8 +194,7 @@ export class Ctx {
});
};

return next2(document, previousResultId, token)

return p(document, previousResultId, token)
},
}
};
Expand Down

0 comments on commit 9dea73b

Please sign in to comment.