Everywhere: Remove source location prefix from assertions

When an assertion gets called the stacktrace provides enough
source information anyways
This commit is contained in:
networkException 2021-10-24 23:11:34 +02:00
parent 5afae11193
commit be84284020
2 changed files with 13 additions and 17 deletions

View file

@ -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<T extends Type>(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<T extends Type, U extends Type>(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<T extends Type>(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<T extends Type, U extends Type>(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 };
}

View file

@ -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<T extends Type>(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<T extends Type, U extends Type>(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 };
}