@@ -104,7 +104,14 @@ export class ReviewFileGenerator {
104104 stringWriter . write ( ReviewFileGenerator . _getAedocSynopsis ( collector , astDeclaration , messagesToReport ) ) ;
105105
106106 const span : Span = new Span ( astDeclaration . declaration ) ;
107- ReviewFileGenerator . _modifySpan ( collector , span , entity , astDeclaration , false ) ;
107+
108+ const declarationMetadata : DeclarationMetadata = collector . fetchMetadata ( astDeclaration ) ;
109+ if ( declarationMetadata . isPreapproved ) {
110+ ReviewFileGenerator . _modifySpanForPreapproved ( span ) ;
111+ } else {
112+ ReviewFileGenerator . _modifySpan ( collector , span , entity , astDeclaration , false ) ;
113+ }
114+
108115 span . writeModifiedText ( stringWriter . stringBuilder ) ;
109116 stringWriter . writeLine ( '\n' ) ;
110117 }
@@ -301,6 +308,57 @@ export class ReviewFileGenerator {
301308 }
302309 }
303310
311+ /**
312+ * For declarations marked as `@preapproved`, this is used instead of _modifySpan().
313+ */
314+ private static _modifySpanForPreapproved ( span : Span ) : void {
315+ // Match something like this:
316+ //
317+ // ClassDeclaration:
318+ // SyntaxList:
319+ // ExportKeyword: pre=[export] sep=[ ]
320+ // DeclareKeyword: pre=[declare] sep=[ ]
321+ // ClassKeyword: pre=[class] sep=[ ]
322+ // Identifier: pre=[_PreapprovedClass] sep=[ ]
323+ // FirstPunctuation: pre=[{] sep=[\n\n ]
324+ // SyntaxList:
325+ // ...
326+ // CloseBraceToken: pre=[ }]
327+ //
328+ // or this:
329+ // ModuleDeclaration:
330+ // SyntaxList:
331+ // ExportKeyword: pre=[export] sep=[ ]
332+ // DeclareKeyword: pre=[declare] sep=[ ]
333+ // NamespaceKeyword: pre=[namespace] sep=[ ]
334+ // Identifier: pre=[_PreapprovedNamespace] sep=[ ]
335+ // ModuleBlock:
336+ // FirstPunctuation: pre=[{] sep=[\n\n ]
337+ // SyntaxList:
338+ // ...
339+ // CloseBraceToken: pre=[ }]
340+ //
341+ // And reduce it to something like this:
342+ //
343+ // // @internal (undocumented)
344+ // class _PreapprovedClass { /* (preapproved) */ }
345+ //
346+
347+ let skipRest : boolean = false ;
348+ for ( const child of span . children ) {
349+ if ( skipRest
350+ || child . kind === ts . SyntaxKind . SyntaxList
351+ || child . kind === ts . SyntaxKind . JSDocComment ) {
352+ child . modification . skipAll ( ) ;
353+ }
354+ if ( child . kind === ts . SyntaxKind . Identifier ) {
355+ skipRest = true ;
356+ child . modification . omitSeparatorAfter = true ;
357+ child . modification . suffix = ' { /* (preapproved) */ }' ;
358+ }
359+ }
360+ }
361+
304362 /**
305363 * Writes a synopsis of the AEDoc comments, which indicates the release tag,
306364 * whether the item has been documented, and any warnings that were detected
0 commit comments