MCPcopy Create free account
hub / github.com/angular/angular / formatWithPlaceholders

Function formatWithPlaceholders

packages/compiler-cli/preprocessor/test/utils.ts:270–289  ·  view source on GitHub ↗

* Format content that might contain ellipses by using placeholders

(filePath: string, content: string)

Source from the content-addressed store, hash-verified

268 * Format content that might contain ellipses by using placeholders
269 */
270async function formatWithPlaceholders(filePath: string, content: string): Promise<string> {
271 if (!content.includes('…')) {
272 return formatContent(filePath, content);
273 }
274
275 // Try using a comment placeholder first (valid in most places)
276 const commentPlaceholder = '/*__ELLIPSIS__*/';
277 // Prettier adds spaces around comments: /* __ELLIPSIS__ */
278 const commentRegex = /\/\*\s*__ELLIPSIS__\s*\*\//g;
279
280 try {
281 const withComments = content.replace(/…/g, commentPlaceholder);
282 const formatted = await formatContent(filePath, withComments);
283 return formatted.replace(commentRegex, '…');
284 } catch (e) {
285 // Return original on error
286 }
287
288 return content;
289}
290
291function applyEllipses(actual: string, expected: string): string {
292 const changes = diffLines(expected, actual);

Callers 1

mergeGoldenFunction · 0.85

Calls 2

formatContentFunction · 0.85
replaceMethod · 0.45

Tested by

no test coverage detected