MCPcopy Create free account
hub / github.com/babel/babel / finishNodeAtNode

Function finishNodeAtNode

packages/babel-parser/src/parser/node.ts:122–142  ·  view source on GitHub ↗
(
    node: Omit<T, "type">,
    type: T["type"],
    endNode: NodeType,
  )

Source from the content-addressed store, hash-verified

120 }
121
122 finishNodeAtNode<T extends NodeType>(
123 node: Omit<T, "type">,
124 type: T["type"],
125 endNode: NodeType,
126 ): T {
127 if (!process.env.IS_PUBLISH && node.end! > 0) {
128 throw new Error(
129 "Do not call finishNode*() twice on the same node." +
130 " Instead use resetEndLocation() or change type directly.",
131 );
132 }
133 (node as T).type = type;
134 node.end = endNode.end;
135 const { optionFlags } = this;
136 if (optionFlags & OptionFlags.Locations) {
137 node.loc!.end = endNode.loc!.end;
138 }
139 if (optionFlags & OptionFlags.Ranges) node.range![1] = node.end!;
140 if (optionFlags & OptionFlags.AttachComment) this.processComment(node as T);
141 return node as T;
142 }
143
144 resetStartLocation(node: BaseNode, startLoc: Position): void {
145 node.start = startLoc.index;

Callers

nothing calls this directly

Calls 1

processCommentMethod · 0.80

Tested by

no test coverage detected