MCPcopy
hub / github.com/prettier/prettier / restoreNameAndValue

Function restoreNameAndValue

src/language-html/parse/postprocess.js:157–186  ·  view source on GitHub ↗

* @param {Ast.Node} node

(node)

Source from the content-addressed store, hash-verified

155 * @param {Ast.Node} node
156 */
157function restoreNameAndValue(node) {
158 switch (node.kind) {
159 case "element":
160 restoreName(node);
161 for (const attr of node.attrs) {
162 restoreName(attr);
163 if (!attr.valueSpan) {
164 attr.value = null;
165 } else {
166 attr.value = attr.valueSpan.toString();
167 if (/["']/.test(attr.value[0])) {
168 attr.value = attr.value.slice(1, -1);
169 }
170 }
171 }
172 break;
173
174 case "comment":
175 node.value = node.sourceSpan
176 .toString()
177 .slice("<!--".length, -"-->".length);
178 break;
179
180 case "text":
181 node.value = node.sourceSpan.toString();
182 break;
183
184 // No default
185 }
186}
187
188/**
189 * @param {Ast.Node} node

Callers 1

visitMethod · 0.85

Calls 3

restoreNameFunction · 0.85
toStringMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…