From 3c4e1c8f3e10dde9690d23534eb2208498b009c4 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Wed, 4 Sep 2024 23:27:03 +0300 Subject: [PATCH 1/2] Change fields to methods to support overriding --- packages/langium/src/parser/indentation-aware.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/langium/src/parser/indentation-aware.ts b/packages/langium/src/parser/indentation-aware.ts index 79bf645a2..9ab89f148 100644 --- a/packages/langium/src/parser/indentation-aware.ts +++ b/packages/langium/src/parser/indentation-aware.ts @@ -15,6 +15,8 @@ import { DefaultLexer, isTokenTypeArray } from './lexer.js'; type IndentationAwareDelimiter = [begin: TokenName, end: TokenName]; +export type TokenGroups = { [groupName: string]: IToken[] }; + export interface IndentationTokenBuilderOptions { /** * The name of the token used to denote indentation in the grammar. @@ -112,13 +114,13 @@ export class IndentationAwareTokenBuilder { + protected indentMatcher(text: string, offset: number, tokens: IToken[], _groups: TokenGroups): ReturnType { const { indentTokenName } = this.options; if (!this.isStartOfLine(text, offset)) { @@ -256,7 +258,7 @@ export class IndentationAwareTokenBuilder { + protected dedentMatcher(text: string, offset: number, tokens: IToken[], _groups: TokenGroups): ReturnType { const { dedentTokenName } = this.options; if (!this.isStartOfLine(text, offset)) { @@ -306,7 +308,7 @@ export class IndentationAwareTokenBuilder Date: Thu, 5 Sep 2024 13:44:24 +0000 Subject: [PATCH 2/2] Adjust types --- packages/langium/src/parser/indentation-aware.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/langium/src/parser/indentation-aware.ts b/packages/langium/src/parser/indentation-aware.ts index 9ab89f148..6db1ca2fb 100644 --- a/packages/langium/src/parser/indentation-aware.ts +++ b/packages/langium/src/parser/indentation-aware.ts @@ -15,8 +15,6 @@ import { DefaultLexer, isTokenTypeArray } from './lexer.js'; type IndentationAwareDelimiter = [begin: TokenName, end: TokenName]; -export type TokenGroups = { [groupName: string]: IToken[] }; - export interface IndentationTokenBuilderOptions { /** * The name of the token used to denote indentation in the grammar. @@ -231,7 +229,7 @@ export class IndentationAwareTokenBuilder { + protected indentMatcher(text: string, offset: number, tokens: IToken[], _groups: Record): ReturnType { const { indentTokenName } = this.options; if (!this.isStartOfLine(text, offset)) { @@ -268,7 +266,7 @@ export class IndentationAwareTokenBuilder { + protected dedentMatcher(text: string, offset: number, tokens: IToken[], _groups: Record): ReturnType { const { dedentTokenName } = this.options; if (!this.isStartOfLine(text, offset)) {