TemplateExtensions class

Extension methods for LG.

Methods

convertToRange(ParserRuleContext, number)

Convert antlr parser into Range.

evalEscape(string)

Escape \ from text.

getPrefixErrorMessage(NormalTemplateStringContext)

Get prefix error message from normal template sting context.

isPureExpression(KeyValueStructureValueContext)

If a value is pure Expression.

newGuid()

Generate new guid string.

normalizePath(string)

Normalize authored path to os path. path is from authored content which doesn't know what OS it is running on. This method treats / and \ both as seperators regardless of OS, for windows that means / -> \ and for linux/mac \ -> /. This allows author to use ../foo.lg or ..\foo.lg as equivelents for importing.

readLine(string)

Read line from text.

trimExpression(string)

Trim expression. ${abc} => abc, ${a == {}} => a == {}.

Method Details

convertToRange(ParserRuleContext, number)

Convert antlr parser into Range.

static function convertToRange(context: ParserRuleContext, lineOffset?: number): Range

Parameters

context

ParserRuleContext

Antlr parse context.

lineOffset

number

Returns

Range object.

evalEscape(string)

Escape \ from text.

static function evalEscape(exp: string): string

Parameters

exp

string

Input text.

Returns

string

Escaped text.

getPrefixErrorMessage(NormalTemplateStringContext)

Get prefix error message from normal template sting context.

static function getPrefixErrorMessage(context: NormalTemplateStringContext): string

Parameters

context
NormalTemplateStringContext

Normal template sting context.

Returns

string

Prefix error message.

isPureExpression(KeyValueStructureValueContext)

If a value is pure Expression.

static function isPureExpression(ctx: KeyValueStructureValueContext): boolean

Parameters

ctx
KeyValueStructureValueContext

Key value structure value context.

Returns

boolean

True if the value is pure Expression, false otherwise.

newGuid()

Generate new guid string.

static function newGuid(): string

Returns

string

The new guid string.

normalizePath(string)

Normalize authored path to os path. path is from authored content which doesn't know what OS it is running on. This method treats / and \ both as seperators regardless of OS, for windows that means / -> \ and for linux/mac \ -> /. This allows author to use ../foo.lg or ..\foo.lg as equivelents for importing.

static function normalizePath(ambiguousPath: string): string

Parameters

ambiguousPath

string

AuthoredPath.

Returns

string

Path expressed as OS path.

readLine(string)

Read line from text.

static function readLine(input: string): string[]

Parameters

input

string

Text content.

Returns

string[]

Split read line.

trimExpression(string)

Trim expression. ${abc} => abc, ${a == {}} => a == {}.

static function trimExpression(expression: string): string

Parameters

expression

string

Input expression string.

Returns

string

Pure expression string.