diff --git a/src/Acornima.Extras/Jsx/JsxParser.cs b/src/Acornima.Extras/Jsx/JsxParser.cs index d7e51b2..e268f8f 100644 --- a/src/Acornima.Extras/Jsx/JsxParser.cs +++ b/src/Acornima.Extras/Jsx/JsxParser.cs @@ -338,6 +338,6 @@ private JsxEmptyExpression ParseEmptyExpression() ref readonly var tokenizer = ref _parser._tokenizer; var startMarker = new Marker(tokenizer._lastTokenEnd, tokenizer._lastTokenEndLocation); - return _parser.FinishNodeAt(startMarker, _parser.StartNode(), new JsxEmptyExpression(), default); + return _parser.FinishNodeAt(startMarker, _parser.StartNode(), new JsxEmptyExpression()); } } diff --git a/src/Acornima/Parser.Expression.cs b/src/Acornima/Parser.Expression.cs index b30d4fe..38e6440 100644 --- a/src/Acornima/Parser.Expression.cs +++ b/src/Acornima/Parser.Expression.cs @@ -1199,7 +1199,7 @@ private Expression ParseParenAndDistinguishExpression(bool canBeArrow, Expressio { exprList[i] = (Expression)parameters[i]; } - val = FinishNodeAt(innerStartMarker, innerEndMarker, new SequenceExpression(NodeList.From(ref exprList)), default); + val = FinishNodeAt(innerStartMarker, innerEndMarker, new SequenceExpression(NodeList.From(ref exprList))); } else { diff --git a/src/Acornima/Parser.Helpers.cs b/src/Acornima/Parser.Helpers.cs index df4fa23..6d5391d 100644 --- a/src/Acornima/Parser.Helpers.cs +++ b/src/Acornima/Parser.Helpers.cs @@ -25,10 +25,18 @@ internal Marker StartNode() return new Marker(_tokenizer._start, _tokenizer._startLocation); } - internal T FinishNodeAt(in Marker startMarker, in Marker endMarker, T node, Ref scope) where T : Node + internal T FinishNodeAt(in Marker startMarker, in Marker endMarker, T node) where T : Node { // https://github.com/acornjs/acorn/blob/8.11.3/acorn/src/node.js > `function finishNodeAt`, `pp.finishNodeAt = function` + node._range = new Range(startMarker.Index, endMarker.Index); + node._location = new SourceLocation(startMarker.Position, endMarker.Position, _tokenizer._sourceFile); + _options._onNode?.Invoke(node, new OnNodeContext(default, _scopeStack)); + return node; + } + + internal T FinishNodeAt(in Marker startMarker, in Marker endMarker, T node, Ref scope) where T : Node + { node._range = new Range(startMarker.Index, endMarker.Index); node._location = new SourceLocation(startMarker.Position, endMarker.Position, _tokenizer._sourceFile); _options._onNode?.Invoke(node, new OnNodeContext(scope, _scopeStack)); @@ -40,7 +48,7 @@ internal T FinishNode(in Marker startMarker, T node) where T : Node { // https://github.com/acornjs/acorn/blob/8.11.3/acorn/src/node.js > `pp.finishNode = function` - return FinishNodeAt(startMarker, new Marker(_tokenizer._lastTokenEnd, _tokenizer._lastTokenEndLocation), node, default); + return FinishNodeAt(startMarker, new Marker(_tokenizer._lastTokenEnd, _tokenizer._lastTokenEndLocation), node); } [MethodImpl(MethodImplOptions.AggressiveInlining)]