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

Function finishNodeAt

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

createPositionMethod · 0.80
processCommentMethod · 0.80

Tested by

no test coverage detected