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

Function finishNodeAt

packages/babel-parser/src/parser/node.ts:98–118  ·  view source on GitHub ↗
(
    node: Omit<T, "type">,
    type: T["type"],
    endLoc: Position,
  )

Source from the content-addressed store, hash-verified

96 // Finish node at given position
97
98 finishNodeAt<T extends NodeType>(
99 node: Omit<T, "type">,
100 type: T["type"],
101 endLoc: Position,
102 ): T {
103 if (!process.env.IS_PUBLISH && node.end! > 0) {
104 throw new Error(
105 "Do not call finishNode*() twice on the same node." +
106 " Instead use resetEndLocation() or change type directly.",
107 );
108 }
109 (node as T).type = type;
110 node.end = endLoc.index;
111 const { optionFlags } = this;
112 if (optionFlags & OptionFlags.Locations) {
113 node.loc!.end = this.createPosition(endLoc);
114 }
115 if (optionFlags & OptionFlags.Ranges) node.range![1] = endLoc.index;
116 if (optionFlags & OptionFlags.AttachComment) this.processComment(node as T);
117 return node as T;
118 }
119
120 finishNodeAtNode<T extends NodeType>(
121 node: Omit<T, "type">,

Callers

nothing calls this directly

Calls 2

createPositionMethod · 0.80
processCommentMethod · 0.80

Tested by

no test coverage detected