Skip to content

Commit 3e0909b

Browse files
committed
Store code actions on compiler errors
1 parent 7112569 commit 3e0909b

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/diagnostic.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,7 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
3030
range: subRange(error.range),
3131
severity: DiagnosticSeverity.Error,
3232
source: 'syntax-script',
33-
data: [
34-
{
35-
title: 'Test Action',
36-
kind: CodeActionKind.QuickFix,
37-
edit: {
38-
changes: {
39-
[filePath]: [
40-
{
41-
range:subRange(error.range),
42-
newText:'test'
43-
}
44-
]
45-
}
46-
}
47-
48-
}
49-
] as CodeAction[]
33+
data: error.actions
5034
});
5135
}
5236
} finally {

src/types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Range } from 'lsp-types';
1+
import { CodeAction, CodeActionKind, Range } from 'lsp-types';
22

33
/**
44
* Every token type a syntax script declaration file can contain. If something can't be recognized as a token,
@@ -520,24 +520,26 @@ export interface SyxConfigCompile {
520520
/**
521521
* An error that occured while tokenizing, parsing or compiling a file.
522522
* @author efekos
523-
* @version 1.0.2
523+
* @version 1.0.3
524524
* @since 0.0.1-alpha
525525
*/
526526
export class CompilerError extends Error {
527527
range: Range;
528528
file: string;
529+
actions: CodeAction[] = [{title:'Test Action',kind:CodeActionKind.QuickFix,command:{command:'vscode.editor.open',title:'Open'}}];
529530

530531
/**
531532
* An error that occured while tokenizing a file.
532533
* @param {Range} range Range where the error is.
533534
* @param {string} message Error message.
534535
*/
535-
constructor(range: Range, message: string, file?: string) {
536+
constructor(range: Range, message: string, file?: string,actions?:CodeAction[]) {
536537
super();
537538
this.range = range;
538539
this.message = message;
539540
this.file = file;
540541
this.name = 'CompilerError';
542+
if(actions!==undefined) this.actions = actions;
541543
}
542544
}
543545

0 commit comments

Comments
 (0)