Just want to let you know that I had to patch @pushcorn/hocon-parser@1.1.15 for the project I'm working on.
I'm doing some non-destructive programmatic editing of hocon files using AST from Context object and while doing so I noticed that closeToken of an ArrayNode is not ], but its last value. It does not seem to be intentional:
While at it, I figured it might be useful to add references to previous and next tokens during build to get access to tokens that are otherwise discarded (comments, whitespaces):
diff --git a/node_modules/@pushcorn/hocon-parser/lib/builders/ConfigBuilder.js b/node_modules/@pushcorn/hocon-parser/lib/builders/ConfigBuilder.js
index ae325db..263f500 100644
--- a/node_modules/@pushcorn/hocon-parser/lib/builders/ConfigBuilder.js
+++ b/node_modules/@pushcorn/hocon-parser/lib/builders/ConfigBuilder.js
@@ -12,6 +12,15 @@ class ConfigBuilder extends BuilderAdapter
{
let { rootType, tokens } = this.tokenize (data);
+ for (const i in tokens) {
+ if (tokens[i + 1]) {
+ tokens[i + 1].previousToken = tokens[i];
+ }
+ if (tokens[i - 1]) {
+ tokens[i - 1].nextToken = tokens[i]
+ }
+ }
+
this.context.createNode (rootType).append (...tokens);
}
I'm not sure if you want to add any of that to your code base. I myself are perfectly content using locally patched version. Still, I figured I'd let you know of my findings.
Firstly, thanks for your work on this project!
Just want to let you know that I had to patch
@pushcorn/hocon-parser@1.1.15
for the project I'm working on.I'm doing some non-destructive programmatic editing of hocon files using AST from Context object and while doing so I noticed that
closeToken
of an ArrayNode is not]
, but its last value. It does not seem to be intentional:While at it, I figured it might be useful to add references to previous and next tokens during build to get access to tokens that are otherwise discarded (comments, whitespaces):
I'm not sure if you want to add any of that to your code base. I myself are perfectly content using locally patched version. Still, I figured I'd let you know of my findings.
This issue body was partially generated by patch-package.