Skip to content

Commit

Permalink
Fix diagnostic codes
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed May 30, 2024
1 parent 7923670 commit 488d93f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/lib/VDF/VDFErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type { VDFRange } from "./VDFRange"
* ```
*/
export abstract class VDFSyntaxError extends Error {
public abstract readonly name: string
public range: VDFRange
constructor(unexpected: string, expected: string[], range: VDFRange) {
super(`Unexpected ${unexpected}. Expected ${expected.join(" | ")}.`)
Expand All @@ -25,24 +26,28 @@ export abstract class VDFSyntaxError extends Error {
}

export class UnexpectedCharacterError extends VDFSyntaxError {
public readonly name = "UnexpectedCharacterError"
constructor(unexpected: string, expected: string[], range: VDFRange) {
super(unexpected, expected, range)
}
}

export class UnclosedEscapeSequenceError extends VDFSyntaxError {
public readonly name = "UnclosedEscapeSequenceError"
constructor(range: VDFRange) {
super("Unclosed escape sequence", ["char"], range)
}
}

export class EndOfStreamError extends VDFSyntaxError {
public readonly name = "EndOfStreamError"
constructor(expected: string[], range: VDFRange) {
super("EOF", expected, range)
}
}

export class UnexpectedTokenError extends VDFSyntaxError {
public readonly name = "UnexpectedTokenError"
constructor(unexpected: `'${string}'`, expected: string[], range: VDFRange) {
super(unexpected, expected, range)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/server/LanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export abstract class LanguageServer<T extends DocumentSymbol[]> {
{
range: diagnostics.range,
severity: DiagnosticSeverity.Error,
code: diagnostics.constructor.name,
code: diagnostics.name, // Don't use diagnostics.constructor.name because webpack obfuscates class names
source: this.languageId,
message: diagnostics.message
}
Expand Down

0 comments on commit 488d93f

Please sign in to comment.