MCPcopy
hub / github.com/prettier/prettier / locEnd

Function locEnd

src/language-js/location/overrides.js:92–117  ·  view source on GitHub ↗

@param {Node | Comment} node @return {number}

(node)

Source from the content-addressed store, hash-verified

90@return {number}
91*/
92function locEnd(node) {
93 const { type } = node;
94
95 // Effected by children
96 if (type === "IfStatement") {
97 return locEnd(node.alternate ?? node.consequent);
98 }
99
100 if (
101 type === "ForInStatement" ||
102 type === "ForOfStatement" ||
103 type === "ForStatement" ||
104 type === "LabeledStatement" ||
105 type === "WithStatement" ||
106 type === "WhileStatement"
107 ) {
108 return locEnd(node.body);
109 }
110
111 return (
112 overrides.get(type)?.(
113 // @ts-expect-error -- Comment types
114 node,
115 ) ?? locEndWithFullText(node)
116 );
117}
118
119export { locEnd, shouldAddContentEnd, shouldIgnoredNodePrintSemicolon };

Callers 15

hasSameLocEndFunction · 0.90
onEnterFunction · 0.90
rebalanceLogicalTreeFunction · 0.90
assertCommentsFunction · 0.90
assertRawFunction · 0.90
hasLeadingOwnLineCommentFunction · 0.90
isNextLineEmptyFunction · 0.90
stripCommentsFromTextFunction · 0.90

Calls 2

locEndWithFullTextFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…