Skip to content

Commit

Permalink
Change fields to methods to support overriding (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
aabounegm authored Sep 6, 2024
1 parent f60cfeb commit 707d2f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/langium/src/parser/indentation-aware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key

this.indentTokenType = createToken({
name: this.options.indentTokenName,
pattern: this.indentMatcher,
pattern: this.indentMatcher.bind(this),
line_breaks: false,
});

this.dedentTokenType = createToken({
name: this.options.dedentTokenName,
pattern: this.dedentMatcher,
pattern: this.dedentMatcher.bind(this),
line_breaks: false,
});
}
Expand Down Expand Up @@ -229,7 +229,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key
* @param tokens Previously scanned Tokens
* @param groups Token Groups
*/
protected indentMatcher: CustomPatternMatcherFunc = (text, offset, tokens, _groups) => {
protected indentMatcher(text: string, offset: number, tokens: IToken[], _groups: Record<string, IToken[]>): ReturnType<CustomPatternMatcherFunc> {
const { indentTokenName } = this.options;

if (!this.isStartOfLine(text, offset)) {
Expand All @@ -256,7 +256,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key

// Token already added, let the indentation now be consumed as whitespace and ignored
return null;
};
}

/**
* A custom pattern for matching dedents
Expand All @@ -266,7 +266,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key
* @param tokens Previously scanned Tokens
* @param groups Token Groups
*/
protected dedentMatcher: CustomPatternMatcherFunc = (text, offset, tokens, _groups) => {
protected dedentMatcher(text: string, offset: number, tokens: IToken[], _groups: Record<string, IToken[]>): ReturnType<CustomPatternMatcherFunc> {
const { dedentTokenName } = this.options;

if (!this.isStartOfLine(text, offset)) {
Expand Down Expand Up @@ -306,7 +306,7 @@ export class IndentationAwareTokenBuilder<Terminals extends string = string, Key

// Token already added, let the dedentation now be consumed as whitespace and ignored
return null;
};
}

protected override buildTerminalToken(terminal: TerminalRule): TokenType {
const tokenType = super.buildTerminalToken(terminal);
Expand Down

0 comments on commit 707d2f7

Please sign in to comment.