From be84284020b42e71f61177a1deb42f5c83163132 Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 24 Oct 2021 23:11:34 +0200 Subject: [PATCH] Everywhere: Remove source location prefix from assertions When an assertion gets called the stacktrace provides enough source information anyways --- html/highlighter.ts | 14 ++++++-------- html/tokenizer.ts | 16 +++++++--------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/html/highlighter.ts b/html/highlighter.ts index 218981e..08576fb 100644 --- a/html/highlighter.ts +++ b/html/highlighter.ts @@ -29,7 +29,7 @@ export class Highlighter { case Type.DOCTYPE: this.reconsumeIn(State.DOCTYPE); break; case Type.Comment: this.reconsumeIn(State.Comment); break; case Type.EndOfFile: this.finished = true; break; - default: TODO(`Highlighter#spin, Unimplemented token type '${this.currentToken.type}'`); + default: TODO(`Unimplemented token type '${this.currentToken.type}'`); } break; @@ -160,7 +160,7 @@ export class Highlighter { this.state = State.Undefined; break; - default: TODO(`Highlighter#iterate, Unimplemented state '${this.state}'`); + default: TODO(`Unimplemented state '${this.state}'`); } } @@ -179,7 +179,7 @@ export class Highlighter { private consumeNextTokenOfType(type: T): Token & { type: T } { this.currentToken = this.tokens[this.pointer]; - VERIFY(this.currentToken.type === type, `Highlighter#consumeNextOfType: Expected '${type}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === type, `Expected '${type}', got '${this.currentToken.type}' instead`); this.pointer++; @@ -189,8 +189,7 @@ export class Highlighter { private consumeNextTokenOfEitherType(a: T, b: U): Token & { type: T | U } { this.currentToken = this.tokens[this.pointer]; - VERIFY(this.currentToken.type === a || this.currentToken.type === b, - `Highlighter#consumeNextTokenOfEitherType: Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === a || this.currentToken.type === b, `Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); this.pointer++; @@ -212,14 +211,13 @@ export class Highlighter { } private currentTokenOfType(type: T): Token & { type: T } { - VERIFY(this.currentToken.type === type, `Highlighter#currentTokenOfType: Expected '${type}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === type, `Expected '${type}', got '${this.currentToken.type}' instead`); return this.currentToken as Token & { type: T }; } private currentTokenOfEitherType(a: T, b: U): Token & { type: T | U } { - VERIFY(this.currentToken.type === a || this.currentToken.type === b, - `Highlighter#currentTokenOfEitherType: Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === a || this.currentToken.type === b, `Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); return this.currentToken as Token & { type: T }; } diff --git a/html/tokenizer.ts b/html/tokenizer.ts index 0af5441..98476fe 100644 --- a/html/tokenizer.ts +++ b/html/tokenizer.ts @@ -510,7 +510,7 @@ export class Tokenizer { break; } - default: TODO(`Tokenizer#iterate, Unimplemented state '${this.state}'`); + default: TODO(`Unimplemented state '${this.state}'`); } } @@ -581,7 +581,7 @@ export class Tokenizer { for (let i = 0; i < input.length; i++) { const consumed = this.consumeNext(); - VERIFY(consumed === input[i], `Tokenizer#consumeNextFew: Expected '${input[i]}' (${input} at ${i}), got ${consumed} instead`); + VERIFY(consumed === input[i], `Expected '${input[i]}' (${input} at ${i}), got ${consumed} instead`); } } @@ -589,8 +589,7 @@ export class Tokenizer { for (let i = 0; i < input.length; i++) { const consumed = this.consumeNext()?.toLowerCase(); - VERIFY(consumed === input[i].toLowerCase(), - `Tokenizer#consumeNextFewCaseInsensitive: Expected '${input[i].toLowerCase()}' (${input.toLowerCase()} at ${i}), got ${consumed} instead`); + VERIFY(consumed === input[i].toLowerCase(), `Expected '${input[i].toLowerCase()}' (${input.toLowerCase()} at ${i}), got ${consumed} instead`); } } @@ -599,26 +598,25 @@ export class Tokenizer { } private emitCurrentOfType(type: Type): void { - VERIFY(this.currentToken.type === type, `Tokenizer#emitCurrentOfType: Expected '${type}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === type, `Expected '${type}', got '${this.currentToken.type}' instead`); this.tokens.push(this.currentToken); } private emitCurrentOfEitherType(a: Type, b: Type): void { - VERIFY(this.currentToken.type === a || this.currentToken.type === b, `Tokenizer#emitCurrentOfEitherType: Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === a || this.currentToken.type === b, `Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); this.tokens.push(this.currentToken); } private currentOfType(type: T): Token & { type: T } { - VERIFY(this.currentToken.type === type, `Tokenizer#currentOfType: Expected '${type}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === type, `Expected '${type}', got '${this.currentToken.type}' instead`); return this.currentToken as Token & { type: T }; } private currentOfEitherType(a: T, b: U): Token & { type: T | U } { - VERIFY(this.currentToken.type === a || this.currentToken.type === b, - `Tokenizer#currentOfEitherType: Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); + VERIFY(this.currentToken.type === a || this.currentToken.type === b, `Expected '${a}' or '${b}', got '${this.currentToken.type}' instead`); return this.currentToken as Token & { type: T }; }