From 23be9488959408bd94b2113cb9dfb48ec17aaa7f Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Mon, 9 Jan 2023 14:06:35 -0800 Subject: [PATCH] Bring in latest changes --- .../src/templates/schema/definition.ts | 2 +- .../templates/schema/property-definition.ts | 2 +- .../src/templates/tokens/template-token.ts | 21 ++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/actions-workflow-parser/src/templates/schema/definition.ts b/actions-workflow-parser/src/templates/schema/definition.ts index e7a1ead..febc341 100644 --- a/actions-workflow-parser/src/templates/schema/definition.ts +++ b/actions-workflow-parser/src/templates/schema/definition.ts @@ -22,7 +22,7 @@ export abstract class Definition { // A key to uniquely identify a definition public readonly key: string - public description: string | undefined + public readonly description: string | undefined public constructor(key: string, definition?: MappingToken) { this.key = key diff --git a/actions-workflow-parser/src/templates/schema/property-definition.ts b/actions-workflow-parser/src/templates/schema/property-definition.ts index 1a94683..886a8e7 100644 --- a/actions-workflow-parser/src/templates/schema/property-definition.ts +++ b/actions-workflow-parser/src/templates/schema/property-definition.ts @@ -10,7 +10,7 @@ import { TokenType } from "../tokens/types" export class PropertyDefinition { public readonly type: string = "" public readonly required: boolean = false - public description: string | undefined + public readonly description: string | undefined public constructor(token: TemplateToken) { if (token.templateTokenType === TokenType.String) { diff --git a/actions-workflow-parser/src/templates/tokens/template-token.ts b/actions-workflow-parser/src/templates/tokens/template-token.ts index 33bf8eb..baae830 100644 --- a/actions-workflow-parser/src/templates/tokens/template-token.ts +++ b/actions-workflow-parser/src/templates/tokens/template-token.ts @@ -24,6 +24,7 @@ export class TemplateTokenError extends Error { export abstract class TemplateToken { // Fields for serialization private readonly type: TokenType + private _description: string | undefined public readonly file: number | undefined public readonly range: TokenRange | undefined public definitionInfo: DefinitionInfo | undefined @@ -56,20 +57,20 @@ export abstract class TemplateToken { return this.range?.start[1] } + public get definition(): Definition | undefined { + return this.definitionInfo?.definition + } + get description(): string | undefined { - return this.propertyDefinition?.description || this.definition?.description + return ( + this._description || + this.propertyDefinition?.description || + this.definition?.description + ) } set description(description: string | undefined) { - if (this.propertyDefinition) { - this.propertyDefinition.description = description - } else if (this.definition) { - this.definition.description = description - } - } - - public get definition(): Definition | undefined { - return this.definitionInfo?.definition + this._description = description } public abstract get isScalar(): boolean