MCPcopy
hub / github.com/prettier/prettier / printMethod

Function printMethod

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

Source from the content-addressed store, hash-verified

104- `TSDeclareMethod` (TypeScript)
105*/
106function printMethod(path, options, print) {
107 const { node } = path;
108 const { kind } = node;
109 const value = node.value || node;
110 const parts = [];
111
112 if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
113 if (value.async) {
114 parts.push("async ");
115 }
116 } else {
117 assert.ok(kind === "get" || kind === "set");
118
119 parts.push(kind, " ");
120 }
121
122 // A `getter`/`setter` can't be a generator, but it's recoverable
123 if (value.generator) {
124 parts.push("*");
125 }
126
127 parts.push(
128 printKey(path, options, print),
129 node.optional ? "?" : "",
130 node === value ? printMethodValue(path, options, print) : print("value"),
131 );
132
133 return parts;
134}
135
136/*
137- `ObjectMethod`

Callers 2

printClassMethodFunction · 0.90
printEstreeFunction · 0.90

Calls 3

printKeyFunction · 0.90
printMethodValueFunction · 0.85
printFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…