2015-06-12 18:01:48 +02:00
namespace ts {
2019-01-30 00:13:26 +01:00
/*@internal*/
2019-01-30 18:41:43 +01:00
export const infoFile = ".tsbuildinfo" ;
2017-01-30 21:27:24 +01:00
const brackets = createBracketsMap ( ) ;
2018-09-05 02:50:06 +02:00
const syntheticParent : TextRange = { pos : - 1 , end : - 1 } ;
2016-09-27 23:02:10 +02:00
2019-02-07 19:14:38 +01:00
/*@internal*/
export function isInfoFile ( file : string ) {
return endsWith ( file , ` / ${ infoFile } ` ) ;
}
2017-05-27 00:37:41 +02:00
/*@internal*/
/ * *
* Iterates over the source files that are expected to have an emit output .
*
* @param host An EmitHost .
* @param action The action to execute .
* @param sourceFilesOrTargetSourceFile
* If an array , the full list of source files to emit .
* Else , calls ` getSourceFilesToEmit ` with the ( optional ) target source file to determine the list of source files to emit .
* /
2018-01-11 20:52:46 +01:00
export function forEachEmittedFile < T > (
2019-02-05 21:30:20 +01:00
host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle | undefined ) = > T ,
2018-03-16 06:23:10 +01:00
sourceFilesOrTargetSourceFile? : ReadonlyArray < SourceFile > | SourceFile ,
2019-02-06 04:35:08 +01:00
emitOnlyDtsFiles = false ,
onlyBuildInfo? : boolean ,
includeBuildInfo? : boolean ) {
2017-05-27 00:37:41 +02:00
const sourceFiles = isArray ( sourceFilesOrTargetSourceFile ) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit ( host , sourceFilesOrTargetSourceFile ) ;
const options = host . getCompilerOptions ( ) ;
if ( options . outFile || options . out ) {
2019-02-01 23:46:58 +01:00
const prepends = host . getPrependNodes ( ) ;
if ( sourceFiles . length || prepends . length ) {
const bundle = createBundle ( sourceFiles , prepends ) ;
2018-03-16 06:23:10 +01:00
const result = action ( getOutputPathsFor ( bundle , host , emitOnlyDtsFiles ) , bundle ) ;
2018-01-11 20:52:46 +01:00
if ( result ) {
return result ;
}
2017-05-27 00:37:41 +02:00
}
}
else {
2019-02-06 04:35:08 +01:00
if ( ! onlyBuildInfo ) {
for ( const sourceFile of sourceFiles ) {
const result = action ( getOutputPathsFor ( sourceFile , host , emitOnlyDtsFiles ) , sourceFile ) ;
if ( result ) {
return result ;
}
2018-01-11 20:52:46 +01:00
}
2017-05-27 00:37:41 +02:00
}
2019-02-06 04:35:08 +01:00
if ( includeBuildInfo ) {
const buildInfoPath = getOutputPathForBuildInfo ( host . getCompilerOptions ( ) , host . getProjectReferences ( ) ) ;
2019-02-08 01:13:55 +01:00
if ( buildInfoPath ) return action ( { buildInfoPath } , /*sourceFileOrBundle*/ undefined ) ;
2019-02-06 04:35:08 +01:00
}
2017-05-27 00:37:41 +02:00
}
}
2019-02-05 21:30:20 +01:00
/*@internal*/
export function getOutputPathForBuildInfo ( options : CompilerOptions , projectReferences : ReadonlyArray < ProjectReference > | undefined ) {
if ( ! options . composite && ! length ( projectReferences ) ) return undefined ;
const outPath = options . outFile || options . out ;
if ( outPath ) return combinePaths ( getDirectoryPath ( outPath ) , infoFile ) ;
if ( options . outDir ) return combinePaths ( options . outDir , infoFile ) ;
return options . configFilePath && combinePaths ( getDirectoryPath ( options . configFilePath ) , infoFile ) ;
2019-01-31 02:48:34 +01:00
}
2019-01-24 21:40:52 +01:00
/*@internal*/
2019-01-31 02:48:34 +01:00
export function getOutputPathsForBundle ( options : CompilerOptions , forceDtsPaths : boolean , projectReferences : ReadonlyArray < ProjectReference > | undefined ) : EmitFileNames {
2019-01-24 21:40:52 +01:00
const outPath = options . outFile || options . out ! ;
const jsFilePath = options . emitDeclarationOnly ? undefined : outPath ;
const sourceMapFilePath = jsFilePath && getSourceMapFilePath ( jsFilePath , options ) ;
const declarationFilePath = ( forceDtsPaths || getEmitDeclarations ( options ) ) ? removeFileExtension ( outPath ) + Extension.Dts : undefined ;
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled ( options ) ? declarationFilePath + ".map" : undefined ;
2019-02-05 21:30:20 +01:00
const buildInfoPath = getOutputPathForBuildInfo ( options , projectReferences ) ;
2019-01-30 19:01:49 +01:00
return { jsFilePath , sourceMapFilePath , declarationFilePath , declarationMapPath , buildInfoPath } ;
2019-01-24 21:40:52 +01:00
}
2018-03-16 06:23:10 +01:00
/*@internal*/
2018-05-22 23:46:57 +02:00
export function getOutputPathsFor ( sourceFile : SourceFile | Bundle , host : EmitHost , forceDtsPaths : boolean ) : EmitFileNames {
2018-03-16 06:23:10 +01:00
const options = host . getCompilerOptions ( ) ;
if ( sourceFile . kind === SyntaxKind . Bundle ) {
2019-01-31 02:48:34 +01:00
return getOutputPathsForBundle ( options , forceDtsPaths , host . getProjectReferences ( ) ) ;
2018-03-16 06:23:10 +01:00
}
else {
2018-10-11 19:09:47 +02:00
const ownOutputFilePath = getOwnEmitOutputFilePath ( sourceFile . fileName , host , getOutputExtension ( sourceFile , options ) ) ;
// If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it
2018-10-11 18:31:04 +02:00
const isJsonEmittedToSameLocation = isJsonSourceFile ( sourceFile ) &&
comparePaths ( sourceFile . fileName , ownOutputFilePath , host . getCurrentDirectory ( ) , ! host . useCaseSensitiveFileNames ( ) ) === Comparison . EqualTo ;
const jsFilePath = options . emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath ;
2018-10-11 19:09:47 +02:00
const sourceMapFilePath = ! jsFilePath || isJsonSourceFile ( sourceFile ) ? undefined : getSourceMapFilePath ( jsFilePath , options ) ;
2018-03-16 06:23:10 +01:00
// For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error
2018-09-12 19:44:46 +02:00
const isJs = isSourceFileJS ( sourceFile ) ;
2018-07-21 01:53:59 +02:00
const declarationFilePath = ( ( forceDtsPaths || getEmitDeclarations ( options ) ) && ! isJs ) ? getDeclarationEmitOutputFilePath ( sourceFile . fileName , host ) : undefined ;
2018-10-11 19:09:47 +02:00
const declarationMapPath = declarationFilePath && getAreDeclarationMapsEnabled ( options ) ? declarationFilePath + ".map" : undefined ;
2019-01-30 19:01:49 +01:00
return { jsFilePath , sourceMapFilePath , declarationFilePath , declarationMapPath , buildInfoPath : undefined } ;
2018-03-16 06:23:10 +01:00
}
}
2017-05-27 00:37:41 +02:00
function getSourceMapFilePath ( jsFilePath : string , options : CompilerOptions ) {
2018-03-26 21:15:34 +02:00
return ( options . sourceMap && ! options . inlineSourceMap ) ? jsFilePath + ".map" : undefined ;
2017-05-27 00:37:41 +02:00
}
// JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
// So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
// For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
2017-11-10 01:01:33 +01:00
/* @internal */
export function getOutputExtension ( sourceFile : SourceFile , options : CompilerOptions ) : Extension {
2017-01-17 22:51:00 +01:00
if ( isJsonSourceFile ( sourceFile ) ) {
return Extension . Json ;
}
2017-05-27 00:37:41 +02:00
if ( options . jsx === JsxEmit . Preserve ) {
2018-09-12 19:44:46 +02:00
if ( isSourceFileJS ( sourceFile ) ) {
2017-06-15 18:59:37 +02:00
if ( fileExtensionIs ( sourceFile . fileName , Extension . Jsx ) ) {
return Extension . Jsx ;
2017-05-27 00:37:41 +02:00
}
}
else if ( sourceFile . languageVariant === LanguageVariant . JSX ) {
// TypeScript source file preserving JSX syntax
2017-06-15 18:59:37 +02:00
return Extension . Jsx ;
2017-05-27 00:37:41 +02:00
}
}
2017-06-15 18:59:37 +02:00
return Extension . Js ;
2017-05-27 00:37:41 +02:00
}
2017-01-30 21:27:24 +01:00
/*@internal*/
2015-02-06 03:26:56 +01:00
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
2019-02-06 04:35:08 +01:00
export function emitFiles ( resolver : EmitResolver , host : EmitHost , targetSourceFile : SourceFile | undefined , emitOnlyDtsFiles? : boolean , transformers? : TransformerFactory < Bundle | SourceFile > [ ] , declarationTransformers? : TransformerFactory < Bundle | SourceFile > [ ] , onlyBuildInfo? : boolean ) : EmitResult {
2015-11-04 23:02:33 +01:00
const compilerOptions = host . getCompilerOptions ( ) ;
2018-09-05 02:50:06 +02:00
const sourceMapDataList : SourceMapEmitResult [ ] | undefined = ( compilerOptions . sourceMap || compilerOptions . inlineSourceMap || getAreDeclarationMapsEnabled ( compilerOptions ) ) ? [ ] : undefined ;
2018-05-22 23:46:57 +02:00
const emittedFilesList : string [ ] | undefined = compilerOptions . listEmittedFiles ? [ ] : undefined ;
2015-11-06 21:39:42 +01:00
const emitterDiagnostics = createDiagnosticCollection ( ) ;
2018-08-22 21:42:36 +02:00
const newLine = getNewLineCharacter ( compilerOptions , ( ) = > host . getNewLine ( ) ) ;
2016-06-07 19:32:03 +02:00
const writer = createTextWriter ( newLine ) ;
2018-09-07 23:11:54 +02:00
const { enter , exit } = performance . createTimer ( "printTime" , "beforePrint" , "afterPrint" ) ;
2019-02-07 23:25:16 +01:00
let bundleBuildInfo : BundleBuildInfo | undefined ;
2016-06-07 19:32:03 +02:00
let emitSkipped = false ;
2018-07-11 22:34:30 +02:00
let exportedModulesFromDeclarationEmit : ExportedModulesFromDeclarationEmit | undefined ;
2016-06-07 19:32:03 +02:00
// Emit each output file
2018-09-07 23:11:54 +02:00
enter ( ) ;
2019-02-06 04:35:08 +01:00
forEachEmittedFile ( host , emitSourceFileOrBundle , getSourceFilesToEmit ( host , targetSourceFile ) , emitOnlyDtsFiles , onlyBuildInfo , ! targetSourceFile ) ;
2018-09-07 23:11:54 +02:00
exit ( ) ;
2015-02-05 23:46:50 +01:00
2016-09-27 00:21:03 +02:00
2015-02-05 23:46:50 +01:00
return {
2015-10-21 00:51:37 +02:00
emitSkipped ,
2015-10-30 21:43:52 +01:00
diagnostics : emitterDiagnostics.getDiagnostics ( ) ,
2016-04-06 22:25:29 +02:00
emittedFiles : emittedFilesList ,
2018-05-22 23:46:57 +02:00
sourceMaps : sourceMapDataList ,
2018-07-11 22:34:30 +02:00
exportedModulesFromDeclarationEmit
2015-02-05 23:46:50 +01:00
} ;
2019-02-05 21:30:20 +01:00
function emitSourceFileOrBundle ( { jsFilePath , sourceMapFilePath , declarationFilePath , declarationMapPath , buildInfoPath } : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle | undefined ) {
2019-02-07 23:25:16 +01:00
if ( buildInfoPath && sourceFileOrBundle && isBundle ( sourceFileOrBundle ) ) {
2019-02-11 22:44:37 +01:00
bundleBuildInfo = { commonSourceDirectory : host.getCommonSourceDirectory ( ) } ;
2019-02-07 23:25:16 +01:00
}
emitJsFileOrBundle ( sourceFileOrBundle , jsFilePath , sourceMapFilePath ) ;
emitDeclarationFileOrBundle ( sourceFileOrBundle , declarationFilePath , declarationMapPath ) ;
emitBuildInfo ( bundleBuildInfo , buildInfoPath ) ;
2015-10-11 10:12:26 +02:00
2016-06-07 19:32:03 +02:00
if ( ! emitSkipped && emittedFilesList ) {
2016-09-27 23:02:10 +02:00
if ( ! emitOnlyDtsFiles ) {
2018-10-11 19:09:47 +02:00
if ( jsFilePath ) {
emittedFilesList . push ( jsFilePath ) ;
}
if ( sourceMapFilePath ) {
emittedFilesList . push ( sourceMapFilePath ) ;
}
2019-01-30 19:01:49 +01:00
if ( buildInfoPath ) {
emittedFilesList . push ( buildInfoPath ) ;
2018-10-11 19:09:47 +02:00
}
2015-10-11 10:12:26 +02:00
}
2016-06-07 19:32:03 +02:00
if ( declarationFilePath ) {
emittedFilesList . push ( declarationFilePath ) ;
2015-10-11 10:12:26 +02:00
}
2018-10-11 19:09:47 +02:00
if ( declarationMapPath ) {
emittedFilesList . push ( declarationMapPath ) ;
2018-05-08 00:12:50 +02:00
}
2015-10-11 10:12:26 +02:00
}
}
2019-02-07 23:25:16 +01:00
function emitBuildInfo ( bundle : BundleBuildInfo | undefined , buildInfoPath : string | undefined ) {
2019-02-05 21:30:20 +01:00
// Write build information if applicable
2019-02-20 21:55:08 +01:00
if ( ! buildInfoPath || targetSourceFile || emitSkipped ) return ;
2019-02-06 04:35:08 +01:00
const program = host . getProgramBuildInfo ( ) ;
2019-02-07 23:25:16 +01:00
if ( ! bundle && ! program ) return ;
writeFile ( host , emitterDiagnostics , buildInfoPath , getBuildInfoText ( { bundle , program } ) , /*writeByteOrderMark*/ false ) ;
2019-02-05 21:30:20 +01:00
}
2019-02-07 23:25:16 +01:00
function emitJsFileOrBundle ( sourceFileOrBundle : SourceFile | Bundle | undefined , jsFilePath : string | undefined , sourceMapFilePath : string | undefined ) {
2019-02-05 21:30:20 +01:00
if ( ! sourceFileOrBundle || emitOnlyDtsFiles || ! jsFilePath ) {
2018-03-16 06:23:10 +01:00
return ;
}
2018-10-11 19:09:47 +02:00
// Make sure not to write js file and source map file if any of them cannot be written
if ( ( jsFilePath && host . isEmitBlocked ( jsFilePath ) ) || compilerOptions . noEmit ) {
emitSkipped = true ;
2018-03-16 06:23:10 +01:00
return ;
}
// Transform the source files
2018-05-22 23:46:57 +02:00
const transform = transformNodes ( resolver , host , compilerOptions , [ sourceFileOrBundle ] , transformers ! , /*allowDtsFiles*/ false ) ;
2018-03-16 06:23:10 +01:00
2018-08-22 21:42:36 +02:00
const printerOptions : PrinterOptions = {
removeComments : compilerOptions.removeComments ,
newLine : compilerOptions.newLine ,
noEmitHelpers : compilerOptions.noEmitHelpers ,
module : compilerOptions.module ,
target : compilerOptions.target ,
sourceMap : compilerOptions.sourceMap ,
inlineSourceMap : compilerOptions.inlineSourceMap ,
2018-09-05 02:50:06 +02:00
inlineSources : compilerOptions.inlineSources ,
2018-08-22 21:42:36 +02:00
extendedDiagnostics : compilerOptions.extendedDiagnostics ,
2019-02-11 22:44:37 +01:00
writeBundleFileInfo : ! ! bundleBuildInfo
2018-08-22 21:42:36 +02:00
} ;
2018-03-16 06:23:10 +01:00
// Create a printer to print the nodes
2018-08-22 21:42:36 +02:00
const printer = createPrinter ( printerOptions , {
2018-03-16 06:23:10 +01:00
// resolver hooks
hasGlobalName : resolver.hasGlobalName ,
// transform hooks
onEmitNode : transform.emitNodeWithNotification ,
substituteNode : transform.substituteNode ,
} ) ;
2018-05-08 00:12:50 +02:00
Debug . assert ( transform . transformed . length === 1 , "Should only see one output from the transform" ) ;
2019-02-11 22:13:19 +01:00
printSourceFileOrBundle ( jsFilePath , sourceMapFilePath , transform . transformed [ 0 ] , printer , compilerOptions ) ;
2018-03-16 06:23:10 +01:00
// Clean up emit nodes on parse tree
transform . dispose ( ) ;
2019-02-11 22:44:37 +01:00
if ( bundleBuildInfo ) bundleBuildInfo . js = printer . bundleFileInfo ;
2018-03-16 06:23:10 +01:00
}
2019-02-07 23:25:16 +01:00
function emitDeclarationFileOrBundle ( sourceFileOrBundle : SourceFile | Bundle | undefined , declarationFilePath : string | undefined , declarationMapPath : string | undefined ) {
2019-02-05 21:30:20 +01:00
if ( ! sourceFileOrBundle || ! ( declarationFilePath && ! isInJSFile ( sourceFileOrBundle ) ) ) {
2018-03-16 06:23:10 +01:00
return ;
}
const sourceFiles = isSourceFile ( sourceFileOrBundle ) ? [ sourceFileOrBundle ] : sourceFileOrBundle . sourceFiles ;
// Setup and perform the transformation to retrieve declarations from the input files
2018-09-14 00:05:57 +02:00
const nonJsFiles = filter ( sourceFiles , isSourceFileNotJS ) ;
2018-05-08 00:12:50 +02:00
const inputListOrBundle = ( compilerOptions . outFile || compilerOptions . out ) ? [ createBundle ( nonJsFiles , ! isSourceFile ( sourceFileOrBundle ) ? sourceFileOrBundle.prepends : undefined ) ] : nonJsFiles ;
2018-07-09 21:32:52 +02:00
if ( emitOnlyDtsFiles && ! getEmitDeclarations ( compilerOptions ) ) {
2018-06-20 21:25:51 +02:00
// Checker wont collect the linked aliases since thats only done when declaration is enabled.
// Do that here when emitting only dts files
nonJsFiles . forEach ( collectLinkedAliases ) ;
}
2018-05-08 20:20:48 +02:00
const declarationTransform = transformNodes ( resolver , host , compilerOptions , inputListOrBundle , concatenate ( [ transformDeclarations ] , declarationTransformers ) , /*allowDtsFiles*/ false ) ;
2018-03-16 06:23:10 +01:00
if ( length ( declarationTransform . diagnostics ) ) {
2018-05-22 23:46:57 +02:00
for ( const diagnostic of declarationTransform . diagnostics ! ) {
2018-03-16 06:23:10 +01:00
emitterDiagnostics . add ( diagnostic ) ;
}
}
2018-08-22 21:42:36 +02:00
const printerOptions : PrinterOptions = {
removeComments : compilerOptions.removeComments ,
newLine : compilerOptions.newLine ,
noEmitHelpers : true ,
module : compilerOptions.module ,
target : compilerOptions.target ,
sourceMap : compilerOptions.sourceMap ,
inlineSourceMap : compilerOptions.inlineSourceMap ,
extendedDiagnostics : compilerOptions.extendedDiagnostics ,
onlyPrintJsDocStyle : true ,
2019-02-15 23:25:24 +01:00
writeBundleFileInfo : ! ! bundleBuildInfo ,
recordInternalSection : ! ! bundleBuildInfo
2018-08-22 21:42:36 +02:00
} ;
const declarationPrinter = createPrinter ( printerOptions , {
2018-03-16 06:23:10 +01:00
// resolver hooks
hasGlobalName : resolver.hasGlobalName ,
// transform hooks
onEmitNode : declarationTransform.emitNodeWithNotification ,
substituteNode : declarationTransform.substituteNode ,
} ) ;
const declBlocked = ( ! ! declarationTransform . diagnostics && ! ! declarationTransform . diagnostics . length ) || ! ! host . isEmitBlocked ( declarationFilePath ) || ! ! compilerOptions . noEmit ;
emitSkipped = emitSkipped || declBlocked ;
if ( ! declBlocked || emitOnlyDtsFiles ) {
2018-05-08 00:12:50 +02:00
Debug . assert ( declarationTransform . transformed . length === 1 , "Should only see one output from the decl transform" ) ;
2019-02-07 23:25:16 +01:00
printSourceFileOrBundle (
declarationFilePath ,
declarationMapPath ,
declarationTransform . transformed [ 0 ] ,
declarationPrinter ,
{
sourceMap : compilerOptions.declarationMap ,
sourceRoot : compilerOptions.sourceRoot ,
mapRoot : compilerOptions.mapRoot ,
extendedDiagnostics : compilerOptions.extendedDiagnostics ,
// Explicitly do not passthru either `inline` option
}
) ;
2018-07-11 22:34:30 +02:00
if ( emitOnlyDtsFiles && declarationTransform . transformed [ 0 ] . kind === SyntaxKind . SourceFile ) {
const sourceFile = declarationTransform . transformed [ 0 ] as SourceFile ;
2018-08-01 21:20:54 +02:00
exportedModulesFromDeclarationEmit = sourceFile . exportedModulesFromDeclarationEmit ;
2018-07-11 22:34:30 +02:00
}
2018-03-16 06:23:10 +01:00
}
declarationTransform . dispose ( ) ;
2019-02-11 22:44:37 +01:00
if ( bundleBuildInfo ) bundleBuildInfo . dts = declarationPrinter . bundleFileInfo ;
2018-03-16 06:23:10 +01:00
}
2018-06-20 21:25:51 +02:00
function collectLinkedAliases ( node : Node ) {
if ( isExportAssignment ( node ) ) {
if ( node . expression . kind === SyntaxKind . Identifier ) {
resolver . collectLinkedAliases ( node . expression as Identifier , /*setVisibility*/ true ) ;
}
return ;
}
else if ( isExportSpecifier ( node ) ) {
resolver . collectLinkedAliases ( node . propertyName || node . name , /*setVisibility*/ true ) ;
return ;
}
forEachChild ( node , collectLinkedAliases ) ;
}
2019-02-11 22:13:19 +01:00
function printSourceFileOrBundle ( jsFilePath : string , sourceMapFilePath : string | undefined , sourceFileOrBundle : SourceFile | Bundle , printer : Printer , mapOptions : SourceMapOptions ) {
2017-01-27 00:46:26 +01:00
const bundle = sourceFileOrBundle . kind === SyntaxKind . Bundle ? sourceFileOrBundle : undefined ;
const sourceFile = sourceFileOrBundle . kind === SyntaxKind . SourceFile ? sourceFileOrBundle : undefined ;
2018-05-22 23:46:57 +02:00
const sourceFiles = bundle ? bundle . sourceFiles : [ sourceFile ! ] ;
2015-11-24 07:38:05 +01:00
2018-09-05 02:50:06 +02:00
let sourceMapGenerator : SourceMapGenerator | undefined ;
if ( shouldEmitSourceMaps ( mapOptions , sourceFileOrBundle ) ) {
sourceMapGenerator = createSourceMapGenerator (
host ,
getBaseFileName ( normalizeSlashes ( jsFilePath ) ) ,
getSourceRoot ( mapOptions ) ,
getSourceMapDirectory ( mapOptions , jsFilePath , sourceFile ) ,
mapOptions ) ;
2016-06-07 19:32:03 +02:00
}
2015-11-24 07:38:05 +01:00
2018-09-05 02:50:06 +02:00
if ( bundle ) {
2019-02-11 22:13:19 +01:00
printer . writeBundle ( bundle , writer , sourceMapGenerator ) ;
2018-08-22 21:42:36 +02:00
}
else {
2018-09-05 02:50:06 +02:00
printer . writeFile ( sourceFile ! , writer , sourceMapGenerator ) ;
2015-02-14 09:48:46 +01:00
}
2018-09-05 02:50:06 +02:00
if ( sourceMapGenerator ) {
if ( sourceMapDataList ) {
sourceMapDataList . push ( {
inputSourceFileNames : sourceMapGenerator.getSources ( ) ,
sourceMap : sourceMapGenerator.toJSON ( )
} ) ;
}
const sourceMappingURL = getSourceMappingURL (
mapOptions ,
sourceMapGenerator ,
jsFilePath ,
sourceMapFilePath ,
sourceFile ) ;
if ( sourceMappingURL ) {
if ( ! writer . isAtStartOfLine ( ) ) writer . rawWrite ( newLine ) ;
2019-01-31 20:19:37 +01:00
const pos = writer . getTextPos ( ) ;
2018-09-05 02:50:06 +02:00
writer . writeComment ( ` //# ${ "sourceMappingURL" } = ${ sourceMappingURL } ` ) ; // Tools can sometimes see this line as a source mapping url comment
2019-02-11 22:13:19 +01:00
if ( printer . bundleFileInfo ) printer . bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.SourceMapUrl } ) ;
2018-09-05 02:50:06 +02:00
}
// Write the source map
if ( sourceMapFilePath ) {
const sourceMap = sourceMapGenerator . toString ( ) ;
2018-08-22 21:42:36 +02:00
writeFile ( host , emitterDiagnostics , sourceMapFilePath , sourceMap , /*writeByteOrderMark*/ false , sourceFiles ) ;
}
2015-03-24 00:16:29 +01:00
}
2018-09-05 02:50:06 +02:00
else {
writer . writeLine ( ) ;
}
2015-03-24 00:16:29 +01:00
2016-06-07 19:32:03 +02:00
// Write the output file
2018-05-22 23:46:57 +02:00
writeFile ( host , emitterDiagnostics , jsFilePath , writer . getText ( ) , ! ! compilerOptions . emitBOM , sourceFiles ) ;
2015-03-26 18:51:07 +01:00
2016-06-07 19:32:03 +02:00
// Reset state
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writer . clear ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-24 00:16:29 +01:00
2018-09-05 02:50:06 +02:00
interface SourceMapOptions {
sourceMap? : boolean ;
inlineSourceMap? : boolean ;
inlineSources? : boolean ;
sourceRoot? : string ;
mapRoot? : string ;
extendedDiagnostics? : boolean ;
}
function shouldEmitSourceMaps ( mapOptions : SourceMapOptions , sourceFileOrBundle : SourceFile | Bundle ) {
return ( mapOptions . sourceMap || mapOptions . inlineSourceMap )
&& ( sourceFileOrBundle . kind !== SyntaxKind . SourceFile || ! fileExtensionIs ( sourceFileOrBundle . fileName , Extension . Json ) ) ;
}
function getSourceRoot ( mapOptions : SourceMapOptions ) {
// Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the
// relative paths of the sources list in the sourcemap
const sourceRoot = normalizeSlashes ( mapOptions . sourceRoot || "" ) ;
return sourceRoot ? ensureTrailingDirectorySeparator ( sourceRoot ) : sourceRoot ;
2016-06-07 19:32:03 +02:00
}
2015-02-14 09:48:46 +01:00
2018-09-05 02:50:06 +02:00
function getSourceMapDirectory ( mapOptions : SourceMapOptions , filePath : string , sourceFile : SourceFile | undefined ) {
if ( mapOptions . sourceRoot ) return host . getCommonSourceDirectory ( ) ;
if ( mapOptions . mapRoot ) {
let sourceMapDir = normalizeSlashes ( mapOptions . mapRoot ) ;
if ( sourceFile ) {
// For modules or multiple emit files the mapRoot will have directory structure like the sources
// So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map
sourceMapDir = getDirectoryPath ( getSourceFilePathInNewDir ( sourceFile . fileName , host , sourceMapDir ) ) ;
}
if ( getRootLength ( sourceMapDir ) === 0 ) {
// The relative paths are relative to the common directory
sourceMapDir = combinePaths ( host . getCommonSourceDirectory ( ) , sourceMapDir ) ;
}
return sourceMapDir ;
}
return getDirectoryPath ( normalizePath ( filePath ) ) ;
}
function getSourceMappingURL ( mapOptions : SourceMapOptions , sourceMapGenerator : SourceMapGenerator , filePath : string , sourceMapFilePath : string | undefined , sourceFile : SourceFile | undefined ) {
if ( mapOptions . inlineSourceMap ) {
// Encode the sourceMap into the sourceMap url
const sourceMapText = sourceMapGenerator . toString ( ) ;
const base64SourceMapText = base64encode ( sys , sourceMapText ) ;
return ` data:application/json;base64, ${ base64SourceMapText } ` ;
}
const sourceMapFile = getBaseFileName ( normalizeSlashes ( Debug . assertDefined ( sourceMapFilePath ) ) ) ;
if ( mapOptions . mapRoot ) {
let sourceMapDir = normalizeSlashes ( mapOptions . mapRoot ) ;
if ( sourceFile ) {
// For modules or multiple emit files the mapRoot will have directory structure like the sources
// So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map
sourceMapDir = getDirectoryPath ( getSourceFilePathInNewDir ( sourceFile . fileName , host , sourceMapDir ) ) ;
}
if ( getRootLength ( sourceMapDir ) === 0 ) {
// The relative paths are relative to the common directory
sourceMapDir = combinePaths ( host . getCommonSourceDirectory ( ) , sourceMapDir ) ;
return getRelativePathToDirectoryOrUrl (
getDirectoryPath ( normalizePath ( filePath ) ) , // get the relative sourceMapDir path based on jsFilePath
combinePaths ( sourceMapDir , sourceMapFile ) , // this is where user expects to see sourceMap
host . getCurrentDirectory ( ) ,
host . getCanonicalFileName ,
/*isAbsolutePathAnUrl*/ true ) ;
}
else {
return combinePaths ( sourceMapDir , sourceMapFile ) ;
}
}
return sourceMapFile ;
2018-03-26 21:15:34 +02:00
}
2014-07-13 01:04:16 +02:00
}
2015-10-01 00:45:23 +02:00
2019-02-01 23:46:58 +01:00
function getBuildInfoText ( buildInfo : BuildInfo ) {
return JSON . stringify ( buildInfo , undefined , 2 ) ;
}
2019-02-06 04:35:08 +01:00
/*@internal*/
export const notImplementedResolver : EmitResolver = {
2019-02-01 23:46:58 +01:00
hasGlobalName : notImplemented ,
getReferencedExportContainer : notImplemented ,
getReferencedImportDeclaration : notImplemented ,
getReferencedDeclarationWithCollidingName : notImplemented ,
isDeclarationWithCollidingName : notImplemented ,
isValueAliasDeclaration : notImplemented ,
isReferencedAliasDeclaration : notImplemented ,
isTopLevelValueImportEqualsWithEntityName : notImplemented ,
getNodeCheckFlags : notImplemented ,
isDeclarationVisible : notImplemented ,
isLateBound : ( _node ) : _node is LateBoundDeclaration = > false ,
collectLinkedAliases : notImplemented ,
isImplementationOfOverload : notImplemented ,
isRequiredInitializedParameter : notImplemented ,
isOptionalUninitializedParameterProperty : notImplemented ,
isExpandoFunctionDeclaration : notImplemented ,
getPropertiesOfContainerFunction : notImplemented ,
createTypeOfDeclaration : notImplemented ,
createReturnTypeOfSignatureDeclaration : notImplemented ,
createTypeOfExpression : notImplemented ,
createLiteralConstValue : notImplemented ,
isSymbolAccessible : notImplemented ,
isEntityNameVisible : notImplemented ,
// Returns the constant value this property access resolves to: notImplemented, or 'undefined' for a non-constant
getConstantValue : notImplemented ,
getReferencedValueDeclaration : notImplemented ,
getTypeReferenceSerializationKind : notImplemented ,
isOptionalParameter : notImplemented ,
module ExportsSomeValue : notImplemented ,
isArgumentsLocalBinding : notImplemented ,
getExternalModuleFileFromDeclaration : notImplemented ,
getTypeReferenceDirectivesForEntityName : notImplemented ,
getTypeReferenceDirectivesForSymbol : notImplemented ,
isLiteralConstDeclaration : notImplemented ,
getJsxFactoryEntity : notImplemented ,
getAllAccessorDeclarations : notImplemented ,
getSymbolOfExternalModuleSpecifier : notImplemented ,
isBindingCapturedByNode : notImplemented ,
} ;
/*@internal*/
/** File that isnt present resulting in error or output files */
export type EmitUsingBuildInfoResult = string | ReadonlyArray < OutputFile > ;
/*@internal*/
export interface EmitUsingBuildInfoHost extends ModuleResolutionHost {
getCurrentDirectory ( ) : string ;
getCanonicalFileName ( fileName : string ) : string ;
useCaseSensitiveFileNames ( ) : boolean ;
getNewLine ( ) : string ;
}
2019-02-11 22:44:37 +01:00
function createSourceFilesForPrologues ( bundle : BundleFileInfo ) : ReadonlyArray < SourceFile > {
return map ( bundle . sources && bundle . sources . prologues , prologueInfo = > {
2019-02-05 00:22:23 +01:00
const sourceFile = createNode ( SyntaxKind . SourceFile , 0 , prologueInfo . text . length ) as SourceFile ;
sourceFile . fileName = prologueInfo . file ;
sourceFile . text = prologueInfo . text ;
sourceFile . statements = createNodeArray ( prologueInfo . directives . map ( directive = > {
const statement = createNode ( SyntaxKind . ExpressionStatement , directive . pos , directive . end ) as PrologueDirective ;
statement . expression = createNode ( SyntaxKind . StringLiteral , directive . expression . pos , directive . expression . end ) as StringLiteral ;
statement . expression . text = directive . expression . text ;
return statement ;
} ) ) ;
return sourceFile ;
} ) || emptyArray ;
}
2019-02-01 23:46:58 +01:00
/*@internal*/
export function emitUsingBuildInfo ( config : ParsedCommandLine , host : EmitUsingBuildInfoHost , getCommandLine : ( ref : ProjectReference ) = > ParsedCommandLine | undefined ) : EmitUsingBuildInfoResult {
2019-02-02 03:40:04 +01:00
const { buildInfoPath , jsFilePath , sourceMapFilePath , declarationFilePath , declarationMapPath } = getOutputPathsForBundle ( config . options , /*forceDtsPaths*/ false , config . projectReferences ) ;
2019-02-01 23:46:58 +01:00
const buildInfoText = host . readFile ( Debug . assertDefined ( buildInfoPath ) ) ;
if ( ! buildInfoText ) return buildInfoPath ! ;
const jsFileText = host . readFile ( Debug . assertDefined ( jsFilePath ) ) ;
if ( ! jsFileText ) return jsFilePath ! ;
const sourceMapText = sourceMapFilePath && host . readFile ( sourceMapFilePath ) ;
// error if no source map or for now if inline sourcemap
if ( ( sourceMapFilePath && ! sourceMapText ) || config . options . inlineSourceMap ) return sourceMapFilePath || "inline sourcemap decoding" ;
2019-02-15 23:25:24 +01:00
const stripInternal = config . options . stripInternal ;
2019-02-02 03:40:04 +01:00
const declarationMapText = declarationMapPath && host . readFile ( declarationMapPath ) ;
// error if no source map or for now if inline sourcemap
if ( ( declarationMapPath && ! declarationMapText ) || config . options . inlineSourceMap ) return declarationMapPath || "inline sourcemap decoding" ;
// read declaration text
2019-02-15 23:25:24 +01:00
const shouldHaveDeclarationText = stripInternal || declarationMapText ;
const declarationText = shouldHaveDeclarationText && host . readFile ( declarationFilePath ! ) ;
if ( shouldHaveDeclarationText && ! declarationText ) return declarationFilePath ! ;
2019-02-01 23:46:58 +01:00
const buildInfo = JSON . parse ( buildInfoText ) as BuildInfo ;
2019-02-07 23:25:16 +01:00
if ( ! buildInfo . bundle || ! buildInfo . bundle . js || ( declarationMapText && ! buildInfo . bundle . dts ) ) return buildInfoPath ! ;
2019-02-01 23:46:58 +01:00
const ownPrependInput = createInputFiles (
jsFileText ,
2019-02-02 03:40:04 +01:00
declarationText ! ,
2019-02-01 23:46:58 +01:00
sourceMapFilePath ,
sourceMapText ,
2019-02-02 03:40:04 +01:00
declarationMapPath ,
declarationMapText ,
2019-02-01 23:46:58 +01:00
jsFilePath ,
2019-02-02 03:40:04 +01:00
declarationFilePath ,
2019-02-01 23:46:58 +01:00
buildInfoPath ,
buildInfo ,
/*onlyOwnText*/ true
) ;
2019-02-02 05:10:31 +01:00
const optionsWithoutDeclaration = clone ( config . options ) ;
optionsWithoutDeclaration . declaration = false ;
optionsWithoutDeclaration . composite = false ;
2019-02-01 23:46:58 +01:00
const outputFiles : OutputFile [ ] = [ ] ;
2019-02-07 23:25:16 +01:00
const newBundle : BundleBuildInfo = clone ( buildInfo . bundle ) ;
2019-02-02 05:10:31 +01:00
let writeByteOrderMarkBuildInfo = false ;
const prependNodes = createPrependNodes ( config . projectReferences , getCommandLine , f = > host . readFile ( f ) ) ;
2019-02-04 22:36:45 +01:00
const jsPrepend = createUnparsedJsSourceFile ( ownPrependInput ) ;
2019-02-11 22:44:37 +01:00
const sourceFilesForJsEmit = createSourceFilesForPrologues ( buildInfo . bundle . js ) ;
2019-02-21 00:14:47 +01:00
let currentBuildInfoType : "js" | "dts" = "js" ;
2019-02-01 23:46:58 +01:00
const emitHost : EmitHost = {
2019-02-04 22:36:45 +01:00
getPrependNodes : memoize ( ( ) = > [ . . . prependNodes , jsPrepend ] ) ,
2019-02-01 23:46:58 +01:00
getProjectReferences : ( ) = > config . projectReferences ,
getCanonicalFileName : host.getCanonicalFileName ,
2019-02-07 23:25:16 +01:00
getCommonSourceDirectory : ( ) = > buildInfo . bundle ! . commonSourceDirectory ,
2019-02-02 05:10:31 +01:00
getCompilerOptions : ( ) = > optionsWithoutDeclaration ,
2019-02-01 23:46:58 +01:00
getCurrentDirectory : ( ) = > host . getCurrentDirectory ( ) ,
getNewLine : ( ) = > host . getNewLine ( ) ,
getSourceFile : notImplemented ,
getSourceFileByPath : notImplemented ,
2019-02-05 00:22:23 +01:00
getSourceFiles : ( ) = > sourceFilesForJsEmit ,
2019-02-01 23:46:58 +01:00
getLibFileFromReference : notImplemented ,
2019-02-05 00:22:23 +01:00
isSourceFileFromExternalLibrary : returnFalse ,
2019-02-01 23:46:58 +01:00
writeFile : ( name , text , writeByteOrderMark ) = > {
2019-02-21 00:14:47 +01:00
switch ( name ) {
case jsFilePath :
if ( jsFileText !== text ) {
outputFiles . push ( { name , text , writeByteOrderMark } ) ;
}
break ;
case sourceMapFilePath :
if ( sourceMapText !== text ) {
outputFiles . push ( { name , text , writeByteOrderMark } ) ;
}
break ;
case buildInfoPath :
if ( currentBuildInfoType === "js" || stripInternal ) {
const buildInfo = JSON . parse ( text ) as BuildInfo ;
newBundle [ currentBuildInfoType ] = buildInfo . bundle && buildInfo . bundle [ currentBuildInfoType ] ;
writeByteOrderMarkBuildInfo = writeByteOrderMarkBuildInfo || writeByteOrderMark ;
}
break ;
case declarationFilePath :
if ( stripInternal && declarationText !== text ) {
outputFiles . push ( { name , text , writeByteOrderMark } ) ;
}
break ;
case declarationMapPath :
if ( declarationMapText !== text ) {
outputFiles . push ( { name , text , writeByteOrderMark } ) ;
}
break ;
default :
Debug . assertNever ( name as never ) ;
2019-02-01 23:46:58 +01:00
}
} ,
isEmitBlocked : returnFalse ,
readFile : f = > host . readFile ( f ) ,
fileExists : f = > host . fileExists ( f ) ,
2019-02-02 05:10:31 +01:00
directoryExists : host.directoryExists && ( f = > host . directoryExists ! ( f ) ) ,
2019-02-01 23:46:58 +01:00
useCaseSensitiveFileNames : ( ) = > host . useCaseSensitiveFileNames ( ) ,
2019-02-06 04:35:08 +01:00
getProgramBuildInfo : ( ) = > undefined
2019-02-01 23:46:58 +01:00
} ;
2019-02-02 05:10:31 +01:00
// Emit js
2019-02-05 21:34:15 +01:00
emitFiles ( notImplementedResolver , emitHost , /*targetSourceFile*/ undefined , /*emitOnlyDtsFiles*/ false , getTransformers ( optionsWithoutDeclaration ) ) ;
2019-02-02 05:10:31 +01:00
// Emit d.ts map
2019-02-15 23:25:24 +01:00
if ( shouldHaveDeclarationText ) {
2019-02-21 00:14:47 +01:00
currentBuildInfoType = "dts" ;
2019-02-20 19:54:31 +01:00
const dtsPrepends = prependNodes . map ( prepend = > createUnparsedSourceFile ( prepend , "dts" , stripInternal ) ) ;
emitHost . getPrependNodes = memoize ( ( ) = > [ . . . dtsPrepends , createUnparsedDtsSourceFile ( ownPrependInput ) ] ) ;
2019-02-02 05:10:31 +01:00
emitHost . getCompilerOptions = ( ) = > config . options ;
2019-02-05 00:22:23 +01:00
emitHost . getSourceFiles = ( ) = > emptyArray ;
2019-02-05 21:34:15 +01:00
emitFiles ( notImplementedResolver , emitHost , /*targetSourceFile*/ undefined , /*emitOnlyDtsFiles*/ true ) ;
2019-02-02 05:10:31 +01:00
}
2019-02-07 23:25:16 +01:00
outputFiles . push ( { name : buildInfoPath ! , text : getBuildInfoText ( { program : buildInfo.program , bundle : newBundle } ) , writeByteOrderMark : writeByteOrderMarkBuildInfo } ) ;
2019-02-01 23:46:58 +01:00
return outputFiles ;
}
2018-05-04 01:04:52 +02:00
const enum PipelinePhase {
Notification ,
2018-09-07 23:11:54 +02:00
Substitution ,
2018-05-04 01:04:52 +02:00
Comments ,
SourceMaps ,
Emit
}
2017-01-30 21:27:24 +01:00
export function createPrinter ( printerOptions : PrinterOptions = { } , handlers : PrintHandlers = { } ) : Printer {
const {
hasGlobalName ,
2018-09-07 23:11:54 +02:00
onEmitNode = noEmitNotification ,
substituteNode = noEmitSubstitution ,
2017-03-15 19:44:36 +01:00
onBeforeEmitNodeArray ,
2017-05-19 19:18:42 +02:00
onAfterEmitNodeArray ,
onBeforeEmitToken ,
onAfterEmitToken
2017-01-30 21:27:24 +01:00
} = handlers ;
2018-09-07 23:11:54 +02:00
const extendedDiagnostics = ! ! printerOptions . extendedDiagnostics ;
2017-01-30 21:27:24 +01:00
const newLine = getNewLineCharacter ( printerOptions ) ;
2018-09-05 02:50:06 +02:00
const module Kind = getEmitModuleKind ( printerOptions ) ;
const bundledHelpers = createMap < boolean > ( ) ;
2017-01-30 21:27:24 +01:00
2018-11-10 02:18:34 +01:00
let currentSourceFile : SourceFile | undefined ;
2017-01-30 21:27:24 +01:00
let nodeIdToGeneratedName : string [ ] ; // Map of generated names for specific nodes.
let autoGeneratedIdToGeneratedName : string [ ] ; // Map of generated names for temp and loop variables.
2017-07-07 19:34:36 +02:00
let generatedNames : Map < true > ; // Set of names generated by the NameGenerator.
2017-01-30 21:27:24 +01:00
let tempFlagsStack : TempFlags [ ] ; // Stack of enclosing name generation scopes.
let tempFlags : TempFlags ; // TempFlags for the current name generation scope.
2018-01-16 21:33:55 +01:00
let reservedNamesStack : Map < true > [ ] ; // Stack of TempFlags reserved in enclosing name generation scopes.
let reservedNames : Map < true > ; // TempFlags to reserve in nested name generation scopes.
2017-01-30 21:27:24 +01:00
let writer : EmitTextWriter ;
2018-09-05 02:50:06 +02:00
let ownWriter : EmitTextWriter ; // Reusable `EmitTextWriter` for basic printing.
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
let write = writeBase ;
2018-03-31 02:43:37 +02:00
let isOwnFileEmit : boolean ;
2019-02-11 22:44:37 +01:00
const bundleFileInfo = printerOptions . writeBundleFileInfo ? { sections : [ ] } as BundleFileInfo : undefined ;
2019-02-15 23:25:24 +01:00
const recordInternalSection = printerOptions . recordInternalSection ;
let sourceFileTextPos = 0 ;
2017-01-30 21:27:24 +01:00
2018-09-05 02:50:06 +02:00
// Source Maps
let sourceMapsDisabled = true ;
let sourceMapGenerator : SourceMapGenerator | undefined ;
2018-09-07 23:11:54 +02:00
let sourceMapSource : SourceMapSource ;
2018-09-05 02:50:06 +02:00
let sourceMapSourceIndex = - 1 ;
// Comments
let containerPos = - 1 ;
let containerEnd = - 1 ;
let declarationListContainerEnd = - 1 ;
let currentLineMap : ReadonlyArray < number > | undefined ;
let detachedCommentsInfo : { nodePos : number , detachedCommentEndPos : number } [ ] | undefined ;
let hasWrittenComment = false ;
let commentsDisabled = ! ! printerOptions . removeComments ;
2018-09-07 23:11:54 +02:00
const { enter : enterComment , exit : exitComment } = performance . createTimerIf ( extendedDiagnostics , "commentTime" , "beforeComment" , "afterComment" ) ;
2018-09-05 02:50:06 +02:00
2017-01-30 21:27:24 +01:00
reset ( ) ;
return {
// public API
printNode ,
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
printList ,
2017-01-30 21:27:24 +01:00
printFile ,
printBundle ,
// internal API
writeNode ,
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeList ,
2017-01-30 21:27:24 +01:00
writeFile ,
2019-02-11 22:13:19 +01:00
writeBundle ,
bundleFileInfo
2017-01-30 21:27:24 +01:00
} ;
function printNode ( hint : EmitHint , node : Node , sourceFile : SourceFile ) : string {
2017-02-02 01:16:04 +01:00
switch ( hint ) {
case EmitHint . SourceFile :
Debug . assert ( isSourceFile ( node ) , "Expected a SourceFile node." ) ;
break ;
case EmitHint . IdentifierName :
Debug . assert ( isIdentifier ( node ) , "Expected an Identifier node." ) ;
break ;
case EmitHint . Expression :
Debug . assert ( isExpression ( node ) , "Expected an Expression node." ) ;
break ;
}
switch ( node . kind ) {
case SyntaxKind.SourceFile : return printFile ( < SourceFile > node ) ;
case SyntaxKind.Bundle : return printBundle ( < Bundle > node ) ;
2018-05-08 00:12:50 +02:00
case SyntaxKind.UnparsedSource : return printUnparsedSource ( < UnparsedSource > node ) ;
2017-02-02 01:16:04 +01:00
}
2017-01-30 21:27:24 +01:00
writeNode ( hint , node , sourceFile , beginPrint ( ) ) ;
return endPrint ( ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function printList < T extends Node > ( format : ListFormat , nodes : NodeArray < T > , sourceFile : SourceFile ) {
writeList ( format , nodes , sourceFile , beginPrint ( ) ) ;
return endPrint ( ) ;
}
2017-01-30 21:27:24 +01:00
function printBundle ( bundle : Bundle ) : string {
2019-02-11 22:13:19 +01:00
writeBundle ( bundle , beginPrint ( ) , /*sourceMapEmitter*/ undefined ) ;
2017-01-30 21:27:24 +01:00
return endPrint ( ) ;
2016-09-26 20:20:24 +02:00
}
2017-01-30 21:27:24 +01:00
function printFile ( sourceFile : SourceFile ) : string {
2018-09-05 02:50:06 +02:00
writeFile ( sourceFile , beginPrint ( ) , /*sourceMapEmitter*/ undefined ) ;
2017-01-30 21:27:24 +01:00
return endPrint ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-02-18 21:10:00 +01:00
2018-05-08 00:12:50 +02:00
function printUnparsedSource ( unparsed : UnparsedSource ) : string {
writeUnparsedSource ( unparsed , beginPrint ( ) ) ;
return endPrint ( ) ;
}
2017-05-13 01:27:35 +02:00
/ * *
* If ` sourceFile ` is ` undefined ` , ` node ` must be a synthesized ` TypeNode ` .
* /
function writeNode ( hint : EmitHint , node : TypeNode , sourceFile : undefined , output : EmitTextWriter ) : void ;
function writeNode ( hint : EmitHint , node : Node , sourceFile : SourceFile , output : EmitTextWriter ) : void ;
2017-03-30 23:14:15 +02:00
function writeNode ( hint : EmitHint , node : Node , sourceFile : SourceFile | undefined , output : EmitTextWriter ) {
2017-01-30 21:27:24 +01:00
const previousWriter = writer ;
2018-09-05 02:50:06 +02:00
setWriter ( output , /*_sourceMapGenerator*/ undefined ) ;
2017-01-30 21:27:24 +01:00
print ( hint , node , sourceFile ) ;
reset ( ) ;
writer = previousWriter ;
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeList < T extends Node > ( format : ListFormat , nodes : NodeArray < T > , sourceFile : SourceFile | undefined , output : EmitTextWriter ) {
const previousWriter = writer ;
2018-09-05 02:50:06 +02:00
setWriter ( output , /*_sourceMapGenerator*/ undefined ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( sourceFile ) {
setSourceFile ( sourceFile ) ;
}
emitList ( syntheticParent , nodes , format ) ;
reset ( ) ;
writer = previousWriter ;
}
2019-01-26 01:39:38 +01:00
function getTextPosWithWriteLine() {
return writer . getTextPosWithWriteLine ? writer . getTextPosWithWriteLine ( ) : writer . getTextPos ( ) ;
}
2019-02-15 23:25:24 +01:00
function updateOrPushBundleFileTextLike ( pos : number , end : number , kind : BundleFileTextLikeKind ) {
const last = lastOrUndefined ( bundleFileInfo ! . sections ) ;
if ( last && last . kind === kind ) {
last . end = end ;
}
else {
bundleFileInfo ! . sections . push ( { pos , end , kind } ) ;
}
}
function recordBundleFileTextSection ( end : number ) {
if ( sourceFileTextPos < end ) {
updateOrPushBundleFileTextLike ( sourceFileTextPos , end , BundleFileSectionKind . Text ) ;
return true ;
}
return false ;
}
2019-02-11 22:13:19 +01:00
function writeBundle ( bundle : Bundle , output : EmitTextWriter , sourceMapGenerator : SourceMapGenerator | undefined ) {
2018-03-31 02:43:37 +02:00
isOwnFileEmit = false ;
2017-01-30 21:27:24 +01:00
const previousWriter = writer ;
2018-09-05 02:50:06 +02:00
setWriter ( output , sourceMapGenerator ) ;
2017-02-24 00:27:22 +01:00
emitShebangIfNeeded ( bundle ) ;
2017-02-24 20:37:34 +01:00
emitPrologueDirectivesIfNeeded ( bundle ) ;
2018-03-31 02:43:37 +02:00
emitHelpers ( bundle ) ;
2018-03-16 06:23:10 +01:00
emitSyntheticTripleSlashReferencesIfNeeded ( bundle ) ;
2018-05-08 00:12:50 +02:00
for ( const prepend of bundle . prepends ) {
writeLine ( ) ;
2019-02-20 21:55:08 +01:00
const pos = writer . getTextPos ( ) ;
2019-02-15 18:46:37 +01:00
const savedSections = bundleFileInfo && bundleFileInfo . sections ;
if ( savedSections ) bundleFileInfo ! . sections = [ ] ;
2018-08-22 21:42:36 +02:00
print ( EmitHint . Unspecified , prepend , /*sourceFile*/ undefined ) ;
2019-02-01 23:46:58 +01:00
if ( bundleFileInfo ) {
2019-02-15 18:46:37 +01:00
const newSections = bundleFileInfo . sections ;
bundleFileInfo . sections = savedSections ! ;
2019-02-20 22:09:38 +01:00
if ( prepend . oldFileOfCurrentEmit ) bundleFileInfo . sections . push ( . . . newSections ) ;
2019-02-15 18:46:37 +01:00
else {
newSections . forEach ( section = > Debug . assert ( isBundleFileTextLike ( section ) ) ) ;
bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.Prepend , data : ( prepend as UnparsedSource ) . fileName , texts : newSections as BundleFileTextLike [ ] } ) ;
}
2019-02-01 23:46:58 +01:00
}
2018-05-08 00:12:50 +02:00
}
2019-02-15 23:25:24 +01:00
sourceFileTextPos = getTextPosWithWriteLine ( ) ;
2017-01-30 21:27:24 +01:00
for ( const sourceFile of bundle . sourceFiles ) {
print ( EmitHint . SourceFile , sourceFile , sourceFile ) ;
2016-07-21 03:43:41 +02:00
}
2019-02-01 23:46:58 +01:00
if ( bundleFileInfo && bundle . sourceFiles . length ) {
2019-02-05 00:22:23 +01:00
const end = writer . getTextPos ( ) ;
2019-02-15 23:25:24 +01:00
if ( recordBundleFileTextSection ( end ) ) {
2019-02-05 00:22:23 +01:00
// Store prologues
const prologues = getPrologueDirectivesFromBundledSourceFiles ( bundle ) ;
2019-02-11 22:44:37 +01:00
if ( prologues ) {
if ( ! bundleFileInfo . sources ) bundleFileInfo . sources = { } ;
bundleFileInfo . sources . prologues = prologues ;
}
2019-02-05 00:22:23 +01:00
// Store helpes
const helpers = getHelpersFromBundledSourceFiles ( bundle ) ;
2019-02-11 22:44:37 +01:00
if ( helpers ) {
if ( ! bundleFileInfo . sources ) bundleFileInfo . sources = { } ;
bundleFileInfo . sources . helpers = helpers ;
}
2019-02-05 00:22:23 +01:00
}
else {
// Ensure we have text section
2019-02-15 18:46:37 +01:00
Debug . assert ( ! ! bundleFileInfo . sections . length && isBundleFileTextLike ( last ( bundleFileInfo . sections ) ) ) ;
2019-02-05 00:22:23 +01:00
}
2019-02-02 01:52:00 +01:00
}
2019-01-26 01:39:38 +01:00
2017-01-30 21:27:24 +01:00
reset ( ) ;
writer = previousWriter ;
}
2016-09-27 00:21:03 +02:00
2018-05-08 00:12:50 +02:00
function writeUnparsedSource ( unparsed : UnparsedSource , output : EmitTextWriter ) {
const previousWriter = writer ;
2018-09-05 02:50:06 +02:00
setWriter ( output , /*_sourceMapGenerator*/ undefined ) ;
2018-05-08 00:12:50 +02:00
print ( EmitHint . Unspecified , unparsed , /*sourceFile*/ undefined ) ;
reset ( ) ;
writer = previousWriter ;
}
2018-09-05 02:50:06 +02:00
function writeFile ( sourceFile : SourceFile , output : EmitTextWriter , sourceMapGenerator : SourceMapGenerator | undefined ) {
2018-03-31 02:43:37 +02:00
isOwnFileEmit = true ;
2017-01-30 21:27:24 +01:00
const previousWriter = writer ;
2018-09-05 02:50:06 +02:00
setWriter ( output , sourceMapGenerator ) ;
2017-02-24 00:27:22 +01:00
emitShebangIfNeeded ( sourceFile ) ;
2017-02-24 20:37:34 +01:00
emitPrologueDirectivesIfNeeded ( sourceFile ) ;
2017-01-30 21:27:24 +01:00
print ( EmitHint . SourceFile , sourceFile , sourceFile ) ;
reset ( ) ;
writer = previousWriter ;
2016-07-21 03:43:41 +02:00
}
2017-01-30 21:27:24 +01:00
function beginPrint() {
return ownWriter || ( ownWriter = createTextWriter ( newLine ) ) ;
}
function endPrint() {
2017-01-30 22:40:42 +01:00
const text = ownWriter . getText ( ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
ownWriter . clear ( ) ;
2017-01-30 21:27:24 +01:00
return text ;
}
2017-03-30 23:14:15 +02:00
function print ( hint : EmitHint , node : Node , sourceFile : SourceFile | undefined ) {
if ( sourceFile ) {
setSourceFile ( sourceFile ) ;
}
2018-05-04 01:04:52 +02:00
2018-09-07 23:11:54 +02:00
const pipelinePhase = getPipelinePhase ( PipelinePhase . Notification , node ) ;
2018-05-04 01:04:52 +02:00
pipelinePhase ( hint , node ) ;
2017-01-30 21:27:24 +01:00
}
2018-11-10 02:18:34 +01:00
function setSourceFile ( sourceFile : SourceFile | undefined ) {
2017-01-30 21:27:24 +01:00
currentSourceFile = sourceFile ;
2018-09-05 02:50:06 +02:00
currentLineMap = undefined ;
detachedCommentsInfo = undefined ;
2018-11-10 02:18:34 +01:00
if ( sourceFile ) {
setSourceMapSource ( sourceFile ) ;
}
2017-01-30 21:27:24 +01:00
}
2016-09-27 00:21:03 +02:00
2018-09-05 02:50:06 +02:00
function setWriter ( _writer : EmitTextWriter | undefined , _sourceMapGenerator : SourceMapGenerator | undefined ) {
if ( _writer && printerOptions . omitTrailingSemicolon ) {
_writer = getTrailingSemicolonOmittingWriter ( _writer ) ;
2018-08-22 21:42:36 +02:00
}
2018-09-05 02:50:06 +02:00
writer = _writer ! ; // TODO: GH#18217
sourceMapGenerator = _sourceMapGenerator ;
sourceMapsDisabled = ! writer || ! sourceMapGenerator ;
2016-07-21 03:43:41 +02:00
}
2017-01-30 21:27:24 +01:00
function reset() {
nodeIdToGeneratedName = [ ] ;
autoGeneratedIdToGeneratedName = [ ] ;
2017-07-07 19:34:36 +02:00
generatedNames = createMap < true > ( ) ;
2017-01-30 21:27:24 +01:00
tempFlagsStack = [ ] ;
tempFlags = TempFlags . Auto ;
2018-01-16 21:33:55 +01:00
reservedNamesStack = [ ] ;
2018-09-05 02:50:06 +02:00
currentSourceFile = undefined ! ;
currentLineMap = undefined ! ;
detachedCommentsInfo = undefined ;
setWriter ( /*output*/ undefined , /*_sourceMapGenerator*/ undefined ) ;
}
function getCurrentLineMap() {
2018-11-10 02:18:34 +01:00
return currentLineMap || ( currentLineMap = getLineStarts ( currentSourceFile ! ) ) ;
2016-06-07 19:32:03 +02:00
}
2015-02-18 21:10:00 +01:00
2018-05-04 01:04:52 +02:00
function emit ( node : Node | undefined ) {
2018-09-07 23:11:54 +02:00
if ( node === undefined ) return ;
2019-02-15 23:25:24 +01:00
const end = writer . getTextPos ( ) ;
const pos = getTextPosWithWriteLine ( ) ;
2018-09-07 23:11:54 +02:00
const pipelinePhase = getPipelinePhase ( PipelinePhase . Notification , node ) ;
2018-05-04 01:04:52 +02:00
pipelinePhase ( EmitHint . Unspecified , node ) ;
2019-02-15 23:25:24 +01:00
if ( recordInternalSection && bundleFileInfo && currentSourceFile && ( isDeclaration ( node ) || isVariableStatement ( node ) ) && isInternalDeclaration ( node , currentSourceFile ) ) {
recordBundleFileTextSection ( end ) ;
updateOrPushBundleFileTextLike ( pos , writer . getTextPos ( ) , BundleFileSectionKind . Internal ) ;
sourceFileTextPos = getTextPosWithWriteLine ( ) ;
}
2017-09-07 23:30:19 +02:00
}
2018-05-04 01:04:52 +02:00
function emitIdentifierName ( node : Identifier | undefined ) {
2018-09-07 23:11:54 +02:00
if ( node === undefined ) return ;
const pipelinePhase = getPipelinePhase ( PipelinePhase . Notification , node ) ;
2018-05-04 01:04:52 +02:00
pipelinePhase ( EmitHint . IdentifierName , node ) ;
2017-01-30 21:27:24 +01:00
}
2018-05-04 01:04:52 +02:00
function emitExpression ( node : Expression | undefined ) {
2018-09-07 23:11:54 +02:00
if ( node === undefined ) return ;
const pipelinePhase = getPipelinePhase ( PipelinePhase . Notification , node ) ;
2018-05-04 01:04:52 +02:00
pipelinePhase ( EmitHint . Expression , node ) ;
2017-01-30 21:27:24 +01:00
}
2018-09-07 23:11:54 +02:00
function getPipelinePhase ( phase : PipelinePhase , node : Node ) {
2018-05-04 01:04:52 +02:00
switch ( phase ) {
case PipelinePhase . Notification :
2018-09-07 23:11:54 +02:00
if ( onEmitNode !== noEmitNotification ) {
2018-05-04 01:04:52 +02:00
return pipelineEmitWithNotification ;
}
// falls through
2017-01-30 21:27:24 +01:00
2018-09-07 23:11:54 +02:00
case PipelinePhase . Substitution :
if ( substituteNode !== noEmitSubstitution ) {
return pipelineEmitWithSubstitution ;
}
// falls through
2018-05-04 01:04:52 +02:00
case PipelinePhase . Comments :
2018-09-07 23:11:54 +02:00
if ( ! commentsDisabled && node . kind !== SyntaxKind . SourceFile ) {
2018-05-04 01:04:52 +02:00
return pipelineEmitWithComments ;
}
2018-09-07 23:11:54 +02:00
// falls through
2014-08-22 23:40:47 +02:00
2018-05-04 01:04:52 +02:00
case PipelinePhase . SourceMaps :
2018-09-07 23:11:54 +02:00
if ( ! sourceMapsDisabled && node . kind !== SyntaxKind . SourceFile && ! isInJsonFile ( node ) ) {
2018-05-04 01:04:52 +02:00
return pipelineEmitWithSourceMap ;
}
// falls through
case PipelinePhase . Emit :
return pipelineEmitWithHint ;
default :
2018-09-07 23:11:54 +02:00
return Debug . assertNever ( phase ) ;
2016-09-27 00:21:03 +02:00
}
2016-09-26 20:20:24 +02:00
}
2018-09-07 23:11:54 +02:00
function getNextPipelinePhase ( currentPhase : PipelinePhase , node : Node ) {
return getPipelinePhase ( currentPhase + 1 , node ) ;
2017-01-30 21:27:24 +01:00
}
2018-05-04 01:04:52 +02:00
function pipelineEmitWithNotification ( hint : EmitHint , node : Node ) {
2018-09-07 23:11:54 +02:00
const pipelinePhase = getNextPipelinePhase ( PipelinePhase . Notification , node ) ;
2018-10-08 23:13:48 +02:00
onEmitNode ( hint , node , pipelinePhase ) ;
2017-09-07 23:30:19 +02:00
}
2018-05-04 01:04:52 +02:00
function pipelineEmitWithHint ( hint : EmitHint , node : Node ) : void {
if ( hint === EmitHint . SourceFile ) return emitSourceFile ( cast ( node , isSourceFile ) ) ;
if ( hint === EmitHint . IdentifierName ) return emitIdentifier ( cast ( node , isIdentifier ) ) ;
if ( hint === EmitHint . MappedTypeParameter ) return emitMappedTypeParameter ( cast ( node , isTypeParameterDeclaration ) ) ;
2018-08-22 21:42:36 +02:00
if ( hint === EmitHint . EmbeddedStatement ) {
Debug . assertNode ( node , isEmptyStatement ) ;
return emitEmptyStatement ( /*isEmbeddedStatement*/ true ) ;
}
2018-05-04 01:04:52 +02:00
if ( hint === EmitHint . Unspecified ) {
if ( isKeyword ( node . kind ) ) return writeTokenNode ( node , writeKeyword ) ;
switch ( node . kind ) {
// Pseudo-literals
case SyntaxKind . TemplateHead :
case SyntaxKind . TemplateMiddle :
case SyntaxKind . TemplateTail :
return emitLiteral ( < LiteralExpression > node ) ;
2018-05-08 00:12:50 +02:00
case SyntaxKind . UnparsedSource :
2019-02-15 18:46:37 +01:00
case SyntaxKind . UnparsedPrepend :
return emitUnparsedSourceOrPrepend ( < UnparsedSource > node ) ;
2018-05-08 00:12:50 +02:00
2019-01-17 21:11:51 +01:00
case SyntaxKind . UnparsedPrologue :
2019-02-15 18:46:37 +01:00
return writeUnparsedNode ( < UnparsedNode > node ) ;
2019-01-31 19:40:46 +01:00
case SyntaxKind . UnparsedText :
2019-02-15 23:25:24 +01:00
case SyntaxKind . UnparsedInternalText :
2019-01-31 20:19:37 +01:00
case SyntaxKind . UnparsedSourceMapUrl :
2019-02-15 18:46:37 +01:00
return emitUnparsedTextLike ( < UnparsedTextLike > node ) ;
2019-01-17 21:11:51 +01:00
2019-02-20 19:54:31 +01:00
case SyntaxKind . UnparsedSyntheticReference :
return emitUnparsedSyntheticReference ( < UnparsedSyntheticReference > node ) ;
2019-02-02 05:10:31 +01:00
2018-05-04 01:04:52 +02:00
// Identifiers
case SyntaxKind . Identifier :
return emitIdentifier ( < Identifier > node ) ;
// Parse tree nodes
// Names
case SyntaxKind . QualifiedName :
return emitQualifiedName ( < QualifiedName > node ) ;
case SyntaxKind . ComputedPropertyName :
return emitComputedPropertyName ( < ComputedPropertyName > node ) ;
// Signature elements
case SyntaxKind . TypeParameter :
return emitTypeParameter ( < TypeParameterDeclaration > node ) ;
case SyntaxKind . Parameter :
return emitParameter ( < ParameterDeclaration > node ) ;
case SyntaxKind . Decorator :
return emitDecorator ( < Decorator > node ) ;
// Type members
case SyntaxKind . PropertySignature :
return emitPropertySignature ( < PropertySignature > node ) ;
case SyntaxKind . PropertyDeclaration :
return emitPropertyDeclaration ( < PropertyDeclaration > node ) ;
case SyntaxKind . MethodSignature :
return emitMethodSignature ( < MethodSignature > node ) ;
case SyntaxKind . MethodDeclaration :
return emitMethodDeclaration ( < MethodDeclaration > node ) ;
case SyntaxKind . Constructor :
return emitConstructor ( < ConstructorDeclaration > node ) ;
case SyntaxKind . GetAccessor :
case SyntaxKind . SetAccessor :
return emitAccessorDeclaration ( < AccessorDeclaration > node ) ;
case SyntaxKind . CallSignature :
return emitCallSignature ( < CallSignatureDeclaration > node ) ;
case SyntaxKind . ConstructSignature :
return emitConstructSignature ( < ConstructSignatureDeclaration > node ) ;
case SyntaxKind . IndexSignature :
return emitIndexSignature ( < IndexSignatureDeclaration > node ) ;
// Types
case SyntaxKind . TypePredicate :
return emitTypePredicate ( < TypePredicateNode > node ) ;
case SyntaxKind . TypeReference :
return emitTypeReference ( < TypeReferenceNode > node ) ;
case SyntaxKind . FunctionType :
return emitFunctionType ( < FunctionTypeNode > node ) ;
case SyntaxKind . JSDocFunctionType :
return emitJSDocFunctionType ( node as JSDocFunctionType ) ;
case SyntaxKind . ConstructorType :
return emitConstructorType ( < ConstructorTypeNode > node ) ;
case SyntaxKind . TypeQuery :
return emitTypeQuery ( < TypeQueryNode > node ) ;
case SyntaxKind . TypeLiteral :
return emitTypeLiteral ( < TypeLiteralNode > node ) ;
case SyntaxKind . ArrayType :
return emitArrayType ( < ArrayTypeNode > node ) ;
case SyntaxKind . TupleType :
return emitTupleType ( < TupleTypeNode > node ) ;
2018-06-09 21:19:11 +02:00
case SyntaxKind . OptionalType :
return emitOptionalType ( < OptionalTypeNode > node ) ;
2018-05-04 01:04:52 +02:00
case SyntaxKind . UnionType :
return emitUnionType ( < UnionTypeNode > node ) ;
case SyntaxKind . IntersectionType :
return emitIntersectionType ( < IntersectionTypeNode > node ) ;
case SyntaxKind . ConditionalType :
return emitConditionalType ( < ConditionalTypeNode > node ) ;
case SyntaxKind . InferType :
return emitInferType ( < InferTypeNode > node ) ;
case SyntaxKind . ParenthesizedType :
return emitParenthesizedType ( < ParenthesizedTypeNode > node ) ;
case SyntaxKind . ExpressionWithTypeArguments :
return emitExpressionWithTypeArguments ( < ExpressionWithTypeArguments > node ) ;
case SyntaxKind . ThisType :
return emitThisType ( ) ;
case SyntaxKind . TypeOperator :
return emitTypeOperator ( < TypeOperatorNode > node ) ;
case SyntaxKind . IndexedAccessType :
return emitIndexedAccessType ( < IndexedAccessTypeNode > node ) ;
case SyntaxKind . MappedType :
return emitMappedType ( < MappedTypeNode > node ) ;
case SyntaxKind . LiteralType :
return emitLiteralType ( < LiteralTypeNode > node ) ;
case SyntaxKind . ImportType :
return emitImportTypeNode ( < ImportTypeNode > node ) ;
case SyntaxKind . JSDocAllType :
2018-08-22 21:42:36 +02:00
writePunctuation ( "*" ) ;
2018-05-04 01:04:52 +02:00
return ;
case SyntaxKind . JSDocUnknownType :
2018-08-22 21:42:36 +02:00
writePunctuation ( "?" ) ;
2018-05-04 01:04:52 +02:00
return ;
case SyntaxKind . JSDocNullableType :
return emitJSDocNullableType ( node as JSDocNullableType ) ;
case SyntaxKind . JSDocNonNullableType :
return emitJSDocNonNullableType ( node as JSDocNonNullableType ) ;
case SyntaxKind . JSDocOptionalType :
return emitJSDocOptionalType ( node as JSDocOptionalType ) ;
2018-06-15 20:43:16 +02:00
case SyntaxKind . RestType :
2018-05-04 01:04:52 +02:00
case SyntaxKind . JSDocVariadicType :
2018-06-15 20:43:16 +02:00
return emitRestOrJSDocVariadicType ( node as RestTypeNode | JSDocVariadicType ) ;
2018-05-04 01:04:52 +02:00
// Binding patterns
case SyntaxKind . ObjectBindingPattern :
return emitObjectBindingPattern ( < ObjectBindingPattern > node ) ;
case SyntaxKind . ArrayBindingPattern :
return emitArrayBindingPattern ( < ArrayBindingPattern > node ) ;
case SyntaxKind . BindingElement :
return emitBindingElement ( < BindingElement > node ) ;
// Misc
case SyntaxKind . TemplateSpan :
return emitTemplateSpan ( < TemplateSpan > node ) ;
case SyntaxKind . SemicolonClassElement :
return emitSemicolonClassElement ( ) ;
// Statements
case SyntaxKind . Block :
return emitBlock ( < Block > node ) ;
case SyntaxKind . VariableStatement :
return emitVariableStatement ( < VariableStatement > node ) ;
case SyntaxKind . EmptyStatement :
2018-08-22 21:42:36 +02:00
return emitEmptyStatement ( /*isEmbeddedStatement*/ false ) ;
2018-05-04 01:04:52 +02:00
case SyntaxKind . ExpressionStatement :
return emitExpressionStatement ( < ExpressionStatement > node ) ;
case SyntaxKind . IfStatement :
return emitIfStatement ( < IfStatement > node ) ;
case SyntaxKind . DoStatement :
return emitDoStatement ( < DoStatement > node ) ;
case SyntaxKind . WhileStatement :
return emitWhileStatement ( < WhileStatement > node ) ;
case SyntaxKind . ForStatement :
return emitForStatement ( < ForStatement > node ) ;
case SyntaxKind . ForInStatement :
return emitForInStatement ( < ForInStatement > node ) ;
case SyntaxKind . ForOfStatement :
return emitForOfStatement ( < ForOfStatement > node ) ;
case SyntaxKind . ContinueStatement :
return emitContinueStatement ( < ContinueStatement > node ) ;
case SyntaxKind . BreakStatement :
return emitBreakStatement ( < BreakStatement > node ) ;
case SyntaxKind . ReturnStatement :
return emitReturnStatement ( < ReturnStatement > node ) ;
case SyntaxKind . WithStatement :
return emitWithStatement ( < WithStatement > node ) ;
case SyntaxKind . SwitchStatement :
return emitSwitchStatement ( < SwitchStatement > node ) ;
case SyntaxKind . LabeledStatement :
return emitLabeledStatement ( < LabeledStatement > node ) ;
case SyntaxKind . ThrowStatement :
return emitThrowStatement ( < ThrowStatement > node ) ;
case SyntaxKind . TryStatement :
return emitTryStatement ( < TryStatement > node ) ;
case SyntaxKind . DebuggerStatement :
return emitDebuggerStatement ( < DebuggerStatement > node ) ;
// Declarations
case SyntaxKind . VariableDeclaration :
return emitVariableDeclaration ( < VariableDeclaration > node ) ;
case SyntaxKind . VariableDeclarationList :
return emitVariableDeclarationList ( < VariableDeclarationList > node ) ;
case SyntaxKind . FunctionDeclaration :
return emitFunctionDeclaration ( < FunctionDeclaration > node ) ;
case SyntaxKind . ClassDeclaration :
return emitClassDeclaration ( < ClassDeclaration > node ) ;
case SyntaxKind . InterfaceDeclaration :
return emitInterfaceDeclaration ( < InterfaceDeclaration > node ) ;
case SyntaxKind . TypeAliasDeclaration :
return emitTypeAliasDeclaration ( < TypeAliasDeclaration > node ) ;
case SyntaxKind . EnumDeclaration :
return emitEnumDeclaration ( < EnumDeclaration > node ) ;
case SyntaxKind . ModuleDeclaration :
return emitModuleDeclaration ( < ModuleDeclaration > node ) ;
case SyntaxKind . ModuleBlock :
return emitModuleBlock ( < ModuleBlock > node ) ;
case SyntaxKind . CaseBlock :
return emitCaseBlock ( < CaseBlock > node ) ;
case SyntaxKind . NamespaceExportDeclaration :
return emitNamespaceExportDeclaration ( < NamespaceExportDeclaration > node ) ;
case SyntaxKind . ImportEqualsDeclaration :
return emitImportEqualsDeclaration ( < ImportEqualsDeclaration > node ) ;
case SyntaxKind . ImportDeclaration :
return emitImportDeclaration ( < ImportDeclaration > node ) ;
case SyntaxKind . ImportClause :
return emitImportClause ( < ImportClause > node ) ;
case SyntaxKind . NamespaceImport :
return emitNamespaceImport ( < NamespaceImport > node ) ;
case SyntaxKind . NamedImports :
return emitNamedImports ( < NamedImports > node ) ;
case SyntaxKind . ImportSpecifier :
return emitImportSpecifier ( < ImportSpecifier > node ) ;
case SyntaxKind . ExportAssignment :
return emitExportAssignment ( < ExportAssignment > node ) ;
case SyntaxKind . ExportDeclaration :
return emitExportDeclaration ( < ExportDeclaration > node ) ;
case SyntaxKind . NamedExports :
return emitNamedExports ( < NamedExports > node ) ;
case SyntaxKind . ExportSpecifier :
return emitExportSpecifier ( < ExportSpecifier > node ) ;
case SyntaxKind . MissingDeclaration :
return ;
// Module references
case SyntaxKind . ExternalModuleReference :
return emitExternalModuleReference ( < ExternalModuleReference > node ) ;
// JSX (non-expression)
case SyntaxKind . JsxText :
return emitJsxText ( < JsxText > node ) ;
case SyntaxKind . JsxOpeningElement :
case SyntaxKind . JsxOpeningFragment :
return emitJsxOpeningElementOrFragment ( < JsxOpeningElement > node ) ;
case SyntaxKind . JsxClosingElement :
case SyntaxKind . JsxClosingFragment :
return emitJsxClosingElementOrFragment ( < JsxClosingElement > node ) ;
case SyntaxKind . JsxAttribute :
return emitJsxAttribute ( < JsxAttribute > node ) ;
case SyntaxKind . JsxAttributes :
return emitJsxAttributes ( < JsxAttributes > node ) ;
case SyntaxKind . JsxSpreadAttribute :
return emitJsxSpreadAttribute ( < JsxSpreadAttribute > node ) ;
case SyntaxKind . JsxExpression :
return emitJsxExpression ( < JsxExpression > node ) ;
// Clauses
case SyntaxKind . CaseClause :
return emitCaseClause ( < CaseClause > node ) ;
case SyntaxKind . DefaultClause :
return emitDefaultClause ( < DefaultClause > node ) ;
case SyntaxKind . HeritageClause :
return emitHeritageClause ( < HeritageClause > node ) ;
case SyntaxKind . CatchClause :
return emitCatchClause ( < CatchClause > node ) ;
// Property assignments
case SyntaxKind . PropertyAssignment :
return emitPropertyAssignment ( < PropertyAssignment > node ) ;
case SyntaxKind . ShorthandPropertyAssignment :
return emitShorthandPropertyAssignment ( < ShorthandPropertyAssignment > node ) ;
case SyntaxKind . SpreadAssignment :
return emitSpreadAssignment ( node as SpreadAssignment ) ;
// Enum
case SyntaxKind . EnumMember :
return emitEnumMember ( < EnumMember > node ) ;
2018-10-25 01:14:52 +02:00
// JSDoc nodes (only used in codefixes currently)
case SyntaxKind . JSDocParameterTag :
case SyntaxKind . JSDocPropertyTag :
return emitJSDocPropertyLikeTag ( node as JSDocPropertyLikeTag ) ;
case SyntaxKind . JSDocReturnTag :
case SyntaxKind . JSDocTypeTag :
case SyntaxKind . JSDocThisTag :
case SyntaxKind . JSDocEnumTag :
return emitJSDocSimpleTypedTag ( node as JSDocTypeTag ) ;
case SyntaxKind . JSDocAugmentsTag :
return emitJSDocAugmentsTag ( node as JSDocAugmentsTag ) ;
case SyntaxKind . JSDocTemplateTag :
return emitJSDocTemplateTag ( node as JSDocTemplateTag ) ;
case SyntaxKind . JSDocTypedefTag :
return emitJSDocTypedefTag ( node as JSDocTypedefTag ) ;
case SyntaxKind . JSDocCallbackTag :
return emitJSDocCallbackTag ( node as JSDocCallbackTag ) ;
case SyntaxKind . JSDocSignature :
return emitJSDocSignature ( node as JSDocSignature ) ;
case SyntaxKind . JSDocTypeLiteral :
return emitJSDocTypeLiteral ( node as JSDocTypeLiteral ) ;
case SyntaxKind . JSDocClassTag :
case SyntaxKind . JSDocTag :
return emitJSDocSimpleTag ( node as JSDocTag ) ;
case SyntaxKind . JSDocComment :
return emitJSDoc ( node as JSDoc ) ;
2018-05-04 01:04:52 +02:00
// Transformation nodes (ignored)
}
2017-01-30 22:40:42 +01:00
2018-05-04 01:04:52 +02:00
if ( isExpression ( node ) ) {
hint = EmitHint . Expression ;
2018-09-07 23:11:54 +02:00
if ( substituteNode !== noEmitSubstitution ) {
node = substituteNode ( hint , node ) ;
}
2018-05-04 01:04:52 +02:00
}
else if ( isToken ( node ) ) {
return writeTokenNode ( node , writePunctuation ) ;
}
2017-01-30 22:40:42 +01:00
}
2018-05-04 01:04:52 +02:00
if ( hint === EmitHint . Expression ) {
switch ( node . kind ) {
// Literals
case SyntaxKind . NumericLiteral :
2018-10-31 00:56:05 +01:00
case SyntaxKind . BigIntLiteral :
return emitNumericOrBigIntLiteral ( < NumericLiteral | BigIntLiteral > node ) ;
2018-05-04 01:04:52 +02:00
case SyntaxKind . StringLiteral :
case SyntaxKind . RegularExpressionLiteral :
case SyntaxKind . NoSubstitutionTemplateLiteral :
return emitLiteral ( < LiteralExpression > node ) ;
// Identifiers
case SyntaxKind . Identifier :
return emitIdentifier ( < Identifier > node ) ;
// Reserved words
case SyntaxKind . FalseKeyword :
case SyntaxKind . NullKeyword :
case SyntaxKind . SuperKeyword :
case SyntaxKind . TrueKeyword :
case SyntaxKind . ThisKeyword :
case SyntaxKind . ImportKeyword :
writeTokenNode ( node , writeKeyword ) ;
return ;
// Expressions
case SyntaxKind . ArrayLiteralExpression :
return emitArrayLiteralExpression ( < ArrayLiteralExpression > node ) ;
case SyntaxKind . ObjectLiteralExpression :
return emitObjectLiteralExpression ( < ObjectLiteralExpression > node ) ;
case SyntaxKind . PropertyAccessExpression :
return emitPropertyAccessExpression ( < PropertyAccessExpression > node ) ;
case SyntaxKind . ElementAccessExpression :
return emitElementAccessExpression ( < ElementAccessExpression > node ) ;
case SyntaxKind . CallExpression :
return emitCallExpression ( < CallExpression > node ) ;
case SyntaxKind . NewExpression :
return emitNewExpression ( < NewExpression > node ) ;
case SyntaxKind . TaggedTemplateExpression :
return emitTaggedTemplateExpression ( < TaggedTemplateExpression > node ) ;
case SyntaxKind . TypeAssertionExpression :
return emitTypeAssertionExpression ( < TypeAssertion > node ) ;
case SyntaxKind . ParenthesizedExpression :
return emitParenthesizedExpression ( < ParenthesizedExpression > node ) ;
case SyntaxKind . FunctionExpression :
return emitFunctionExpression ( < FunctionExpression > node ) ;
case SyntaxKind . ArrowFunction :
return emitArrowFunction ( < ArrowFunction > node ) ;
case SyntaxKind . DeleteExpression :
return emitDeleteExpression ( < DeleteExpression > node ) ;
case SyntaxKind . TypeOfExpression :
return emitTypeOfExpression ( < TypeOfExpression > node ) ;
case SyntaxKind . VoidExpression :
return emitVoidExpression ( < VoidExpression > node ) ;
case SyntaxKind . AwaitExpression :
return emitAwaitExpression ( < AwaitExpression > node ) ;
case SyntaxKind . PrefixUnaryExpression :
return emitPrefixUnaryExpression ( < PrefixUnaryExpression > node ) ;
case SyntaxKind . PostfixUnaryExpression :
return emitPostfixUnaryExpression ( < PostfixUnaryExpression > node ) ;
case SyntaxKind . BinaryExpression :
return emitBinaryExpression ( < BinaryExpression > node ) ;
case SyntaxKind . ConditionalExpression :
return emitConditionalExpression ( < ConditionalExpression > node ) ;
case SyntaxKind . TemplateExpression :
return emitTemplateExpression ( < TemplateExpression > node ) ;
case SyntaxKind . YieldExpression :
return emitYieldExpression ( < YieldExpression > node ) ;
case SyntaxKind . SpreadElement :
return emitSpreadExpression ( < SpreadElement > node ) ;
case SyntaxKind . ClassExpression :
return emitClassExpression ( < ClassExpression > node ) ;
case SyntaxKind . OmittedExpression :
return ;
case SyntaxKind . AsExpression :
return emitAsExpression ( < AsExpression > node ) ;
case SyntaxKind . NonNullExpression :
return emitNonNullExpression ( < NonNullExpression > node ) ;
case SyntaxKind . MetaProperty :
return emitMetaProperty ( < MetaProperty > node ) ;
// JSX
case SyntaxKind . JsxElement :
return emitJsxElement ( < JsxElement > node ) ;
case SyntaxKind . JsxSelfClosingElement :
return emitJsxSelfClosingElement ( < JsxSelfClosingElement > node ) ;
case SyntaxKind . JsxFragment :
return emitJsxFragment ( < JsxFragment > node ) ;
// Transformation nodes
case SyntaxKind . PartiallyEmittedExpression :
return emitPartiallyEmittedExpression ( < PartiallyEmittedExpression > node ) ;
case SyntaxKind . CommaListExpression :
return emitCommaList ( < CommaListExpression > node ) ;
}
2017-03-15 19:44:36 +01:00
}
2016-06-07 19:32:03 +02:00
}
2015-02-07 05:16:35 +01:00
2018-05-04 01:04:52 +02:00
function emitMappedTypeParameter ( node : TypeParameterDeclaration ) : void {
emit ( node . name ) ;
writeSpace ( ) ;
writeKeyword ( "in" ) ;
writeSpace ( ) ;
emit ( node . constraint ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-17 00:39:14 +02:00
2018-09-07 23:11:54 +02:00
function pipelineEmitWithSubstitution ( hint : EmitHint , node : Node ) {
const pipelinePhase = getNextPipelinePhase ( PipelinePhase . Substitution , node ) ;
pipelinePhase ( hint , substituteNode ( hint , node ) ) ;
2017-02-09 22:10:17 +01:00
}
2019-02-02 02:15:17 +01:00
function getHelpersFromBundledSourceFiles ( bundle : Bundle ) : string [ ] | undefined {
let result : string [ ] | undefined ;
if ( module Kind === ModuleKind . None || printerOptions . noEmitHelpers ) {
return undefined ;
}
const bundledHelpers = createMap < boolean > ( ) ;
for ( const sourceFile of bundle . sourceFiles ) {
const shouldSkip = getExternalHelpersModuleName ( sourceFile ) !== undefined ;
const helpers = getSortedEmitHelpers ( sourceFile ) ;
if ( ! helpers ) continue ;
for ( const helper of helpers ) {
if ( ! helper . scoped && ! shouldSkip && ! bundledHelpers . get ( helper . name ) ) {
bundledHelpers . set ( helper . name , true ) ;
( result || ( result = [ ] ) ) . push ( helper . name ) ;
}
}
}
return result ;
}
2017-02-09 22:10:17 +01:00
2018-03-31 02:43:37 +02:00
function emitHelpers ( node : Node ) {
let helpersEmitted = false ;
const bundle = node . kind === SyntaxKind . Bundle ? < Bundle > node : undefined ;
if ( bundle && module Kind === ModuleKind . None ) {
return ;
}
2019-01-23 23:44:07 +01:00
const numPrepends = bundle ? bundle.prepends.length : 0 ;
const numNodes = bundle ? bundle . sourceFiles . length + numPrepends : 1 ;
2018-03-31 02:43:37 +02:00
for ( let i = 0 ; i < numNodes ; i ++ ) {
2019-01-23 23:44:07 +01:00
const currentNode = bundle ? i < numPrepends ? bundle . prepends [ i ] : bundle . sourceFiles [ i - numPrepends ] : node ;
const sourceFile = isSourceFile ( currentNode ) ? currentNode : isUnparsedSource ( currentNode ) ? undefined : currentSourceFile ! ;
const shouldSkip = printerOptions . noEmitHelpers || ( ! ! sourceFile && getExternalHelpersModuleName ( sourceFile ) !== undefined ) ;
const shouldBundle = ( isSourceFile ( currentNode ) || isUnparsedSource ( currentNode ) ) && ! isOwnFileEmit ;
const helpers = isUnparsedSource ( currentNode ) ? currentNode.helpers : getSortedEmitHelpers ( currentNode ) ;
2018-03-31 02:43:37 +02:00
if ( helpers ) {
2019-01-23 23:44:07 +01:00
for ( const helper of helpers ) {
2018-03-31 02:43:37 +02:00
if ( ! helper . scoped ) {
// Skip the helper if it can be skipped and the noEmitHelpers compiler
// option is set, or if it can be imported and the importHelpers compiler
// option is set.
if ( shouldSkip ) continue ;
// Skip the helper if it can be bundled but hasn't already been emitted and we
// are emitting a bundled module.
if ( shouldBundle ) {
if ( bundledHelpers . get ( helper . name ) ) {
continue ;
}
bundledHelpers . set ( helper . name , true ) ;
}
}
else if ( bundle ) {
// Skip the helper if it is scoped and we are emitting bundled helpers
continue ;
}
2019-01-26 01:39:38 +01:00
const pos = getTextPosWithWriteLine ( ) ;
2018-03-31 02:43:37 +02:00
if ( typeof helper . text === "string" ) {
writeLines ( helper . text ) ;
}
else {
2018-09-13 02:51:57 +02:00
writeLines ( helper . text ( makeFileLevelOptimisticUniqueName ) ) ;
2018-03-31 02:43:37 +02:00
}
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.EmitHelpers , data : helper.name } ) ;
2018-03-31 02:43:37 +02:00
helpersEmitted = true ;
}
}
2017-01-30 21:27:24 +01:00
}
2018-03-31 02:43:37 +02:00
return helpersEmitted ;
2017-01-30 21:27:24 +01:00
}
2019-01-23 23:44:07 +01:00
function getSortedEmitHelpers ( node : Node ) {
const helpers = getEmitHelpers ( node ) ;
return helpers && stableSort ( helpers , compareEmitHelpers ) ;
}
2016-06-07 19:32:03 +02:00
//
// Literals/Pseudo-literals
//
// SyntaxKind.NumericLiteral
2018-10-31 00:56:05 +01:00
// SyntaxKind.BigIntLiteral
function emitNumericOrBigIntLiteral ( node : NumericLiteral | BigIntLiteral ) {
2016-06-15 02:59:44 +02:00
emitLiteral ( node ) ;
}
2016-06-07 19:32:03 +02:00
// SyntaxKind.StringLiteral
// SyntaxKind.RegularExpressionLiteral
// SyntaxKind.NoSubstitutionTemplateLiteral
// SyntaxKind.TemplateHead
// SyntaxKind.TemplateMiddle
// SyntaxKind.TemplateTail
function emitLiteral ( node : LiteralLikeNode ) {
2018-09-17 20:06:39 +02:00
const text = getLiteralTextOfNode ( node , printerOptions . neverAsciiEscape ) ;
2017-01-30 21:27:24 +01:00
if ( ( printerOptions . sourceMap || printerOptions . inlineSourceMap )
2016-06-07 19:32:03 +02:00
&& ( node . kind === SyntaxKind . StringLiteral || isTemplateLiteralKind ( node . kind ) ) ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeLiteral ( text ) ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
else {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
// Quick info expects all literals to be called with writeStringLiteral, as there's no specific type for numberLiterals
writeStringLiteral ( text ) ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
}
2014-07-17 00:39:14 +02:00
2018-05-08 00:12:50 +02:00
// SyntaxKind.UnparsedSource
2019-02-15 18:46:37 +01:00
// SyntaxKind.UnparsedPrepend
function emitUnparsedSourceOrPrepend ( unparsed : UnparsedSource | UnparsedPrepend ) {
2019-01-31 19:40:46 +01:00
for ( const text of unparsed . texts ) {
2019-02-02 05:10:31 +01:00
writeLine ( ) ;
2019-01-31 19:40:46 +01:00
emit ( text ) ;
}
2018-05-08 00:12:50 +02:00
}
2019-01-17 21:11:51 +01:00
// SyntaxKind.UnparsedPrologue
2019-01-31 19:40:46 +01:00
// SyntaxKind.UnparsedText
2019-02-15 23:25:24 +01:00
// SyntaxKind.UnparsedInternalText
2019-02-15 18:46:37 +01:00
// SyntaxKind.UnparsedSourceMapUrl
2019-02-20 19:54:31 +01:00
// SyntaxKind.UnparsedSyntheticReference
2019-02-15 18:46:37 +01:00
function writeUnparsedNode ( unparsed : UnparsedNode ) {
2019-01-17 21:11:51 +01:00
writer . rawWrite ( unparsed . parent . text . substring ( unparsed . pos , unparsed . end ) ) ;
}
2019-02-15 18:46:37 +01:00
// SyntaxKind.UnparsedText
2019-02-15 23:25:24 +01:00
// SyntaxKind.UnparsedInternalText
2019-02-15 18:46:37 +01:00
// SyntaxKind.UnparsedSourceMapUrl
function emitUnparsedTextLike ( unparsed : UnparsedTextLike ) {
const pos = getTextPosWithWriteLine ( ) ;
writeUnparsedNode ( unparsed ) ;
if ( bundleFileInfo ) {
2019-02-15 23:25:24 +01:00
updateOrPushBundleFileTextLike (
2019-02-15 18:46:37 +01:00
pos ,
2019-02-15 23:25:24 +01:00
writer . getTextPos ( ) ,
unparsed . kind === SyntaxKind . UnparsedText ?
BundleFileSectionKind . Text :
unparsed . kind === SyntaxKind . UnparsedInternalText ?
BundleFileSectionKind . Internal :
BundleFileSectionKind . SourceMapUrl
) ;
2019-02-15 18:46:37 +01:00
}
}
2019-02-20 19:54:31 +01:00
// SyntaxKind.UnparsedSyntheticReference
function emitUnparsedSyntheticReference ( unparsed : UnparsedSyntheticReference ) {
2019-02-02 05:10:31 +01:00
const pos = getTextPosWithWriteLine ( ) ;
2019-02-15 18:46:37 +01:00
writeUnparsedNode ( unparsed ) ;
2019-02-02 05:10:31 +01:00
if ( bundleFileInfo ) {
const section = clone ( unparsed . section ) ;
section . pos = pos ;
section . end = writer . getTextPos ( ) ;
bundleFileInfo . sections . push ( section ) ;
}
}
2016-06-07 19:32:03 +02:00
//
// Identifiers
//
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitIdentifier ( node : Identifier ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
const writeText = node . symbol ? writeSymbol : write ;
writeText ( getTextOfNode ( node , /*includeTrivia*/ false ) , node . symbol ) ;
emitList ( node , node . typeArguments , ListFormat . TypeParameters ) ; // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments
2016-06-07 19:32:03 +02:00
}
2014-07-17 00:39:14 +02:00
2016-06-07 19:32:03 +02:00
//
// Names
//
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitQualifiedName ( node : QualifiedName ) {
emitEntityName ( node . left ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "." ) ;
2016-06-07 19:32:03 +02:00
emit ( node . right ) ;
}
function emitEntityName ( node : EntityName ) {
if ( node . kind === SyntaxKind . Identifier ) {
2018-02-17 03:38:00 +01:00
emitExpression ( node ) ;
2016-06-07 19:32:03 +02:00
}
else {
emit ( node ) ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitComputedPropertyName ( node : ComputedPropertyName ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "[" ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "]" ) ;
2016-06-07 19:32:03 +02:00
}
2015-06-26 01:24:41 +02:00
2016-06-07 19:32:03 +02:00
//
// Signature elements
//
2015-06-26 01:24:41 +02:00
2016-06-07 19:32:03 +02:00
function emitTypeParameter ( node : TypeParameterDeclaration ) {
emit ( node . name ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( node . constraint ) {
writeSpace ( ) ;
writeKeyword ( "extends" ) ;
writeSpace ( ) ;
emit ( node . constraint ) ;
}
if ( node . default ) {
writeSpace ( ) ;
writeOperator ( "=" ) ;
writeSpace ( ) ;
emit ( node . default ) ;
}
2016-06-07 19:32:03 +02:00
}
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitParameter ( node : ParameterDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
2018-05-04 01:04:52 +02:00
emit ( node . dotDotDotToken ) ;
emitNodeWithWriter ( node . name , writeParameter ) ;
emit ( node . questionToken ) ;
2017-09-26 21:42:08 +02:00
if ( node . parent && node . parent . kind === SyntaxKind . JSDocFunctionType && ! node . name ) {
2018-05-04 01:04:52 +02:00
emit ( node . type ) ;
2017-09-26 21:42:08 +02:00
}
else {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2017-09-26 21:42:08 +02:00
}
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
// The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer.
emitInitializer ( node . initializer , node . type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos , node ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitDecorator ( decorator : Decorator ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "@" ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( decorator . expression ) ;
}
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
//
// Type members
//
function emitPropertySignature ( node : PropertySignature ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitNodeWithWriter ( node . name , writeProperty ) ;
2018-05-04 01:04:52 +02:00
emit ( node . questionToken ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitPropertyDeclaration ( node : PropertyDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
emit ( node . name ) ;
2018-05-04 01:04:52 +02:00
emit ( node . questionToken ) ;
emit ( node . exclamationToken ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitInitializer ( node . initializer , node . type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end , node ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-23 19:06:44 +01:00
2016-06-07 19:32:03 +02:00
function emitMethodSignature ( node : MethodSignature ) {
2018-05-10 20:16:27 +02:00
pushNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
emit ( node . name ) ;
2018-05-04 01:04:52 +02:00
emit ( node . questionToken ) ;
2016-06-07 19:32:03 +02:00
emitTypeParameters ( node , node . typeParameters ) ;
emitParameters ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2018-05-10 20:16:27 +02:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-17 00:39:14 +02:00
2016-06-07 19:32:03 +02:00
function emitMethodDeclaration ( node : MethodDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
2018-05-04 01:04:52 +02:00
emit ( node . asteriskToken ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
2018-05-04 01:04:52 +02:00
emit ( node . questionToken ) ;
2016-06-07 19:32:03 +02:00
emitSignatureAndBody ( node , emitSignatureHead ) ;
}
2014-08-22 23:40:47 +02:00
2016-06-07 19:32:03 +02:00
function emitConstructor ( node : ConstructorDeclaration ) {
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "constructor" ) ;
2016-06-07 19:32:03 +02:00
emitSignatureAndBody ( node , emitSignatureHead ) ;
}
2014-07-13 01:04:16 +02:00
2016-06-07 19:32:03 +02:00
function emitAccessorDeclaration ( node : AccessorDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( node . kind === SyntaxKind . GetAccessor ? "get" : "set" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
emitSignatureAndBody ( node , emitSignatureHead ) ;
}
2014-08-15 00:41:57 +02:00
2016-06-07 19:32:03 +02:00
function emitCallSignature ( node : CallSignatureDeclaration ) {
2018-05-10 20:16:27 +02:00
pushNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
emitTypeParameters ( node , node . typeParameters ) ;
emitParameters ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2018-05-10 20:16:27 +02:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-07 00:28:06 +01:00
2016-06-07 19:32:03 +02:00
function emitConstructSignature ( node : ConstructSignatureDeclaration ) {
2018-05-10 20:16:27 +02:00
pushNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "new" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitTypeParameters ( node , node . typeParameters ) ;
emitParameters ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2018-05-10 20:16:27 +02:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-07 00:28:06 +01:00
2016-06-07 19:32:03 +02:00
function emitIndexSignature ( node : IndexSignatureDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
emitParametersForIndexSignature ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-24 21:33:35 +01:00
2016-10-10 22:06:58 +02:00
function emitSemicolonClassElement() {
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2016-06-07 19:32:03 +02:00
//
// Types
//
2014-07-13 01:04:16 +02:00
2016-06-07 19:32:03 +02:00
function emitTypePredicate ( node : TypePredicateNode ) {
emit ( node . parameterName ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writeKeyword ( "is" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . type ) ;
}
2015-01-07 00:28:06 +01:00
2016-06-07 19:32:03 +02:00
function emitTypeReference ( node : TypeReferenceNode ) {
emit ( node . typeName ) ;
emitTypeArguments ( node , node . typeArguments ) ;
}
2014-11-21 05:24:08 +01:00
2016-06-07 19:32:03 +02:00
function emitFunctionType ( node : FunctionTypeNode ) {
2018-05-10 20:16:27 +02:00
pushNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
emitTypeParameters ( node , node . typeParameters ) ;
emitParametersForArrow ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "=>" ) ;
writeSpace ( ) ;
2018-05-04 01:04:52 +02:00
emit ( node . type ) ;
2018-05-10 20:16:27 +02:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2017-09-26 21:42:08 +02:00
function emitJSDocFunctionType ( node : JSDocFunctionType ) {
2018-08-22 21:42:36 +02:00
writeKeyword ( "function" ) ;
2017-09-26 21:42:08 +02:00
emitParameters ( node , node . parameters ) ;
2018-08-22 21:42:36 +02:00
writePunctuation ( ":" ) ;
2018-05-04 01:04:52 +02:00
emit ( node . type ) ;
2017-09-26 21:42:08 +02:00
}
2017-09-25 17:56:51 +02:00
function emitJSDocNullableType ( node : JSDocNullableType ) {
2018-08-22 21:42:36 +02:00
writePunctuation ( "?" ) ;
2017-09-25 17:56:51 +02:00
emit ( node . type ) ;
}
function emitJSDocNonNullableType ( node : JSDocNonNullableType ) {
2018-08-22 21:42:36 +02:00
writePunctuation ( "!" ) ;
2017-09-25 17:56:51 +02:00
emit ( node . type ) ;
}
function emitJSDocOptionalType ( node : JSDocOptionalType ) {
emit ( node . type ) ;
2018-08-22 21:42:36 +02:00
writePunctuation ( "=" ) ;
2017-09-25 17:56:51 +02:00
}
2016-06-07 19:32:03 +02:00
function emitConstructorType ( node : ConstructorTypeNode ) {
2018-05-10 20:16:27 +02:00
pushNameGenerationScope ( node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "new" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitTypeParameters ( node , node . typeParameters ) ;
2017-06-08 00:13:24 +02:00
emitParameters ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "=>" ) ;
writeSpace ( ) ;
2018-05-04 01:04:52 +02:00
emit ( node . type ) ;
2018-05-10 20:16:27 +02:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2014-08-22 23:17:52 +02:00
2016-06-07 19:32:03 +02:00
function emitTypeQuery ( node : TypeQueryNode ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "typeof" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . exprName ) ;
}
2015-06-18 23:01:49 +02:00
2016-06-07 19:32:03 +02:00
function emitTypeLiteral ( node : TypeLiteralNode ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "{" ) ;
2017-09-07 23:30:19 +02:00
const flags = getEmitFlags ( node ) & EmitFlags . SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers ;
emitList ( node , node . members , flags | ListFormat . NoSpaceIfEmpty ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
2015-06-18 23:01:49 +02:00
2016-06-07 19:32:03 +02:00
function emitArrayType ( node : ArrayTypeNode ) {
emit ( node . elementType ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "[" ) ;
writePunctuation ( "]" ) ;
2016-06-07 19:32:03 +02:00
}
2015-06-18 23:01:49 +02:00
2018-06-15 20:43:16 +02:00
function emitRestOrJSDocVariadicType ( node : RestTypeNode | JSDocVariadicType ) {
2018-08-22 21:42:36 +02:00
writePunctuation ( "..." ) ;
2017-09-25 17:56:51 +02:00
emit ( node . type ) ;
}
2016-06-07 19:32:03 +02:00
function emitTupleType ( node : TupleTypeNode ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "[" ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . elementTypes , ListFormat . TupleTypeElements ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "]" ) ;
2016-06-07 19:32:03 +02:00
}
2015-06-18 23:01:49 +02:00
2018-06-09 21:19:11 +02:00
function emitOptionalType ( node : OptionalTypeNode ) {
emit ( node . type ) ;
2018-08-22 21:42:36 +02:00
writePunctuation ( "?" ) ;
2018-06-09 21:19:11 +02:00
}
2016-06-07 19:32:03 +02:00
function emitUnionType ( node : UnionTypeNode ) {
emitList ( node , node . types , ListFormat . UnionTypeConstituents ) ;
}
2015-06-18 23:01:49 +02:00
2016-06-07 19:32:03 +02:00
function emitIntersectionType ( node : IntersectionTypeNode ) {
emitList ( node , node . types , ListFormat . IntersectionTypeConstituents ) ;
}
2016-01-29 08:29:08 +01:00
2017-12-05 23:18:11 +01:00
function emitConditionalType ( node : ConditionalTypeNode ) {
2018-01-15 16:59:46 +01:00
emit ( node . checkType ) ;
2018-02-03 20:32:24 +01:00
writeSpace ( ) ;
writeKeyword ( "extends" ) ;
writeSpace ( ) ;
2018-01-15 16:59:46 +01:00
emit ( node . extendsType ) ;
2018-02-03 20:32:24 +01:00
writeSpace ( ) ;
writePunctuation ( "?" ) ;
writeSpace ( ) ;
2017-12-05 23:18:11 +01:00
emit ( node . trueType ) ;
2018-02-03 20:32:24 +01:00
writeSpace ( ) ;
writePunctuation ( ":" ) ;
writeSpace ( ) ;
2017-12-05 23:18:11 +01:00
emit ( node . falseType ) ;
}
2018-01-25 21:25:00 +01:00
function emitInferType ( node : InferTypeNode ) {
2018-02-03 20:32:24 +01:00
writeKeyword ( "infer" ) ;
writeSpace ( ) ;
2018-01-25 21:25:00 +01:00
emit ( node . typeParameter ) ;
}
2016-06-07 19:32:03 +02:00
function emitParenthesizedType ( node : ParenthesizedTypeNode ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "(" ) ;
2016-06-07 19:32:03 +02:00
emit ( node . type ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ")" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-03 02:02:26 +02:00
2016-10-10 22:06:58 +02:00
function emitThisType() {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "this" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-03 02:02:26 +02:00
2016-10-25 00:24:26 +02:00
function emitTypeOperator ( node : TypeOperatorNode ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeTokenText ( node . operator , writeKeyword ) ;
writeSpace ( ) ;
2016-10-25 00:24:26 +02:00
emit ( node . type ) ;
}
2016-11-11 00:20:29 +01:00
function emitIndexedAccessType ( node : IndexedAccessTypeNode ) {
2016-10-25 23:32:20 +02:00
emit ( node . objectType ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "[" ) ;
2016-10-26 22:39:12 +02:00
emit ( node . indexType ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "]" ) ;
2016-10-25 23:32:20 +02:00
}
2016-11-11 00:20:29 +01:00
function emitMappedType ( node : MappedTypeNode ) {
2017-05-09 22:14:39 +02:00
const emitFlags = getEmitFlags ( node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "{" ) ;
2017-05-09 22:14:39 +02:00
if ( emitFlags & EmitFlags . SingleLine ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-05-09 22:14:39 +02:00
}
else {
writeLine ( ) ;
increaseIndent ( ) ;
}
2017-09-07 23:30:19 +02:00
if ( node . readonlyToken ) {
emit ( node . readonlyToken ) ;
2018-02-13 01:20:49 +01:00
if ( node . readonlyToken . kind !== SyntaxKind . ReadonlyKeyword ) {
writeKeyword ( "readonly" ) ;
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-09-07 23:30:19 +02:00
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "[" ) ;
2018-05-04 01:04:52 +02:00
2018-09-07 23:11:54 +02:00
const pipelinePhase = getPipelinePhase ( PipelinePhase . Notification , node . typeParameter ) ;
2018-05-04 01:04:52 +02:00
pipelinePhase ( EmitHint . MappedTypeParameter , node . typeParameter ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "]" ) ;
2018-02-13 01:20:49 +01:00
if ( node . questionToken ) {
emit ( node . questionToken ) ;
if ( node . questionToken . kind !== SyntaxKind . QuestionToken ) {
writePunctuation ( "?" ) ;
}
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ":" ) ;
writeSpace ( ) ;
2018-05-04 01:04:52 +02:00
emit ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2017-05-09 22:14:39 +02:00
if ( emitFlags & EmitFlags . SingleLine ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-05-09 22:14:39 +02:00
}
else {
writeLine ( ) ;
decreaseIndent ( ) ;
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-11-11 00:20:29 +01:00
}
2016-08-02 20:45:56 +02:00
function emitLiteralType ( node : LiteralTypeNode ) {
emitExpression ( node . literal ) ;
}
2014-10-11 01:44:14 +02:00
2018-04-02 19:18:23 +02:00
function emitImportTypeNode ( node : ImportTypeNode ) {
if ( node . isTypeOf ) {
writeKeyword ( "typeof" ) ;
writeSpace ( ) ;
}
writeKeyword ( "import" ) ;
writePunctuation ( "(" ) ;
emit ( node . argument ) ;
writePunctuation ( ")" ) ;
if ( node . qualifier ) {
writePunctuation ( "." ) ;
emit ( node . qualifier ) ;
}
emitTypeArguments ( node , node . typeArguments ) ;
}
2016-06-07 19:32:03 +02:00
//
// Binding patterns
//
2015-04-03 02:23:25 +02:00
2016-06-07 19:32:03 +02:00
function emitObjectBindingPattern ( node : ObjectBindingPattern ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "{" ) ;
2018-01-09 22:15:47 +01:00
emitList ( node , node . elements , ListFormat . ObjectBindingPatternElements ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
2014-08-22 02:17:02 +02:00
2016-06-07 19:32:03 +02:00
function emitArrayBindingPattern ( node : ArrayBindingPattern ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "[" ) ;
2018-01-09 22:15:47 +01:00
emitList ( node , node . elements , ListFormat . ArrayBindingPatternElements ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "]" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-03 02:23:25 +02:00
2016-06-07 19:32:03 +02:00
function emitBindingElement ( node : BindingElement ) {
2018-05-04 01:04:52 +02:00
emit ( node . dotDotDotToken ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( node . propertyName ) {
emit ( node . propertyName ) ;
writePunctuation ( ":" ) ;
writeSpace ( ) ;
}
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitInitializer ( node . initializer , node . name . end , node ) ;
2016-06-07 19:32:03 +02:00
}
2016-02-04 23:18:23 +01:00
2016-06-07 19:32:03 +02:00
//
// Expressions
//
2015-03-10 20:12:41 +01:00
2016-06-07 19:32:03 +02:00
function emitArrayLiteralExpression ( node : ArrayLiteralExpression ) {
const elements = node . elements ;
2017-09-07 23:30:19 +02:00
const preferNewLine = node . multiLine ? ListFormat.PreferNewLine : ListFormat.None ;
emitExpressionList ( node , elements , ListFormat . ArrayLiteralExpressionElements | preferNewLine ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-31 22:23:46 +02:00
2016-06-07 19:32:03 +02:00
function emitObjectLiteralExpression ( node : ObjectLiteralExpression ) {
2018-05-02 22:34:14 +02:00
forEach ( node . properties , generateMemberNames ) ;
2017-09-07 23:30:19 +02:00
const indentedFlag = getEmitFlags ( node ) & EmitFlags . Indented ;
if ( indentedFlag ) {
increaseIndent ( ) ;
2015-03-17 21:41:29 +01:00
}
2015-03-23 22:09:38 +01:00
2017-09-07 23:30:19 +02:00
const preferNewLine = node . multiLine ? ListFormat.PreferNewLine : ListFormat.None ;
2018-11-10 02:18:34 +01:00
const allowTrailingComma = currentSourceFile ! . languageVersion >= ScriptTarget . ES5 && ! isJsonSourceFile ( currentSourceFile ! ) ? ListFormat.AllowTrailingComma : ListFormat.None ;
2017-09-07 23:30:19 +02:00
emitList ( node , node . properties , ListFormat . ObjectLiteralExpressionProperties | allowTrailingComma | preferNewLine ) ;
2015-04-03 02:23:25 +02:00
2017-09-07 23:30:19 +02:00
if ( indentedFlag ) {
decreaseIndent ( ) ;
2014-08-22 02:17:02 +02:00
}
2016-06-07 19:32:03 +02:00
}
2014-08-22 02:17:02 +02:00
2016-06-07 19:32:03 +02:00
function emitPropertyAccessExpression ( node : PropertyAccessExpression ) {
2016-07-11 21:41:12 +02:00
let indentBeforeDot = false ;
let indentAfterDot = false ;
2018-12-07 03:06:59 +01:00
const dotRangeFirstCommentStart = skipTrivia (
currentSourceFile ! . text ,
node . expression . end ,
/*stopAfterLineBreak*/ false ,
/*stopAtComments*/ true
) ;
const dotRangeStart = skipTrivia ( currentSourceFile ! . text , dotRangeFirstCommentStart ) ;
const dotRangeEnd = dotRangeStart + 1 ;
2016-09-26 20:20:24 +02:00
if ( ! ( getEmitFlags ( node ) & EmitFlags . NoIndentation ) ) {
2017-08-10 21:52:15 +02:00
const dotToken = createToken ( SyntaxKind . DotToken ) ;
2018-12-07 03:06:59 +01:00
dotToken . pos = node . expression . end ;
2017-08-10 21:52:15 +02:00
dotToken . end = dotRangeEnd ;
2016-07-11 21:41:12 +02:00
indentBeforeDot = needsIndentation ( node , node . expression , dotToken ) ;
indentAfterDot = needsIndentation ( node , dotToken , node . name ) ;
}
2016-02-23 01:10:32 +01:00
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentBeforeDot , /*writeSpaceIfNotIndenting*/ false ) ;
2016-09-27 02:53:46 +02:00
2018-12-07 03:06:59 +01:00
const dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart ;
const shouldEmitDotDot = ! indentBeforeDot && needsDotDotForPropertyAccess ( node . expression , dotHasCommentTrivia ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
if ( shouldEmitDotDot ) {
writePunctuation ( "." ) ;
}
emitTokenWithComment ( SyntaxKind . DotToken , node . expression . end , writePunctuation , node ) ;
2016-09-27 02:53:46 +02:00
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentAfterDot , /*writeSpaceIfNotIndenting*/ false ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
decreaseIndentIf ( indentBeforeDot , indentAfterDot ) ;
}
2015-03-12 18:27:46 +01:00
2016-06-07 19:32:03 +02:00
// 1..toString is a valid property access, emit a dot after the literal
// Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal
2018-12-07 03:06:59 +01:00
function needsDotDotForPropertyAccess ( expression : Expression , dotHasTrivia : boolean ) {
2017-04-03 23:02:14 +02:00
expression = skipPartiallyEmittedExpressions ( expression ) ;
if ( isNumericLiteral ( expression ) ) {
2017-01-24 22:42:05 +01:00
// check if numeric literal is a decimal literal that was originally written with a dot
2018-09-17 20:06:39 +02:00
const text = getLiteralTextOfNode ( < LiteralExpression > expression , /*neverAsciiEscape*/ true ) ;
2018-12-07 03:06:59 +01:00
// If he number will be printed verbatim and it doesn't already contain a dot, add one
// if the expression doesn't have any comments that will be emitted.
return ! expression . numericLiteralFlags && ! stringContains ( text , tokenToString ( SyntaxKind . DotToken ) ! ) &&
( ! dotHasTrivia || printerOptions . removeComments ) ;
2014-08-19 19:43:13 +02:00
}
2016-09-29 03:57:17 +02:00
else if ( isPropertyAccessExpression ( expression ) || isElementAccessExpression ( expression ) ) {
2016-06-07 19:32:03 +02:00
// check if constant enum value is integer
2016-09-27 02:53:46 +02:00
const constantValue = getConstantValue ( expression ) ;
2016-06-07 19:32:03 +02:00
// isFinite handles cases when constantValue is undefined
2017-04-29 17:37:33 +02:00
return typeof constantValue === "number" && isFinite ( constantValue )
2016-09-27 02:53:46 +02:00
&& Math . floor ( constantValue ) === constantValue
2017-01-30 21:27:24 +01:00
&& printerOptions . removeComments ;
2015-03-17 21:41:29 +01:00
}
2016-06-07 19:32:03 +02:00
}
2015-06-18 23:01:49 +02:00
2016-06-07 19:32:03 +02:00
function emitElementAccessExpression ( node : ElementAccessExpression ) {
emitExpression ( node . expression ) ;
2018-04-25 22:30:34 +02:00
emitTokenWithComment ( SyntaxKind . OpenBracketToken , node . expression . end , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . argumentExpression ) ;
2018-04-25 22:30:34 +02:00
emitTokenWithComment ( SyntaxKind . CloseBracketToken , node . argumentExpression . end , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-24 22:16:52 +01:00
2016-06-07 19:32:03 +02:00
function emitCallExpression ( node : CallExpression ) {
emitExpression ( node . expression ) ;
2016-10-15 03:10:34 +02:00
emitTypeArguments ( node , node . typeArguments ) ;
2016-06-07 19:32:03 +02:00
emitExpressionList ( node , node . arguments , ListFormat . CallExpressionArguments ) ;
}
2016-01-28 01:13:51 +01:00
2016-06-07 19:32:03 +02:00
function emitNewExpression ( node : NewExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . NewKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
2016-10-15 03:10:34 +02:00
emitTypeArguments ( node , node . typeArguments ) ;
2016-06-07 19:32:03 +02:00
emitExpressionList ( node , node . arguments , ListFormat . NewExpressionArguments ) ;
}
2015-04-02 02:58:28 +02:00
2016-06-07 19:32:03 +02:00
function emitTaggedTemplateExpression ( node : TaggedTemplateExpression ) {
emitExpression ( node . tag ) ;
2018-04-14 08:15:02 +02:00
emitTypeArguments ( node , node . typeArguments ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . template ) ;
}
2015-04-02 02:58:28 +02:00
2016-06-07 19:32:03 +02:00
function emitTypeAssertionExpression ( node : TypeAssertion ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "<" ) ;
2017-01-30 21:27:24 +01:00
emit ( node . type ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ">" ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
}
2015-03-24 22:16:52 +01:00
2016-06-07 19:32:03 +02:00
function emitParenthesizedExpression ( node : ParenthesizedExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . OpenParenToken , node . pos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression ? node.expression.end : openParenPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-17 21:41:29 +01:00
2016-06-07 19:32:03 +02:00
function emitFunctionExpression ( node : FunctionExpression ) {
2018-05-02 22:34:14 +02:00
generateNameIfNeeded ( node . name ) ;
2016-06-07 19:32:03 +02:00
emitFunctionDeclarationOrExpression ( node ) ;
}
2015-04-02 02:58:28 +02:00
2016-06-07 19:32:03 +02:00
function emitArrowFunction ( node : ArrowFunction ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
emitSignatureAndBody ( node , emitArrowFunctionHead ) ;
}
2015-03-18 01:09:39 +01:00
2016-06-07 19:32:03 +02:00
function emitArrowFunctionHead ( node : ArrowFunction ) {
emitTypeParameters ( node , node . typeParameters ) ;
emitParametersForArrow ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
writeSpace ( ) ;
2017-09-07 23:30:19 +02:00
emit ( node . equalsGreaterThanToken ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-18 01:09:39 +01:00
2016-06-07 19:32:03 +02:00
function emitDeleteExpression ( node : DeleteExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . DeleteKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitTypeOfExpression ( node : TypeOfExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . TypeOfKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitVoidExpression ( node : VoidExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . VoidKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitAwaitExpression ( node : AwaitExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . AwaitKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitPrefixUnaryExpression ( node : PrefixUnaryExpression ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeTokenText ( node . operator , writeOperator ) ;
2016-06-07 19:32:03 +02:00
if ( shouldEmitWhitespaceBeforeOperand ( node ) ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2015-06-19 19:32:10 +02:00
}
2016-06-07 19:32:03 +02:00
emitExpression ( node . operand ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function shouldEmitWhitespaceBeforeOperand ( node : PrefixUnaryExpression ) {
// In some cases, we need to emit a space between the operator and the operand. One obvious case
// is when the operator is an identifier, like delete or typeof. We also need to do this for plus
// and minus expressions in certain cases. Specifically, consider the following two cases (parens
// are just for clarity of exposition, and not part of the source code):
//
// (+(+1))
// (+(++1))
//
// We need to emit a space in both cases. In the first case, the absence of a space will make
// the resulting expression a prefix increment operation. And in the second, it will make the resulting
// expression a prefix increment whose operand is a plus expression - (++(+x))
// The same is true of minus of course.
const operand = node . operand ;
return operand . kind === SyntaxKind . PrefixUnaryExpression
&& ( ( node . operator === SyntaxKind . PlusToken && ( ( < PrefixUnaryExpression > operand ) . operator === SyntaxKind . PlusToken || ( < PrefixUnaryExpression > operand ) . operator === SyntaxKind . PlusPlusToken ) )
2017-05-19 19:18:42 +02:00
|| ( node . operator === SyntaxKind . MinusToken && ( ( < PrefixUnaryExpression > operand ) . operator === SyntaxKind . MinusToken || ( < PrefixUnaryExpression > operand ) . operator === SyntaxKind . MinusMinusToken ) ) ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-17 00:13:31 +02:00
2016-06-07 19:32:03 +02:00
function emitPostfixUnaryExpression ( node : PostfixUnaryExpression ) {
emitExpression ( node . operand ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeTokenText ( node . operator , writeOperator ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitBinaryExpression ( node : BinaryExpression ) {
const isCommaOperator = node . operatorToken . kind !== SyntaxKind . CommaToken ;
const indentBeforeOperator = needsIndentation ( node , node . left , node . operatorToken ) ;
const indentAfterOperator = needsIndentation ( node , node . operatorToken , node . right ) ;
emitExpression ( node . left ) ;
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentBeforeOperator , isCommaOperator ) ;
2017-08-05 04:12:13 +02:00
emitLeadingCommentsOfPosition ( node . operatorToken . pos ) ;
2018-08-22 21:42:36 +02:00
writeTokenNode ( node . operatorToken , node . operatorToken . kind === SyntaxKind . InKeyword ? writeKeyword : writeOperator ) ;
2017-08-09 23:27:37 +02:00
emitTrailingCommentsOfPosition ( node . operatorToken . end , /*prefixSpace*/ true ) ; // Binary operators should have a space before the comment starts
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentAfterOperator , /*writeSpaceIfNotIndenting*/ true ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . right ) ;
decreaseIndentIf ( indentBeforeOperator , indentAfterOperator ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitConditionalExpression ( node : ConditionalExpression ) {
const indentBeforeQuestion = needsIndentation ( node , node . condition , node . questionToken ) ;
const indentAfterQuestion = needsIndentation ( node , node . questionToken , node . whenTrue ) ;
const indentBeforeColon = needsIndentation ( node , node . whenTrue , node . colonToken ) ;
const indentAfterColon = needsIndentation ( node , node . colonToken , node . whenFalse ) ;
emitExpression ( node . condition ) ;
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentBeforeQuestion , /*writeSpaceIfNotIndenting*/ true ) ;
2017-09-07 23:30:19 +02:00
emit ( node . questionToken ) ;
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentAfterQuestion , /*writeSpaceIfNotIndenting*/ true ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . whenTrue ) ;
decreaseIndentIf ( indentBeforeQuestion , indentAfterQuestion ) ;
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentBeforeColon , /*writeSpaceIfNotIndenting*/ true ) ;
2017-09-07 23:30:19 +02:00
emit ( node . colonToken ) ;
2018-08-22 21:42:36 +02:00
increaseIndentIf ( indentAfterColon , /*writeSpaceIfNotIndenting*/ true ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . whenFalse ) ;
decreaseIndentIf ( indentBeforeColon , indentAfterColon ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitTemplateExpression ( node : TemplateExpression ) {
emit ( node . head ) ;
emitList ( node , node . templateSpans , ListFormat . TemplateExpressionSpans ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitYieldExpression ( node : YieldExpression ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . YieldKeyword , node . pos , writeKeyword , node ) ;
2018-05-04 01:04:52 +02:00
emit ( node . asteriskToken ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitExpressionWithLeadingSpace ( node . expression ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
2016-11-07 17:36:03 +01:00
function emitSpreadExpression ( node : SpreadElement ) {
2018-11-14 23:20:07 +01:00
emitTokenWithComment ( SyntaxKind . DotDotDotToken , node . pos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitClassExpression ( node : ClassExpression ) {
2018-05-02 22:34:14 +02:00
generateNameIfNeeded ( node . name ) ;
2016-06-07 19:32:03 +02:00
emitClassDeclarationOrExpression ( node ) ;
}
function emitExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) {
emitExpression ( node . expression ) ;
emitTypeArguments ( node , node . typeArguments ) ;
}
function emitAsExpression ( node : AsExpression ) {
emitExpression ( node . expression ) ;
if ( node . type ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writeKeyword ( "as" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . type ) ;
2015-06-19 19:32:10 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitNonNullExpression ( node : NonNullExpression ) {
emitExpression ( node . expression ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeOperator ( "!" ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
2016-12-09 02:31:18 +01:00
function emitMetaProperty ( node : MetaProperty ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeToken ( node . keywordToken , node . pos , writePunctuation ) ;
writePunctuation ( "." ) ;
2016-12-09 02:31:18 +01:00
emit ( node . name ) ;
}
2016-06-07 19:32:03 +02:00
//
// Misc
//
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitTemplateSpan ( node : TemplateSpan ) {
emitExpression ( node . expression ) ;
emit ( node . literal ) ;
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
//
// Statements
//
2015-07-27 13:52:57 +02:00
2016-10-10 22:06:58 +02:00
function emitBlock ( node : Block ) {
2017-09-18 19:05:44 +02:00
emitBlockStatements ( node , /*forceSingleLine*/ ! node . multiLine && isEmptyBlock ( node ) ) ;
2016-06-07 19:32:03 +02:00
}
2014-08-22 23:40:47 +02:00
2017-09-18 19:05:44 +02:00
function emitBlockStatements ( node : BlockLike , forceSingleLine : boolean ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenBraceToken , node . pos , writePunctuation , /*contextNode*/ node ) ;
2017-09-18 19:05:44 +02:00
const format = forceSingleLine || getEmitFlags ( node ) & EmitFlags . SingleLine ? ListFormat.SingleLineBlockStatements : ListFormat.MultiLineBlockStatements ;
emitList ( node , node . statements , format ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseBraceToken , node . statements . end , writePunctuation , /*contextNode*/ node , /*indentLeading*/ ! ! ( format & ListFormat . MultiLine ) ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-23 00:58:00 +01:00
2016-06-07 19:32:03 +02:00
function emitVariableStatement ( node : VariableStatement ) {
emitModifiers ( node , node . modifiers ) ;
emit ( node . declarationList ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-23 00:58:00 +01:00
2018-08-22 21:42:36 +02:00
function emitEmptyStatement ( isEmbeddedStatement : boolean ) {
// While most trailing semicolons are possibly insignificant, an embedded "empty"
// statement is significant and cannot be elided by a trailing-semicolon-omitting writer.
if ( isEmbeddedStatement ) {
writePunctuation ( ";" ) ;
}
else {
writeTrailingSemicolon ( ) ;
}
2016-06-07 19:32:03 +02:00
}
2015-11-23 21:55:29 +01:00
2018-08-22 21:42:36 +02:00
2016-06-07 19:32:03 +02:00
function emitExpressionStatement ( node : ExpressionStatement ) {
emitExpression ( node . expression ) ;
2018-08-31 22:05:52 +02:00
// Emit semicolon in non json files
// or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
2018-11-10 02:18:34 +01:00
if ( ! isJsonSourceFile ( currentSourceFile ! ) || nodeIsSynthesized ( node . expression ) ) {
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2017-01-17 22:51:00 +01:00
}
2016-06-07 19:32:03 +02:00
}
function emitIfStatement ( node : IfStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . IfKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression . end , writePunctuation , node ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . thenStatement ) ;
2016-06-07 19:32:03 +02:00
if ( node . elseStatement ) {
2016-12-05 21:30:14 +01:00
writeLineOrSpace ( node ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . ElseKeyword , node . thenStatement . end , writeKeyword , node ) ;
2016-06-07 19:32:03 +02:00
if ( node . elseStatement . kind === SyntaxKind . IfStatement ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . elseStatement ) ;
2014-08-22 23:40:47 +02:00
}
2016-06-07 19:32:03 +02:00
else {
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . elseStatement ) ;
2015-02-13 03:05:02 +01:00
}
2015-01-22 23:45:55 +01:00
}
2016-06-07 19:32:03 +02:00
}
2014-08-22 23:40:47 +02:00
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
function emitWhileClause ( node : WhileStatement | DoStatement , startPos : number ) {
const openParenPos = emitTokenWithComment ( SyntaxKind . WhileKeyword , startPos , writeKeyword , node ) ;
writeSpace ( ) ;
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
emitExpression ( node . expression ) ;
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression . end , writePunctuation , node ) ;
}
2016-06-07 19:32:03 +02:00
function emitDoStatement ( node : DoStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . DoKeyword , node . pos , writeKeyword , node ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . statement ) ;
2016-06-07 19:32:03 +02:00
if ( isBlock ( node . statement ) ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2014-07-18 23:40:47 +02:00
}
2016-06-07 19:32:03 +02:00
else {
2016-12-05 21:30:14 +01:00
writeLineOrSpace ( node ) ;
2014-07-18 23:40:47 +02:00
}
2014-07-16 19:49:11 +02:00
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitWhileClause ( node , node . statement . end ) ;
writePunctuation ( ";" ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2016-06-07 19:32:03 +02:00
function emitWhileStatement ( node : WhileStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitWhileClause ( node , node . pos ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . statement ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-23 00:58:00 +01:00
2016-06-07 19:32:03 +02:00
function emitForStatement ( node : ForStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . ForKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
let pos = emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , /*contextNode*/ node ) ;
2016-06-07 19:32:03 +02:00
emitForBinding ( node . initializer ) ;
2018-08-22 21:42:36 +02:00
pos = emitTokenWithComment ( SyntaxKind . SemicolonToken , node . initializer ? node.initializer.end : pos , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitExpressionWithLeadingSpace ( node . condition ) ;
2018-08-22 21:42:36 +02:00
pos = emitTokenWithComment ( SyntaxKind . SemicolonToken , node . condition ? node.condition.end : pos , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitExpressionWithLeadingSpace ( node . incrementor ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . incrementor ? node.incrementor.end : pos , writePunctuation , node ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . statement ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-13 22:57:26 +02:00
2016-06-07 19:32:03 +02:00
function emitForInStatement ( node : ForInStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . ForKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitForBinding ( node . initializer ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . InKeyword , node . initializer . end , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression . end , writePunctuation , node ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . statement ) ;
2016-06-07 19:32:03 +02:00
}
2015-11-23 21:55:29 +01:00
2016-06-07 19:32:03 +02:00
function emitForOfStatement ( node : ForOfStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . ForKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
emitWithTrailingSpace ( node . awaitModifier ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitForBinding ( node . initializer ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OfKeyword , node . initializer . end , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression . end , writePunctuation , node ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . statement ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2018-05-22 23:46:57 +02:00
function emitForBinding ( node : VariableDeclarationList | Expression | undefined ) {
2016-06-07 19:32:03 +02:00
if ( node !== undefined ) {
if ( node . kind === SyntaxKind . VariableDeclarationList ) {
emit ( node ) ;
2014-08-14 18:01:38 +02:00
}
2016-06-07 19:32:03 +02:00
else {
2018-02-17 03:38:00 +01:00
emitExpression ( node ) ;
2015-03-25 05:54:36 +01:00
}
2016-06-07 19:32:03 +02:00
}
}
2015-04-13 22:57:26 +02:00
2016-06-07 19:32:03 +02:00
function emitContinueStatement ( node : ContinueStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . ContinueKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitWithLeadingSpace ( node . label ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-02-14 09:48:46 +01:00
2016-06-07 19:32:03 +02:00
function emitBreakStatement ( node : BreakStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . BreakKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitWithLeadingSpace ( node . label ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-02-14 09:48:46 +01:00
2018-03-23 22:13:40 +01:00
function emitTokenWithComment ( token : SyntaxKind , pos : number , writer : ( s : string ) = > void , contextNode : Node , indentLeading? : boolean ) {
const node = getParseTreeNode ( contextNode ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const isSimilarNode = node && node . kind === contextNode . kind ;
const startPos = pos ;
if ( isSimilarNode ) {
2018-11-10 02:18:34 +01:00
pos = skipTrivia ( currentSourceFile ! . text , pos ) ;
2017-08-09 04:53:53 +02:00
}
2018-03-23 22:13:40 +01:00
if ( emitLeadingCommentsOfPosition && isSimilarNode && contextNode . pos !== startPos ) {
2018-11-10 02:18:34 +01:00
const needsIndent = indentLeading && ! positionsAreOnSameLine ( startPos , pos , currentSourceFile ! ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
if ( needsIndent ) {
increaseIndent ( ) ;
}
emitLeadingCommentsOfPosition ( startPos ) ;
if ( needsIndent ) {
decreaseIndent ( ) ;
}
}
pos = writeTokenText ( token , writer , pos ) ;
2018-03-23 22:13:40 +01:00
if ( emitTrailingCommentsOfPosition && isSimilarNode && contextNode . end !== pos ) {
2017-08-09 04:53:53 +02:00
emitTrailingCommentsOfPosition ( pos , /*prefixSpace*/ true ) ;
}
return pos ;
}
2016-06-07 19:32:03 +02:00
function emitReturnStatement ( node : ReturnStatement ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTokenWithComment ( SyntaxKind . ReturnKeyword , node . pos , writeKeyword , /*contextNode*/ node ) ;
emitExpressionWithLeadingSpace ( node . expression ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-10-11 10:12:26 +02:00
2016-06-07 19:32:03 +02:00
function emitWithStatement ( node : WithStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . WithKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression . end , writePunctuation , node ) ;
2016-12-05 21:30:14 +01:00
emitEmbeddedStatement ( node , node . statement ) ;
2016-06-07 19:32:03 +02:00
}
2015-10-01 00:45:23 +02:00
2016-06-07 19:32:03 +02:00
function emitSwitchStatement ( node : SwitchStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . SwitchKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . expression . end , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . caseBlock ) ;
}
2014-07-17 00:39:14 +02:00
2016-06-07 19:32:03 +02:00
function emitLabeledStatement ( node : LabeledStatement ) {
emit ( node . label ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . ColonToken , node . label . end , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . statement ) ;
}
2014-07-17 00:39:14 +02:00
2016-06-07 19:32:03 +02:00
function emitThrowStatement ( node : ThrowStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . ThrowKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitExpressionWithLeadingSpace ( node . expression ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-21 23:09:54 +01:00
2016-06-07 19:32:03 +02:00
function emitTryStatement ( node : TryStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . TryKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . tryBlock ) ;
2016-12-05 21:30:14 +01:00
if ( node . catchClause ) {
writeLineOrSpace ( node ) ;
emit ( node . catchClause ) ;
}
2016-06-07 19:32:03 +02:00
if ( node . finallyBlock ) {
2016-12-05 21:30:14 +01:00
writeLineOrSpace ( node ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . FinallyKeyword , ( node . catchClause || node . tryBlock ) . end , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . finallyBlock ) ;
2015-03-24 00:56:29 +01:00
}
2016-06-07 19:32:03 +02:00
}
2015-03-24 00:56:29 +01:00
2016-06-07 19:32:03 +02:00
function emitDebuggerStatement ( node : DebuggerStatement ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeToken ( SyntaxKind . DebuggerKeyword , node . pos , writeKeyword ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-22 17:10:10 +01:00
2016-06-07 19:32:03 +02:00
//
// Declarations
//
2015-03-12 08:17:40 +01:00
2016-06-07 19:32:03 +02:00
function emitVariableDeclaration ( node : VariableDeclaration ) {
emit ( node . name ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitInitializer ( node . initializer , node . type ? node.type.end : node.name.end , node ) ;
2016-06-07 19:32:03 +02:00
}
function emitVariableDeclarationList ( node : VariableDeclarationList ) {
2018-06-30 01:47:11 +02:00
writeKeyword ( isLet ( node ) ? "let" : isVarConst ( node ) ? "const" : "var" ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . declarations , ListFormat . VariableDeclarationList ) ;
}
function emitFunctionDeclaration ( node : FunctionDeclaration ) {
emitFunctionDeclarationOrExpression ( node ) ;
}
2015-03-12 08:17:40 +01:00
2016-06-07 19:32:03 +02:00
function emitFunctionDeclarationOrExpression ( node : FunctionDeclaration | FunctionExpression ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "function" ) ;
2018-05-04 01:04:52 +02:00
emit ( node . asteriskToken ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2018-05-22 23:46:57 +02:00
emitIdentifierName ( node . name ! ) ; // TODO: GH#18217
2016-06-07 19:32:03 +02:00
emitSignatureAndBody ( node , emitSignatureHead ) ;
}
2017-03-15 19:44:36 +01:00
function emitBlockCallback ( _hint : EmitHint , body : Node ) : void {
emitBlockFunctionBody ( < Block > body ) ;
}
2016-06-07 19:32:03 +02:00
function emitSignatureAndBody ( node : FunctionLikeDeclaration , emitSignatureHead : ( node : SignatureDeclaration ) = > void ) {
const body = node . body ;
if ( body ) {
if ( isBlock ( body ) ) {
2016-09-26 20:20:24 +02:00
const indentedFlag = getEmitFlags ( node ) & EmitFlags . Indented ;
2016-06-07 19:32:03 +02:00
if ( indentedFlag ) {
increaseIndent ( ) ;
}
2017-11-06 21:51:34 +01:00
pushNameGenerationScope ( node ) ;
2018-05-02 22:34:14 +02:00
forEach ( node . parameters , generateNames ) ;
generateNames ( node . body ) ;
2017-11-06 21:51:34 +01:00
emitSignatureHead ( node ) ;
if ( onEmitNode ) {
onEmitNode ( EmitHint . Unspecified , body , emitBlockCallback ) ;
2016-06-15 02:59:44 +02:00
}
else {
2017-11-06 21:51:34 +01:00
emitBlockFunctionBody ( body ) ;
2016-06-15 02:59:44 +02:00
}
2017-11-06 21:51:34 +01:00
popNameGenerationScope ( node ) ;
2016-06-15 02:59:44 +02:00
2016-06-07 19:32:03 +02:00
if ( indentedFlag ) {
decreaseIndent ( ) ;
2015-03-12 08:17:40 +01:00
}
}
else {
2016-06-07 19:32:03 +02:00
emitSignatureHead ( node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( body ) ;
2015-03-12 08:17:40 +01:00
}
2015-03-16 02:23:48 +01:00
}
2016-06-07 19:32:03 +02:00
else {
emitSignatureHead ( node ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2015-02-08 17:03:15 +01:00
}
2014-08-05 02:59:33 +02:00
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitSignatureHead ( node : FunctionDeclaration | FunctionExpression | MethodDeclaration | AccessorDeclaration | ConstructorDeclaration ) {
emitTypeParameters ( node , node . typeParameters ) ;
emitParameters ( node , node . parameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
emitTypeAnnotation ( node . type ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-22 00:56:30 +02:00
2016-10-10 22:06:58 +02:00
function shouldEmitBlockFunctionBodyOnSingleLine ( body : Block ) {
2016-06-07 19:32:03 +02:00
// We must emit a function body as a single-line body in the following case:
// * The body has NodeEmitFlags.SingleLine specified.
2015-07-22 00:56:30 +02:00
2016-06-07 19:32:03 +02:00
// We must emit a function body as a multi-line body in the following cases:
// * The body is explicitly marked as multi-line.
// * A non-synthesized body's start and end position are on different lines.
// * Any statement in the body starts on a new line.
2015-07-27 13:52:57 +02:00
2016-09-26 20:20:24 +02:00
if ( getEmitFlags ( body ) & EmitFlags . SingleLine ) {
2016-06-07 19:32:03 +02:00
return true ;
2014-07-13 01:04:16 +02:00
}
2014-08-08 22:56:53 +02:00
2016-06-07 19:32:03 +02:00
if ( body . multiLine ) {
return false ;
2015-03-23 20:37:22 +01:00
}
2018-11-10 02:18:34 +01:00
if ( ! nodeIsSynthesized ( body ) && ! rangeIsOnSingleLine ( body , currentSourceFile ! ) ) {
2016-06-07 19:32:03 +02:00
return false ;
}
2015-03-23 20:37:22 +01:00
2016-06-07 19:32:03 +02:00
if ( shouldWriteLeadingLineTerminator ( body , body . statements , ListFormat . PreserveLines )
|| shouldWriteClosingLineTerminator ( body , body . statements , ListFormat . PreserveLines ) ) {
return false ;
2015-02-13 03:05:02 +01:00
}
2018-05-22 23:46:57 +02:00
let previousStatement : Statement | undefined ;
2016-06-07 19:32:03 +02:00
for ( const statement of body . statements ) {
if ( shouldWriteSeparatingLineTerminator ( previousStatement , statement , ListFormat . PreserveLines ) ) {
return false ;
2015-03-21 21:12:39 +01:00
}
2016-06-07 19:32:03 +02:00
previousStatement = statement ;
2015-03-21 21:12:39 +01:00
}
2016-06-07 19:32:03 +02:00
return true ;
}
2016-10-10 22:06:58 +02:00
function emitBlockFunctionBody ( body : Block ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "{" ) ;
2016-06-07 19:32:03 +02:00
increaseIndent ( ) ;
2017-01-30 21:27:24 +01:00
const emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine ( body )
? emitBlockFunctionBodyOnSingleLine
: emitBlockFunctionBodyWorker ;
2017-03-02 19:51:51 +01:00
if ( emitBodyWithDetachedComments ) {
emitBodyWithDetachedComments ( body , body . statements , emitBlockFunctionBody ) ;
}
else {
emitBlockFunctionBody ( body ) ;
}
2016-06-07 19:32:03 +02:00
decreaseIndent ( ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeToken ( SyntaxKind . CloseBraceToken , body . statements . end , writePunctuation , body ) ;
2016-06-07 19:32:03 +02:00
}
function emitBlockFunctionBodyOnSingleLine ( body : Block ) {
emitBlockFunctionBodyWorker ( body , /*emitBlockFunctionBodyOnSingleLine*/ true ) ;
}
function emitBlockFunctionBodyWorker ( body : Block , emitBlockFunctionBodyOnSingleLine? : boolean ) {
// Emit all the prologue directives (like "use strict").
2019-01-26 01:39:38 +01:00
const statementOffset = emitPrologueDirectives ( body . statements ) ;
2017-01-30 21:27:24 +01:00
const pos = writer . getTextPos ( ) ;
2018-03-31 02:43:37 +02:00
emitHelpers ( body ) ;
2017-01-30 21:27:24 +01:00
if ( statementOffset === 0 && pos === writer . getTextPos ( ) && emitBlockFunctionBodyOnSingleLine ) {
2016-06-07 19:32:03 +02:00
decreaseIndent ( ) ;
emitList ( body , body . statements , ListFormat . SingleLineFunctionBodyStatements ) ;
increaseIndent ( ) ;
2015-03-21 23:46:16 +01:00
}
2016-06-07 19:32:03 +02:00
else {
emitList ( body , body . statements , ListFormat . MultiLineFunctionBodyStatements , statementOffset ) ;
2015-04-10 21:10:38 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitClassDeclaration ( node : ClassDeclaration ) {
emitClassDeclarationOrExpression ( node ) ;
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitClassDeclarationOrExpression ( node : ClassDeclaration | ClassExpression ) {
2018-05-02 22:34:14 +02:00
forEach ( node . members , generateMemberNames ) ;
2016-06-07 19:32:03 +02:00
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "class" ) ;
if ( node . name ) {
writeSpace ( ) ;
emitIdentifierName ( node . name ) ;
}
2015-04-10 21:10:38 +02:00
2016-09-26 20:20:24 +02:00
const indentedFlag = getEmitFlags ( node ) & EmitFlags . Indented ;
2016-06-07 19:32:03 +02:00
if ( indentedFlag ) {
increaseIndent ( ) ;
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
emitTypeParameters ( node , node . typeParameters ) ;
emitList ( node , node . heritageClauses , ListFormat . ClassHeritageClauses ) ;
2015-04-10 21:10:38 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "{" ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . members , ListFormat . ClassMembers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
if ( indentedFlag ) {
decreaseIndent ( ) ;
2015-04-10 21:10:38 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitInterfaceDeclaration ( node : InterfaceDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "interface" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
emitTypeParameters ( node , node . typeParameters ) ;
emitList ( node , node . heritageClauses , ListFormat . HeritageClauses ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "{" ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . members , ListFormat . InterfaceMembers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitTypeAliasDeclaration ( node : TypeAliasDeclaration ) {
emitDecorators ( node , node . decorators ) ;
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "type" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
emitTypeParameters ( node , node . typeParameters ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "=" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . type ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitEnumDeclaration ( node : EnumDeclaration ) {
emitModifiers ( node , node . modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "enum" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "{" ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . members , ListFormat . EnumMembers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitModuleDeclaration ( node : ModuleDeclaration ) {
2017-09-22 09:12:37 +02:00
emitModifiers ( node , node . modifiers ) ;
if ( ~ node . flags & NodeFlags . GlobalAugmentation ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( node . flags & NodeFlags . Namespace ? "namespace" : "module" ) ;
writeSpace ( ) ;
2017-09-21 21:15:27 +02:00
}
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
let body = node . body ;
2018-08-22 21:42:36 +02:00
if ( ! body ) return writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
while ( body . kind === SyntaxKind . ModuleDeclaration ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "." ) ;
2016-06-07 19:32:03 +02:00
emit ( ( < ModuleDeclaration > body ) . name ) ;
2018-05-22 23:46:57 +02:00
body = ( < ModuleDeclaration > body ) . body ! ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( body ) ;
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitModuleBlock ( node : ModuleBlock ) {
2017-11-06 21:51:34 +01:00
pushNameGenerationScope ( node ) ;
2018-05-02 22:34:14 +02:00
forEach ( node . statements , generateNames ) ;
2017-09-18 19:05:44 +02:00
emitBlockStatements ( node , /*forceSingleLine*/ isEmptyBlock ( node ) ) ;
2017-11-06 21:51:34 +01:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitCaseBlock ( node : CaseBlock ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenBraceToken , node . pos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . clauses , ListFormat . CaseBlockClauses ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseBraceToken , node . clauses . end , writePunctuation , node , /*indentLeading*/ true ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitImportEqualsDeclaration ( node : ImportEqualsDeclaration ) {
emitModifiers ( node , node . modifiers ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . ImportKeyword , node . modifiers ? node.modifiers.end : node.pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . EqualsToken , node . name . end , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitModuleReference ( node . module Reference ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-06-18 23:01:49 +02:00
2016-06-07 19:32:03 +02:00
function emitModuleReference ( node : ModuleReference ) {
if ( node . kind === SyntaxKind . Identifier ) {
2018-02-17 03:38:00 +01:00
emitExpression ( node ) ;
2016-06-07 19:32:03 +02:00
}
else {
emit ( node ) ;
}
}
2015-04-29 03:51:29 +02:00
2016-06-07 19:32:03 +02:00
function emitImportDeclaration ( node : ImportDeclaration ) {
emitModifiers ( node , node . modifiers ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . ImportKeyword , node . modifiers ? node.modifiers.end : node.pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
if ( node . importClause ) {
emit ( node . importClause ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . FromKeyword , node . importClause . end , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
}
emitExpression ( node . module Specifier ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitImportClause ( node : ImportClause ) {
2018-05-04 01:04:52 +02:00
emit ( node . name ) ;
2016-06-07 19:32:03 +02:00
if ( node . name && node . namedBindings ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CommaToken , node . name . end , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
}
2018-05-04 01:04:52 +02:00
emit ( node . namedBindings ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 05:17:55 +02:00
2016-06-07 19:32:03 +02:00
function emitNamespaceImport ( node : NamespaceImport ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const asPos = emitTokenWithComment ( SyntaxKind . AsteriskToken , node . pos , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . AsKeyword , asPos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
}
2015-06-18 23:01:49 +02:00
2016-06-07 19:32:03 +02:00
function emitNamedImports ( node : NamedImports ) {
emitNamedImportsOrExports ( node ) ;
}
2015-04-29 20:43:23 +02:00
2016-06-07 19:32:03 +02:00
function emitImportSpecifier ( node : ImportSpecifier ) {
emitImportOrExportSpecifier ( node ) ;
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitExportAssignment ( node : ExportAssignment ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const nextPos = emitTokenWithComment ( SyntaxKind . ExportKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
if ( node . isExportEquals ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . EqualsToken , nextPos , writeOperator , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
}
else {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . DefaultKeyword , nextPos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
}
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitExportDeclaration ( node : ExportDeclaration ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
let nextPos = emitTokenWithComment ( SyntaxKind . ExportKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
if ( node . exportClause ) {
emit ( node . exportClause ) ;
}
else {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
nextPos = emitTokenWithComment ( SyntaxKind . AsteriskToken , nextPos , writePunctuation , node ) ;
2016-06-07 19:32:03 +02:00
}
if ( node . module Specifier ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const fromPos = node . exportClause ? node.exportClause.end : nextPos ;
emitTokenWithComment ( SyntaxKind . FromKeyword , fromPos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . module Specifier ) ;
2015-04-29 01:18:33 +02:00
}
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2017-05-23 20:07:34 +02:00
function emitNamespaceExportDeclaration ( node : NamespaceExportDeclaration ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
let nextPos = emitTokenWithComment ( SyntaxKind . ExportKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
nextPos = emitTokenWithComment ( SyntaxKind . AsKeyword , nextPos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
nextPos = emitTokenWithComment ( SyntaxKind . NamespaceKeyword , nextPos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-05-23 20:07:34 +02:00
emit ( node . name ) ;
2018-08-22 21:42:36 +02:00
writeTrailingSemicolon ( ) ;
2017-05-23 20:07:34 +02:00
}
2016-06-07 19:32:03 +02:00
function emitNamedExports ( node : NamedExports ) {
emitNamedImportsOrExports ( node ) ;
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitExportSpecifier ( node : ExportSpecifier ) {
emitImportOrExportSpecifier ( node ) ;
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitNamedImportsOrExports ( node : NamedImportsOrExports ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "{" ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . elements , ListFormat . NamedImportsOrExportsElements ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
2015-05-11 09:07:49 +02:00
2016-06-07 19:32:03 +02:00
function emitImportOrExportSpecifier ( node : ImportOrExportSpecifier ) {
if ( node . propertyName ) {
emit ( node . propertyName ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . AsKeyword , node . propertyName . end , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
}
2015-05-11 09:07:49 +02:00
2016-06-07 19:32:03 +02:00
emit ( node . name ) ;
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
//
// Module references
//
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitExternalModuleReference ( node : ExternalModuleReference ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeKeyword ( "require" ) ;
writePunctuation ( "(" ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ")" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
//
// JSX
//
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitJsxElement ( node : JsxElement ) {
emit ( node . openingElement ) ;
2017-10-14 02:14:56 +02:00
emitList ( node , node . children , ListFormat . JsxElementOrFragmentChildren ) ;
2016-06-07 19:32:03 +02:00
emit ( node . closingElement ) ;
}
2015-04-29 01:18:33 +02:00
2016-06-07 19:32:03 +02:00
function emitJsxSelfClosingElement ( node : JsxSelfClosingElement ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "<" ) ;
2016-06-07 19:32:03 +02:00
emitJsxTagName ( node . tagName ) ;
2019-01-11 06:34:18 +01:00
emitTypeArguments ( node , node . typeArguments ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2018-03-12 22:03:25 +01:00
emit ( node . attributes ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "/>" ) ;
2016-06-07 19:32:03 +02:00
}
2015-05-11 07:23:12 +02:00
2017-10-14 02:14:56 +02:00
function emitJsxFragment ( node : JsxFragment ) {
emit ( node . openingFragment ) ;
emitList ( node , node . children , ListFormat . JsxElementOrFragmentChildren ) ;
emit ( node . closingFragment ) ;
}
function emitJsxOpeningElementOrFragment ( node : JsxOpeningElement | JsxOpeningFragment ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "<" ) ;
2017-10-14 02:14:56 +02:00
if ( isJsxOpeningElement ( node ) ) {
emitJsxTagName ( node . tagName ) ;
2019-01-11 06:34:18 +01:00
emitTypeArguments ( node , node . typeArguments ) ;
2017-10-14 02:14:56 +02:00
if ( node . attributes . properties && node . attributes . properties . length > 0 ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-10-14 02:14:56 +02:00
}
2018-03-12 22:03:25 +01:00
emit ( node . attributes ) ;
2017-01-19 00:12:36 +01:00
}
2017-10-14 02:14:56 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ">" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-22 07:27:33 +02:00
2016-06-07 19:32:03 +02:00
function emitJsxText ( node : JsxText ) {
writer . writeLiteral ( getTextOfNode ( node , /*includeTrivia*/ true ) ) ;
}
2015-04-10 21:10:38 +02:00
2017-10-14 02:14:56 +02:00
function emitJsxClosingElementOrFragment ( node : JsxClosingElement | JsxClosingFragment ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "</" ) ;
2017-10-14 02:14:56 +02:00
if ( isJsxClosingElement ( node ) ) {
emitJsxTagName ( node . tagName ) ;
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ">" ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-22 07:27:33 +02:00
2017-01-19 00:12:36 +01:00
function emitJsxAttributes ( node : JsxAttributes ) {
emitList ( node , node . properties , ListFormat . JsxElementAttributes ) ;
}
2016-06-07 19:32:03 +02:00
function emitJsxAttribute ( node : JsxAttribute ) {
emit ( node . name ) ;
2018-05-22 23:46:57 +02:00
emitNodeWithPrefix ( "=" , writePunctuation , node . initializer ! , emit ) ; // TODO: GH#18217
2016-06-07 19:32:03 +02:00
}
2015-04-11 15:14:19 +02:00
2016-06-07 19:32:03 +02:00
function emitJsxSpreadAttribute ( node : JsxSpreadAttribute ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "{..." ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
2015-05-11 09:07:49 +02:00
2016-06-07 19:32:03 +02:00
function emitJsxExpression ( node : JsxExpression ) {
if ( node . expression ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "{" ) ;
2018-05-04 01:04:52 +02:00
emit ( node . dotDotDotToken ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "}" ) ;
2016-06-07 19:32:03 +02:00
}
}
2015-04-22 07:27:33 +02:00
[Transforms] Merge master 07/11 into transform (#9697)
* Use merge2, gulp-if, gulp-newer, and more projects
* Add watch task
* Working non-inline sourcemaps for runtests
* browser tests now also loads sourcemaps from disk
* Lazypipes and better services stream management
* export interface used by other exported functions
* Make goto-definition work for `this` parameter
* Add new error for rest parameters
* Add error message for rest parameter properties
* Fix case when a document contains multiple script blocks with different base indentations.
Use the base indent size if it is greater that the indentation of the inherited predecessor
* Fix rwc-runner from breaking change in compiler (#9284)
* Signatures use JSDoc to determine optionality
* Changed implementation to use closure
* Updated tests
* Fixed linting error
* Adding Code of Conduct notice
* Don't crash when JS class property is self-referential.
Fixes #9293
* Remove stale baselines
* For optionality, check question token before JSDoc
* Accept rest parameter properties error baselines
* Change binding pattern parameter property error
* Accept binding pattern properties error baselines
* Lint
* Port the sync version diagnostics API from tsserverVS-WIP branch to 2.0
* Do copyright without gulp-if and lazypipe
* Change test comment and accept baseline
* Remove tsd scripts task from gulpfile
* Make use of module compiler option explicit, add strip internal to tsconfigs
* Remove Signature#thisType and use Signature#thisParameter everywhere
* Add Gulpfile lint to jake, fix lints
* Change reference tests to verify actual ranges referenced and not just their count
* Respond to PR comments
* Add new lint rule
* Fix object whitespace lints
* Fix case of gulpfile dependencies
* 1. pass subshell args 2. fix build order in services
1. /bin/sh requires its arguments joined into a single string unlike
cmd.
2. services/ depends on a couple of files from server/ but the order was
implicit, and changed from jakefile. Now the order is explicit in the
tsconfig.
* Fix single-quote lint
* Check for exactly one space
* Fix excess whitespace issues
* Add matchFiles test to Gulpfile
This was merged while the gulpfile was still in-progress
* Fix LKG useDebug task and newLine flag
* Update LKG
* Clean before LKG in Gulpfile
* Fix lint
* Correct the api string name
* Allow space in exec cmds
* Fix typo
* Add new APIs to protocol
* Fix bug where `exports.` was prepended to namespace export accesses
* Remove unnecessary parameter
* extract expression into function
* Add fourslash tests & address CR comments
* Fix 8549: Using variable as Jsx tagname (#9337)
* Parse JSXElement's name as property access instead of just entity name. So when one accesses property of the class through this, checker will check correctly
* wip - just resolve to any type for now
* Resolve string type to anytype and look up property in intrinsicElementsType of Jsx
* Add tests and update baselines
* Remove unneccessary comment
* wip-address PR
* Address PR
* Add tets and update baselines
* Fix linting error
* Unused identifiers compiler code (#9200)
* Code changes to update references of the Identifiers
* Added code for handling function, method and coonstructor level local variables and parameters
* Rebased with origin master
* Code changes to handle unused private variables, private methods and typed parameters
* Code changes to handle namespace level elements
* Code changes to handle unimplemented interfaces
* Code to optimize the d.ts check
* Correct Code change to handle the parameters for methods inside interfaces
* Fix for lint error
* Remove Trailing whitespace
* Code changes to handle interface implementations
* Changes to display the error position correctly
* Compiler Test Cases
* Adding condition to ignore constructor parameters
* Removing unnecessary tests
* Additional changes for compiler code
* Additional changes to handle constructor scenario
* Fixing the consolidated case
* Changed logic to search for private instead of public
* Response to PR Comments
* Changed the error code in test cases as result of merge with master
* Adding the missing file
* Adding the missing file II
* Response to PR comments
* Code changes for checking unused imports
* Test Cases for Unused Imports
* Response to PR comments
* Code change specific to position of Import Declaration
* Code change for handling the position for unused import
* New scenarios for handling parameters in lambda function, type parameters in methods, etc.
* Additional scenarios based on PR comments
* Removing a redundant check
* Added ambient check to imports and typeparatmeter reporting
* Added one more scenario to handle type parameters
* Added new scenario for TypeParameter on Interface
* Refactoring the code
* Added scenario to handle private class elements declared in constructor.
* Minor change to erro reporting
* Fix 8355: Fix emit metadata different between transpile and tsc --isolatedModule (#9232)
* Instead of returning undefined for unknownSymbol return itself
* Add Transpile unittest
* Wip - Add project tests
* Add project tests and baselines
* Update existed tests
* Add tests for emitting metadata with module targetting system
* Fix 8467: Fix incorrect emit for accessing static property in static propertyDeclaration (#8551)
* Fix incorrect emit for accessing static property in static propertyDeclaration
* Update tests and baselines
* Update function name
* Fix when accessing static property inside arrow function
* Add tests and baselines
* do not format comma/closeparen in jsxelement
* format jsx expression
* Remove extra baselines
* Fixed bugs and linting
* Added project tests for node_modules JavaScript searches
* Removed old TODO comment
* make rules optional
* Fixed the regexp for removing full paths
* Fix type of the disableSizeLimit option
* Update version to 2.0.0
* Remove upper boilerplate from issue template
Our issue stats did not improve appreciably when we added the issue template. Reduce upper boilerplate text and try to make it more action-oriented
* Remove unused compiler option (#9381)
* Update LKG
* Added emitHost method to return source from node modules
* Marked new method internal
* Update issue_template.md
* new options should be optional for compatibility
* Add getCurrentDirectory to ServerHost
* Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location
* VarDate interface and relevant Date.prototype members
* Port 9396 to release 2.0
* Fix 9363: Object destructuring broken-variables are bound to the wrong object (#9383)
* Fix emit incorrect destructuring mapping in var declaration
* Add tests and baselines
* Add additional tests and baselines
* Fix crash in async functions when targetting ES5.
When targetting ES5 and with --noImplicitReturns,
an async function whose return type could not be determined would cause
a compiler crash.
* Add This type to lib
* Merge master into release-2.0 (#9400)
* do not format comma/closeparen in jsxelement
* format jsx expression
* make rules optional
* Remove upper boilerplate from issue template
Our issue stats did not improve appreciably when we added the issue template. Reduce upper boilerplate text and try to make it more action-oriented
* Update issue_template.md
* new options should be optional for compatibility
* Add getCurrentDirectory to ServerHost
* Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location
* VarDate interface and relevant Date.prototype members
* Fix 9363: Object destructuring broken-variables are bound to the wrong object (#9383)
* Fix emit incorrect destructuring mapping in var declaration
* Add tests and baselines
* Add additional tests and baselines
* Fix #9402: Do not report unused identifier errors for catch variables
* getVarDate should be on the Date interface
* Defere checking unsed identifier checks
* Do not scan nodes preceding formatted region, just skip over them
* Don't emit source files found under node_modules
* Destructuring assignment removes undefined from type when default value is given
* Add nullcheck when calculating indentations for implort clause
* Use a deferred list to check for unused identifiers
* push checks to checkUnusedIdentifiersDeferred
* use isParameterPropertyDeclaration to test for paramter propoerties
* runtests-parallel skips empty buckets
Previously, it would enter them as buckets with no tests, which would
make our test runners run *every* test.
This was very obvious on machines with lots of cores.
* Report unused identifiers in for statements
* Do not check ambients, and overloads
* Add tests
* Consolidate type reference marking in getTypeFromTypeReference
* Handel type aliases
* Add tests
* Add test
* Dont load JavaScript if types packages are present
* Renamed API
* Use checkExpression, not checkExpressionCached
* Do not report unused errors for module augmentations
* Consolidate refernce marking in resolveName to allow marking aliases correctelly
* add tests
* Code review comments
* Only mark symbols found in a local symbol table
* Show "<unknown>" if the name of a declaration is unavailable
* Parse `export default async function` as a declaration
* Respond to PR comments
* Better name for test
* handel private properties correctelly
* Port 9426 to release 2.0
* Handel Swtich statements
check for locals on for statments
only mark private properties
* Removed one error to avoid full path issues
* Don't emit source files found under node_modules
(cherry picked from commit 5f8cf1af3e4be61037cbafd698535d32d292941f)
* Dont load JavaScript if types packages are present
(cherry picked from commit 5a45c44eb789f52ceb1aa0e23a230ecb599bfb08)
* Renamed API
(cherry picked from commit d8047b607f11cdf319284bb344282582c7c0aea0)
* Removed one error to avoid full path issues
(cherry picked from commit 5e4f13f342a75ec8f7cf65cb669bec9d6e6c5581)
* Fix incorrectly-saved quote symbols in ThirdPartyNoticeText.txt
* Fix #9458: exclude parameters starting with underscore from unusedParamter checks
* change variable name for strict mode
* Increase timeout from running RWC. As UWDWeb takes slightly longer now (#9454)
* Handle relative paths in tsconfig exclude and include globs
* Merge master into release branch 06/30 (#9447)
* do not format comma/closeparen in jsxelement
* format jsx expression
* make rules optional
* Remove upper boilerplate from issue template
Our issue stats did not improve appreciably when we added the issue template. Reduce upper boilerplate text and try to make it more action-oriented
* Update issue_template.md
* new options should be optional for compatibility
* Add getCurrentDirectory to ServerHost
* Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location
* VarDate interface and relevant Date.prototype members
* Fix 9363: Object destructuring broken-variables are bound to the wrong object (#9383)
* Fix emit incorrect destructuring mapping in var declaration
* Add tests and baselines
* Add additional tests and baselines
* Fix crash in async functions when targetting ES5.
When targetting ES5 and with --noImplicitReturns,
an async function whose return type could not be determined would cause
a compiler crash.
* Add This type to lib
* getVarDate should be on the Date interface
* Don't emit source files found under node_modules
* Destructuring assignment removes undefined from type when default value is given
* Add nullcheck when calculating indentations for implort clause
* Add test
* Dont load JavaScript if types packages are present
* Renamed API
* Use checkExpression, not checkExpressionCached
* Show "<unknown>" if the name of a declaration is unavailable
* Parse `export default async function` as a declaration
* Removed one error to avoid full path issues
* Fix incorrectly-saved quote symbols in ThirdPartyNoticeText.txt
* Improve names of whitespace functions
* Handle relative paths in tsconfig exclude and include globs
Port 9475 to release 2.0
* add new method getEmitOutputObject to return result of the emit as object with properties instead of json string
* fix linter
* Fix PromiseLike to be compatible with es6-promise (#9484)
* Fix reading files from IOLog because previous our API captures (#9483)
* Fix reading files from IOLog because previous our API captures
* Refactoring the ioLog
* Exclude FlowSwitchClause from flow graph for case expressions
* Add regression test
* Update LKG
* Update language in comment
* Add .mailmap file
* Add authors script to generate authors from repo
* Update AUTHORS.md for release-2.0
* Update script to pass more than one argument
* Remove the unused text buffer from ScriptInfo
* Fix #9531: account for async as an contextual keyword when parsing export assignments
* Update LKG
* Swap q from a reference to an import
* Fix #9550: exclude 'this' type parameters from unusedParameters checks.
* Update comment to reflect new dependency
* Avoid putting children tags in jsdoccomment
* Parse the result of getDirectories call
* Update harness getDirectories implementation for shims
* Fix multiple Salsa assignment-declarations
Previously, all assignment-declarations needed to be of the same kind:
either all `this.p = ...` assignments or `C.prototype.p = ...`
assignments.
* Test for multiple salsa assignment-declarations
* Add test for parsed @typedef tag node shape
* Provide a symbol for salsa-inferred class types
* Update .mailmap
* Fix module tracking
* Updated test with relative import
* Fixed the node tracking and a harness bug
* fixed lint error
* Fixed implicit any
* Added missing test files
* Removed duplicate logic
* Update conflicting baseline.
PR #9574 added a baseline that #9578 caused to be changed. The two PRs
went in so close to each other that the CI build didn't catch the change
to the new test's baseline.
* Fix type of JSXTagName
* Update baselines to use double-quote
* Update baselines when emitting metadata decorator
* Update baselines for async-await function
* Update baselines for comment in capturing down-level for...of and for...in
* Add missing Transpile tests
* Remove old JS transpile baselines
* Passing program as argument in emitWorker
* Port PR#9607 transforms
* Port new JSDOC tests to use baseline
* substitute alias for class expression in statics
* Address new lint warnings
* Change name for substitution function.
2016-07-19 00:38:30 +02:00
function emitJsxTagName ( node : JsxTagNameExpression ) {
2016-06-07 19:32:03 +02:00
if ( node . kind === SyntaxKind . Identifier ) {
2018-06-30 01:50:44 +02:00
emitExpression ( node ) ;
2016-06-07 19:32:03 +02:00
}
else {
emit ( node ) ;
}
}
2015-05-11 09:07:49 +02:00
2016-06-07 19:32:03 +02:00
//
// Clauses
//
2015-05-11 09:07:49 +02:00
2016-06-07 19:32:03 +02:00
function emitCaseClause ( node : CaseClause ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CaseKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . expression ) ;
2015-04-11 15:33:09 +02:00
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitCaseOrDefaultClauseRest ( node , node . statements , node . expression . end ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-22 07:27:33 +02:00
2016-06-07 19:32:03 +02:00
function emitDefaultClause ( node : DefaultClause ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const pos = emitTokenWithComment ( SyntaxKind . DefaultKeyword , node . pos , writeKeyword , node ) ;
emitCaseOrDefaultClauseRest ( node , node . statements , pos ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
function emitCaseOrDefaultClauseRest ( parentNode : Node , statements : NodeArray < Statement > , colonPos : number ) {
2016-06-07 19:32:03 +02:00
const emitAsSingleStatement =
statements . length === 1 &&
(
// treat synthesized nodes as located on the same line for emit purposes
nodeIsSynthesized ( parentNode ) ||
nodeIsSynthesized ( statements [ 0 ] ) ||
2018-11-10 02:18:34 +01:00
rangeStartPositionsAreOnSameLine ( parentNode , statements [ 0 ] , currentSourceFile ! )
2016-06-07 19:32:03 +02:00
) ;
2017-09-07 23:30:19 +02:00
let format = ListFormat . CaseOrDefaultClauseStatements ;
2016-06-07 19:32:03 +02:00
if ( emitAsSingleStatement ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
writeToken ( SyntaxKind . ColonToken , colonPos , writePunctuation , parentNode ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-09-07 23:30:19 +02:00
format &= ~ ( ListFormat . MultiLine | ListFormat . Indented ) ;
2016-06-07 19:32:03 +02:00
}
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
else {
emitTokenWithComment ( SyntaxKind . ColonToken , colonPos , writePunctuation , parentNode ) ;
}
2017-09-07 23:30:19 +02:00
emitList ( parentNode , statements , format ) ;
2016-06-07 19:32:03 +02:00
}
2015-07-27 13:52:57 +02:00
2016-06-07 19:32:03 +02:00
function emitHeritageClause ( node : HeritageClause ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writeTokenText ( node . token , writeKeyword ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitList ( node , node . types , ListFormat . HeritageClauseTypes ) ;
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitCatchClause ( node : CatchClause ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
const openParenPos = emitTokenWithComment ( SyntaxKind . CatchKeyword , node . pos , writeKeyword , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-07-30 10:30:59 +02:00
if ( node . variableDeclaration ) {
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . OpenParenToken , openParenPos , writePunctuation , node ) ;
2017-07-30 10:30:59 +02:00
emit ( node . variableDeclaration ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . CloseParenToken , node . variableDeclaration . end , writePunctuation , node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-07-30 10:30:59 +02:00
}
2016-06-07 19:32:03 +02:00
emit ( node . block ) ;
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
//
// Property assignments
//
function emitPropertyAssignment ( node : PropertyAssignment ) {
emit ( node . name ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( ":" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
// This is to ensure that we emit comment in the following case:
// For example:
// obj = {
// id: /*comment1*/ ()=>void
// }
// "comment1" is not considered to be leading comment for node.initializer
// but rather a trailing comment on the previous node.
const initializer = node . initializer ;
2017-01-30 21:27:24 +01:00
if ( emitTrailingCommentsOfPosition && ( getEmitFlags ( initializer ) & EmitFlags . NoLeadingComments ) === 0 ) {
2016-09-26 20:20:24 +02:00
const commentRange = getCommentRange ( initializer ) ;
2016-06-07 19:32:03 +02:00
emitTrailingCommentsOfPosition ( commentRange . pos ) ;
}
2016-09-08 16:49:29 +02:00
emitExpression ( initializer ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
function emitShorthandPropertyAssignment ( node : ShorthandPropertyAssignment ) {
emit ( node . name ) ;
if ( node . objectAssignmentInitializer ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
writePunctuation ( "=" ) ;
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emitExpression ( node . objectAssignmentInitializer ) ;
2015-04-10 21:10:38 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-04-10 21:10:38 +02:00
2016-11-07 18:04:00 +01:00
function emitSpreadAssignment ( node : SpreadAssignment ) {
if ( node . expression ) {
2018-11-14 23:20:07 +01:00
emitTokenWithComment ( SyntaxKind . DotDotDotToken , node . pos , writePunctuation , node ) ;
2016-11-07 18:04:00 +01:00
emitExpression ( node . expression ) ;
}
}
2016-06-07 19:32:03 +02:00
//
// Enum
//
2015-10-01 00:45:23 +02:00
2016-06-07 19:32:03 +02:00
function emitEnumMember ( node : EnumMember ) {
emit ( node . name ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitInitializer ( node . initializer , node . name . end , node ) ;
2016-06-07 19:32:03 +02:00
}
2015-04-10 21:10:38 +02:00
2018-10-25 01:14:52 +02:00
//
// JSDoc
//
function emitJSDoc ( node : JSDoc ) {
write ( "/**" ) ;
if ( node . comment ) {
const lines = node . comment . split ( /\r\n?|\n/g ) ;
for ( const line of lines ) {
writeLine ( ) ;
writeSpace ( ) ;
writePunctuation ( "*" ) ;
writeSpace ( ) ;
write ( line ) ;
}
}
if ( node . tags ) {
if ( node . tags . length === 1 && node . tags [ 0 ] . kind === SyntaxKind . JSDocTypeTag && ! node . comment ) {
writeSpace ( ) ;
emit ( node . tags [ 0 ] ) ;
}
else {
emitList ( node , node . tags , ListFormat . JSDocComment ) ;
}
}
writeSpace ( ) ;
write ( "*/" ) ;
}
function emitJSDocSimpleTypedTag ( tag : JSDocTypeTag | JSDocThisTag | JSDocEnumTag | JSDocReturnTag ) {
emitJSDocTagName ( tag . tagName ) ;
emitJSDocTypeExpression ( tag . typeExpression ) ;
emitJSDocComment ( tag . comment ) ;
}
function emitJSDocAugmentsTag ( tag : JSDocAugmentsTag ) {
emitJSDocTagName ( tag . tagName ) ;
writeSpace ( ) ;
writePunctuation ( "{" ) ;
emit ( tag . class ) ;
writePunctuation ( "}" ) ;
emitJSDocComment ( tag . comment ) ;
}
function emitJSDocTemplateTag ( tag : JSDocTemplateTag ) {
emitJSDocTagName ( tag . tagName ) ;
emitJSDocTypeExpression ( tag . constraint ) ;
writeSpace ( ) ;
emitList ( tag , tag . typeParameters , ListFormat . CommaListElements ) ;
emitJSDocComment ( tag . comment ) ;
}
function emitJSDocTypedefTag ( tag : JSDocTypedefTag ) {
emitJSDocTagName ( tag . tagName ) ;
if ( tag . typeExpression ) {
if ( tag . typeExpression . kind === SyntaxKind . JSDocTypeExpression ) {
emitJSDocTypeExpression ( tag . typeExpression ) ;
}
else {
writeSpace ( ) ;
writePunctuation ( "{" ) ;
write ( "Object" ) ;
if ( tag . typeExpression . isArrayType ) {
writePunctuation ( "[" ) ;
writePunctuation ( "]" ) ;
}
writePunctuation ( "}" ) ;
}
}
if ( tag . fullName ) {
writeSpace ( ) ;
emit ( tag . fullName ) ;
}
emitJSDocComment ( tag . comment ) ;
if ( tag . typeExpression && tag . typeExpression . kind === SyntaxKind . JSDocTypeLiteral ) {
emitJSDocTypeLiteral ( tag . typeExpression ) ;
}
}
function emitJSDocCallbackTag ( tag : JSDocCallbackTag ) {
emitJSDocTagName ( tag . tagName ) ;
if ( tag . name ) {
writeSpace ( ) ;
emit ( tag . name ) ;
}
emitJSDocComment ( tag . comment ) ;
emitJSDocSignature ( tag . typeExpression ) ;
}
function emitJSDocSimpleTag ( tag : JSDocTag ) {
emitJSDocTagName ( tag . tagName ) ;
emitJSDocComment ( tag . comment ) ;
}
function emitJSDocTypeLiteral ( lit : JSDocTypeLiteral ) {
emitList ( lit , createNodeArray ( lit . jsDocPropertyTags ) , ListFormat . JSDocComment ) ;
}
function emitJSDocSignature ( sig : JSDocSignature ) {
if ( sig . typeParameters ) {
emitList ( sig , createNodeArray ( sig . typeParameters ) , ListFormat . JSDocComment ) ;
}
if ( sig . parameters ) {
emitList ( sig , createNodeArray ( sig . parameters ) , ListFormat . JSDocComment ) ;
}
if ( sig . type ) {
writeLine ( ) ;
writeSpace ( ) ;
writePunctuation ( "*" ) ;
writeSpace ( ) ;
emit ( sig . type ) ;
}
}
function emitJSDocPropertyLikeTag ( param : JSDocPropertyLikeTag ) {
emitJSDocTagName ( param . tagName ) ;
emitJSDocTypeExpression ( param . typeExpression ) ;
writeSpace ( ) ;
if ( param . isBracketed ) {
writePunctuation ( "[" ) ;
}
emit ( param . name ) ;
if ( param . isBracketed ) {
writePunctuation ( "]" ) ;
}
emitJSDocComment ( param . comment ) ;
}
function emitJSDocTagName ( tagName : Identifier ) {
writePunctuation ( "@" ) ;
emit ( tagName ) ;
}
function emitJSDocComment ( comment : string | undefined ) {
if ( comment ) {
writeSpace ( ) ;
write ( comment ) ;
}
}
function emitJSDocTypeExpression ( typeExpression : JSDocTypeExpression | undefined ) {
if ( typeExpression ) {
writeSpace ( ) ;
writePunctuation ( "{" ) ;
emit ( typeExpression . type ) ;
writePunctuation ( "}" ) ;
}
}
2016-06-07 19:32:03 +02:00
//
// Top-level nodes
//
function emitSourceFile ( node : SourceFile ) {
writeLine ( ) ;
2017-03-02 19:51:51 +01:00
const statements = node . statements ;
2017-03-06 18:57:37 +01:00
if ( emitBodyWithDetachedComments ) {
2017-03-29 17:42:39 +02:00
// Emit detached comment if there are no prologue directives or if the first node is synthesized.
2017-03-06 18:57:37 +01:00
// The synthesized node will have no leading comment so some comments may be missed.
const shouldEmitDetachedComment = statements . length === 0 ||
! isPrologueDirective ( statements [ 0 ] ) ||
nodeIsSynthesized ( statements [ 0 ] ) ;
if ( shouldEmitDetachedComment ) {
emitBodyWithDetachedComments ( node , statements , emitSourceFileWorker ) ;
return ;
}
2017-03-02 19:51:51 +01:00
}
2017-03-06 18:57:37 +01:00
emitSourceFileWorker ( node ) ;
2016-06-07 19:32:03 +02:00
}
2015-10-01 00:45:23 +02:00
2018-03-16 06:23:10 +01:00
function emitSyntheticTripleSlashReferencesIfNeeded ( node : Bundle ) {
2018-08-21 01:02:19 +02:00
emitTripleSlashDirectives ( ! ! node . hasNoDefaultLib , node . syntheticFileReferences || [ ] , node . syntheticTypeReferences || [ ] , node . syntheticLibReferences || [ ] ) ;
2019-02-20 19:54:31 +01:00
for ( const prepend of node . prepends ) {
if ( isUnparsedSource ( prepend ) && prepend . syntheticReferences ) {
for ( const ref of prepend . syntheticReferences ) {
emit ( ref ) ;
writeLine ( ) ;
}
}
}
2018-03-16 06:23:10 +01:00
}
function emitTripleSlashDirectivesIfNeeded ( node : SourceFile ) {
2018-08-21 01:02:19 +02:00
if ( node . isDeclarationFile ) emitTripleSlashDirectives ( node . hasNoDefaultLib , node . referencedFiles , node . typeReferenceDirectives , node . libReferenceDirectives ) ;
2018-03-16 06:23:10 +01:00
}
2018-08-21 01:02:19 +02:00
function emitTripleSlashDirectives ( hasNoDefaultLib : boolean , files : ReadonlyArray < FileReference > , types : ReadonlyArray < FileReference > , libs : ReadonlyArray < FileReference > ) {
2018-03-30 00:38:29 +02:00
if ( hasNoDefaultLib ) {
2019-01-26 01:39:38 +01:00
const pos = writer . getTextPos ( ) ;
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <reference no-default-lib="true"/> ` ) ;
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.NoDefaultLib } ) ;
2018-03-30 00:38:29 +02:00
writeLine ( ) ;
}
2018-03-29 22:43:31 +02:00
if ( currentSourceFile && currentSourceFile . module Name ) {
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <amd-module name=" ${ currentSourceFile . module Name } " /> ` ) ;
2018-03-29 22:43:31 +02:00
writeLine ( ) ;
}
if ( currentSourceFile && currentSourceFile . amdDependencies ) {
for ( const dep of currentSourceFile . amdDependencies ) {
if ( dep . name ) {
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <amd-dependency name=" ${ dep . name } " path=" ${ dep . path } " /> ` ) ;
2018-03-29 22:43:31 +02:00
}
else {
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <amd-dependency path=" ${ dep . path } " /> ` ) ;
2018-03-29 22:43:31 +02:00
}
writeLine ( ) ;
}
}
2018-03-16 06:23:10 +01:00
for ( const directive of files ) {
2019-01-26 01:39:38 +01:00
const pos = writer . getTextPos ( ) ;
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <reference path=" ${ directive . fileName } " /> ` ) ;
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.Reference , data : directive.fileName } ) ;
2018-03-16 06:23:10 +01:00
writeLine ( ) ;
}
for ( const directive of types ) {
2019-01-26 01:39:38 +01:00
const pos = writer . getTextPos ( ) ;
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <reference types=" ${ directive . fileName } " /> ` ) ;
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.Type , data : directive.fileName } ) ;
2018-03-16 06:23:10 +01:00
writeLine ( ) ;
}
2018-08-21 01:02:19 +02:00
for ( const directive of libs ) {
2019-01-26 01:39:38 +01:00
const pos = writer . getTextPos ( ) ;
2018-08-22 21:42:36 +02:00
writeComment ( ` /// <reference lib=" ${ directive . fileName } " /> ` ) ;
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.Lib , data : directive.fileName } ) ;
2018-08-21 01:02:19 +02:00
writeLine ( ) ;
}
2018-03-16 06:23:10 +01:00
}
2016-06-07 19:32:03 +02:00
function emitSourceFileWorker ( node : SourceFile ) {
const statements = node . statements ;
2017-11-06 21:51:34 +01:00
pushNameGenerationScope ( node ) ;
2018-05-02 22:34:14 +02:00
forEach ( node . statements , generateNames ) ;
2018-03-31 02:43:37 +02:00
emitHelpers ( node ) ;
2017-03-02 19:51:51 +01:00
const index = findIndex ( statements , statement = > ! isPrologueDirective ( statement ) ) ;
2018-03-16 06:23:10 +01:00
emitTripleSlashDirectivesIfNeeded ( node ) ;
2017-03-02 19:51:51 +01:00
emitList ( node , statements , ListFormat . MultiLine , index === - 1 ? statements.length : index ) ;
2017-11-06 21:51:34 +01:00
popNameGenerationScope ( node ) ;
2016-06-07 19:32:03 +02:00
}
2015-10-01 00:45:23 +02:00
2016-06-07 19:32:03 +02:00
// Transformation nodes
2015-10-01 00:45:23 +02:00
2016-06-07 19:32:03 +02:00
function emitPartiallyEmittedExpression ( node : PartiallyEmittedExpression ) {
emitExpression ( node . expression ) ;
}
2015-04-10 21:10:38 +02:00
2017-05-12 18:57:39 +02:00
function emitCommaList ( node : CommaListExpression ) {
2017-05-12 08:51:20 +02:00
emitExpressionList ( node , node . elements , ListFormat . CommaListElements ) ;
}
2016-06-07 19:32:03 +02:00
/ * *
* Emits any prologue directives at the start of a Statement list , returning the
* number of prologue directives written to the output .
* /
2019-01-26 01:39:38 +01:00
function emitPrologueDirectives ( statements : ReadonlyArray < Node > , sourceFile? : SourceFile , seenPrologueDirectives? : Map < true > ) : number {
let needsToSetSourceFile = ! ! sourceFile ;
2016-06-07 19:32:03 +02:00
for ( let i = 0 ; i < statements . length ; i ++ ) {
2017-02-24 20:37:34 +01:00
const statement = statements [ i ] ;
if ( isPrologueDirective ( statement ) ) {
const shouldEmitPrologueDirective = seenPrologueDirectives ? ! seenPrologueDirectives . has ( statement . expression . text ) : true ;
if ( shouldEmitPrologueDirective ) {
2019-01-26 01:39:38 +01:00
if ( needsToSetSourceFile ) {
needsToSetSourceFile = false ;
setSourceFile ( sourceFile ! ) ;
2017-02-24 20:37:34 +01:00
}
2019-01-26 01:39:38 +01:00
writeLine ( ) ;
const pos = writer . getTextPos ( ) ;
2017-02-24 20:37:34 +01:00
emit ( statement ) ;
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.Prologue , data : statement.expression.text } ) ;
2017-02-24 20:37:34 +01:00
if ( seenPrologueDirectives ) {
2017-07-07 19:34:36 +02:00
seenPrologueDirectives . set ( statement . expression . text , true ) ;
2017-02-24 20:37:34 +01:00
}
2015-02-10 23:59:20 +01:00
}
2016-06-07 19:32:03 +02:00
}
else {
// return index of the first non prologue directive
return i ;
}
}
2015-04-10 21:10:38 +02:00
2016-06-07 19:32:03 +02:00
return statements . length ;
}
2015-08-07 01:38:53 +02:00
2019-01-17 21:11:51 +01:00
function emitUnparsedPrologues ( prologues : ReadonlyArray < UnparsedPrologue > , seenPrologueDirectives : Map < true > ) {
for ( const prologue of prologues ) {
2019-01-31 20:45:42 +01:00
if ( ! seenPrologueDirectives . has ( prologue . data ) ) {
2019-01-26 01:39:38 +01:00
writeLine ( ) ;
const pos = writer . getTextPos ( ) ;
2019-01-17 21:11:51 +01:00
emit ( prologue ) ;
2019-02-02 01:52:00 +01:00
if ( bundleFileInfo ) bundleFileInfo . sections . push ( { pos , end : writer.getTextPos ( ) , kind : BundleFileSectionKind.Prologue , data : prologue.data } ) ;
2019-01-17 21:11:51 +01:00
if ( seenPrologueDirectives ) {
2019-01-31 20:45:42 +01:00
seenPrologueDirectives . set ( prologue . data , true ) ;
2019-01-17 21:11:51 +01:00
}
}
}
}
2017-02-24 20:37:34 +01:00
function emitPrologueDirectivesIfNeeded ( sourceFileOrBundle : Bundle | SourceFile ) {
2017-03-06 18:57:37 +01:00
if ( isSourceFile ( sourceFileOrBundle ) ) {
2019-01-26 01:39:38 +01:00
emitPrologueDirectives ( sourceFileOrBundle . statements , sourceFileOrBundle ) ;
2017-02-24 20:37:34 +01:00
}
else {
2017-07-07 19:34:36 +02:00
const seenPrologueDirectives = createMap < true > ( ) ;
2019-01-17 21:11:51 +01:00
for ( const prepend of sourceFileOrBundle . prepends ) {
emitUnparsedPrologues ( ( prepend as UnparsedSource ) . prologues , seenPrologueDirectives ) ;
}
2018-02-17 03:38:00 +01:00
for ( const sourceFile of sourceFileOrBundle . sourceFiles ) {
2019-01-26 01:39:38 +01:00
emitPrologueDirectives ( sourceFile . statements , sourceFile , seenPrologueDirectives ) ;
2017-02-24 20:37:34 +01:00
}
2018-11-10 02:18:34 +01:00
setSourceFile ( undefined ) ;
2017-02-24 20:37:34 +01:00
}
}
2015-04-20 22:40:13 +02:00
2019-02-04 23:49:24 +01:00
function getPrologueDirectivesFromBundledSourceFiles ( bundle : Bundle ) : SourceFilePrologueInfo [ ] | undefined {
const seenPrologueDirectives = createMap < true > ( ) ;
let prologues : SourceFilePrologueInfo [ ] | undefined ;
for ( const sourceFile of bundle . sourceFiles ) {
let directives : SourceFilePrologueDirective [ ] | undefined ;
let end = 0 ;
for ( const statement of sourceFile . statements ) {
if ( ! isPrologueDirective ( statement ) ) break ;
if ( seenPrologueDirectives . has ( statement . expression . text ) ) continue ;
seenPrologueDirectives . set ( statement . expression . text , true ) ;
( directives || ( directives = [ ] ) ) . push ( {
pos : statement.pos ,
end : statement.end ,
expression : {
pos : statement.expression.pos ,
end : statement.expression.end ,
text : statement.expression.text
}
} ) ;
end = end < statement . end ? statement.end : end ;
}
if ( directives ) ( prologues || ( prologues = [ ] ) ) . push ( { file : sourceFile.fileName , text : sourceFile.text.substring ( 0 , end ) , directives } ) ;
}
return prologues ;
}
2019-01-16 19:47:11 +01:00
function emitShebangIfNeeded ( sourceFileOrBundle : Bundle | SourceFile | UnparsedSource ) {
if ( isSourceFile ( sourceFileOrBundle ) || isUnparsedSource ( sourceFileOrBundle ) ) {
2017-03-02 19:51:51 +01:00
const shebang = getShebang ( sourceFileOrBundle . text ) ;
if ( shebang ) {
2018-08-22 21:42:36 +02:00
writeComment ( shebang ) ;
2017-03-02 19:51:51 +01:00
writeLine ( ) ;
return true ;
}
2017-02-24 00:27:22 +01:00
}
else {
2019-01-16 19:47:11 +01:00
for ( const prepend of sourceFileOrBundle . prepends ) {
Debug . assertNode ( prepend , isUnparsedSource ) ;
if ( emitShebangIfNeeded ( prepend as UnparsedSource ) ) {
return true ;
}
}
2017-03-02 19:51:51 +01:00
for ( const sourceFile of sourceFileOrBundle . sourceFiles ) {
2017-02-24 00:31:19 +01:00
// Emit only the first encountered shebang
2017-03-02 19:51:51 +01:00
if ( emitShebangIfNeeded ( sourceFile ) ) {
2019-01-16 19:47:11 +01:00
return true ;
2017-02-24 00:27:22 +01:00
}
}
}
2016-06-07 19:32:03 +02:00
}
2017-02-24 20:37:34 +01:00
//
// Helpers
//
2018-05-04 01:04:52 +02:00
function emitNodeWithWriter ( node : Node | undefined , writer : typeof write ) {
if ( ! node ) return ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
const savedWrite = write ;
write = writer ;
emit ( node ) ;
write = savedWrite ;
}
2018-05-22 23:46:57 +02:00
function emitModifiers ( node : Node , modifiers : NodeArray < Modifier > | undefined ) {
2016-06-07 19:32:03 +02:00
if ( modifiers && modifiers . length ) {
emitList ( node , modifiers , ListFormat . Modifiers ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
}
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function emitTypeAnnotation ( node : TypeNode | undefined ) {
if ( node ) {
writePunctuation ( ":" ) ;
writeSpace ( ) ;
emit ( node ) ;
}
2016-06-07 19:32:03 +02:00
}
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
function emitInitializer ( node : Expression | undefined , equalCommentStartPos : number , container : Node ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( node ) {
writeSpace ( ) ;
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
emitTokenWithComment ( SyntaxKind . EqualsToken , equalCommentStartPos , writeOperator , container ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
emitExpression ( node ) ;
}
2016-06-07 19:32:03 +02:00
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function emitNodeWithPrefix ( prefix : string , prefixWriter : ( s : string ) = > void , node : Node , emit : ( node : Node ) = > void ) {
2016-06-07 19:32:03 +02:00
if ( node ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
prefixWriter ( prefix ) ;
2016-06-07 19:32:03 +02:00
emit ( node ) ;
}
}
2015-09-26 00:22:01 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function emitWithLeadingSpace ( node : Node | undefined ) {
2016-06-07 19:32:03 +02:00
if ( node ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node ) ;
}
}
2015-09-26 00:22:01 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function emitExpressionWithLeadingSpace ( node : Expression | undefined ) {
if ( node ) {
writeSpace ( ) ;
emitExpression ( node ) ;
}
}
function emitWithTrailingSpace ( node : Node | undefined ) {
2016-06-07 19:32:03 +02:00
if ( node ) {
emit ( node ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2015-09-26 00:22:01 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-09-26 00:22:01 +02:00
2016-12-05 21:30:14 +01:00
function emitEmbeddedStatement ( parent : Node , node : Statement ) {
if ( isBlock ( node ) || getEmitFlags ( parent ) & EmitFlags . SingleLine ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2016-06-07 19:32:03 +02:00
emit ( node ) ;
}
else {
2015-04-03 08:05:58 +02:00
writeLine ( ) ;
2014-10-11 01:44:14 +02:00
increaseIndent ( ) ;
2018-08-22 21:42:36 +02:00
if ( isEmptyStatement ( node ) ) {
2018-09-07 23:11:54 +02:00
const pipelinePhase = getPipelinePhase ( PipelinePhase . Notification , node ) ;
2018-08-22 21:42:36 +02:00
pipelinePhase ( EmitHint . EmbeddedStatement , node ) ;
}
else {
emit ( node ) ;
}
2014-10-11 01:44:14 +02:00
decreaseIndent ( ) ;
2014-07-12 00:13:01 +02:00
}
2016-06-07 19:32:03 +02:00
}
2014-07-12 00:13:01 +02:00
2018-05-22 23:46:57 +02:00
function emitDecorators ( parentNode : Node , decorators : NodeArray < Decorator > | undefined ) {
2016-06-07 19:32:03 +02:00
emitList ( parentNode , decorators , ListFormat . Decorators ) ;
}
2015-03-02 21:17:05 +01:00
2018-05-22 23:46:57 +02:00
function emitTypeArguments ( parentNode : Node , typeArguments : NodeArray < TypeNode > | undefined ) {
2016-06-07 19:32:03 +02:00
emitList ( parentNode , typeArguments , ListFormat . TypeArguments ) ;
}
2015-04-03 08:05:58 +02:00
2018-05-22 23:46:57 +02:00
function emitTypeParameters ( parentNode : SignatureDeclaration | InterfaceDeclaration | TypeAliasDeclaration | ClassDeclaration | ClassExpression , typeParameters : NodeArray < TypeParameterDeclaration > | undefined ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( isFunctionLike ( parentNode ) && parentNode . typeArguments ) { // Quick info uses type arguments in place of type parameters on instantiated signatures
return emitTypeArguments ( parentNode , parentNode . typeArguments ) ;
}
2016-06-07 19:32:03 +02:00
emitList ( parentNode , typeParameters , ListFormat . TypeParameters ) ;
}
2015-09-26 00:22:01 +02:00
2016-06-07 19:32:03 +02:00
function emitParameters ( parentNode : Node , parameters : NodeArray < ParameterDeclaration > ) {
emitList ( parentNode , parameters , ListFormat . Parameters ) ;
}
2015-04-03 08:05:58 +02:00
2017-09-26 21:42:08 +02:00
function canEmitSimpleArrowHead ( parentNode : FunctionTypeNode | ArrowFunction , parameters : NodeArray < ParameterDeclaration > ) {
2017-06-08 00:13:24 +02:00
const parameter = singleOrUndefined ( parameters ) ;
return parameter
&& parameter . pos === parentNode . pos // may not have parsed tokens between parent and parameter
2018-09-11 09:39:11 +02:00
&& isArrowFunction ( parentNode ) // only arrow functions may have simple arrow head
&& ! parentNode . type // arrow function may not have return type annotation
2017-06-08 00:13:24 +02:00
&& ! some ( parentNode . decorators ) // parent may not have decorators
&& ! some ( parentNode . modifiers ) // parent may not have modifiers
&& ! some ( parentNode . typeParameters ) // parent may not have type parameters
&& ! some ( parameter . decorators ) // parameter may not have decorators
&& ! some ( parameter . modifiers ) // parameter may not have modifiers
&& ! parameter . dotDotDotToken // parameter may not be rest
&& ! parameter . questionToken // parameter may not be optional
&& ! parameter . type // parameter may not have a type annotation
&& ! parameter . initializer // parameter may not have an initializer
&& isIdentifier ( parameter . name ) ; // parameter name must be identifier
}
2017-09-26 21:42:08 +02:00
function emitParametersForArrow ( parentNode : FunctionTypeNode | ArrowFunction , parameters : NodeArray < ParameterDeclaration > ) {
2017-06-08 00:13:24 +02:00
if ( canEmitSimpleArrowHead ( parentNode , parameters ) ) {
2017-09-07 23:30:19 +02:00
emitList ( parentNode , parameters , ListFormat . Parameters & ~ ListFormat . Parenthesis ) ;
2015-03-17 03:25:02 +01:00
}
2016-06-07 19:32:03 +02:00
else {
emitParameters ( parentNode , parameters ) ;
2014-10-11 01:44:14 +02:00
}
2016-06-07 19:32:03 +02:00
}
2014-08-04 21:06:07 +02:00
2016-06-07 19:32:03 +02:00
function emitParametersForIndexSignature ( parentNode : Node , parameters : NodeArray < ParameterDeclaration > ) {
emitList ( parentNode , parameters , ListFormat . IndexSignatureParameters ) ;
}
2015-06-18 23:01:49 +02:00
2018-05-22 23:46:57 +02:00
function emitList ( parentNode : TextRange , children : NodeArray < Node > | undefined , format : ListFormat , start? : number , count? : number ) {
2016-06-07 19:32:03 +02:00
emitNodeList ( emit , parentNode , children , format , start , count ) ;
}
2015-08-20 21:20:28 +02:00
2018-05-22 23:46:57 +02:00
function emitExpressionList ( parentNode : TextRange , children : NodeArray < Node > | undefined , format : ListFormat , start? : number , count? : number ) {
emitNodeList ( emitExpression as ( node : Node ) = > void , parentNode , children , format , start , count ) ; // TODO: GH#18217
2016-06-07 19:32:03 +02:00
}
2015-06-18 23:01:49 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeDelimiter ( format : ListFormat ) {
switch ( format & ListFormat . DelimitersMask ) {
case ListFormat . None :
break ;
case ListFormat . CommaDelimited :
writePunctuation ( "," ) ;
break ;
case ListFormat . BarDelimited :
writeSpace ( ) ;
writePunctuation ( "|" ) ;
break ;
2018-10-25 01:14:52 +02:00
case ListFormat . AsteriskDelimited :
writeSpace ( ) ;
writePunctuation ( "*" ) ;
writeSpace ( ) ;
break ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
case ListFormat . AmpersandDelimited :
writeSpace ( ) ;
writePunctuation ( "&" ) ;
break ;
}
}
2018-05-22 23:46:57 +02:00
function emitNodeList ( emit : ( node : Node ) = > void , parentNode : TextRange , children : NodeArray < Node > | undefined , format : ListFormat , start = 0 , count = children ? children . length - start : 0 ) {
2016-06-07 19:32:03 +02:00
const isUndefined = children === undefined ;
if ( isUndefined && format & ListFormat . OptionalIfUndefined ) {
return ;
}
2015-08-20 21:20:28 +02:00
2018-05-22 23:46:57 +02:00
const isEmpty = children === undefined || start >= children . length || count === 0 ;
2016-06-07 19:32:03 +02:00
if ( isEmpty && format & ListFormat . OptionalIfEmpty ) {
2017-09-14 23:30:50 +02:00
if ( onBeforeEmitNodeArray ) {
onBeforeEmitNodeArray ( children ) ;
}
if ( onAfterEmitNodeArray ) {
onAfterEmitNodeArray ( children ) ;
}
2016-06-07 19:32:03 +02:00
return ;
2015-06-18 23:01:49 +02:00
}
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . BracketsMask ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( getOpeningBracket ( format ) ) ;
2018-03-16 06:23:10 +01:00
if ( isEmpty && ! isUndefined ) {
2018-05-22 23:46:57 +02:00
// TODO: GH#18217
emitTrailingCommentsOfPosition ( children ! . pos , /*prefixSpace*/ true ) ; // Emit comments within empty bracketed lists
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
}
2016-06-07 19:32:03 +02:00
}
2016-01-27 07:59:34 +01:00
2017-03-15 19:44:36 +01:00
if ( onBeforeEmitNodeArray ) {
onBeforeEmitNodeArray ( children ) ;
}
2016-06-07 19:32:03 +02:00
if ( isEmpty ) {
// Write a line terminator if the parent node was multi-line
if ( format & ListFormat . MultiLine ) {
writeLine ( ) ;
2016-01-27 07:59:34 +01:00
}
2017-09-07 23:30:19 +02:00
else if ( format & ListFormat . SpaceBetweenBraces && ! ( format & ListFormat . NoSpaceIfEmpty ) ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2015-06-18 23:01:49 +02:00
}
}
2016-06-07 19:32:03 +02:00
else {
// Write the opening line terminator or leading whitespace.
const mayEmitInterveningComments = ( format & ListFormat . NoInterveningComments ) === 0 ;
let shouldEmitInterveningComments = mayEmitInterveningComments ;
2018-05-22 23:46:57 +02:00
if ( shouldWriteLeadingLineTerminator ( parentNode , children ! , format ) ) { // TODO: GH#18217
2016-06-07 19:32:03 +02:00
writeLine ( ) ;
shouldEmitInterveningComments = false ;
}
else if ( format & ListFormat . SpaceBetweenBraces ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2015-06-18 23:01:49 +02:00
}
2016-06-07 19:32:03 +02:00
// Increase the indent, if requested.
if ( format & ListFormat . Indented ) {
increaseIndent ( ) ;
2015-06-18 23:01:49 +02:00
}
2016-06-07 19:32:03 +02:00
// Emit each child.
2018-05-22 23:46:57 +02:00
let previousSibling : Node | undefined ;
let shouldDecreaseIndentAfterEmit = false ;
2016-06-07 19:32:03 +02:00
for ( let i = 0 ; i < count ; i ++ ) {
2018-05-22 23:46:57 +02:00
const child = children ! [ start + i ] ;
2015-11-24 22:31:30 +01:00
2016-06-07 19:32:03 +02:00
// Write the delimiter if this is not the first node.
2018-10-25 01:14:52 +02:00
if ( format & ListFormat . AsteriskDelimited ) {
// always write JSDoc in the format "\n *"
writeLine ( ) ;
writeDelimiter ( format ) ;
}
else if ( previousSibling ) {
2017-02-07 03:13:17 +01:00
// i.e
// function commentedParameters(
// /* Parameter a */
// a
2017-02-08 19:17:58 +01:00
// /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline
2017-02-07 03:13:17 +01:00
// ,
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( format & ListFormat . DelimitersMask && previousSibling . end !== parentNode . end ) {
2017-02-08 19:17:58 +01:00
emitLeadingCommentsOfPosition ( previousSibling . end ) ;
2017-02-07 03:13:17 +01:00
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeDelimiter ( format ) ;
2016-06-07 19:32:03 +02:00
// Write either a line terminator or whitespace to separate the elements.
if ( shouldWriteSeparatingLineTerminator ( previousSibling , child , format ) ) {
// If a synthesized node in a single-line list starts on a new
// line, we should increase the indent.
if ( ( format & ( ListFormat . LinesMask | ListFormat . Indented ) ) === ListFormat . SingleLine ) {
increaseIndent ( ) ;
shouldDecreaseIndentAfterEmit = true ;
}
2015-11-24 22:31:30 +01:00
2014-10-11 01:44:14 +02:00
writeLine ( ) ;
2016-06-07 19:32:03 +02:00
shouldEmitInterveningComments = false ;
}
else if ( previousSibling && format & ListFormat . SpaceBetweenSiblings ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2014-07-19 03:07:38 +02:00
}
}
2014-07-12 01:36:06 +02:00
2017-01-30 21:27:24 +01:00
// Emit this child.
2016-06-07 19:32:03 +02:00
if ( shouldEmitInterveningComments ) {
2017-01-30 21:27:24 +01:00
if ( emitTrailingCommentsOfPosition ) {
const commentRange = getCommentRange ( child ) ;
emitTrailingCommentsOfPosition ( commentRange . pos ) ;
}
2015-03-17 21:41:29 +01:00
}
2016-06-07 19:32:03 +02:00
else {
shouldEmitInterveningComments = mayEmitInterveningComments ;
Add support for --noEmitHelpers flag
This PR is a Work In Progress that addresses multiple `__extends`
being output as described in #1350: Multiple `__extends` being output
when `--module amd` is set.
The issue still exists as of `v1.5.0 - f53e6a8`.
Apparently a fix was created for this in #1356 but according to #2009, a
[comment](https://github.com/Microsoft/TypeScript/issues/2009#issuecomment-74136291)
later indicated that this was never merged in.
Further conversation continued in #2487 but did not yield any result. I
refer to my earlier recommendation in #1350.
> My question is this, would the TypeScript team be open to a flag that
> can be passed to tsc that will generate something like the following
> ```ts
> define(["require", "exports", "__extends", './mammal'], function (require, exports, __extends, Mammal) {
> var Human = (function (_super) {
> __extends(Human, _super);
> function Human() {
> _super.apply(this, arguments);
> }
> return Human;
> })(Mammal);
> return Human;
> });
> ```
To continue with the naming convention I have chosen the flag
`--noEmitHelpers`.
2015-04-24 04:16:11 +02:00
}
2016-06-07 19:32:03 +02:00
emit ( child ) ;
2016-04-08 03:30:26 +02:00
2016-06-07 19:32:03 +02:00
if ( shouldDecreaseIndentAfterEmit ) {
decreaseIndent ( ) ;
shouldDecreaseIndentAfterEmit = false ;
2015-04-02 02:58:28 +02:00
}
2016-06-07 19:32:03 +02:00
previousSibling = child ;
}
2015-07-09 23:44:47 +02:00
2016-06-07 19:32:03 +02:00
// Write a trailing comma, if requested.
2018-05-22 23:46:57 +02:00
const hasTrailingComma = ( format & ListFormat . AllowTrailingComma ) && children ! . hasTrailingComma ;
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . CommaDelimited && hasTrailingComma ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( "," ) ;
2015-04-02 02:58:28 +02:00
}
2015-07-31 20:54:03 +02:00
2017-02-07 03:13:17 +01:00
// Emit any trailing comment of the last element in the list
// i.e
// var array = [...
// 2
// /* end of element 2 */
// ];
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
if ( previousSibling && format & ListFormat . DelimitersMask && previousSibling . end !== parentNode . end && ! ( getEmitFlags ( previousSibling ) & EmitFlags . NoTrailingComments ) ) {
2017-02-08 19:17:58 +01:00
emitLeadingCommentsOfPosition ( previousSibling . end ) ;
2017-02-07 03:13:17 +01:00
}
2016-06-07 19:32:03 +02:00
// Decrease the indent, if requested.
if ( format & ListFormat . Indented ) {
decreaseIndent ( ) ;
}
2015-07-31 20:54:03 +02:00
2016-06-07 19:32:03 +02:00
// Write the closing line terminator or closing whitespace.
2018-05-22 23:46:57 +02:00
if ( shouldWriteClosingLineTerminator ( parentNode , children ! , format ) ) {
2016-06-07 19:32:03 +02:00
writeLine ( ) ;
2014-07-12 00:13:01 +02:00
}
2016-06-07 19:32:03 +02:00
else if ( format & ListFormat . SpaceBetweenBraces ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2014-07-12 00:13:01 +02:00
}
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2017-03-15 19:44:36 +01:00
if ( onAfterEmitNodeArray ) {
onAfterEmitNodeArray ( children ) ;
}
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . BracketsMask ) {
2018-03-16 06:23:10 +01:00
if ( isEmpty && ! isUndefined ) {
2018-05-22 23:46:57 +02:00
// TODO: GH#18217
emitLeadingCommentsOfPosition ( children ! . end ) ; // Emit leading comments within empty lists
Much better comment preservation (#22141)
* Retain comments on (and produce sourcemaps on) the equals token in initializers
* Improved comments/sourcemaps for await, yield, while, and for
* Retain comments on block curly-braces
* Emit comments for if statements
* Improved switch case comment emit
* Improve comment and sourcemap emit for try/catch, throw, and continue statements
* Improve sourcemap emit and comments for with statements
* More accurate sourcemaps+comments emit for new, typeof, void, and delete
* Improve comment emit for element access expressions
* Preserve more comments on imports and exports
* Make function a bit more defensive like other usages of emitTrailingCommentsOfPosition
* Support preserving comments within empty lists
* Handle leading comments of tokens, conditionally indent leading comments
* Stop heuristically sourcemapping tokens
When the transform was trivial it worked, but was unneeded, but when it was complex, it was brittle - best leave source mapping up to the transformers
* Fix unneeded +1
* Tighten up element access comments
* Handle comments on parenthesized expression tokens
* Fix nit
2018-03-03 02:23:59 +01:00
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writePunctuation ( getClosingBracket ( format ) ) ;
2014-07-13 01:04:16 +02:00
}
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2018-09-05 02:50:06 +02:00
// Writers
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeLiteral ( s : string ) {
writer . writeLiteral ( s ) ;
}
function writeStringLiteral ( s : string ) {
writer . writeStringLiteral ( s ) ;
}
function writeBase ( s : string ) {
2017-01-30 21:27:24 +01:00
writer . write ( s ) ;
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeSymbol ( s : string , sym : Symbol ) {
writer . writeSymbol ( s , sym ) ;
}
function writePunctuation ( s : string ) {
writer . writePunctuation ( s ) ;
}
2018-08-22 21:42:36 +02:00
function writeTrailingSemicolon() {
writer . writeTrailingSemicolon ( ";" ) ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
}
function writeKeyword ( s : string ) {
writer . writeKeyword ( s ) ;
}
function writeOperator ( s : string ) {
writer . writeOperator ( s ) ;
}
function writeParameter ( s : string ) {
writer . writeParameter ( s ) ;
}
2018-08-22 21:42:36 +02:00
function writeComment ( s : string ) {
writer . writeComment ( s ) ;
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeSpace() {
writer . writeSpace ( " " ) ;
}
function writeProperty ( s : string ) {
writer . writeProperty ( s ) ;
}
2017-01-30 21:27:24 +01:00
function writeLine() {
writer . writeLine ( ) ;
}
function increaseIndent() {
writer . increaseIndent ( ) ;
}
function decreaseIndent() {
writer . decreaseIndent ( ) ;
2016-12-05 21:30:14 +01:00
}
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeToken ( token : SyntaxKind , pos : number , writer : ( s : string ) = > void , contextNode? : Node ) {
2018-09-05 02:50:06 +02:00
return ! sourceMapsDisabled
? emitTokenWithSourceMap ( contextNode , token , writer , pos , writeTokenText )
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
: writeTokenText ( token , writer , pos ) ;
2016-06-07 19:32:03 +02:00
}
2015-01-23 00:58:00 +01:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function writeTokenNode ( node : Node , writer : ( s : string ) = > void ) {
2017-05-19 19:18:42 +02:00
if ( onBeforeEmitToken ) {
onBeforeEmitToken ( node ) ;
}
2018-05-22 23:46:57 +02:00
writer ( tokenToString ( node . kind ) ! ) ;
2017-05-19 19:18:42 +02:00
if ( onAfterEmitToken ) {
onAfterEmitToken ( node ) ;
}
}
2018-05-22 23:46:57 +02:00
function writeTokenText ( token : SyntaxKind , writer : ( s : string ) = > void ) : void ;
function writeTokenText ( token : SyntaxKind , writer : ( s : string ) = > void , pos : number ) : number ;
function writeTokenText ( token : SyntaxKind , writer : ( s : string ) = > void , pos? : number ) : number {
const tokenString = tokenToString ( token ) ! ;
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writer ( tokenString ) ;
2018-05-22 23:46:57 +02:00
return pos ! < 0 ? pos ! : pos ! + tokenString . length ;
2016-06-07 19:32:03 +02:00
}
2015-01-23 00:58:00 +01:00
2017-01-30 21:27:24 +01:00
function writeLineOrSpace ( node : Node ) {
if ( getEmitFlags ( node ) & EmitFlags . SingleLine ) {
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
writeSpace ( ) ;
2017-01-30 21:27:24 +01:00
}
else {
writeLine ( ) ;
}
}
function writeLines ( text : string ) : void {
const lines = text . split ( /\r\n?|\n/g ) ;
const indentation = guessIndentation ( lines ) ;
2017-11-03 23:20:35 +01:00
for ( const lineText of lines ) {
const line = indentation ? lineText . slice ( indentation ) : lineText ;
2017-01-30 21:27:24 +01:00
if ( line . length ) {
writeLine ( ) ;
write ( line ) ;
}
}
}
2018-08-22 21:42:36 +02:00
function increaseIndentIf ( value : boolean , writeSpaceIfNotIndenting : boolean ) {
2016-06-07 19:32:03 +02:00
if ( value ) {
increaseIndent ( ) ;
writeLine ( ) ;
2015-11-24 07:38:05 +01:00
}
2018-08-22 21:42:36 +02:00
else if ( writeSpaceIfNotIndenting ) {
writeSpace ( ) ;
2015-07-30 20:11:36 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-07-30 20:11:36 +02:00
2016-06-07 19:32:03 +02:00
// Helper function to decrease the indent if we previously indented. Allows multiple
// previous indent values to be considered at a time. This also allows caller to just
// call this once, passing in all their appropriate indent values, instead of needing
// to call this helper function multiple times.
2018-08-22 21:42:36 +02:00
function decreaseIndentIf ( value1 : boolean , value2 : boolean ) {
2016-06-07 19:32:03 +02:00
if ( value1 ) {
decreaseIndent ( ) ;
2015-07-30 20:11:36 +02:00
}
2016-06-07 19:32:03 +02:00
if ( value2 ) {
decreaseIndent ( ) ;
}
}
2015-01-23 00:58:00 +01:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function shouldWriteLeadingLineTerminator ( parentNode : TextRange , children : NodeArray < Node > , format : ListFormat ) {
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . MultiLine ) {
return true ;
}
2015-01-23 00:58:00 +01:00
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . PreserveLines ) {
if ( format & ListFormat . PreferNewLine ) {
return true ;
2015-01-23 00:58:00 +01:00
}
2016-06-07 19:32:03 +02:00
const firstChild = children [ 0 ] ;
if ( firstChild === undefined ) {
2018-11-10 02:18:34 +01:00
return ! rangeIsOnSingleLine ( parentNode , currentSourceFile ! ) ;
2016-06-07 19:32:03 +02:00
}
else if ( positionIsSynthesized ( parentNode . pos ) || nodeIsSynthesized ( firstChild ) ) {
return synthesizedNodeStartsOnNewLine ( firstChild , format ) ;
2015-03-18 02:34:42 +01:00
}
2016-06-07 19:32:03 +02:00
else {
2018-11-10 02:18:34 +01:00
return ! rangeStartPositionsAreOnSameLine ( parentNode , firstChild , currentSourceFile ! ) ;
2016-06-07 19:32:03 +02:00
}
}
else {
return false ;
}
}
2015-03-18 02:34:42 +01:00
2018-05-22 23:46:57 +02:00
function shouldWriteSeparatingLineTerminator ( previousNode : Node | undefined , nextNode : Node , format : ListFormat ) {
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . MultiLine ) {
2015-01-23 00:58:00 +01:00
return true ;
}
2016-06-07 19:32:03 +02:00
else if ( format & ListFormat . PreserveLines ) {
if ( previousNode === undefined || nextNode === undefined ) {
return false ;
}
else if ( nodeIsSynthesized ( previousNode ) || nodeIsSynthesized ( nextNode ) ) {
return synthesizedNodeStartsOnNewLine ( previousNode , format ) || synthesizedNodeStartsOnNewLine ( nextNode , format ) ;
}
else {
2018-11-10 02:18:34 +01:00
return ! rangeEndIsOnSameLineAsRangeStart ( previousNode , nextNode , currentSourceFile ! ) ;
2014-08-07 03:42:14 +02:00
}
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
else {
2017-11-06 21:51:34 +01:00
return getStartsOnNewLine ( nextNode ) ;
2016-06-07 19:32:03 +02:00
}
}
2014-07-17 00:39:14 +02:00
Fully deprecate the symbol display builder, reimplement in terms of node builder (#18860)
* Remove SymbolWriter, give methods to EmitTextWriter
* Unification of writers is done-ish
* Make node builder support more flags
* Write out mixins like we used to
* Accept prototype-free baselines
* Use instantiated constraint when building mapped type nodes
* Accept better mapped type baselines
* Report inaccessible this in node builder
* Turns out there was a bug in our codefix, too
* Symbol display builder usage falling
* Replace signatureToString with a nodeBuilder solution
* Replace the last internal usages of the symbol writer
* Accept semicolon additions
* Accept updated symbol baseline output
* Start using node builder for some LS operations
* Remove those pesky trailing semicolons on signatures
* Get signature printing much closer to old output
* Parameter lists should not be indented by default, especially when single-line
* Signatures up to snuff
* Type quickinfo emit is up to snuff
* Start of symbol writer replacement, needs a bit more for full compat
* Slightly mor accurate to old behavior
* Replicate qualified name type argument output correctly
* Bring back the old symbol baselines
* Mostly identical to old symbol emit now
* Perfectly matches old behavior thus far
* Replace another usage of the symbol builder
* Another usage removed
* Another usage removed
* Remove final uses of symbol display builder
* Remove implementation and types for unused symbol display builder
* Cleanup in the checker
* monomorphize new emitter code
* Replace emitWithSuffix
* Push space character to interface with writer
* List emit
* Fix lack of usage of emitExpression
* writeList, not printList
* Remove listy writes and replace with new printer calls
* Move ListFormat into types.ts
* Remove most new XToString functions in favor of node builder functions
* Accept API breaks
* Add getSymbolDisplayBuilder polyfill
* Accept updated API baseline
* Move definition to make diff easier to read
* Reinternalize some things
* Remove trailign whitespace
* Reorder for zero diff
* Remove newline
* Make shim mor eperfectly imitate old behavior
* Style feedback
* Rename reset to clear to maintain backcompat with SymbolWriter
* Fix quickfix
* Keep EmitTextWriter internal
* Remove EmitTextWriter from public API
* Mimic default name declaration emit fix
* Fix tests broken by merge
* use isFunctionLike
* Cleanup, sync TypeFormat and NodeBuilder flags
* Reorder Node initialization so pos and end are first, so a TextRange hidden class is made first to reduce future polymorphism
* Use variable instead of ternary
* Write helper for emitNodeWithWriter
* Emitter cleanup
* Cleanup whitespace, comment
* Reuse printer
* Raise error if display parts writer uses rawWrite
* Hide writer parameter through different function instead of overload, rename function in emitter
* Make less printer
* fix lint
2018-01-16 18:53:42 +01:00
function shouldWriteClosingLineTerminator ( parentNode : TextRange , children : NodeArray < Node > , format : ListFormat ) {
2016-06-07 19:32:03 +02:00
if ( format & ListFormat . MultiLine ) {
return ( format & ListFormat . NoTrailingNewLine ) === 0 ;
2014-07-13 01:04:16 +02:00
}
2016-06-07 19:32:03 +02:00
else if ( format & ListFormat . PreserveLines ) {
if ( format & ListFormat . PreferNewLine ) {
return true ;
}
2014-07-13 01:04:16 +02:00
2016-06-07 19:32:03 +02:00
const lastChild = lastOrUndefined ( children ) ;
if ( lastChild === undefined ) {
2018-11-10 02:18:34 +01:00
return ! rangeIsOnSingleLine ( parentNode , currentSourceFile ! ) ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
else if ( positionIsSynthesized ( parentNode . pos ) || nodeIsSynthesized ( lastChild ) ) {
return synthesizedNodeStartsOnNewLine ( lastChild , format ) ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
else {
2018-11-10 02:18:34 +01:00
return ! rangeEndPositionsAreOnSameLine ( parentNode , lastChild , currentSourceFile ! ) ;
2015-03-18 03:25:40 +01:00
}
2016-06-07 19:32:03 +02:00
}
else {
2015-08-25 22:47:02 +02:00
return false ;
2015-03-18 03:25:40 +01:00
}
2016-06-07 19:32:03 +02:00
}
2015-03-18 03:25:40 +01:00
2018-05-22 23:46:57 +02:00
function synthesizedNodeStartsOnNewLine ( node : Node , format : ListFormat ) {
2016-06-07 19:32:03 +02:00
if ( nodeIsSynthesized ( node ) ) {
2017-11-06 21:51:34 +01:00
const startsOnNewLine = getStartsOnNewLine ( node ) ;
2016-06-07 19:32:03 +02:00
if ( startsOnNewLine === undefined ) {
return ( format & ListFormat . PreferNewLine ) !== 0 ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
return startsOnNewLine ;
2014-07-17 00:39:14 +02:00
}
2014-08-07 02:58:03 +02:00
2016-06-07 19:32:03 +02:00
return ( format & ListFormat . PreferNewLine ) !== 0 ;
}
function needsIndentation ( parent : Node , node1 : Node , node2 : Node ) : boolean {
parent = skipSynthesizedParentheses ( parent ) ;
node1 = skipSynthesizedParentheses ( node1 ) ;
node2 = skipSynthesizedParentheses ( node2 ) ;
// Always use a newline for synthesized code if the synthesizer desires it.
2017-11-06 21:51:34 +01:00
if ( getStartsOnNewLine ( node2 ) ) {
2016-06-07 19:32:03 +02:00
return true ;
2015-03-18 02:34:42 +01:00
}
2016-06-07 19:32:03 +02:00
return ! nodeIsSynthesized ( parent )
&& ! nodeIsSynthesized ( node1 )
&& ! nodeIsSynthesized ( node2 )
2018-11-10 02:18:34 +01:00
&& ! rangeEndIsOnSameLineAsRangeStart ( node1 , node2 , currentSourceFile ! ) ;
2016-06-07 19:32:03 +02:00
}
2017-01-30 21:27:24 +01:00
function isEmptyBlock ( block : BlockLike ) {
return block . statements . length === 0
2018-11-10 02:18:34 +01:00
&& rangeEndIsOnSameLineAsRangeStart ( block , block , currentSourceFile ! ) ;
2017-01-30 21:27:24 +01:00
}
2016-06-07 19:32:03 +02:00
function skipSynthesizedParentheses ( node : Node ) {
while ( node . kind === SyntaxKind . ParenthesizedExpression && nodeIsSynthesized ( node ) ) {
node = ( < ParenthesizedExpression > node ) . expression ;
2015-03-18 02:34:42 +01:00
}
2016-06-07 19:32:03 +02:00
return node ;
}
function getTextOfNode ( node : Node , includeTrivia? : boolean ) : string {
if ( isGeneratedIdentifier ( node ) ) {
2017-01-30 21:27:24 +01:00
return generateName ( node ) ;
2016-06-07 19:32:03 +02:00
}
2018-05-10 20:16:27 +02:00
else if ( isIdentifier ( node ) && ( nodeIsSynthesized ( node ) || ! node . parent || ! currentSourceFile || ( node . parent && currentSourceFile && getSourceFileOfNode ( node ) !== getOriginalNode ( currentSourceFile ) ) ) ) {
2017-09-29 18:57:31 +02:00
return idText ( node ) ;
2016-06-07 19:32:03 +02:00
}
else if ( node . kind === SyntaxKind . StringLiteral && ( < StringLiteral > node ) . textSourceNode ) {
2018-05-22 23:46:57 +02:00
return getTextOfNode ( ( < StringLiteral > node ) . textSourceNode ! , includeTrivia ) ;
2016-06-07 19:32:03 +02:00
}
else if ( isLiteralExpression ( node ) && ( nodeIsSynthesized ( node ) || ! node . parent ) ) {
return node . text ;
2015-03-18 02:34:42 +01:00
}
2018-11-10 02:18:34 +01:00
return getSourceTextOfNodeFromSourceFile ( currentSourceFile ! , node , includeTrivia ) ;
2016-06-07 19:32:03 +02:00
}
2015-10-01 00:45:23 +02:00
2018-09-17 20:06:39 +02:00
function getLiteralTextOfNode ( node : LiteralLikeNode , neverAsciiEscape : boolean | undefined ) : string {
2016-06-07 19:32:03 +02:00
if ( node . kind === SyntaxKind . StringLiteral && ( < StringLiteral > node ) . textSourceNode ) {
2018-05-22 23:46:57 +02:00
const textSourceNode = ( < StringLiteral > node ) . textSourceNode ! ;
2016-06-07 19:32:03 +02:00
if ( isIdentifier ( textSourceNode ) ) {
2018-09-17 20:06:39 +02:00
return neverAsciiEscape || ( getEmitFlags ( node ) & EmitFlags . NoAsciiEscaping ) ?
2017-05-16 03:42:49 +02:00
` " ${ escapeString ( getTextOfNode ( textSourceNode ) ) } " ` :
2017-05-17 00:28:32 +02:00
` " ${ escapeNonAsciiString ( getTextOfNode ( textSourceNode ) ) } " ` ;
2015-08-25 22:47:02 +02:00
}
else {
2018-09-17 20:06:39 +02:00
return getLiteralTextOfNode ( textSourceNode , neverAsciiEscape ) ;
2015-08-25 22:47:02 +02:00
}
2016-06-07 19:32:03 +02:00
}
2015-03-18 02:34:42 +01:00
2018-11-10 02:18:34 +01:00
return getLiteralText ( node , currentSourceFile ! , neverAsciiEscape ) ;
2016-06-07 19:32:03 +02:00
}
2015-03-18 02:34:42 +01:00
2017-01-30 21:27:24 +01:00
/ * *
* Push a new name generation scope .
* /
2017-11-06 21:51:34 +01:00
function pushNameGenerationScope ( node : Node | undefined ) {
if ( node && getEmitFlags ( node ) & EmitFlags . ReuseTempVariableScope ) {
return ;
}
2017-01-30 21:27:24 +01:00
tempFlagsStack . push ( tempFlags ) ;
tempFlags = 0 ;
2018-01-16 21:33:55 +01:00
reservedNamesStack . push ( reservedNames ) ;
2016-10-04 04:05:12 +02:00
}
2017-01-30 21:27:24 +01:00
/ * *
* Pop the current name generation scope .
* /
2017-11-06 21:51:34 +01:00
function popNameGenerationScope ( node : Node | undefined ) {
if ( node && getEmitFlags ( node ) & EmitFlags . ReuseTempVariableScope ) {
return ;
}
2018-05-22 23:46:57 +02:00
tempFlags = tempFlagsStack . pop ( ) ! ;
reservedNames = reservedNamesStack . pop ( ) ! ;
2018-01-16 21:33:55 +01:00
}
function reserveNameInNestedScopes ( name : string ) {
if ( ! reservedNames || reservedNames === lastOrUndefined ( reservedNamesStack ) ) {
reservedNames = createMap < true > ( ) ;
}
reservedNames . set ( name , true ) ;
2017-01-30 21:27:24 +01:00
}
2018-05-02 22:34:14 +02:00
function generateNames ( node : Node | undefined ) {
if ( ! node ) return ;
switch ( node . kind ) {
case SyntaxKind . Block :
forEach ( ( < Block > node ) . statements , generateNames ) ;
break ;
case SyntaxKind . LabeledStatement :
case SyntaxKind . WithStatement :
case SyntaxKind . DoStatement :
case SyntaxKind . WhileStatement :
generateNames ( ( < LabeledStatement | WithStatement | DoStatement | WhileStatement > node ) . statement ) ;
break ;
case SyntaxKind . IfStatement :
generateNames ( ( < IfStatement > node ) . thenStatement ) ;
generateNames ( ( < IfStatement > node ) . elseStatement ) ;
break ;
case SyntaxKind . ForStatement :
case SyntaxKind . ForOfStatement :
case SyntaxKind . ForInStatement :
generateNames ( ( < ForStatement | ForInOrOfStatement > node ) . initializer ) ;
generateNames ( ( < ForStatement | ForInOrOfStatement > node ) . statement ) ;
break ;
case SyntaxKind . SwitchStatement :
generateNames ( ( < SwitchStatement > node ) . caseBlock ) ;
break ;
case SyntaxKind . CaseBlock :
forEach ( ( < CaseBlock > node ) . clauses , generateNames ) ;
break ;
case SyntaxKind . CaseClause :
case SyntaxKind . DefaultClause :
forEach ( ( < CaseOrDefaultClause > node ) . statements , generateNames ) ;
break ;
case SyntaxKind . TryStatement :
generateNames ( ( < TryStatement > node ) . tryBlock ) ;
generateNames ( ( < TryStatement > node ) . catchClause ) ;
generateNames ( ( < TryStatement > node ) . finallyBlock ) ;
break ;
case SyntaxKind . CatchClause :
generateNames ( ( < CatchClause > node ) . variableDeclaration ) ;
generateNames ( ( < CatchClause > node ) . block ) ;
break ;
case SyntaxKind . VariableStatement :
generateNames ( ( < VariableStatement > node ) . declarationList ) ;
break ;
case SyntaxKind . VariableDeclarationList :
forEach ( ( < VariableDeclarationList > node ) . declarations , generateNames ) ;
break ;
case SyntaxKind . VariableDeclaration :
case SyntaxKind . Parameter :
case SyntaxKind . BindingElement :
case SyntaxKind . ClassDeclaration :
generateNameIfNeeded ( ( < NamedDeclaration > node ) . name ) ;
break ;
case SyntaxKind . FunctionDeclaration :
generateNameIfNeeded ( ( < FunctionDeclaration > node ) . name ) ;
if ( getEmitFlags ( node ) & EmitFlags . ReuseTempVariableScope ) {
forEach ( ( < FunctionDeclaration > node ) . parameters , generateNames ) ;
generateNames ( ( < FunctionDeclaration > node ) . body ) ;
}
break ;
case SyntaxKind . ObjectBindingPattern :
case SyntaxKind . ArrayBindingPattern :
forEach ( ( < BindingPattern > node ) . elements , generateNames ) ;
break ;
case SyntaxKind . ImportDeclaration :
generateNames ( ( < ImportDeclaration > node ) . importClause ) ;
break ;
case SyntaxKind . ImportClause :
generateNameIfNeeded ( ( < ImportClause > node ) . name ) ;
generateNames ( ( < ImportClause > node ) . namedBindings ) ;
break ;
case SyntaxKind . NamespaceImport :
generateNameIfNeeded ( ( < NamespaceImport > node ) . name ) ;
break ;
case SyntaxKind . NamedImports :
forEach ( ( < NamedImports > node ) . elements , generateNames ) ;
break ;
case SyntaxKind . ImportSpecifier :
generateNameIfNeeded ( ( < ImportSpecifier > node ) . propertyName || ( < ImportSpecifier > node ) . name ) ;
break ;
}
}
function generateMemberNames ( node : Node | undefined ) {
if ( ! node ) return ;
switch ( node . kind ) {
case SyntaxKind . PropertyAssignment :
case SyntaxKind . ShorthandPropertyAssignment :
case SyntaxKind . PropertyDeclaration :
case SyntaxKind . MethodDeclaration :
case SyntaxKind . GetAccessor :
case SyntaxKind . SetAccessor :
generateNameIfNeeded ( ( < NamedDeclaration > node ) . name ) ;
break ;
}
}
function generateNameIfNeeded ( name : DeclarationName | undefined ) {
if ( name ) {
if ( isGeneratedIdentifier ( name ) ) {
generateName ( name ) ;
}
else if ( isBindingPattern ( name ) ) {
generateNames ( name ) ;
}
}
}
2017-01-30 21:27:24 +01:00
/ * *
* Generate the text for a generated identifier .
* /
function generateName ( name : GeneratedIdentifier ) {
2018-01-16 21:33:55 +01:00
if ( ( name . autoGenerateFlags & GeneratedIdentifierFlags . KindMask ) === GeneratedIdentifierFlags . Node ) {
2017-01-30 21:27:24 +01:00
// Node names generate unique names based on their original node
// and are cached based on that node's id.
2018-05-10 20:16:27 +02:00
return generateNameCached ( getNodeForGeneratedName ( name ) , name . autoGenerateFlags ) ;
2017-01-30 21:27:24 +01:00
}
else {
// Auto, Loop, and Unique names are cached based on their unique
// autoGenerateId.
2018-05-22 23:46:57 +02:00
const autoGenerateId = name . autoGenerateId ! ;
2017-07-06 23:45:50 +02:00
return autoGeneratedIdToGeneratedName [ autoGenerateId ] || ( autoGeneratedIdToGeneratedName [ autoGenerateId ] = makeName ( name ) ) ;
2017-01-30 21:27:24 +01:00
}
2016-06-07 19:32:03 +02:00
}
2015-03-18 02:34:42 +01:00
2018-05-10 20:16:27 +02:00
function generateNameCached ( node : Node , flags? : GeneratedIdentifierFlags ) {
2017-01-30 21:27:24 +01:00
const nodeId = getNodeId ( node ) ;
2018-05-10 20:16:27 +02:00
return nodeIdToGeneratedName [ nodeId ] || ( nodeIdToGeneratedName [ nodeId ] = generateNameForNode ( node , flags ) ) ;
2017-01-30 21:27:24 +01:00
}
/ * *
* Returns a value indicating whether a name is unique globally , within the current file ,
* or within the NameGenerator .
* /
2016-06-07 19:32:03 +02:00
function isUniqueName ( name : string ) : boolean {
2018-03-31 02:43:37 +02:00
return isFileLevelUniqueName ( name )
2018-01-16 21:33:55 +01:00
&& ! generatedNames . has ( name )
&& ! ( reservedNames && reservedNames . has ( name ) ) ;
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
2018-03-31 02:43:37 +02:00
/ * *
* Returns a value indicating whether a name is unique globally or within the current file .
* /
function isFileLevelUniqueName ( name : string ) {
2018-05-10 20:16:27 +02:00
return currentSourceFile ? ts . isFileLevelUniqueName ( currentSourceFile , name , hasGlobalName ) : true ;
2018-03-31 02:43:37 +02:00
}
2017-01-30 21:27:24 +01:00
/ * *
* Returns a value indicating whether a name is unique within a container .
* /
2016-06-07 19:32:03 +02:00
function isUniqueLocalName ( name : string , container : Node ) : boolean {
2018-05-22 23:46:57 +02:00
for ( let node = container ; isNodeDescendantOf ( node , container ) ; node = node . nextContainer ! ) {
2016-12-05 23:13:32 +01:00
if ( node . locals ) {
2017-07-06 23:45:50 +02:00
const local = node . locals . get ( escapeLeadingUnderscores ( name ) ) ;
2016-06-07 19:32:03 +02:00
// We conservatively include alias symbols to cover cases where they're emitted as locals
2016-12-05 23:13:32 +01:00
if ( local && local . flags & ( SymbolFlags . Value | SymbolFlags . ExportValue | SymbolFlags . Alias ) ) {
2016-06-07 19:32:03 +02:00
return false ;
}
2015-09-01 05:33:02 +02:00
}
2015-08-07 02:20:35 +02:00
}
2016-06-07 19:32:03 +02:00
return true ;
}
2015-08-07 02:20:35 +02:00
2016-06-07 19:32:03 +02:00
/ * *
2017-01-30 21:27:24 +01:00
* Return the next available name in the pattern _a . . . _z , _0 , _1 , . . .
* TempFlags . _i or TempFlags . _n may be used to express a preference for that dedicated name .
* Note that names generated by makeTempVariableName and makeUniqueName will never conflict .
* /
2018-01-16 21:33:55 +01:00
function makeTempVariableName ( flags : TempFlags , reservedInNestedScopes? : boolean ) : string {
2016-06-07 19:32:03 +02:00
if ( flags && ! ( tempFlags & flags ) ) {
const name = flags === TempFlags . _i ? "_i" : "_n" ;
if ( isUniqueName ( name ) ) {
tempFlags |= flags ;
2018-01-16 21:33:55 +01:00
if ( reservedInNestedScopes ) {
reserveNameInNestedScopes ( name ) ;
}
2016-06-07 19:32:03 +02:00
return name ;
}
}
while ( true ) {
const count = tempFlags & TempFlags . CountMask ;
tempFlags ++ ;
// Skip over 'i' and 'n'
if ( count !== 8 && count !== 13 ) {
const name = count < 26
? "_" + String . fromCharCode ( CharacterCodes . a + count )
: "_" + ( count - 26 ) ;
if ( isUniqueName ( name ) ) {
2018-01-16 21:33:55 +01:00
if ( reservedInNestedScopes ) {
reserveNameInNestedScopes ( name ) ;
}
2016-06-07 19:32:03 +02:00
return name ;
}
2015-09-01 05:33:02 +02:00
}
2016-06-07 19:32:03 +02:00
}
}
2015-09-01 05:33:02 +02:00
2017-01-30 21:27:24 +01:00
/ * *
* Generate a name that is unique within the current file and doesn ' t conflict with any names
* in global scope . The name is formed by adding an '_n' suffix to the specified base name ,
* where n is a positive integer . Note that names generated by makeTempVariableName and
* makeUniqueName are guaranteed to never conflict .
2018-03-16 06:23:10 +01:00
* If ` optimistic ` is set , the first instance will use 'baseName' verbatim instead of 'baseName_1'
2017-01-30 21:27:24 +01:00
* /
2018-05-10 20:16:27 +02:00
function makeUniqueName ( baseName : string , checkFn : ( name : string ) = > boolean = isUniqueName , optimistic? : boolean , scoped? : boolean ) : string {
2018-03-16 06:23:10 +01:00
if ( optimistic ) {
2018-03-31 02:43:37 +02:00
if ( checkFn ( baseName ) ) {
2018-05-10 20:16:27 +02:00
if ( scoped ) {
reserveNameInNestedScopes ( baseName ) ;
}
else {
generatedNames . set ( baseName , true ) ;
}
2018-03-16 06:23:10 +01:00
return baseName ;
}
}
2016-06-07 19:32:03 +02:00
// Find the first unique 'name_n', where n is a positive number
if ( baseName . charCodeAt ( baseName . length - 1 ) !== CharacterCodes . _ ) {
baseName += "_" ;
}
let i = 1 ;
while ( true ) {
const generatedName = baseName + i ;
2018-03-31 02:43:37 +02:00
if ( checkFn ( generatedName ) ) {
2018-05-10 20:16:27 +02:00
if ( scoped ) {
reserveNameInNestedScopes ( generatedName ) ;
}
else {
generatedNames . set ( generatedName , true ) ;
}
2016-12-12 17:42:12 +01:00
return generatedName ;
2014-07-17 00:39:14 +02:00
}
2016-06-07 19:32:03 +02:00
i ++ ;
}
}
2015-03-18 02:34:42 +01:00
2018-09-13 02:51:57 +02:00
function makeFileLevelOptimisticUniqueName ( name : string ) {
2018-03-31 02:43:37 +02:00
return makeUniqueName ( name , isFileLevelUniqueName , /*optimistic*/ true ) ;
}
2017-01-30 21:27:24 +01:00
/ * *
* Generates a unique name for a ModuleDeclaration or EnumDeclaration .
* /
2017-02-03 21:40:39 +01:00
function generateNameForModuleOrEnum ( node : ModuleDeclaration | EnumDeclaration ) {
2016-06-07 19:32:03 +02:00
const name = getTextOfNode ( node . name ) ;
// Use module/enum name itself if it is unique, otherwise make a unique variation
return isUniqueLocalName ( name , node ) ? name : makeUniqueName ( name ) ;
}
2015-03-18 02:34:42 +01:00
2017-01-30 21:27:24 +01:00
/ * *
* Generates a unique name for an ImportDeclaration or ExportDeclaration .
* /
2016-06-07 19:32:03 +02:00
function generateNameForImportOrExportDeclaration ( node : ImportDeclaration | ExportDeclaration ) {
2018-05-22 23:46:57 +02:00
const expr = getExternalModuleName ( node ) ! ; // TODO: GH#18217
2017-07-25 22:16:34 +02:00
const baseName = isStringLiteral ( expr ) ?
makeIdentifierFromModuleName ( expr . text ) : "module" ;
2016-06-07 19:32:03 +02:00
return makeUniqueName ( baseName ) ;
}
2014-07-13 01:04:16 +02:00
2017-01-30 21:27:24 +01:00
/ * *
* Generates a unique name for a default export .
* /
2016-06-07 19:32:03 +02:00
function generateNameForExportDefault() {
return makeUniqueName ( "default" ) ;
}
2014-08-07 02:06:59 +02:00
2017-01-30 21:27:24 +01:00
/ * *
* Generates a unique name for a class expression .
* /
2016-06-07 19:32:03 +02:00
function generateNameForClassExpression() {
return makeUniqueName ( "class" ) ;
}
2015-10-01 00:45:23 +02:00
2017-02-03 21:40:39 +01:00
function generateNameForMethodOrAccessor ( node : MethodDeclaration | AccessorDeclaration ) {
2016-12-09 02:31:18 +01:00
if ( isIdentifier ( node . name ) ) {
2017-02-03 21:40:39 +01:00
return generateNameCached ( node . name ) ;
2016-12-09 02:31:18 +01:00
}
return makeTempVariableName ( TempFlags . Auto ) ;
}
2016-06-07 19:32:03 +02:00
/ * *
* Generates a unique name from a node .
* /
2018-05-10 20:16:27 +02:00
function generateNameForNode ( node : Node , flags? : GeneratedIdentifierFlags ) : string {
2016-06-07 19:32:03 +02:00
switch ( node . kind ) {
case SyntaxKind . Identifier :
2018-05-10 20:16:27 +02:00
return makeUniqueName (
getTextOfNode ( node ) ,
isUniqueName ,
2018-05-22 23:46:57 +02:00
! ! ( flags ! & GeneratedIdentifierFlags . Optimistic ) ,
! ! ( flags ! & GeneratedIdentifierFlags . ReservedInNestedScopes )
2018-05-10 20:16:27 +02:00
) ;
2016-06-07 19:32:03 +02:00
case SyntaxKind . ModuleDeclaration :
case SyntaxKind . EnumDeclaration :
2017-02-03 21:40:39 +01:00
return generateNameForModuleOrEnum ( < ModuleDeclaration | EnumDeclaration > node ) ;
2016-06-07 19:32:03 +02:00
case SyntaxKind . ImportDeclaration :
case SyntaxKind . ExportDeclaration :
return generateNameForImportOrExportDeclaration ( < ImportDeclaration | ExportDeclaration > node ) ;
case SyntaxKind . FunctionDeclaration :
case SyntaxKind . ClassDeclaration :
case SyntaxKind . ExportAssignment :
return generateNameForExportDefault ( ) ;
case SyntaxKind . ClassExpression :
return generateNameForClassExpression ( ) ;
2016-12-09 02:31:18 +01:00
case SyntaxKind . MethodDeclaration :
case SyntaxKind . GetAccessor :
case SyntaxKind . SetAccessor :
2017-02-03 21:40:39 +01:00
return generateNameForMethodOrAccessor ( < MethodDeclaration | AccessorDeclaration > node ) ;
2016-06-07 19:32:03 +02:00
default :
return makeTempVariableName ( TempFlags . Auto ) ;
2015-11-24 07:38:05 +01:00
}
2016-06-07 19:32:03 +02:00
}
2015-11-24 07:38:05 +01:00
2016-06-07 19:32:03 +02:00
/ * *
* Generates a unique identifier for a node .
* /
2017-01-30 21:27:24 +01:00
function makeName ( name : GeneratedIdentifier ) {
2018-01-16 21:33:55 +01:00
switch ( name . autoGenerateFlags & GeneratedIdentifierFlags . KindMask ) {
case GeneratedIdentifierFlags . Auto :
return makeTempVariableName ( TempFlags . Auto , ! ! ( name . autoGenerateFlags & GeneratedIdentifierFlags . ReservedInNestedScopes ) ) ;
case GeneratedIdentifierFlags . Loop :
return makeTempVariableName ( TempFlags . _i , ! ! ( name . autoGenerateFlags & GeneratedIdentifierFlags . ReservedInNestedScopes ) ) ;
case GeneratedIdentifierFlags . Unique :
2018-03-31 02:43:37 +02:00
return makeUniqueName (
idText ( name ) ,
( name . autoGenerateFlags & GeneratedIdentifierFlags . FileLevel ) ? isFileLevelUniqueName : isUniqueName ,
2018-05-10 20:16:27 +02:00
! ! ( name . autoGenerateFlags & GeneratedIdentifierFlags . Optimistic ) ,
! ! ( name . autoGenerateFlags & GeneratedIdentifierFlags . ReservedInNestedScopes )
2018-03-31 02:43:37 +02:00
) ;
2016-06-07 19:32:03 +02:00
}
2018-05-22 23:46:57 +02:00
return Debug . fail ( "Unsupported GeneratedIdentifierKind." ) ;
2016-06-07 19:32:03 +02:00
}
/ * *
* Gets the node from which a name should be generated .
* /
2017-01-30 21:27:24 +01:00
function getNodeForGeneratedName ( name : GeneratedIdentifier ) {
2016-06-07 19:32:03 +02:00
const autoGenerateId = name . autoGenerateId ;
let node = name as Node ;
let original = node . original ;
while ( original ) {
node = original ;
// if "node" is a different generated name (having a different
// "autoGenerateId"), use it and stop traversing.
if ( isIdentifier ( node )
2018-05-22 23:46:57 +02:00
&& ! ! ( node . autoGenerateFlags ! & GeneratedIdentifierFlags . Node )
2016-06-07 19:32:03 +02:00
&& node . autoGenerateId !== autoGenerateId ) {
break ;
2015-08-02 04:24:18 +02:00
}
2016-06-07 19:32:03 +02:00
original = node . original ;
2015-08-02 04:24:18 +02:00
}
2016-06-07 19:32:03 +02:00
// otherwise, return the original node for the source;
return node ;
2014-07-13 01:04:16 +02:00
}
2018-09-05 02:50:06 +02:00
// Comments
2018-09-07 23:11:54 +02:00
function pipelineEmitWithComments ( hint : EmitHint , node : Node ) {
enterComment ( ) ;
hasWrittenComment = false ;
const emitFlags = getEmitFlags ( node ) ;
const { pos , end } = getCommentRange ( node ) ;
const isEmittedNode = node . kind !== SyntaxKind . NotEmittedStatement ;
// We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation.
// It is expensive to walk entire tree just to set one kind of node to have no comments.
const skipLeadingComments = pos < 0 || ( emitFlags & EmitFlags . NoLeadingComments ) !== 0 || node . kind === SyntaxKind . JsxText ;
const skipTrailingComments = end < 0 || ( emitFlags & EmitFlags . NoTrailingComments ) !== 0 || node . kind === SyntaxKind . JsxText ;
// Save current container state on the stack.
const savedContainerPos = containerPos ;
const savedContainerEnd = containerEnd ;
const savedDeclarationListContainerEnd = declarationListContainerEnd ;
if ( ( pos > 0 || end > 0 ) && pos !== end ) {
// Emit leading comments if the position is not synthesized and the node
// has not opted out from emitting leading comments.
if ( ! skipLeadingComments ) {
emitLeadingComments ( pos , isEmittedNode ) ;
2018-09-05 02:50:06 +02:00
}
2018-09-07 23:11:54 +02:00
if ( ! skipLeadingComments || ( pos >= 0 && ( emitFlags & EmitFlags . NoLeadingComments ) !== 0 ) ) {
2018-10-08 23:13:48 +02:00
// Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments.
2018-09-07 23:11:54 +02:00
containerPos = pos ;
}
2018-09-05 02:50:06 +02:00
2018-09-07 23:11:54 +02:00
if ( ! skipTrailingComments || ( end >= 0 && ( emitFlags & EmitFlags . NoTrailingComments ) !== 0 ) ) {
// As above.
containerEnd = end ;
2018-09-05 02:50:06 +02:00
2018-09-07 23:11:54 +02:00
// To avoid invalid comment emit in a down-level binding pattern, we
// keep track of the last declaration list container's end
if ( node . kind === SyntaxKind . VariableDeclarationList ) {
declarationListContainerEnd = end ;
2018-09-05 02:50:06 +02:00
}
}
}
2018-09-07 23:11:54 +02:00
forEach ( getSyntheticLeadingComments ( node ) , emitLeadingSynthesizedComment ) ;
exitComment ( ) ;
2018-09-05 02:50:06 +02:00
2018-09-07 23:11:54 +02:00
const pipelinePhase = getNextPipelinePhase ( PipelinePhase . Comments , node ) ;
if ( emitFlags & EmitFlags . NoNestedComments ) {
commentsDisabled = true ;
pipelinePhase ( hint , node ) ;
commentsDisabled = false ;
}
else {
pipelinePhase ( hint , node ) ;
2018-09-05 02:50:06 +02:00
}
2018-09-07 23:11:54 +02:00
enterComment ( ) ;
forEach ( getSyntheticTrailingComments ( node ) , emitTrailingSynthesizedComment ) ;
if ( ( pos > 0 || end > 0 ) && pos !== end ) {
// Restore previous container state.
containerPos = savedContainerPos ;
containerEnd = savedContainerEnd ;
declarationListContainerEnd = savedDeclarationListContainerEnd ;
2018-09-05 02:50:06 +02:00
2018-09-07 23:11:54 +02:00
// Emit trailing comments if the position is not synthesized and the node
// has not opted out from emitting leading comments and is an emitted node.
if ( ! skipTrailingComments && isEmittedNode ) {
emitTrailingComments ( end ) ;
2018-09-05 02:50:06 +02:00
}
}
2018-09-07 23:11:54 +02:00
exitComment ( ) ;
2018-09-05 02:50:06 +02:00
}
function emitLeadingSynthesizedComment ( comment : SynthesizedComment ) {
if ( comment . kind === SyntaxKind . SingleLineCommentTrivia ) {
writer . writeLine ( ) ;
}
writeSynthesizedComment ( comment ) ;
if ( comment . hasTrailingNewLine || comment . kind === SyntaxKind . SingleLineCommentTrivia ) {
writer . writeLine ( ) ;
}
else {
writer . writeSpace ( " " ) ;
}
}
function emitTrailingSynthesizedComment ( comment : SynthesizedComment ) {
if ( ! writer . isAtStartOfLine ( ) ) {
writer . writeSpace ( " " ) ;
}
writeSynthesizedComment ( comment ) ;
if ( comment . hasTrailingNewLine ) {
writer . writeLine ( ) ;
}
}
function writeSynthesizedComment ( comment : SynthesizedComment ) {
const text = formatSynthesizedComment ( comment ) ;
const lineMap = comment . kind === SyntaxKind . MultiLineCommentTrivia ? computeLineStarts ( text ) : undefined ;
writeCommentRange ( text , lineMap ! , writer , 0 , text . length , newLine ) ;
}
function formatSynthesizedComment ( comment : SynthesizedComment ) {
return comment . kind === SyntaxKind . MultiLineCommentTrivia
? ` /* ${ comment . text } */ `
: ` // ${ comment . text } ` ;
}
function emitBodyWithDetachedComments ( node : Node , detachedRange : TextRange , emitCallback : ( node : Node ) = > void ) {
2018-09-07 23:11:54 +02:00
enterComment ( ) ;
2018-09-05 02:50:06 +02:00
const { pos , end } = detachedRange ;
const emitFlags = getEmitFlags ( node ) ;
const skipLeadingComments = pos < 0 || ( emitFlags & EmitFlags . NoLeadingComments ) !== 0 ;
const skipTrailingComments = commentsDisabled || end < 0 || ( emitFlags & EmitFlags . NoTrailingComments ) !== 0 ;
if ( ! skipLeadingComments ) {
emitDetachedCommentsAndUpdateCommentsInfo ( detachedRange ) ;
}
2018-09-07 23:11:54 +02:00
exitComment ( ) ;
2018-09-05 02:50:06 +02:00
if ( emitFlags & EmitFlags . NoNestedComments && ! commentsDisabled ) {
commentsDisabled = true ;
emitCallback ( node ) ;
commentsDisabled = false ;
}
else {
emitCallback ( node ) ;
}
2018-09-07 23:11:54 +02:00
enterComment ( ) ;
2018-09-05 02:50:06 +02:00
if ( ! skipTrailingComments ) {
emitLeadingComments ( detachedRange . end , /*isEmittedNode*/ true ) ;
if ( hasWrittenComment && ! writer . isAtStartOfLine ( ) ) {
writer . writeLine ( ) ;
}
}
2018-09-07 23:11:54 +02:00
exitComment ( ) ;
2018-09-05 02:50:06 +02:00
}
function emitLeadingComments ( pos : number , isEmittedNode : boolean ) {
hasWrittenComment = false ;
if ( isEmittedNode ) {
forEachLeadingCommentToEmit ( pos , emitLeadingComment ) ;
}
else if ( pos === 0 ) {
// If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
// unless it is a triple slash comment at the top of the file.
// For Example:
// /// <reference-path ...>
// declare var x;
// /// <reference-path ...>
// interface F {}
// The first /// will NOT be removed while the second one will be removed even though both node will not be emitted
forEachLeadingCommentToEmit ( pos , emitTripleSlashLeadingComment ) ;
}
}
function emitTripleSlashLeadingComment ( commentPos : number , commentEnd : number , kind : SyntaxKind , hasTrailingNewLine : boolean , rangePos : number ) {
if ( isTripleSlashComment ( commentPos , commentEnd ) ) {
emitLeadingComment ( commentPos , commentEnd , kind , hasTrailingNewLine , rangePos ) ;
}
}
function shouldWriteComment ( text : string , pos : number ) {
if ( printerOptions . onlyPrintJsDocStyle ) {
return ( isJSDocLikeText ( text , pos ) || isPinnedComment ( text , pos ) ) ;
}
return true ;
}
function emitLeadingComment ( commentPos : number , commentEnd : number , kind : SyntaxKind , hasTrailingNewLine : boolean , rangePos : number ) {
2018-11-10 02:18:34 +01:00
if ( ! shouldWriteComment ( currentSourceFile ! . text , commentPos ) ) return ;
2018-09-05 02:50:06 +02:00
if ( ! hasWrittenComment ) {
emitNewLineBeforeLeadingCommentOfPosition ( getCurrentLineMap ( ) , writer , rangePos , commentPos ) ;
hasWrittenComment = true ;
}
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
emitPos ( commentPos ) ;
2018-11-10 02:18:34 +01:00
writeCommentRange ( currentSourceFile ! . text , getCurrentLineMap ( ) , writer , commentPos , commentEnd , newLine ) ;
2018-09-05 02:50:06 +02:00
emitPos ( commentEnd ) ;
if ( hasTrailingNewLine ) {
writer . writeLine ( ) ;
}
else if ( kind === SyntaxKind . MultiLineCommentTrivia ) {
writer . writeSpace ( " " ) ;
}
}
function emitLeadingCommentsOfPosition ( pos : number ) {
if ( commentsDisabled || pos === - 1 ) {
return ;
}
emitLeadingComments ( pos , /*isEmittedNode*/ true ) ;
}
function emitTrailingComments ( pos : number ) {
forEachTrailingCommentToEmit ( pos , emitTrailingComment ) ;
}
function emitTrailingComment ( commentPos : number , commentEnd : number , _kind : SyntaxKind , hasTrailingNewLine : boolean ) {
2018-11-10 02:18:34 +01:00
if ( ! shouldWriteComment ( currentSourceFile ! . text , commentPos ) ) return ;
2018-09-05 02:50:06 +02:00
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
if ( ! writer . isAtStartOfLine ( ) ) {
writer . writeSpace ( " " ) ;
}
emitPos ( commentPos ) ;
2018-11-10 02:18:34 +01:00
writeCommentRange ( currentSourceFile ! . text , getCurrentLineMap ( ) , writer , commentPos , commentEnd , newLine ) ;
2018-09-05 02:50:06 +02:00
emitPos ( commentEnd ) ;
if ( hasTrailingNewLine ) {
writer . writeLine ( ) ;
}
}
function emitTrailingCommentsOfPosition ( pos : number , prefixSpace? : boolean ) {
if ( commentsDisabled ) {
return ;
}
2018-09-07 23:11:54 +02:00
enterComment ( ) ;
2018-09-05 02:50:06 +02:00
forEachTrailingCommentToEmit ( pos , prefixSpace ? emitTrailingComment : emitTrailingCommentOfPosition ) ;
2018-09-07 23:11:54 +02:00
exitComment ( ) ;
2018-09-05 02:50:06 +02:00
}
function emitTrailingCommentOfPosition ( commentPos : number , commentEnd : number , _kind : SyntaxKind , hasTrailingNewLine : boolean ) {
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
emitPos ( commentPos ) ;
2018-11-10 02:18:34 +01:00
writeCommentRange ( currentSourceFile ! . text , getCurrentLineMap ( ) , writer , commentPos , commentEnd , newLine ) ;
2018-09-05 02:50:06 +02:00
emitPos ( commentEnd ) ;
if ( hasTrailingNewLine ) {
writer . writeLine ( ) ;
}
else {
writer . writeSpace ( " " ) ;
}
}
function forEachLeadingCommentToEmit ( pos : number , cb : ( commentPos : number , commentEnd : number , kind : SyntaxKind , hasTrailingNewLine : boolean , rangePos : number ) = > void ) {
// Emit the leading comments only if the container's pos doesn't match because the container should take care of emitting these comments
2018-10-08 23:13:48 +02:00
if ( currentSourceFile && ( containerPos === - 1 || pos !== containerPos ) ) {
2018-09-05 02:50:06 +02:00
if ( hasDetachedComments ( pos ) ) {
forEachLeadingCommentWithoutDetachedComments ( cb ) ;
}
else {
forEachLeadingCommentRange ( currentSourceFile . text , pos , cb , /*state*/ pos ) ;
}
}
}
function forEachTrailingCommentToEmit ( end : number , cb : ( commentPos : number , commentEnd : number , kind : SyntaxKind , hasTrailingNewLine : boolean ) = > void ) {
// Emit the trailing comments only if the container's end doesn't match because the container should take care of emitting these comments
2018-10-08 23:13:48 +02:00
if ( currentSourceFile && ( containerEnd === - 1 || ( end !== containerEnd && end !== declarationListContainerEnd ) ) ) {
2018-09-05 02:50:06 +02:00
forEachTrailingCommentRange ( currentSourceFile . text , end , cb ) ;
}
}
function hasDetachedComments ( pos : number ) {
return detachedCommentsInfo !== undefined && last ( detachedCommentsInfo ) . nodePos === pos ;
}
function forEachLeadingCommentWithoutDetachedComments ( cb : ( commentPos : number , commentEnd : number , kind : SyntaxKind , hasTrailingNewLine : boolean , rangePos : number ) = > void ) {
// get the leading comments from detachedPos
const pos = last ( detachedCommentsInfo ! ) . detachedCommentEndPos ;
if ( detachedCommentsInfo ! . length - 1 ) {
detachedCommentsInfo ! . pop ( ) ;
}
else {
detachedCommentsInfo = undefined ;
}
2018-11-10 02:18:34 +01:00
forEachLeadingCommentRange ( currentSourceFile ! . text , pos , cb , /*state*/ pos ) ;
2018-09-05 02:50:06 +02:00
}
function emitDetachedCommentsAndUpdateCommentsInfo ( range : TextRange ) {
2018-11-10 02:18:34 +01:00
const currentDetachedCommentInfo = emitDetachedComments ( currentSourceFile ! . text , getCurrentLineMap ( ) , writer , emitComment , range , newLine , commentsDisabled ) ;
2018-09-05 02:50:06 +02:00
if ( currentDetachedCommentInfo ) {
if ( detachedCommentsInfo ) {
detachedCommentsInfo . push ( currentDetachedCommentInfo ) ;
}
else {
detachedCommentsInfo = [ currentDetachedCommentInfo ] ;
}
}
}
function emitComment ( text : string , lineMap : number [ ] , writer : EmitTextWriter , commentPos : number , commentEnd : number , newLine : string ) {
2018-11-10 02:18:34 +01:00
if ( ! shouldWriteComment ( currentSourceFile ! . text , commentPos ) ) return ;
2018-09-05 02:50:06 +02:00
emitPos ( commentPos ) ;
writeCommentRange ( text , lineMap , writer , commentPos , commentEnd , newLine ) ;
emitPos ( commentEnd ) ;
}
/ * *
* Determine if the given comment is a triple - slash
*
* @return true if the comment is a triple - slash comment else false
* /
function isTripleSlashComment ( commentPos : number , commentEnd : number ) {
2018-11-10 02:18:34 +01:00
return isRecognizedTripleSlashComment ( currentSourceFile ! . text , commentPos , commentEnd ) ;
2018-09-05 02:50:06 +02:00
}
// Source Maps
2019-01-17 21:11:51 +01:00
function getParsedSourceMap ( node : UnparsedSource ) {
if ( node . parsedSourceMap === undefined && node . sourceMapText !== undefined ) {
node . parsedSourceMap = tryParseRawSourceMap ( node . sourceMapText ) || false ;
}
return node . parsedSourceMap || undefined ;
}
2018-09-07 23:11:54 +02:00
function pipelineEmitWithSourceMap ( hint : EmitHint , node : Node ) {
const pipelinePhase = getNextPipelinePhase ( PipelinePhase . SourceMaps , node ) ;
2019-02-15 18:46:37 +01:00
if ( isUnparsedSource ( node ) || isUnparsedPrepend ( node ) ) {
2019-01-17 21:11:51 +01:00
pipelinePhase ( hint , node ) ;
}
2019-01-31 19:40:46 +01:00
else if ( isUnparsedNode ( node ) ) {
2019-01-17 21:11:51 +01:00
const parsed = getParsedSourceMap ( node . parent ) ;
2019-01-29 23:44:00 +01:00
if ( parsed && sourceMapGenerator ) {
sourceMapGenerator . appendSourceMap (
2019-01-17 21:11:51 +01:00
writer . getLine ( ) ,
writer . getColumn ( ) ,
parsed ,
node . parent . sourceMapPath ! ,
node . parent . getLineAndCharacterOfPosition ( node . pos ) ,
node . parent . getLineAndCharacterOfPosition ( node . end )
) ;
2018-09-07 23:11:54 +02:00
}
pipelinePhase ( hint , node ) ;
}
else {
const { pos , end , source = sourceMapSource } = getSourceMapRange ( node ) ;
const emitFlags = getEmitFlags ( node ) ;
if ( node . kind !== SyntaxKind . NotEmittedStatement
&& ( emitFlags & EmitFlags . NoLeadingSourceMap ) === 0
&& pos >= 0 ) {
emitSourcePos ( source , skipSourceTrivia ( source , pos ) ) ;
}
if ( emitFlags & EmitFlags . NoNestedSourceMaps ) {
sourceMapsDisabled = true ;
pipelinePhase ( hint , node ) ;
sourceMapsDisabled = false ;
}
else {
pipelinePhase ( hint , node ) ;
}
if ( node . kind !== SyntaxKind . NotEmittedStatement
&& ( emitFlags & EmitFlags . NoTrailingSourceMap ) === 0
&& end >= 0 ) {
emitSourcePos ( source , end ) ;
}
}
}
2018-09-05 02:50:06 +02:00
/ * *
2019-01-24 11:20:17 +01:00
* Skips trivia such as comments and white - space that can be optionally overridden by the source - map source
2018-09-05 02:50:06 +02:00
* /
2018-09-07 23:11:54 +02:00
function skipSourceTrivia ( source : SourceMapSource , pos : number ) : number {
2019-01-24 11:20:17 +01:00
return source . skipTrivia ? source . skipTrivia ( pos ) : skipTrivia ( source . text , pos ) ;
2018-09-05 02:50:06 +02:00
}
/ * *
* Emits a mapping .
*
* If the position is synthetic ( undefined or a negative value ) , no mapping will be
* created .
*
* @param pos The position .
* /
function emitPos ( pos : number ) {
if ( sourceMapsDisabled || positionIsSynthesized ( pos ) || isJsonSourceMapSource ( sourceMapSource ) ) {
return ;
}
2019-01-11 21:24:33 +01:00
const { line : sourceLine , character : sourceCharacter } = getLineAndCharacterOfPosition ( sourceMapSource , pos ) ;
2018-09-05 02:50:06 +02:00
sourceMapGenerator ! . addMapping (
writer . getLine ( ) ,
writer . getColumn ( ) ,
sourceMapSourceIndex ,
sourceLine ,
sourceCharacter ,
/*nameIndex*/ undefined ) ;
}
2018-09-07 23:11:54 +02:00
function emitSourcePos ( source : SourceMapSource , pos : number ) {
if ( source !== sourceMapSource ) {
const savedSourceMapSource = sourceMapSource ;
setSourceMapSource ( source ) ;
emitPos ( pos ) ;
setSourceMapSource ( savedSourceMapSource ) ;
2018-09-05 02:50:06 +02:00
}
2018-09-07 23:11:54 +02:00
else {
emitPos ( pos ) ;
2018-09-05 02:50:06 +02:00
}
}
/ * *
* Emits a token of a node with possible leading and trailing source maps .
*
* @param node The node containing the token .
* @param token The token to emit .
* @param tokenStartPos The start pos of the token .
* @param emitCallback The callback used to emit the token .
* /
function emitTokenWithSourceMap ( node : Node | undefined , token : SyntaxKind , writer : ( s : string ) = > void , tokenPos : number , emitCallback : ( token : SyntaxKind , writer : ( s : string ) = > void , tokenStartPos : number ) = > number ) {
if ( sourceMapsDisabled || node && isInJsonFile ( node ) ) {
return emitCallback ( token , writer , tokenPos ) ;
}
const emitNode = node && node . emitNode ;
const emitFlags = emitNode && emitNode . flags || EmitFlags . None ;
const range = emitNode && emitNode . tokenSourceMapRanges && emitNode . tokenSourceMapRanges [ token ] ;
2018-09-07 23:11:54 +02:00
const source = range && range . source || sourceMapSource ;
2018-09-05 02:50:06 +02:00
2018-09-07 23:11:54 +02:00
tokenPos = skipSourceTrivia ( source , range ? range.pos : tokenPos ) ;
2018-09-05 02:50:06 +02:00
if ( ( emitFlags & EmitFlags . NoTokenLeadingSourceMaps ) === 0 && tokenPos >= 0 ) {
2018-09-07 23:11:54 +02:00
emitSourcePos ( source , tokenPos ) ;
2018-09-05 02:50:06 +02:00
}
tokenPos = emitCallback ( token , writer , tokenPos ) ;
if ( range ) tokenPos = range . end ;
if ( ( emitFlags & EmitFlags . NoTokenTrailingSourceMaps ) === 0 && tokenPos >= 0 ) {
2018-09-07 23:11:54 +02:00
emitSourcePos ( source , tokenPos ) ;
2018-09-05 02:50:06 +02:00
}
return tokenPos ;
}
function setSourceMapSource ( source : SourceMapSource ) {
if ( sourceMapsDisabled ) {
return ;
}
sourceMapSource = source ;
if ( isJsonSourceMapSource ( source ) ) {
return ;
}
sourceMapSourceIndex = sourceMapGenerator ! . addSource ( source . fileName ) ;
if ( printerOptions . inlineSources ) {
sourceMapGenerator ! . setSourceContent ( sourceMapSourceIndex , source . text ) ;
}
}
function isJsonSourceMapSource ( sourceFile : SourceMapSource ) {
return fileExtensionIs ( sourceFile . fileName , Extension . Json ) ;
}
2017-01-30 21:27:24 +01:00
}
2014-07-13 01:04:16 +02:00
2017-01-30 21:27:24 +01:00
function createBracketsMap() {
const brackets : string [ ] [ ] = [ ] ;
brackets [ ListFormat . Braces ] = [ "{" , "}" ] ;
brackets [ ListFormat . Parenthesis ] = [ "(" , ")" ] ;
brackets [ ListFormat . AngleBrackets ] = [ "<" , ">" ] ;
brackets [ ListFormat . SquareBrackets ] = [ "[" , "]" ] ;
return brackets ;
}
2016-06-07 19:32:03 +02:00
2017-01-30 21:27:24 +01:00
function getOpeningBracket ( format : ListFormat ) {
return brackets [ format & ListFormat . BracketsMask ] [ 0 ] ;
}
2016-06-07 19:32:03 +02:00
2017-01-30 21:27:24 +01:00
function getClosingBracket ( format : ListFormat ) {
return brackets [ format & ListFormat . BracketsMask ] [ 1 ] ;
}
2016-06-07 19:32:03 +02:00
2017-01-30 21:27:24 +01:00
// Flags enum to track count of temp variables and a few dedicated names
const enum TempFlags {
2017-05-19 19:18:42 +02:00
Auto = 0x00000000 , // No preferred name
2017-01-30 21:27:24 +01:00
CountMask = 0x0FFFFFFF , // Temp variable counter
2017-05-19 19:18:42 +02:00
_i = 0x10000000 , // Use/preference flag for '_i'
2016-06-07 19:32:03 +02:00
}
2014-07-13 01:04:16 +02:00
}