From 7f75351fafebf2c244f6baa7e5b4b7601913b770 Mon Sep 17 00:00:00 2001 From: Clement HUSSENOT-DESENONGES Date: Mon, 9 Sep 2024 13:33:15 +0200 Subject: [PATCH 1/4] feat(!reference): Allow !reference --- src/loader.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/loader.ts b/src/loader.ts index fe4b7dd..28cf895 100644 --- a/src/loader.ts +++ b/src/loader.ts @@ -1574,7 +1574,15 @@ function composeNode(state:State, parentIndent, nodeContext, allowToSeek, allowC } if (null !== state.tag && '!' !== state.tag) { - if (state.tag=="!include"){ + if (state.tag == "!reference") { + if (!state.result) { + state.result = ast.newScalar(); + state.result.startPosition = state.position; + state.result.endPosition = state.position; + throwError(state, "!reference without value"); + } + state.result.kind = ast.Kind.REFERENCE_REF; + } else if (state.tag=="!include"){ if (!state.result){ state.result=ast.newScalar(); state.result.startPosition=state.position; From 34e66ca339f99d5ee6a22069583ade2449c6a2df Mon Sep 17 00:00:00 2001 From: Clement HUSSENOT-DESENONGES Date: Mon, 9 Sep 2024 13:41:47 +0200 Subject: [PATCH 2/4] docs(doc): Add the missing const and doc --- README.md | 2 +- src/yamlAST.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3decaeb..c679933 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The type information below is relevant when using TypeScript, if using from Java ### YAMLNode `YAMLNode` class is an ancestor for all node kinds. It's `kind` field determine node kind, one of `Kind` enum: - * `SCALAR`, `MAPPING`, `MAP`, `SEQ`, `ANCHOR_REF` or `INCLUDE_REF`. + * `SCALAR`, `MAPPING`, `MAP`, `SEQ`, `ANCHOR_REF`, `INCLUDE_REF` or `REFERENCE_REF`. After node kind is determined, it can be cast to one of the `YAMLNode` descendants types: * `YAMLScalar`, `YAMLMapping`, `YamlMap`, `YAMLSequence` or `YAMLAnchorReference`. diff --git a/src/yamlAST.ts b/src/yamlAST.ts index d82bc63..ddc50e6 100644 --- a/src/yamlAST.ts +++ b/src/yamlAST.ts @@ -9,7 +9,8 @@ export enum Kind{ MAP, SEQ, ANCHOR_REF, - INCLUDE_REF + INCLUDE_REF, + REFERENCE_REF } export interface YAMLDocument { From a799a8695aa583a60080344ed80f67f535d57c95 Mon Sep 17 00:00:00 2001 From: Clement HUSSENOT-DESENONGES Date: Mon, 16 Sep 2024 11:02:13 +0200 Subject: [PATCH 3/4] feat(dumper): Add a behavior for the reference tag --- src/dumper.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/dumper.ts b/src/dumper.ts index 85d1ecd..b97e534 100644 --- a/src/dumper.ts +++ b/src/dumper.ts @@ -227,6 +227,10 @@ function writeScalar(state, object, level) { state.dump=""+object;//FIXME return; } + if (object.indexOf("!reference")==0){ + state.dump=""+object;//FIXME + return; + } if (object.indexOf("!$$$novalue")==0){ state.dump="";//FIXME return; From d1be0c920dfdf4ad38e9ab8aa05609cfa504d3a7 Mon Sep 17 00:00:00 2001 From: Clement HUSSENOT-DESENONGES Date: Mon, 16 Sep 2024 11:02:43 +0200 Subject: [PATCH 4/4] docs(readme): More infos about the reference tag --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c679933..e15e490 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ In additional to parsing YAML to AST, it has following features: * restoration after the errors and reporting errors as a part of AST nodes. * built-in support for `!include` tag used in RAML +* built-in support fot `!reference` tag used in Gitlab CI. ## Usage The type information below is relevant when using TypeScript, if using from JavaScript only the field/method information is relevant.