MCPcopy
hub / github.com/prettier/prettier / printMethodValue

Function printMethodValue

src/language-js/print/function.js:147–175  ·  view source on GitHub ↗
(path, options, print)

Source from the content-addressed store, hash-verified

145- `TSEmptyBodyFunctionExpression` (TypeScript)
146*/
147function printMethodValue(path, options, print) {
148 const { node } = path;
149 const parametersDoc = printFunctionParameters(path, options, print);
150 const returnTypeDoc = printReturnType(path, print);
151 const shouldBreakParameters = shouldBreakFunctionParameters(node);
152 const shouldGroupParameters = shouldGroupFunctionParameters(
153 node,
154 returnTypeDoc,
155 );
156 const parts = [
157 print("typeParameters"),
158 group([
159 shouldBreakParameters
160 ? group(parametersDoc, { shouldBreak: true })
161 : shouldGroupParameters
162 ? group(parametersDoc)
163 : parametersDoc,
164 returnTypeDoc,
165 ]),
166 ];
167
168 if (node.body) {
169 parts.push(" ", print("body"));
170 } else {
171 parts.push(printSemicolon(options));
172 }
173
174 return parts;
175}
176
177function canPrintParamsWithoutParens(node) {
178 const parameters = getFunctionParameters(node);

Callers 3

printTypescriptFunction · 0.90
printFunctionFunction · 0.85
printMethodFunction · 0.85

Calls 7

printFunctionParametersFunction · 0.90
groupFunction · 0.90
printSemicolonFunction · 0.90
printReturnTypeFunction · 0.85
printFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…