From b4a382bdd2a9cb25555e1f852b9e759372bc996f Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 11 Jan 2018 14:53:31 -0800 Subject: [PATCH 1/7] Stop explicitly storing newline in refactoring/code fix contexts It's already in the EditorSettings and the LanguageServiceHost. Fixes #18291 Fixes #18445 --- src/harness/unittests/extractTestHelpers.ts | 2 -- src/services/codeFixProvider.ts | 5 ++-- .../addMissingInvocationForDecorator.ts | 2 +- ...correctQualifiedNameToIndexedAccessType.ts | 2 +- .../codefixes/disableJsDiagnostics.ts | 6 +++-- src/services/codefixes/fixAddMissingMember.ts | 14 +++++----- .../codefixes/fixAwaitInSyncFunction.ts | 2 +- ...sDoesntImplementInheritedAbstractMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 2 +- .../fixClassSuperMustPrecedeThisAccess.ts | 2 +- .../fixConstructorForDerivedNeedSuperCall.ts | 2 +- .../fixExtendsInterfaceBecomesImplements.ts | 2 +- .../fixForgottenThisPropertyAccess.ts | 2 +- .../codefixes/fixInvalidImportSyntax.ts | 6 ++--- src/services/codefixes/fixSpelling.ts | 2 +- src/services/codefixes/fixUnusedIdentifier.ts | 4 +-- src/services/codefixes/importFixes.ts | 27 +++++++++---------- src/services/completions.ts | 1 - src/services/refactorProvider.ts | 20 ++++++++++++-- .../refactors/annotateWithTypeFromJSDoc.ts | 4 +-- .../refactors/convertFunctionToEs6Class.ts | 2 +- src/services/refactors/convertToEs6Module.ts | 2 +- src/services/refactors/extractSymbol.ts | 4 +-- src/services/refactors/useDefaultImport.ts | 2 +- src/services/services.ts | 7 ++--- 25 files changed, 67 insertions(+), 59 deletions(-) diff --git a/src/harness/unittests/extractTestHelpers.ts b/src/harness/unittests/extractTestHelpers.ts index a04f443c3c9..f519555bd26 100644 --- a/src/harness/unittests/extractTestHelpers.ts +++ b/src/harness/unittests/extractTestHelpers.ts @@ -121,7 +121,6 @@ namespace ts { const sourceFile = program.getSourceFile(path); const context: RefactorContext = { cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse }, - newLineCharacter, program, file: sourceFile, startPosition: selectionRange.start, @@ -185,7 +184,6 @@ namespace ts { const sourceFile = program.getSourceFile(f.path); const context: RefactorContext = { cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse }, - newLineCharacter, program, file: sourceFile, startPosition: selectionRange.start, diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index aa1f2fb6885..619bcc8813c 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -7,10 +7,9 @@ namespace ts { getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions; } - export interface CodeFixContextBase extends textChanges.TextChangesContext { + export interface CodeFixContextBase extends RefactorOrCodeFixContext { sourceFile: SourceFile; program: Program; - host: LanguageServiceHost; cancellationToken: CancellationToken; } @@ -84,7 +83,7 @@ namespace ts { export function codeFixAll(context: CodeFixAllContext, errorCodes: number[], use: (changes: textChanges.ChangeTracker, error: Diagnostic, commands: Push) => void): CombinedCodeActions { const commands: CodeActionCommand[] = []; - const changes = textChanges.ChangeTracker.with(context, t => + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => eachDiagnostic(context, errorCodes, diag => use(t, diag, commands))); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } diff --git a/src/services/codefixes/addMissingInvocationForDecorator.ts b/src/services/codefixes/addMissingInvocationForDecorator.ts index d063df87be4..25214f08218 100644 --- a/src/services/codefixes/addMissingInvocationForDecorator.ts +++ b/src/services/codefixes/addMissingInvocationForDecorator.ts @@ -5,7 +5,7 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions: (context) => { - const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => makeChange(t, context.sourceFile, context.span.start)); return [{ description: getLocaleSpecificMessage(Diagnostics.Call_decorator_expression), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts index de4498035be..076ea6135ae 100644 --- a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts +++ b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts @@ -7,7 +7,7 @@ namespace ts.codefix { getCodeActions(context) { const qualifiedName = getQualifiedName(context.sourceFile, context.span.start); if (!qualifiedName) return undefined; - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, qualifiedName)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, context.sourceFile, qualifiedName)); const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Rewrite_as_the_indexed_access_type_0), [`${qualifiedName.left.text}["${qualifiedName.right.text}"]`]); return [{ description, changes, fixId }]; }, diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index 6a59e61d52d..cf006a6066c 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -9,12 +9,14 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions(context) { - const { sourceFile, program, newLineCharacter, span } = context; + const { sourceFile, program, span } = context; if (!isInJavaScriptFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { return undefined; } + const newLineCharacter = getNewLineFromContext(context); + return [{ description: getLocaleSpecificMessage(Diagnostics.Ignore_this_error_message), changes: [createFileTextChanges(sourceFile.fileName, [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)])], @@ -36,7 +38,7 @@ namespace ts.codefix { fixIds: [fixId], // No point applying as a group, doing it once will fix all errors getAllCodeActions: context => codeFixAllWithTextChanges(context, errorCodes, (changes, err) => { if (err.start !== undefined) { - changes.push(getIgnoreCommentLocationForLocation(err.file!, err.start, context.newLineCharacter)); + changes.push(getIgnoreCommentLocationForLocation(err.file!, err.start, getNewLineFromContext(context))); } }), }); diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 0fc6a430e19..8e45efa09ad 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -96,7 +96,7 @@ namespace ts.codefix { } function getActionsForAddMissingMemberInJavaScriptFile(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, tokenName: string, makeStatic: boolean): CodeFixAction | undefined { - const changes = textChanges.ChangeTracker.with(context, t => addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic)); if (changes.length === 0) return undefined; const description = formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? Diagnostics.Initialize_static_property_0 : Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]); return { description, changes, fixId }; @@ -142,9 +142,9 @@ namespace ts.codefix { return typeNode || createKeywordTypeNode(SyntaxKind.AnyKeyword); } - function createAddPropertyDeclarationAction(context: textChanges.TextChangesContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, makeStatic: boolean, tokenName: string, typeNode: TypeNode): CodeFixAction { + function createAddPropertyDeclarationAction(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, makeStatic: boolean, tokenName: string, typeNode: TypeNode): CodeFixAction { const description = formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0), [tokenName]); - const changes = textChanges.ChangeTracker.with(context, t => addPropertyDeclaration(t, classDeclarationSourceFile, classDeclaration, tokenName, typeNode, makeStatic)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addPropertyDeclaration(t, classDeclarationSourceFile, classDeclaration, tokenName, typeNode, makeStatic)); return { description, changes, fixId }; } @@ -159,7 +159,7 @@ namespace ts.codefix { changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, property); } - function createAddIndexSignatureAction(context: textChanges.TextChangesContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, tokenName: string, typeNode: TypeNode): CodeFixAction { + function createAddIndexSignatureAction(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, tokenName: string, typeNode: TypeNode): CodeFixAction { // Index signatures cannot have the static modifier. const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); const indexingParameter = createParameter( @@ -176,14 +176,14 @@ namespace ts.codefix { [indexingParameter], typeNode); - const changes = textChanges.ChangeTracker.with(context, t => t.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, indexSignature)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => t.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, indexSignature)); // No fixId here because code-fix-all currently only works on adding individual named properties. return { description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_property_0), [tokenName]), changes, fixId: undefined }; } - function getActionForMethodDeclaration(context: textChanges.TextChangesContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, token: Identifier, callExpression: CallExpression, makeStatic: boolean, inJs: boolean): CodeFixAction | undefined { + function getActionForMethodDeclaration(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, token: Identifier, callExpression: CallExpression, makeStatic: boolean, inJs: boolean): CodeFixAction | undefined { const description = formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0), [token.text]); - const changes = textChanges.ChangeTracker.with(context, t => addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs)); return { description, changes, fixId }; } diff --git a/src/services/codefixes/fixAwaitInSyncFunction.ts b/src/services/codefixes/fixAwaitInSyncFunction.ts index 883993e7b51..7d09e5f214f 100644 --- a/src/services/codefixes/fixAwaitInSyncFunction.ts +++ b/src/services/codefixes/fixAwaitInSyncFunction.ts @@ -11,7 +11,7 @@ namespace ts.codefix { const { sourceFile, span } = context; const nodes = getNodes(sourceFile, span.start); if (!nodes) return undefined; - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, nodes)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, nodes)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_async_modifier_to_containing_function), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index da3685339ab..6e215666ddf 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -9,7 +9,7 @@ namespace ts.codefix { errorCodes, getCodeActions(context) { const { program, sourceFile, span } = context; - const changes = textChanges.ChangeTracker.with(context, t => + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMissingMembers(getClass(sourceFile, span.start), sourceFile, program.getTypeChecker(), t)); return changes.length === 0 ? undefined : [{ description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), changes, fixId }]; }, diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 0236b0c79b7..1eb5bfac986 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -10,7 +10,7 @@ namespace ts.codefix { const classDeclaration = getClass(sourceFile, span.start); const checker = program.getTypeChecker(); return mapDefined(getClassImplementsHeritageClauseElements(classDeclaration), implementedTypeNode => { - const changes = textChanges.ChangeTracker.with(context, t => addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, t)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, t)); if (changes.length === 0) return undefined; const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); return { description, changes, fixId }; diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 1595bbf3c13..76c1c588097 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -9,7 +9,7 @@ namespace ts.codefix { const nodes = getNodes(sourceFile, span.start); if (!nodes) return undefined; const { constructor, superCall } = nodes; - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, constructor, superCall)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, constructor, superCall)); return [{ description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 8fe2e8458a8..0b747344e3b 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -7,7 +7,7 @@ namespace ts.codefix { getCodeActions(context) { const { sourceFile, span } = context; const ctr = getNode(sourceFile, span.start); - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, ctr)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, ctr)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index d98ca556f47..a4e91410db5 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -9,7 +9,7 @@ namespace ts.codefix { const nodes = getNodes(sourceFile, context.span.start); if (!nodes) return undefined; const { extendsToken, heritageClauses } = nodes; - const changes = textChanges.ChangeTracker.with(context, t => doChanges(t, sourceFile, extendsToken, heritageClauses)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChanges(t, sourceFile, extendsToken, heritageClauses)); return [{ description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index 19610da0b15..8c337c16c4f 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -7,7 +7,7 @@ namespace ts.codefix { getCodeActions(context) { const { sourceFile } = context; const token = getNode(sourceFile, context.span.start); - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, token)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, token)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index f98f1eaea7c..0bfc6a6090d 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -32,7 +32,7 @@ namespace ts.codefix { createImportClause(namespace.name, /*namedBindings*/ undefined), node.moduleSpecifier ); - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); const changes = changeTracker.getChanges(); variations.push({ @@ -48,7 +48,7 @@ namespace ts.codefix { namespace.name, createExternalModuleReference(node.moduleSpecifier) ); - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); const changes = changeTracker.getChanges(); variations.push({ @@ -86,7 +86,7 @@ namespace ts.codefix { addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); } const propertyAccess = createPropertyAccess(expr, "default"); - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); changeTracker.replaceNode(sourceFile, expr, propertyAccess, {}); const changes = changeTracker.getChanges(); fixes.push({ diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 729f14e9ef9..95159012f48 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -12,7 +12,7 @@ namespace ts.codefix { const info = getInfo(sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; const { node, suggestion } = info; - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestion)); + const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, node, suggestion)); const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]); return [{ description, changes, fixId }]; }, diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index b7d948b3deb..93c8ae80ac9 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -13,13 +13,13 @@ namespace ts.codefix { const token = getToken(sourceFile, context.span.start); const result: CodeFixAction[] = []; - const deletion = textChanges.ChangeTracker.with(context, t => tryDeleteDeclaration(t, sourceFile, token)); + const deletion = textChanges.ChangeTracker.with(toTextChangesContext(context), t => tryDeleteDeclaration(t, sourceFile, token)); if (deletion.length) { const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), [token.getText()]); result.push({ description, changes: deletion, fixId: fixIdDelete }); } - const prefix = textChanges.ChangeTracker.with(context, t => tryPrefixDeclaration(t, context.errorCode, sourceFile, token)); + const prefix = textChanges.ChangeTracker.with(toTextChangesContext(context), t => tryPrefixDeclaration(t, context.errorCode, sourceFile, token)); if (prefix.length) { const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Prefix_0_with_an_underscore), [token.getText()]); result.push({ description, changes: prefix, fixId: fixIdPrefix }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 8f69cd95c11..204030e3104 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -24,16 +24,14 @@ namespace ts.codefix { moduleSpecifier?: string; } - interface SymbolContext extends textChanges.TextChangesContext { + interface SymbolContext { sourceFile: SourceFile; symbolName: string; + formatContext: ts.formatting.FormatContext; } - interface SymbolAndTokenContext extends SymbolContext { + interface ImportCodeFixContext extends SymbolContext { symbolToken: Identifier | undefined; - } - - interface ImportCodeFixContext extends SymbolAndTokenContext { host: LanguageServiceHost; program: Program; checker: TypeChecker; @@ -173,7 +171,6 @@ namespace ts.codefix { const symbolToken = cast(getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false), isIdentifier); return { host: context.host, - newLineCharacter: context.newLineCharacter, formatContext: context.formatContext, sourceFile: context.sourceFile, program, @@ -260,7 +257,7 @@ namespace ts.codefix { } } - function getCodeActionForNewImport(context: SymbolContext & { kind: ImportKind }, moduleSpecifier: string): ImportCodeAction { + function getCodeActionForNewImport(context: SymbolContext & RefactorOrCodeFixContext & { kind: ImportKind }, moduleSpecifier: string): ImportCodeAction { const { kind, sourceFile, symbolName } = context; const lastImportDeclaration = findLast(sourceFile.statements, isAnyImportSyntax); @@ -278,7 +275,7 @@ namespace ts.codefix { createIdentifier(symbolName), createExternalModuleReference(quotedModuleSpecifier)); - const changes = ChangeTracker.with(context, changeTracker => { + const changes = ChangeTracker.with(toTextChangesContext(context), changeTracker => { if (lastImportDeclaration) { changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl); } @@ -672,33 +669,33 @@ namespace ts.codefix { return expression && isStringLiteral(expression) ? expression.text : undefined; } - function tryUpdateExistingImport(context: SymbolContext & { kind: ImportKind }, importClause: ImportClause | ImportEqualsDeclaration): FileTextChanges[] | undefined { + function tryUpdateExistingImport(context: SymbolContext & RefactorOrCodeFixContext & { kind: ImportKind }, importClause: ImportClause | ImportEqualsDeclaration): FileTextChanges[] | undefined { const { symbolName, sourceFile, kind } = context; const { name } = importClause; const { namedBindings } = importClause.kind !== SyntaxKind.ImportEqualsDeclaration && importClause; switch (kind) { case ImportKind.Default: - return name ? undefined : ChangeTracker.with(context, t => + return name ? undefined : ChangeTracker.with(toTextChangesContext(context), t => t.replaceNode(sourceFile, importClause, createImportClause(createIdentifier(symbolName), namedBindings))); case ImportKind.Named: { const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(symbolName)); if (namedBindings && namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length !== 0) { // There are already named imports; add another. - return ChangeTracker.with(context, t => t.insertNodeInListAfter( + return ChangeTracker.with(toTextChangesContext(context), t => t.insertNodeInListAfter( sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier)); } if (!namedBindings || namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length === 0) { - return ChangeTracker.with(context, t => + return ChangeTracker.with(toTextChangesContext(context), t => t.replaceNode(sourceFile, importClause, createImportClause(name, createNamedImports([newImportSpecifier])))); } return undefined; } case ImportKind.Namespace: - return namedBindings ? undefined : ChangeTracker.with(context, t => + return namedBindings ? undefined : ChangeTracker.with(toTextChangesContext(context), t => t.replaceNode(sourceFile, importClause, createImportClause(name, createNamespaceImport(createIdentifier(symbolName))))); case ImportKind.Equals: @@ -709,7 +706,7 @@ namespace ts.codefix { } } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext, symbolToken: Identifier): ImportCodeAction { + function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext & RefactorOrCodeFixContext, symbolToken: Identifier): ImportCodeAction { const { symbolName, sourceFile } = context; /** @@ -723,7 +720,7 @@ namespace ts.codefix { * become "ns.foo" */ // Prefix the node instead of it replacing it, because this may be used for import completions and we don't want the text changes to overlap with the identifier being completed. - const changes = ChangeTracker.with(context, tracker => + const changes = ChangeTracker.with(toTextChangesContext(context), tracker => tracker.changeIdentifierToPropertyAccess(sourceFile, namespacePrefix, symbolToken)); return createCodeAction(Diagnostics.Change_0_to_1, [symbolName, `${namespacePrefix}.${symbolName}`], changes, "CodeChange", /*moduleSpecifier*/ undefined); } diff --git a/src/services/completions.ts b/src/services/completions.ts index 36a10a1b578..82e7065228a 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -627,7 +627,6 @@ namespace ts.Completions { host, program, checker, - newLineCharacter: host.getNewLine(), compilerOptions, sourceFile, formatContext, diff --git a/src/services/refactorProvider.ts b/src/services/refactorProvider.ts index 85ef9113bda..3d2a60e63e9 100644 --- a/src/services/refactorProvider.ts +++ b/src/services/refactorProvider.ts @@ -14,12 +14,28 @@ namespace ts { getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined; } - export interface RefactorContext extends textChanges.TextChangesContext { + export interface RefactorOrCodeFixContext { + host: LanguageServiceHost; + formatContext: ts.formatting.FormatContext; + } + + export function getNewLineFromContext(context: RefactorOrCodeFixContext) { + const formatSettings = context.formatContext.options; + return formatSettings ? formatSettings.newLineCharacter : context.host.getNewLine(); + } + + export function toTextChangesContext(context: RefactorOrCodeFixContext): textChanges.TextChangesContext { + return { + newLineCharacter: getNewLineFromContext(context), + formatContext: context.formatContext, + }; + } + + export interface RefactorContext extends RefactorOrCodeFixContext { file: SourceFile; startPosition: number; endPosition?: number; program: Program; - host: LanguageServiceHost; cancellationToken?: CancellationToken; } diff --git a/src/services/refactors/annotateWithTypeFromJSDoc.ts b/src/services/refactors/annotateWithTypeFromJSDoc.ts index d3bf59638b2..a39cdc20c42 100644 --- a/src/services/refactors/annotateWithTypeFromJSDoc.ts +++ b/src/services/refactors/annotateWithTypeFromJSDoc.ts @@ -78,7 +78,7 @@ namespace ts.refactor.annotateWithTypeFromJSDoc { return Debug.fail(`!decl || !jsdocType || decl.type: !${decl} || !${jsdocType} || ${decl.type}`); } - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); const declarationWithType = addType(decl, transformJSDocType(jsdocType) as TypeNode); suppressLeadingAndTrailingTrivia(declarationWithType); changeTracker.replaceRange(sourceFile, { pos: decl.getStart(), end: decl.end }, declarationWithType); @@ -93,7 +93,7 @@ namespace ts.refactor.annotateWithTypeFromJSDoc { const sourceFile = context.file; const token = getTokenAtPosition(sourceFile, context.startPosition, /*includeJsDocComment*/ false); const decl = findAncestor(token, isFunctionLikeDeclaration); - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); const functionWithType = addTypesToFunctionLike(decl); suppressLeadingAndTrailingTrivia(functionWithType); changeTracker.replaceRange(sourceFile, { pos: decl.getStart(), end: decl.end }, functionWithType); diff --git a/src/services/refactors/convertFunctionToEs6Class.ts b/src/services/refactors/convertFunctionToEs6Class.ts index cddf40ae017..93e39bc683c 100644 --- a/src/services/refactors/convertFunctionToEs6Class.ts +++ b/src/services/refactors/convertFunctionToEs6Class.ts @@ -59,7 +59,7 @@ namespace ts.refactor.convertFunctionToES6Class { } const ctorDeclaration = ctorSymbol.valueDeclaration; - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); let precedingNode: Node; let newClassDeclaration: ClassDeclaration; diff --git a/src/services/refactors/convertToEs6Module.ts b/src/services/refactors/convertToEs6Module.ts index 1046bf90aa6..933797554dd 100644 --- a/src/services/refactors/convertToEs6Module.ts +++ b/src/services/refactors/convertToEs6Module.ts @@ -74,7 +74,7 @@ namespace ts.refactor { Debug.assertEqual(actionName, _actionName); const { file, program } = context; Debug.assert(isSourceFileJavaScript(file)); - const edits = textChanges.ChangeTracker.with(context, changes => { + const edits = textChanges.ChangeTracker.with(toTextChangesContext(context), changes => { const moduleExportsChangedToDefault = convertFileToEs6Module(file, program.getTypeChecker(), changes, program.getCompilerOptions().target); if (moduleExportsChangedToDefault) { for (const importingFile of program.getSourceFiles()) { diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index b3110a0ca36..9a9c30756a4 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -806,7 +806,7 @@ namespace ts.refactor.extractSymbol { ); } - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); const minInsertionPos = (isReadonlyArray(range.range) ? last(range.range) : range.range).end; const nodeToInsertBefore = getNodeToInsertFunctionBefore(minInsertionPos, scope); if (nodeToInsertBefore) { @@ -1011,7 +1011,7 @@ namespace ts.refactor.extractSymbol { const initializer = transformConstantInitializer(node, substitutions); suppressLeadingAndTrailingTrivia(initializer); - const changeTracker = textChanges.ChangeTracker.fromContext(context); + const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); if (isClassLike(scope)) { Debug.assert(!isJS); // See CannotExtractToJSClass diff --git a/src/services/refactors/useDefaultImport.ts b/src/services/refactors/useDefaultImport.ts index a103168f67b..e64eaf0bfcb 100644 --- a/src/services/refactors/useDefaultImport.ts +++ b/src/services/refactors/useDefaultImport.ts @@ -54,7 +54,7 @@ namespace ts.refactor.installTypesForPackage { const newImportClause = createImportClause(name, /*namedBindings*/ undefined); const newImportStatement = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newImportClause, moduleSpecifier); return { - edits: textChanges.ChangeTracker.with(context, t => t.replaceNode(file, importStatement, newImportStatement)), + edits: textChanges.ChangeTracker.with(toTextChangesContext(context), t => t.replaceNode(file, importStatement, newImportStatement)), renameFilename: undefined, renameLocation: undefined, }; diff --git a/src/services/services.ts b/src/services/services.ts index 4236416fbb3..1692da9872b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1887,12 +1887,11 @@ namespace ts { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = createTextSpanFromBounds(start, end); - const newLineCharacter = getNewLineOrDefaultFromHost(host); const formatContext = formatting.getFormatContext(formatOptions); return flatMap(deduplicate(errorCodes, equateValues, compareValues), errorCode => { cancellationToken.throwIfCancellationRequested(); - return codefix.getFixes({ errorCode, sourceFile, span, program, newLineCharacter, host, cancellationToken, formatContext }); + return codefix.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext }); }); } @@ -1900,10 +1899,9 @@ namespace ts { synchronizeHostData(); Debug.assert(scope.type === "file"); const sourceFile = getValidSourceFile(scope.fileName); - const newLineCharacter = getNewLineOrDefaultFromHost(host); const formatContext = formatting.getFormatContext(formatOptions); - return codefix.getAllFixes({ fixId, sourceFile, program, newLineCharacter, host, cancellationToken, formatContext }); + return codefix.getAllFixes({ fixId, sourceFile, program, host, cancellationToken, formatContext }); } function applyCodeActionCommand(action: CodeActionCommand): Promise; @@ -2134,7 +2132,6 @@ namespace ts { startPosition, endPosition, program: getProgram(), - newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), host, formatContext: formatting.getFormatContext(formatOptions), cancellationToken, From db3f7c538e324be4219dab947e3734f81e07b508 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 11 Jan 2018 17:43:27 -0800 Subject: [PATCH 2/7] Update test baselines --- .../fourslash/autoFormattingOnPasting.ts | 12 ++-- tests/cases/fourslash/classInterfaceInsert.ts | 2 +- .../fourslash/codeFixAddMissingMember.ts | 2 +- .../fourslash/codeFixAddMissingMember2.ts | 2 +- .../fourslash/codeFixAddMissingMember3.ts | 2 +- .../fourslash/codeFixAddMissingMember4.ts | 4 +- .../fourslash/codeFixAddMissingMember5.ts | 4 +- .../fourslash/codeFixAddMissingMember6.ts | 4 +- .../fourslash/codeFixAddMissingMember7.ts | 4 +- .../fourslash/codeFixAddMissingMember_all.ts | 8 +-- .../codeFixAddMissingMember_all_js.ts | 10 ++-- ...ClassImplementClassFunctionVoidInferred.ts | 8 +-- ...prExtendsAbstractExpressionWithTypeArgs.ts | 4 +- ...assExtendAbstractExpressionWithTypeArgs.ts | 4 +- .../codeFixClassExtendAbstractGetterSetter.ts | 16 ++--- .../codeFixClassExtendAbstractMethod.ts | 22 +++---- .../codeFixClassExtendAbstractMethodThis.ts | 8 +-- ...stractMethodTypeParamsInstantiateNumber.ts | 8 +-- ...endAbstractMethodTypeParamsInstantiateU.ts | 8 +-- .../codeFixClassExtendAbstractMethod_all.ts | 16 ++--- .../codeFixClassExtendAbstractProperty.ts | 8 +-- .../codeFixClassExtendAbstractPropertyThis.ts | 4 +- ...FixClassExtendAbstractProtectedProperty.ts | 4 +- ...odeFixClassExtendAbstractPublicProperty.ts | 4 +- ...ImplementClassAbstractGettersAndSetters.ts | 8 +-- ...ClassImplementClassFunctionVoidInferred.ts | 8 +-- ...xClassImplementClassMultipleSignatures1.ts | 10 ++-- ...xClassImplementClassMultipleSignatures2.ts | 14 ++--- ...FixClassImplementClassPropertyModifiers.ts | 8 +-- ...FixClassImplementClassPropertyTypeQuery.ts | 4 +- .../codeFixClassImplementDeepInheritance.ts | 14 ++--- .../codeFixClassImplementDefaultClass.ts | 4 +- ...odeFixClassImplementInterfaceArrayTuple.ts | 8 +-- ...xClassImplementInterfaceClassExpression.ts | 4 +- .../codeFixClassImplementInterfaceComments.ts | 12 ++-- ...lementInterfaceComputedPropertyLiterals.ts | 18 +++--- ...aceComputedPropertyNameWellKnownSymbols.ts | 58 +++++++++---------- ...deFixClassImplementInterfaceInNamespace.ts | 8 +-- ...ssImplementInterfaceIndexSignaturesBoth.ts | 6 +- ...ImplementInterfaceIndexSignaturesNumber.ts | 4 +- ...ImplementInterfaceIndexSignaturesString.ts | 4 +- ...codeFixClassImplementInterfaceIndexType.ts | 4 +- ...mplementInterfaceInheritsAbstractMethod.ts | 8 +-- ...odeFixClassImplementInterfaceMappedType.ts | 4 +- ...ImplementInterfaceMemberNestedTypeAlias.ts | 10 ++-- ...ixClassImplementInterfaceMemberOrdering.ts | 50 ++++++++-------- ...xClassImplementInterfaceMemberTypeAlias.ts | 10 ++-- ...mentInterfaceMethodThisAndSelfReference.ts | 8 +-- ...ssImplementInterfaceMethodTypePredicate.ts | 12 ++-- ...tInterfaceMultipleMembersAndPunctuation.ts | 26 ++++----- ...assImplementInterfaceMultipleSignatures.ts | 14 ++--- ...plementInterfaceMultipleSignaturesRest1.ts | 14 ++--- ...plementInterfaceMultipleSignaturesRest2.ts | 14 ++--- ...lassImplementInterfaceNamespaceConflict.ts | 4 +- ...ClassImplementInterfaceOptionalProperty.ts | 6 +- .../codeFixClassImplementInterfaceProperty.ts | 10 ++-- ...assImplementInterfacePropertySignatures.ts | 24 ++++---- ...FixClassImplementInterfaceQualifiedName.ts | 4 +- ...mentInterfaceTypeParamInstantiateDeeply.ts | 4 +- ...mentInterfaceTypeParamInstantiateNumber.ts | 4 +- ...ImplementInterfaceTypeParamInstantiateT.ts | 4 +- ...ImplementInterfaceTypeParamInstantiateU.ts | 4 +- ...xClassImplementInterfaceTypeParamMethod.ts | 8 +-- .../codeFixClassImplementInterface_all.ts | 22 +++---- .../codeFixClassSuperMustPrecedeThisAccess.ts | 2 +- ...eFixClassSuperMustPrecedeThisAccess_all.ts | 4 +- ...deFixConstructorForDerivedNeedSuperCall.ts | 4 +- ...xConstructorForDerivedNeedSuperCall_all.ts | 8 +-- .../codeFixDisableJsDiagnosticsInFile_all.ts | 4 +- .../codeFixUndeclaredInStaticMethod.ts | 48 +++++++-------- .../fourslash/codeFixUndeclaredMethod.ts | 36 ++++++------ ...completionAfterBackslashFollowingString.ts | 2 +- ...Import_default_alreadyExistedWithRename.ts | 2 +- .../completionsImport_default_anonymous.ts | 4 +- ...letionsImport_default_didNotExistBefore.ts | 4 +- ...sImport_default_exportDefaultIdentifier.ts | 4 +- .../completionsImport_fromAmbientModule.ts | 4 +- .../completionsImport_multipleWithSameName.ts | 4 +- ...tionsImport_named_exportEqualsNamespace.ts | 4 +- .../fourslash/completionsImport_ofAlias.ts | 4 +- ...mpletionsImport_ofAlias_preferShortPath.ts | 4 +- .../fourslash/completionsImport_require.ts | 8 +-- ...tenceOnIndentionsOfChainedFunctionCalls.ts | 2 +- ...ocCommentTemplateFunctionWithParameters.ts | 4 +- .../fourslash/findReferencesAfterEdit.ts | 2 +- tests/cases/fourslash/formatEmptyBlock.ts | 2 +- .../cases/fourslash/formatTemplateLiteral.ts | 4 +- .../formattingOnDoWhileNoSemicolon.ts | 2 +- .../formattingOnNestedDoWhileByEnter.ts | 2 +- ...formattingWithEnterAfterMultilineString.ts | 2 +- .../fourslash/getOccurrencesAfterEdit.ts | 2 +- .../fourslash/importNameCodeFixReExport.ts | 4 +- .../noSmartIndentInsideMultilineString.ts | 2 +- .../shims-pp/getOccurrencesAtPosition.ts | 2 +- .../shims/getOccurrencesAtPosition.ts | 2 +- .../smartIndentArrayBindingPattern01.ts | 2 +- .../smartIndentArrayBindingPattern02.ts | 2 +- .../cases/fourslash/smartIndentDoStatement.ts | 2 +- .../cases/fourslash/smartIndentIfStatement.ts | 2 +- .../smartIndentInParenthesizedExpression01.ts | 2 +- .../smartIndentObjectBindingPattern01.ts | 2 +- .../smartIndentObjectBindingPattern02.ts | 2 +- .../cases/fourslash/smartIndentOnAccessors.ts | 4 +- .../fourslash/smartIndentOnAccessors01.ts | 4 +- .../smartIndentOnFunctionParameters.ts | 4 +- ...rtIndentOnUnclosedFunctionDeclaration01.ts | 2 +- ...rtIndentOnUnclosedFunctionDeclaration02.ts | 2 +- ...rtIndentOnUnclosedFunctionDeclaration03.ts | 2 +- ...rtIndentOnUnclosedFunctionDeclaration04.ts | 2 +- .../fourslash/smartIndentStartLineInLists.ts | 2 +- .../fourslash/smartIndentTemplateLiterals.ts | 2 +- 111 files changed, 424 insertions(+), 424 deletions(-) diff --git a/tests/cases/fourslash/autoFormattingOnPasting.ts b/tests/cases/fourslash/autoFormattingOnPasting.ts index 5c9e2c86e37..7eb08116041 100644 --- a/tests/cases/fourslash/autoFormattingOnPasting.ts +++ b/tests/cases/fourslash/autoFormattingOnPasting.ts @@ -11,12 +11,12 @@ public testMethod( ) }`); // We're missing scenarios of formatting option settings due to bug 693273 - [TypeScript] Need to improve fourslash support for formatting options. // Missing scenario ** Uncheck Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste ** -//verify.currentFileContentIs("module TestModule {\r\n\ -// class TestClass{\r\n\ -//private foo;\r\n\ -//public testMethod( )\r\n\ -//{}\r\n\ -//}\r\n\ +//verify.currentFileContentIs("module TestModule {\n\ +// class TestClass{\n\ +//private foo;\n\ +//public testMethod( )\n\ +//{}\n\ +//}\n\ //}"); // Missing scenario ** Check Tools->Options->Text Editor->TypeScript->Formatting->General->Format on paste ** verify.currentFileContentIs(`module TestModule { diff --git a/tests/cases/fourslash/classInterfaceInsert.ts b/tests/cases/fourslash/classInterfaceInsert.ts index e2610532083..d645d6eb8eb 100644 --- a/tests/cases/fourslash/classInterfaceInsert.ts +++ b/tests/cases/fourslash/classInterfaceInsert.ts @@ -12,6 +12,6 @@ verify.quickInfoAt("className", "class Sphere"); goTo.marker('interfaceGoesHere'); -edit.insert("\r\ninterface Surface {\r\n reflect: () => number;\r\n}\r\n"); +edit.insert("\ninterface Surface {\n reflect: () => number;\n}\n"); verify.quickInfoAt("className", "class Sphere"); diff --git a/tests/cases/fourslash/codeFixAddMissingMember.ts b/tests/cases/fourslash/codeFixAddMissingMember.ts index 563cc29f4ea..8c337c30318 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember.ts @@ -11,7 +11,7 @@ verify.codeFix({ index: 0, // TODO: GH#18445 newFileContent: `class C { - foo: number;\r + foo: number; method() { this.foo = 10; } diff --git a/tests/cases/fourslash/codeFixAddMissingMember2.ts b/tests/cases/fourslash/codeFixAddMissingMember2.ts index 06e111e63c7..e8a28810a60 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember2.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember2.ts @@ -11,7 +11,7 @@ verify.codeFix({ index: 1, // TODO: GH#18445 newFileContent: `class C { - [x: string]: number;\r + [x: string]: number; method() { this.foo = 10; } diff --git a/tests/cases/fourslash/codeFixAddMissingMember3.ts b/tests/cases/fourslash/codeFixAddMissingMember3.ts index adc099eff74..8367e6918cc 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember3.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember3.ts @@ -11,7 +11,7 @@ verify.codeFix({ index: 0, // TODO: GH#18445 newFileContent: `class C { - static foo: number;\r + static foo: number; static method() { this.foo = 10; } diff --git a/tests/cases/fourslash/codeFixAddMissingMember4.ts b/tests/cases/fourslash/codeFixAddMissingMember4.ts index 97a17959d26..5f84b28cde3 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember4.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember4.ts @@ -17,8 +17,8 @@ verify.codeFix({ index: 0, // TODO: GH#18445 newFileContent: `class C { - constructor() {\r - this.foo = undefined;\r + constructor() { + this.foo = undefined; } method() { this.foo === 10; diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts index a15b564c786..727253f0b9d 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember5.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -18,7 +18,7 @@ verify.codeFix({ static method() { ()=>{ this.foo === 10 }; } -}\r -C.foo = undefined;\r +} +C.foo = undefined; ` }); diff --git a/tests/cases/fourslash/codeFixAddMissingMember6.ts b/tests/cases/fourslash/codeFixAddMissingMember6.ts index a04a14c9ce5..f418f2c3ebc 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember6.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember6.ts @@ -15,8 +15,8 @@ verify.codeFix({ index: 0, // TODO: GH#18445 newFileContent: `class C { - constructor() {\r - this.foo = undefined;\r + constructor() { + this.foo = undefined; } prop = ()=>{ this.foo === 10 }; }` diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts index 0655898218b..8a475ebaf9c 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember7.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -14,7 +14,7 @@ verify.codeFix({ // TODO: GH#18445 newFileContent: `class C { static p = ()=>{ this.foo === 10 }; -}\r -C.foo = undefined;\r +} +C.foo = undefined; ` }); diff --git a/tests/cases/fourslash/codeFixAddMissingMember_all.ts b/tests/cases/fourslash/codeFixAddMissingMember_all.ts index e7edad47227..9b9618ecaeb 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_all.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_all.ts @@ -13,10 +13,10 @@ verify.codeFixAll({ newFileContent: // TODO: GH#18445 `class C { - x: number;\r - y(): any {\r - throw new Error("Method not implemented.");\r - }\r + x: number; + y(): any { + throw new Error("Method not implemented."); + } method() { this.x = 0; this.y(); diff --git a/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts b/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts index 1bc0d03c211..67a91fd8b93 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts @@ -18,11 +18,11 @@ verify.codeFixAll({ newFileContent: // TODO: GH#18445 `class C { - y() {\r - throw new Error("Method not implemented.");\r - }\r - constructor() {\r - this.x = undefined;\r + y() { + throw new Error("Method not implemented."); + } + constructor() { + this.x = undefined; } method() { this.x; diff --git a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts index 68743288c71..9fa45fde8dc 100644 --- a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts @@ -12,9 +12,9 @@ verify.codeFix({ `class A { f() {} } -let B = class implements A {\r - f(): void {\r - throw new Error("Method not implemented.");\r - }\r +let B = class implements A { + f(): void { + throw new Error("Method not implemented."); + } }` }); diff --git a/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts b/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts index 76117f05090..ef85b2c6cdf 100644 --- a/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts +++ b/tests/cases/fourslash/codeFixClassExprExtendsAbstractExpressionWithTypeArgs.ts @@ -20,7 +20,7 @@ verify.codeFix({ return C; } -let B = class extends foo("s") {\r - a: string | number;\r +let B = class extends foo("s") { + a: string | number; }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts b/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts index b7557419de0..e21b7a21e26 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractExpressionWithTypeArgs.ts @@ -20,7 +20,7 @@ verify.codeFix({ return C; } -class B extends foo("s") {\r - a: string | number;\r +class B extends foo("s") { + a: string | number; }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts index 4949ddbf7c5..8dd0e508ce9 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts @@ -42,13 +42,13 @@ verify.codeFix({ // Don't need to add anything in this case. abstract class B extends A {} -class C extends A {\r - a: string | number;\r - b: this;\r - c: A;\r - d: string | number;\r - e: this;\r - f: A;\r - g: string;\r +class C extends A { + a: string | number; + b: this; + c: A; + d: string | number; + e: this; + f: A; + g: string; }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index 462dd1e18ea..7098af8bc27 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -22,16 +22,16 @@ verify.codeFix({ abstract foo(): number; } -class C extends A {\r - f(a: number, b: string): boolean;\r - f(a: number, b: string): this;\r - f(a: string, b: number): Function;\r - f(a: string): Function;\r - f(a: any, b?: any) {\r - throw new Error("Method not implemented.");\r - }\r - foo(): number {\r - throw new Error("Method not implemented.");\r - }\r +class C extends A { + f(a: number, b: string): boolean; + f(a: number, b: string): this; + f(a: string, b: number): Function; + f(a: string): Function; + f(a: any, b?: any) { + throw new Error("Method not implemented."); + } + foo(): number { + throw new Error("Method not implemented."); + } }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts index 7fa5b762787..f0bb90c9443 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts @@ -14,9 +14,9 @@ verify.codeFix({ abstract f(): this; } -class C extends A {\r - f(): this {\r - throw new Error("Method not implemented.");\r - }\r +class C extends A { + f(): this { + throw new Error("Method not implemented."); + } }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts index 01411fb34cb..fdbbda75113 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts @@ -14,9 +14,9 @@ verify.codeFix({ abstract f(x: T): T; } -class C extends A {\r - f(x: number): number {\r - throw new Error("Method not implemented.");\r - }\r +class C extends A { + f(x: number): number { + throw new Error("Method not implemented."); + } }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts index aff612ac95d..41fe94ae634 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts @@ -14,9 +14,9 @@ verify.codeFix({ abstract f(x: T): T; } -class C extends A {\r - f(x: U): U {\r - throw new Error("Method not implemented.");\r - }\r +class C extends A { + f(x: U): U { + throw new Error("Method not implemented."); + } }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts index ba6afb9ac7a..aa28f301cc8 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts @@ -13,14 +13,14 @@ verify.codeFixAll({ `abstract class A { abstract m(): void; } -class B extends A {\r - m(): void {\r - throw new Error("Method not implemented.");\r - }\r +class B extends A { + m(): void { + throw new Error("Method not implemented."); + } } -class C extends A {\r - m(): void {\r - throw new Error("Method not implemented.");\r - }\r +class C extends A { + m(): void { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index 6fd77e90385..e5811016e8c 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -18,9 +18,9 @@ verify.codeFix({ abstract z: A; } -class C extends A {\r - x: number;\r - y: this;\r - z: A;\r +class C extends A { + x: number; + y: this; + z: A; }` }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts index 9531c3b7533..c1184c083a5 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts @@ -14,7 +14,7 @@ verify.codeFix({ abstract x: this; } -class C extends A {\r - x: this;\r +class C extends A { + x: this; }`, }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts index 63a3ed99f67..e2472318e10 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts @@ -14,7 +14,7 @@ verify.codeFix({ protected abstract x: number; } -class C extends A {\r - protected x: number;\r +class C extends A { + protected x: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts index c8696b1ad6c..bb9ed1ec9c5 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts @@ -14,7 +14,7 @@ verify.codeFix({ public abstract x: number; } -class C extends A {\r - public x: number;\r +class C extends A { + public x: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts b/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts index f6fac956c5b..ee28448f06e 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts @@ -28,9 +28,9 @@ verify.codeFix({ abstract set c(arg: number | string); } -class C implements A {\r - a: string;\r - b: number;\r - c: string | number;\r +class C implements A { + a: string; + b: number; + c: string | number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts index dbc0689644f..8b749145ec2 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts @@ -14,9 +14,9 @@ verify.codeFix({ f() {} } -class B implements A {\r - f(): void {\r - throw new Error("Method not implemented.");\r - }\r +class B implements A { + f(): void { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts index 8c563d4dbb7..a2492787bf7 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts @@ -14,10 +14,10 @@ verify.codeFix({ method(a: number, b: string): boolean; method(a: string | number, b?: string | number): boolean | Function { return true; } } -class C implements A {\r - method(a: number, b: string): boolean;\r - method(a: string | number, b?: string | number): boolean | Function {\r - throw new Error("Method not implemented.");\r - }\r +class C implements A { + method(a: number, b: string): boolean; + method(a: string | number, b?: string | number): boolean | Function { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts index de2bfab561e..83e531c9ef4 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts @@ -18,12 +18,12 @@ verify.codeFix({ method(a: string): Function; method(a: string | number, b?: string | number): boolean | Function { return true; } } -class C implements A {\r - method(a: any, b: string): boolean;\r - method(a: string, b: number): Function;\r - method(a: string): Function;\r - method(a: string | number, b?: string | number): boolean | Function {\r - throw new Error("Method not implemented.");\r - }\r +class C implements A { + method(a: any, b: string): boolean; + method(a: string, b: number): Function; + method(a: string): Function; + method(a: string | number, b?: string | number): boolean | Function { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts index f3aa6bc6c6c..59d406541a6 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts @@ -20,9 +20,9 @@ verify.codeFix({ public w: number; } -class C implements A {\r - x: number;\r - protected z: number;\r - public w: number;\r +class C implements A { + x: number; + protected z: number; + public w: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts index 0981db995bb..326ad2b547e 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts @@ -12,7 +12,7 @@ verify.codeFix({ `class A { A: typeof A; } -class D implements A {\r - A: typeof A;\r +class D implements A { + A: typeof A; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts index ae187b93572..785ffb80a08 100644 --- a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts +++ b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts @@ -75,12 +75,12 @@ class C4 extends C3 implements I0, I4, I5 { } interface I6 extends C4 {} -class C5 implements I6 {\r - e: number;\r - f: number;\r - a: number;\r - b: number;\r - d: number;\r - c: number;\r +class C5 implements I6 { + e: number; + f: number; + a: number; + b: number; + d: number; + c: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts b/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts index 53fb9378591..e2ffab5a784 100644 --- a/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts +++ b/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts @@ -8,7 +8,7 @@ verify.codeFix({ // TODO: GH#18445 newFileContent: `interface I { x: number; } -export default class implements I {\r - x: number;\r +export default class implements I { + x: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts index b121fe54ac7..05c5ceaa6bc 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts @@ -18,9 +18,9 @@ verify.codeFix({ z: [number, string, I]; } -class C implements I {\r - x: number[];\r - y: number[];\r - z: [number, string, I];\r +class C implements I { + x: number[]; + y: number[]; + z: [number, string, I]; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts index 8b811a98d25..0340cdf180b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts @@ -9,7 +9,7 @@ verify.codeFix({ // TODO: GH#18445 newFileContent: `interface I { x: number; } -new class implements I {\r - x: number;\r +new class implements I { + x: number; };`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts index 98a00d43f4c..a80dcf0c4b9 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts @@ -36,11 +36,11 @@ verify.codeFix({ /**method signature prefix */foo /**open angle prefix */< /**type parameter name prefix */ X /** closing angle prefix */> /**open paren prefix */(/** parameter prefix */ a/** colon prefix */: /** parameter type prefix */ X /** close paren prefix */) /** colon prefix */: /** return type prefix */ string /** semicolon prefix */; /**close-brace prefix*/ } /**close-brace prefix*/ } -class C implements N.I {\r - /** property prefix */ a /** colon prefix */: N.E.a;\r - /** property prefix */ b /** colon prefix */: N.E;\r - /**method signature prefix */ foo /**open angle prefix */(a: X): string {\r - throw new Error("Method not implemented.");\r - }\r +class C implements N.I { + /** property prefix */ a /** colon prefix */: N.E.a; + /** property prefix */ b /** colon prefix */: N.E; + /**method signature prefix */ foo /**open angle prefix */(a: X): string { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts index 6bbe5f4efd1..4e999d38426 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -20,14 +20,14 @@ verify.codeFix({ [2]: boolean; } -class C implements I {\r - ["foo"](o: any): boolean {\r - throw new Error("Method not implemented.");\r - }\r - ["x"]: boolean;\r - [1](): string {\r - throw new Error("Method not implemented.");\r - }\r - [2]: boolean;\r +class C implements I { + ["foo"](o: any): boolean { + throw new Error("Method not implemented."); + } + ["x"]: boolean; + [1](): string { + throw new Error("Method not implemented."); + } + [2]: boolean; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts index ab8b7ddfebb..be9f6ddbbec 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts @@ -38,34 +38,34 @@ verify.codeFix({ [Symbol.toStringTag]: string; [Symbol.unscopables]: any; } -class C implements I {\r - [Symbol.hasInstance](o: any): boolean {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.isConcatSpreadable]: boolean;\r - [Symbol.iterator]() {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.match]: boolean;\r - [Symbol.replace](...args: {}) {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.search](str: string): number {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.species](): number {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.split](str: string, limit?: number): {} {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.toPrimitive](hint: "number"): number;\r - [Symbol.toPrimitive](hint: "default"): number;\r - [Symbol.toPrimitive](hint: "string"): string;\r - [Symbol.toPrimitive](hint: any) {\r - throw new Error("Method not implemented.");\r - }\r - [Symbol.toStringTag]: string\;\r - [Symbol.unscopables]: any;\r +class C implements I { + [Symbol.hasInstance](o: any): boolean { + throw new Error("Method not implemented."); + } + [Symbol.isConcatSpreadable]: boolean; + [Symbol.iterator]() { + throw new Error("Method not implemented."); + } + [Symbol.match]: boolean; + [Symbol.replace](...args: {}) { + throw new Error("Method not implemented."); + } + [Symbol.search](str: string): number { + throw new Error("Method not implemented."); + } + [Symbol.species](): number { + throw new Error("Method not implemented."); + } + [Symbol.split](str: string, limit?: number): {} { + throw new Error("Method not implemented."); + } + [Symbol.toPrimitive](hint: "number"): number; + [Symbol.toPrimitive](hint: "default"): number; + [Symbol.toPrimitive](hint: "string"): string; + [Symbol.toPrimitive](hint: any) { + throw new Error("Method not implemented."); + } + [Symbol.toStringTag]: string\; + [Symbol.unscopables]: any; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts index 9e01e080af6..b52e4d98c38 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts @@ -24,9 +24,9 @@ interface I1 { f1(); } -class C1 implements N1.I1 {\r - f1(): string {\r - throw new Error("Method not implemented.");\r - }\r +class C1 implements N1.I1 { + f1(): string { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts index 2becd28aa4f..011bed12d8b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts @@ -17,8 +17,8 @@ verify.codeFix({ [y: string]: I; } -class C implements I {\r - [x: number]: I;\r - [y: string]: I;\r +class C implements I { + [x: number]: I; + [y: string]: I; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts index ebd0904e88a..5b4a2bb73c0 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts @@ -12,7 +12,7 @@ verify.codeFix({ `interface I { [x: number]: I; } -class C implements I {\r - [x: number]: I;\r +class C implements I { + [x: number]: I; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts index 4cd6cd0c9a3..5f9c943330b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts @@ -14,7 +14,7 @@ verify.codeFix({ [Ƚ: string]: X; } -class C implements I {\r - [Ƚ: string]: number;\r +class C implements I { + [Ƚ: string]: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts index 7e93871c552..760d15f1d8f 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts @@ -12,7 +12,7 @@ verify.codeFix({ `interface I { x: keyof X; } -class C implements I {\r - x: keyof Y;\r +class C implements I { + x: keyof Y; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts index 83a2c131d97..e4e8c409165 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts @@ -16,9 +16,9 @@ abstract class C2 { abstract fA(); } interface I1 extends C1, C2 { } -class C3 implements I1 {\r - fA() {\r - throw new Error("Method not implemented.");\r - }\r +class C3 implements I1 { + fA() { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts index 5fff622f2db..86a979b23df 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts @@ -12,7 +12,7 @@ verify.codeFix({ `interface I { x: { readonly [K in keyof X]: X[K] }; } -class C implements I {\r - x: { readonly [K in keyof Y]: Y[K]; };\r +class C implements I { + x: { readonly [K in keyof Y]: Y[K]; }; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts index fc1217f1556..af4c591fd37 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts @@ -16,10 +16,10 @@ interface I { x: Either>; foo(x: Either>): void; } -class C implements I {\r - x: Either>;\r - foo(x: Either>): void {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + x: Either>; + foo(x: Either>): void { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts index 4bb20142df3..e7d98d4ee1b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts @@ -62,30 +62,30 @@ interface I { /** a nice safe prime */ 23; } -class C implements I {\r - 1: any;\r - 2: any;\r - 3: any;\r - 4: any;\r - 5: any;\r - 6: any;\r - 7: any;\r - 8: any;\r - 9: any;\r - 10: any;\r - 11: any;\r - 12: any;\r - 13: any;\r - 14: any;\r - 15: any;\r - 16: any;\r - 17: any;\r - 18: any;\r - 19: any;\r - 20: any;\r - 21: any;\r - 22: any;\r - /** a nice safe prime */\r - 23: any;\r +class C implements I { + 1: any; + 2: any; + 3: any; + 4: any; + 5: any; + 6: any; + 7: any; + 8: any; + 9: any; + 10: any; + 11: any; + 12: any; + 13: any; + 14: any; + 15: any; + 16: any; + 17: any; + 18: any; + 19: any; + 20: any; + 21: any; + 22: any; + /** a nice safe prime */ + 23: any; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts index 23f1c79054e..87fda6bcd11 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts @@ -10,10 +10,10 @@ verify.codeFix({ newFileContent: `type MyType = [string, number]; interface I { x: MyType; test(a: MyType): void; } -class C implements I {\r - x: [string, number];\r - test(a: [string, number]): void {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + x: [string, number]; + test(a: [string, number]): void { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 41c8f2254db..c382b9f6858 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -14,9 +14,9 @@ verify.codeFix({ f(x: number, y: this): I } -class C implements I {\r - f(x: number, y: this): I {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + f(x: number, y: this): I { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts index ce1dfead0f3..9c916e3f4c6 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts @@ -16,11 +16,11 @@ verify.codeFix({ f(): this is I; } -class C implements I {\r - f(i: any): i is I;\r - f(): this is I;\r - f(i?: any) {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + f(i: any): i is I; + f(): this is I; + f(i?: any) { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts index afad257a699..9b7a91891a7 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts @@ -24,18 +24,18 @@ verify.codeFix({ h(); } -class C1 implements I1 {\r - x: number;\r - y: number;\r - z: number;\r - f() {\r - throw new Error("Method not implemented.");\r - }\r - g() {\r - throw new Error("Method not implemented.");\r - }\r - h() {\r - throw new Error("Method not implemented.");\r - }\r +class C1 implements I1 { + x: number; + y: number; + z: number; + f() { + throw new Error("Method not implemented."); + } + g() { + throw new Error("Method not implemented."); + } + h() { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts index b8167ccf35b..05b08d6f570 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts @@ -18,12 +18,12 @@ verify.codeFix({ method(a: string): Function; } -class C implements I {\r - method(a: number, b: string): boolean;\r - method(a: string, b: number): Function;\r - method(a: string): Function;\r - method(a: any, b?: any) {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + method(a: number, b: string): boolean; + method(a: string, b: number): Function; + method(a: string): Function; + method(a: any, b?: any) { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts index ee64c1be6bb..91f142db5dd 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts @@ -18,12 +18,12 @@ verify.codeFix({ method(a: string): Function; } -class C implements I {\r - method(a: number, ...b: string[]): boolean;\r - method(a: string, ...b: number[]): Function;\r - method(a: string): Function;\r - method(a: any, ...b?: any[]) {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + method(a: number, ...b: string[]): boolean; + method(a: string, ...b: number[]): Function; + method(a: string): Function; + method(a: any, ...b?: any[]) { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts index 9b4e471a5d8..ae57831f0ea 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts @@ -18,12 +18,12 @@ verify.codeFix({ method(a: string): Function; } -class C implements I {\r - method(a: number, ...b: string[]): boolean;\r - method(a: string, b: number): Function;\r - method(a: string): Function;\r - method(a: any, b?: any, ...rest?: any[]) {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + method(a: number, ...b: string[]): boolean; + method(a: string, b: number): Function; + method(a: string): Function; + method(a: any, b?: any, ...rest?: any[]) { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts index ee9808603cf..bca3c7b5fe2 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -18,7 +18,7 @@ verify.codeFix({ interface I1 { f1(); } -class C1 implements N1.I1 {\r - x: number;\r +class C1 implements N1.I1 { + x: number; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts index ea4f5dbdd91..215d11f1d94 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts @@ -14,8 +14,8 @@ verify.codeFix({ name: string; birthday?: string; } -class Person implements IPerson {\r - name: string;\r - birthday?: string;\r +class Person implements IPerson { + name: string; + birthday?: string; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts index f8fb576800f..db9bf753ef7 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts @@ -22,10 +22,10 @@ interface I { z: symbol; w: object; } -class C implements I {\r - x: E;\r - y: E.a;\r - z: symbol;\r - w: object;\r +class C implements I { + x: E; + y: E.a; + z: symbol; + w: object; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts index 98a0f374ae7..37a35470d53 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts @@ -40,17 +40,17 @@ verify.codeFix({ a9: { (b9: number, c9: string): number; [d9: number]: I }; a10: { (b10: number, c10: string): number; [d10: string]: I }; } -class C implements I {\r - a0: {};\r - a1: (b1: number, c1: string) => number;\r - a2: (b2: number, c2: string) => number;\r - a3: { (b3: number, c3: string): number; x: number; };\r - a4: new (b1: number, c1: string) => number;\r - a5: new (b2: number, c2: string) => number;\r - a6: { new(b3: number, c3: string): number; x: number; };\r - a7: { foo(b7: number, c7: string): number; };\r - a8: { (b81: number, c81: string): number; new(b82: number, c82: string): number; };\r - a9: { (b9: number, c9: string): number;[d9: number]: I; };\r - a10: { (b10: number, c10: string): number;[d10: string]: I; };\r +class C implements I { + a0: {}; + a1: (b1: number, c1: string) => number; + a2: (b2: number, c2: string) => number; + a3: { (b3: number, c3: string): number; x: number; }; + a4: new (b1: number, c1: string) => number; + a5: new (b2: number, c2: string) => number; + a6: { new(b3: number, c3: string): number; x: number; }; + a7: { foo(b7: number, c7: string): number; }; + a8: { (b81: number, c81: string): number; new(b82: number, c82: string): number; }; + a9: { (b9: number, c9: string): number;[d9: number]: I; }; + a10: { (b10: number, c10: string): number;[d10: string]: I; }; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts index c8e88bced9f..9ca2894741c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts @@ -12,7 +12,7 @@ verify.codeFix({ `namespace N { export interface I { y: I; } } -class C1 implements N.I {\r - y: N.I;\r +class C1 implements N.I { + y: N.I; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts index 4b50cf2e69b..486bea3098a 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts @@ -12,7 +12,7 @@ verify.codeFix({ `interface I { x: { y: T, z: T[] }; } -class C implements I {\r - x: { y: number; z: number[]; };\r +class C implements I { + x: { y: number; z: number[]; }; }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts index 6df183d3e44..dde7bc4fc09 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts @@ -8,7 +8,7 @@ verify.codeFix({ // TODO: GH#18445 newFileContent: `interface I { x: T; } -class C implements I {\r - x: number;\r +class C implements I { + x: number; }` }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts index 7be7d21f1e4..4a796bcefc1 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts @@ -8,7 +8,7 @@ verify.codeFix({ // TODO: GH#18445 newFileContent: `interface I { x: T; } -class C implements I {\r - x: T;\r +class C implements I { + x: T; }` }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts index ac4cad80220..efe5295d3b3 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts @@ -8,7 +8,7 @@ verify.codeFix({ // TODO: GH#18445 newFileContent: `interface I { x: T; } -class C implements I {\r - x: U;\r +class C implements I { + x: U; }` }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts index 6a93c84ecf0..5596b091754 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts @@ -12,9 +12,9 @@ verify.codeFix({ `interface I { f(x: T); } -class C implements I {\r - f(x: T) {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I { + f(x: T) { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_all.ts b/tests/cases/fourslash/codeFixClassImplementInterface_all.ts index fb3672a7949..641f355be32 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface_all.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface_all.ts @@ -11,17 +11,17 @@ verify.codeFixAll({ newFileContent: `interface I { i(): void; } interface J { j(): void; } -class C implements I, J {\r - i(): void {\r - throw new Error("Method not implemented.");\r - }\r - j(): void {\r - throw new Error("Method not implemented.");\r - }\r +class C implements I, J { + i(): void { + throw new Error("Method not implemented."); + } + j(): void { + throw new Error("Method not implemented."); + } } -class D implements J {\r - j(): void {\r - throw new Error("Method not implemented.");\r - }\r +class D implements J { + j(): void { + throw new Error("Method not implemented."); + } }`, }); diff --git a/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts b/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts index a4db2c909fd..ab0860a4caa 100644 --- a/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts +++ b/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts @@ -11,6 +11,6 @@ ////} // TODO: GH#18445 verify.rangeAfterCodeFix(` - super();\r + super(); this.a = 12; `, /*includeWhiteSpace*/ true); diff --git a/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_all.ts b/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_all.ts index 0b12fb4b03d..96f3677fda7 100644 --- a/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_all.ts +++ b/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess_all.ts @@ -18,14 +18,14 @@ verify.codeFixAll({ fixId: "classSuperMustPrecedeThisAccess", newFileContent: `class C extends Object { constructor() { - super();\r + super(); this; this; } } class D extends Object { constructor() { - super();\r + super(); this; } }`, diff --git a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts index 402d4196360..030463345f3 100644 --- a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts +++ b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts @@ -13,8 +13,8 @@ verify.codeFix({ `class Base{ } class C extends Base{ - constructor() {\r - super();\r + constructor() { + super(); } }`, }); diff --git a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts index 8aa0e2c6ade..60e6d1d4599 100644 --- a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts +++ b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts @@ -11,13 +11,13 @@ verify.codeFixAll({ fixId: "constructorForDerivedNeedSuperCall", // TODO: GH#18445 newFileContent: `class C extends Object { - constructor() {\r - super();\r + constructor() { + super(); } } class D extends Object { - constructor() {\r - super();\r + constructor() { + super(); } }`, }); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_all.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_all.ts index 527ecb66848..9c3785cf2ae 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_all.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile_all.ts @@ -13,8 +13,8 @@ verify.codeFixAll({ fixId: "disableJsDiagnostics", newFileContent: `let x = ""; -// @ts-ignore\r +// @ts-ignore x = 1; -// @ts-ignore\r +// @ts-ignore x = true;`, }); diff --git a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts index b1fac4e0f12..0a978fab222 100644 --- a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts +++ b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts @@ -14,9 +14,9 @@ verify.codeFix({ index: 0, // TODO: GH#18445 newRangeContent: ` - static m1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + static m1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } `, }); @@ -24,12 +24,12 @@ verify.codeFix({ description: "Declare static method 'm2'", index: 0, newRangeContent: ` - static m2(arg0: any, arg1: any): any {\r - throw new Error("Method not implemented.");\r - }\r - static m1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + static m2(arg0: any, arg1: any): any { + throw new Error("Method not implemented."); + } + static m1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } `, }); @@ -37,13 +37,13 @@ verify.codeFix({ description: "Declare static property 'prop1'", index: 0, newRangeContent: ` - static prop1: number;\r - static m2(arg0: any, arg1: any): any {\r - throw new Error("Method not implemented.");\r - }\r - static m1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + static prop1: number; + static m2(arg0: any, arg1: any): any { + throw new Error("Method not implemented."); + } + static m1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } `, }); @@ -51,13 +51,13 @@ verify.codeFix({ description: "Declare static property 'prop2'", index: 0, newRangeContent: ` - static prop2: string;\r - static prop1: number;\r - static m2(arg0: any, arg1: any): any {\r - throw new Error("Method not implemented.");\r - }\r - static m1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + static prop2: string; + static prop1: number; + static m2(arg0: any, arg1: any): any { + throw new Error("Method not implemented."); + } + static m1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } `, }); diff --git a/tests/cases/fourslash/codeFixUndeclaredMethod.ts b/tests/cases/fourslash/codeFixUndeclaredMethod.ts index 2f291490b14..bffa9fb0897 100644 --- a/tests/cases/fourslash/codeFixUndeclaredMethod.ts +++ b/tests/cases/fourslash/codeFixUndeclaredMethod.ts @@ -15,9 +15,9 @@ verify.codeFix({ index: 0, // TODO: GH#18445 newRangeContent: ` - foo1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + foo1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } `, }); @@ -25,12 +25,12 @@ verify.codeFix({ description: "Declare method 'foo2'", index: 0, newRangeContent: ` - foo2(): any {\r - throw new Error("Method not implemented.");\r - }\r - foo1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + foo2(): any { + throw new Error("Method not implemented."); + } + foo1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } ` }); @@ -38,14 +38,14 @@ verify.codeFix({ description: "Declare method 'foo3'", index: 0, newRangeContent:` - foo3(): any {\r - throw new Error("Method not implemented.");\r - }\r - foo2(): any {\r - throw new Error("Method not implemented.");\r - }\r - foo1(arg0: any, arg1: any, arg2: any): any {\r - throw new Error("Method not implemented.");\r - }\r + foo3(): any { + throw new Error("Method not implemented."); + } + foo2(): any { + throw new Error("Method not implemented."); + } + foo1(arg0: any, arg1: any, arg2: any): any { + throw new Error("Method not implemented."); + } ` }); diff --git a/tests/cases/fourslash/completionAfterBackslashFollowingString.ts b/tests/cases/fourslash/completionAfterBackslashFollowingString.ts index e8eeeb571b6..2e8587ffd1f 100644 --- a/tests/cases/fourslash/completionAfterBackslashFollowingString.ts +++ b/tests/cases/fourslash/completionAfterBackslashFollowingString.ts @@ -1,6 +1,6 @@ /// -////Harness.newLine = "\r"\n/**/ +////Harness.newLine = ""\n/**/ goTo.marker(); verify.not.completionListIsEmpty(); \ No newline at end of file diff --git a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts index 09c0e74002b..0c3df5d0f23 100644 --- a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts +++ b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts @@ -19,6 +19,6 @@ verify.applyCodeActionFromCompletion("", { description: `Import 'foo' from module "./a"`, // TODO: GH#18445 newFileContent: `import f_o_o from "./a"; -import foo from "./a";\r +import foo from "./a"; f;`, }); diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index 35489c1110b..617e3c5f669 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -23,8 +23,8 @@ verify.applyCodeActionFromCompletion("1", { source: "/src/foo-bar", description: `Import 'fooBar' from module "./foo-bar"`, // TODO: GH#18445 - newFileContent: `import fooBar from "./foo-bar";\r -\r + newFileContent: `import fooBar from "./foo-bar"; + def fooB`, }); diff --git a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts index 558be4bee03..0daeabf1ec7 100644 --- a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts @@ -19,7 +19,7 @@ verify.applyCodeActionFromCompletion("", { source: "/a", description: `Import 'foo' from module "./a"`, // TODO: GH#18445 - newFileContent: `import foo from "./a";\r -\r + newFileContent: `import foo from "./a"; + f;`, }); diff --git a/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts b/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts index 7549c2e001b..2b3056313e8 100644 --- a/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts +++ b/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts @@ -20,7 +20,7 @@ verify.applyCodeActionFromCompletion("", { source: "/a", description: `Import 'foo' from module "./a"`, // TODO: GH#18445 - newFileContent: `import foo from "./a";\r -\r + newFileContent: `import foo from "./a"; + f;`, }); diff --git a/tests/cases/fourslash/completionsImport_fromAmbientModule.ts b/tests/cases/fourslash/completionsImport_fromAmbientModule.ts index db9b586eb42..90806f802ee 100644 --- a/tests/cases/fourslash/completionsImport_fromAmbientModule.ts +++ b/tests/cases/fourslash/completionsImport_fromAmbientModule.ts @@ -13,7 +13,7 @@ verify.applyCodeActionFromCompletion("", { source: "m", description: `Import 'x' from module "m"`, // TODO: GH#18445 - newFileContent: `import { x } from "m";\r -\r + newFileContent: `import { x } from "m"; + `, }); diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index d85c04ce9f8..e2bc53a94bf 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -24,7 +24,7 @@ verify.applyCodeActionFromCompletion("", { source: "/b", description: `Import 'foo' from module "./b"`, // TODO: GH#18445 - newFileContent: `import { foo } from "./b";\r -\r + newFileContent: `import { foo } from "./b"; + fo`, }); diff --git a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts index b88ce9cae0d..eb8e86194fe 100644 --- a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts +++ b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts @@ -20,7 +20,7 @@ verify.applyCodeActionFromCompletion("", { source: "/a", description: `Import 'foo' from module "./a"`, // TODO: GH#18445 - newFileContent: `import { foo } from "./a";\r -\r + newFileContent: `import { foo } from "./a"; + f;`, }); diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index 5808e6c9f1a..40889e14033 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -30,7 +30,7 @@ verify.applyCodeActionFromCompletion("", { source: "/a", description: `Import 'foo' from module "./a"`, // TODO: GH#18445 - newFileContent: `import { foo } from "./a";\r -\r + newFileContent: `import { foo } from "./a"; + fo`, }); diff --git a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts index b837b759b53..23938746d25 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts @@ -25,7 +25,7 @@ verify.applyCodeActionFromCompletion("", { source: "/foo/lib/foo", description: `Import 'foo' from module "./foo"`, // TODO: GH#18445 - newFileContent: `import { foo } from "./foo";\r -\r + newFileContent: `import { foo } from "./foo"; + fo`, }); diff --git a/tests/cases/fourslash/completionsImport_require.ts b/tests/cases/fourslash/completionsImport_require.ts index 2355cd06c33..5a0839bfe52 100644 --- a/tests/cases/fourslash/completionsImport_require.ts +++ b/tests/cases/fourslash/completionsImport_require.ts @@ -24,8 +24,8 @@ verify.applyCodeActionFromCompletion("b", { source: "/a", description: `Import 'foo' from module "./a"`, // TODO: GH#18445 - newFileContent: `import { foo } from "./a";\r -\r + newFileContent: `import { foo } from "./a"; + const a = require("./a"); fo`, }); @@ -41,8 +41,8 @@ verify.applyCodeActionFromCompletion("c", { source: "/a", description: `Import 'foo' from module "./a"`, // TODO: GH#18445 - newFileContent: `import { foo } from "./a";\r -\r + newFileContent: `import { foo } from "./a"; + const a = import("./a"); fo`, }); diff --git a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts index ec2ae9b3c22..feead97486b 100644 --- a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts +++ b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts @@ -15,7 +15,7 @@ ////}); goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); goTo.marker("0"); // Won't-fixed: Smart indent during chained function calls verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts index b1955d98417..50cebb527ce 100644 --- a/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts +++ b/tests/cases/fourslash/docCommentTemplateFunctionWithParameters.ts @@ -5,8 +5,8 @@ //// /*1*/ //// function foo(x: number, y: string): boolean {} -const noIndentScaffolding = "/**\r\n * \r\n * @param x\r\n * @param y\r\n */"; -const oneIndentScaffolding = "/**\r\n * \r\n * @param x\r\n * @param y\r\n */"; +const noIndentScaffolding = "/**\n * \n * @param x\n * @param y\n */"; +const oneIndentScaffolding = "/**\n * \n * @param x\n * @param y\n */"; const noIndentOffset = 8; const oneIndentOffset = noIndentOffset + 4; diff --git a/tests/cases/fourslash/findReferencesAfterEdit.ts b/tests/cases/fourslash/findReferencesAfterEdit.ts index 2d57e78c637..599be2255a3 100644 --- a/tests/cases/fourslash/findReferencesAfterEdit.ts +++ b/tests/cases/fourslash/findReferencesAfterEdit.ts @@ -15,6 +15,6 @@ verify.singleReferenceGroup("(property) A.foo: string"); goTo.marker(""); -edit.insert("\r\n"); +edit.insert("\n"); verify.singleReferenceGroup("(property) A.foo: string"); diff --git a/tests/cases/fourslash/formatEmptyBlock.ts b/tests/cases/fourslash/formatEmptyBlock.ts index 565dbc6257c..0521ab6c816 100644 --- a/tests/cases/fourslash/formatEmptyBlock.ts +++ b/tests/cases/fourslash/formatEmptyBlock.ts @@ -3,6 +3,6 @@ ////{} goTo.eof(); -edit.insert("\r\n"); +edit.insert("\n"); goTo.bof(); verify.currentLineContentIs("{ }"); \ No newline at end of file diff --git a/tests/cases/fourslash/formatTemplateLiteral.ts b/tests/cases/fourslash/formatTemplateLiteral.ts index a10f8dba8f2..6ec1ec3082e 100644 --- a/tests/cases/fourslash/formatTemplateLiteral.ts +++ b/tests/cases/fourslash/formatTemplateLiteral.ts @@ -15,10 +15,10 @@ goTo.marker("1"); -edit.insert("\r\n"); // edit will trigger formatting - should succeeed +edit.insert("\n"); // edit will trigger formatting - should succeeed goTo.marker("2"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(0); verify.currentLineContentIs("3`;") diff --git a/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts b/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts index 848f9943925..8304415ebfa 100644 --- a/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts +++ b/tests/cases/fourslash/formattingOnDoWhileNoSemicolon.ts @@ -5,7 +5,7 @@ /////*4*/ i -= 2 /////*5*/ }/*1*/while (1 !== 1) goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); verify.currentLineContentIs("while (1 !== 1)"); goTo.marker("2"); verify.currentLineContentIs("do {"); diff --git a/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts b/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts index e35f4a333b9..2b5dc9a3a5c 100644 --- a/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts +++ b/tests/cases/fourslash/formattingOnNestedDoWhileByEnter.ts @@ -7,7 +7,7 @@ /////*6*/}while(a!==b) /////*7*/}while(a!==b) goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); verify.currentLineContentIs(" {"); goTo.marker("2"); verify.currentLineContentIs("do{"); diff --git a/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts b/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts index e64c7be0492..40fc4a5934b 100644 --- a/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts +++ b/tests/cases/fourslash/formattingWithEnterAfterMultilineString.ts @@ -8,7 +8,7 @@ ////} goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); // We actually need to verify smart (virtual) identation here rather than actual identation. Fourslash support is required. verify.indentationIs(8); goTo.marker("2"); diff --git a/tests/cases/fourslash/getOccurrencesAfterEdit.ts b/tests/cases/fourslash/getOccurrencesAfterEdit.ts index 0654cc3962c..5514e22dce9 100644 --- a/tests/cases/fourslash/getOccurrencesAfterEdit.ts +++ b/tests/cases/fourslash/getOccurrencesAfterEdit.ts @@ -12,7 +12,7 @@ goTo.marker("1"); verify.occurrencesAtPositionCount(2); goTo.marker("0"); -edit.insert("\r\n"); +edit.insert("\n"); goTo.marker("1"); verify.occurrencesAtPositionCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixReExport.ts b/tests/cases/fourslash/importNameCodeFixReExport.ts index eb1c1a91343..e6e5f21f4ac 100644 --- a/tests/cases/fourslash/importNameCodeFixReExport.ts +++ b/tests/cases/fourslash/importNameCodeFixReExport.ts @@ -11,7 +11,7 @@ goTo.file("/b.ts"); // TODO:GH#18445 -verify.rangeAfterCodeFix(`import { x } from "./a";\r -\r +verify.rangeAfterCodeFix(`import { x } from "./a"; + export { x } from "./a"; x;`, /*includeWhiteSpace*/ true); diff --git a/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts b/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts index 06c0fb6e44a..a81bcb2f241 100644 --- a/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts +++ b/tests/cases/fourslash/noSmartIndentInsideMultilineString.ts @@ -7,5 +7,5 @@ ////}; goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(0); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts b/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts index 0654cc3962c..5514e22dce9 100644 --- a/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts +++ b/tests/cases/fourslash/shims-pp/getOccurrencesAtPosition.ts @@ -12,7 +12,7 @@ goTo.marker("1"); verify.occurrencesAtPositionCount(2); goTo.marker("0"); -edit.insert("\r\n"); +edit.insert("\n"); goTo.marker("1"); verify.occurrencesAtPositionCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/shims/getOccurrencesAtPosition.ts b/tests/cases/fourslash/shims/getOccurrencesAtPosition.ts index 0654cc3962c..5514e22dce9 100644 --- a/tests/cases/fourslash/shims/getOccurrencesAtPosition.ts +++ b/tests/cases/fourslash/shims/getOccurrencesAtPosition.ts @@ -12,7 +12,7 @@ goTo.marker("1"); verify.occurrencesAtPositionCount(2); goTo.marker("0"); -edit.insert("\r\n"); +edit.insert("\n"); goTo.marker("1"); verify.occurrencesAtPositionCount(2); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts b/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts index 980f2383299..c16585f452d 100644 --- a/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts +++ b/tests/cases/fourslash/smartIndentArrayBindingPattern01.ts @@ -4,7 +4,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts b/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts index b9a1da7796a..278c9ecf1ee 100644 --- a/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts +++ b/tests/cases/fourslash/smartIndentArrayBindingPattern02.ts @@ -4,7 +4,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentDoStatement.ts b/tests/cases/fourslash/smartIndentDoStatement.ts index d121344bed0..144e04567be 100644 --- a/tests/cases/fourslash/smartIndentDoStatement.ts +++ b/tests/cases/fourslash/smartIndentDoStatement.ts @@ -7,7 +7,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentIfStatement.ts b/tests/cases/fourslash/smartIndentIfStatement.ts index 5a8c5014a77..a59b374be45 100644 --- a/tests/cases/fourslash/smartIndentIfStatement.ts +++ b/tests/cases/fourslash/smartIndentIfStatement.ts @@ -9,7 +9,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts b/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts index 253f58071d9..a3bed952e95 100644 --- a/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts +++ b/tests/cases/fourslash/smartIndentInParenthesizedExpression01.ts @@ -4,7 +4,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts b/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts index e10ef704c2c..a9bae4bbef5 100644 --- a/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts +++ b/tests/cases/fourslash/smartIndentObjectBindingPattern01.ts @@ -4,7 +4,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts b/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts index 9247f5f467b..b4c751f58a1 100644 --- a/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts +++ b/tests/cases/fourslash/smartIndentObjectBindingPattern02.ts @@ -4,7 +4,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentOnAccessors.ts b/tests/cases/fourslash/smartIndentOnAccessors.ts index a7972b1f48b..6176163a5fa 100644 --- a/tests/cases/fourslash/smartIndentOnAccessors.ts +++ b/tests/cases/fourslash/smartIndentOnAccessors.ts @@ -17,7 +17,7 @@ goTo.marker("0"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(8); goTo.marker("1"); verify.currentLineContentIs(" b,"); @@ -26,7 +26,7 @@ verify.currentLineContentIs(" //comment"); goTo.marker("3"); verify.currentLineContentIs(" c"); goTo.marker("4"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(8); goTo.marker("5"); verify.currentLineContentIs(" b,"); diff --git a/tests/cases/fourslash/smartIndentOnAccessors01.ts b/tests/cases/fourslash/smartIndentOnAccessors01.ts index a7972b1f48b..6176163a5fa 100644 --- a/tests/cases/fourslash/smartIndentOnAccessors01.ts +++ b/tests/cases/fourslash/smartIndentOnAccessors01.ts @@ -17,7 +17,7 @@ goTo.marker("0"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(8); goTo.marker("1"); verify.currentLineContentIs(" b,"); @@ -26,7 +26,7 @@ verify.currentLineContentIs(" //comment"); goTo.marker("3"); verify.currentLineContentIs(" c"); goTo.marker("4"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(8); goTo.marker("5"); verify.currentLineContentIs(" b,"); diff --git a/tests/cases/fourslash/smartIndentOnFunctionParameters.ts b/tests/cases/fourslash/smartIndentOnFunctionParameters.ts index 8823bf46917..1bc42fe2a67 100644 --- a/tests/cases/fourslash/smartIndentOnFunctionParameters.ts +++ b/tests/cases/fourslash/smartIndentOnFunctionParameters.ts @@ -12,7 +12,7 @@ //// 2/*7*/ ////] goTo.marker("0"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(4); goTo.marker("2"); verify.currentLineContentIs(" b,"); @@ -21,7 +21,7 @@ verify.currentLineContentIs(" //comment"); goTo.marker("4"); verify.currentLineContentIs(" c"); goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(4); goTo.marker("5"); verify.currentLineContentIs(" //comment"); diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts index 3e08fe5975e..9ee221225e6 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration01.ts @@ -5,7 +5,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts index 3de8b5ec6c3..f1e2d013c40 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration02.ts @@ -5,7 +5,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration03.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration03.ts index 9a6c378f6ce..cb7aad0cc66 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration03.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration03.ts @@ -5,7 +5,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts index 2cfd27f2e3b..73bd7d388c4 100644 --- a/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts +++ b/tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts @@ -5,7 +5,7 @@ function verifyIndentationAfterNewLine(marker: string, indentation: number): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(indentation); } diff --git a/tests/cases/fourslash/smartIndentStartLineInLists.ts b/tests/cases/fourslash/smartIndentStartLineInLists.ts index 3410b4012ee..d61930ef511 100644 --- a/tests/cases/fourslash/smartIndentStartLineInLists.ts +++ b/tests/cases/fourslash/smartIndentStartLineInLists.ts @@ -4,5 +4,5 @@ ////}) goTo.marker("1"); -edit.insert("\r\n"); +edit.insert("\n"); verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/smartIndentTemplateLiterals.ts b/tests/cases/fourslash/smartIndentTemplateLiterals.ts index 679978a515c..38b0252a01b 100644 --- a/tests/cases/fourslash/smartIndentTemplateLiterals.ts +++ b/tests/cases/fourslash/smartIndentTemplateLiterals.ts @@ -7,7 +7,7 @@ function verifyIndentation(marker: string): void { goTo.marker(marker); - edit.insert("\r\n"); + edit.insert("\n"); verify.indentationIs(0); } verifyIndentation("1"); From 3ca1cc406a9362328ac6bd2a16e575146bb23a05 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 17 Jan 2018 15:29:41 -0800 Subject: [PATCH 3/7] Clean up TODOs for #18445 --- src/harness/fourslash.ts | 4 +--- tests/cases/fourslash/codeFixAddMissingMember.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember2.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember3.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember4.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember5.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember6.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember7.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember_all.ts | 1 - tests/cases/fourslash/codeFixAddMissingMember_all_js.ts | 1 - tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts | 1 - .../cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts | 1 - .../fourslash/codeFixClassExtendAbstractProtectedProperty.ts | 1 - .../fourslash/codeFixClassExtendAbstractPublicProperty.ts | 1 - .../codeFixClassImplementClassAbstractGettersAndSetters.ts | 1 - .../codeFixClassImplementClassFunctionVoidInferred.ts | 1 - .../codeFixClassImplementClassMultipleSignatures1.ts | 1 - .../codeFixClassImplementClassMultipleSignatures2.ts | 1 - .../fourslash/codeFixClassImplementClassPropertyModifiers.ts | 1 - .../fourslash/codeFixClassImplementClassPropertyTypeQuery.ts | 1 - tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts | 1 - tests/cases/fourslash/codeFixClassImplementDefaultClass.ts | 1 - .../fourslash/codeFixClassImplementInterfaceArrayTuple.ts | 1 - .../codeFixClassImplementInterfaceClassExpression.ts | 1 - .../cases/fourslash/codeFixClassImplementInterfaceComments.ts | 1 - .../codeFixClassImplementInterfaceComputedPropertyLiterals.ts | 1 - ...sImplementInterfaceComputedPropertyNameWellKnownSymbols.ts | 1 - .../fourslash/codeFixClassImplementInterfaceInNamespace.ts | 1 - .../codeFixClassImplementInterfaceIndexSignaturesBoth.ts | 1 - .../codeFixClassImplementInterfaceIndexSignaturesNumber.ts | 1 - .../codeFixClassImplementInterfaceIndexSignaturesString.ts | 1 - .../fourslash/codeFixClassImplementInterfaceIndexType.ts | 1 - .../codeFixClassImplementInterfaceInheritsAbstractMethod.ts | 1 - .../fourslash/codeFixClassImplementInterfaceMappedType.ts | 1 - .../codeFixClassImplementInterfaceMemberNestedTypeAlias.ts | 1 - .../fourslash/codeFixClassImplementInterfaceMemberOrdering.ts | 1 - .../codeFixClassImplementInterfaceMemberTypeAlias.ts | 1 - ...odeFixClassImplementInterfaceMethodThisAndSelfReference.ts | 1 - .../codeFixClassImplementInterfaceMethodTypePredicate.ts | 1 - ...FixClassImplementInterfaceMultipleMembersAndPunctuation.ts | 1 - .../codeFixClassImplementInterfaceMultipleSignatures.ts | 1 - .../codeFixClassImplementInterfaceMultipleSignaturesRest1.ts | 1 - .../codeFixClassImplementInterfaceMultipleSignaturesRest2.ts | 1 - .../codeFixClassImplementInterfaceNamespaceConflict.ts | 1 - .../codeFixClassImplementInterfaceOptionalProperty.ts | 1 - .../cases/fourslash/codeFixClassImplementInterfaceProperty.ts | 1 - .../codeFixClassImplementInterfacePropertySignatures.ts | 1 - .../fourslash/codeFixClassImplementInterfaceQualifiedName.ts | 1 - ...odeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts | 1 - ...odeFixClassImplementInterfaceTypeParamInstantiateNumber.ts | 1 - .../codeFixClassImplementInterfaceTypeParamInstantiateT.ts | 1 - .../codeFixClassImplementInterfaceTypeParamInstantiateU.ts | 1 - .../codeFixClassImplementInterfaceTypeParamMethod.ts | 1 - tests/cases/fourslash/codeFixClassImplementInterface_all.ts | 2 +- .../cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts | 1 - .../fourslash/codeFixConstructorForDerivedNeedSuperCall.ts | 1 - .../codeFixConstructorForDerivedNeedSuperCall_all.ts | 1 - tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts | 1 - tests/cases/fourslash/codeFixUndeclaredMethod.ts | 1 - .../completionsImport_default_alreadyExistedWithRename.ts | 1 - tests/cases/fourslash/completionsImport_default_anonymous.ts | 1 - .../fourslash/completionsImport_default_didNotExistBefore.ts | 1 - .../completionsImport_default_exportDefaultIdentifier.ts | 1 - tests/cases/fourslash/completionsImport_fromAmbientModule.ts | 1 - .../cases/fourslash/completionsImport_multipleWithSameName.ts | 1 - .../completionsImport_named_exportEqualsNamespace.ts | 1 - .../completionsImport_named_namespaceImportExists.ts | 1 - tests/cases/fourslash/completionsImport_ofAlias.ts | 1 - .../fourslash/completionsImport_ofAlias_preferShortPath.ts | 1 - tests/cases/fourslash/completionsImport_require.ts | 2 -- tests/cases/fourslash/importNameCodeFixReExport.ts | 1 - .../fourslash/server/convertFunctionToEs6Class-server.ts | 1 - 72 files changed, 2 insertions(+), 75 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index df870034270..61b2c088e14 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2568,9 +2568,7 @@ Actual: ${stringify(fullActual)}`); const originalContent = scriptInfo.content; for (const codeFix of codeFixes) { this.applyEdits(codeFix.changes[0].fileName, codeFix.changes[0].textChanges, /*isFormattingEdit*/ false); - let text = this.rangeText(ranges[0]); - // TODO:GH#18445 (remove this line to see errors in many `importNameCodeFix` tests) - text = text.replace(/\r\n/g, "\n"); + const text = this.rangeText(ranges[0]); actualTextArray.push(text); scriptInfo.updateContent(originalContent); } diff --git a/tests/cases/fourslash/codeFixAddMissingMember.ts b/tests/cases/fourslash/codeFixAddMissingMember.ts index 8c337c30318..f5bdf567b20 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember.ts @@ -9,7 +9,6 @@ verify.codeFix({ description: "Declare property 'foo'", index: 0, - // TODO: GH#18445 newFileContent: `class C { foo: number; method() { diff --git a/tests/cases/fourslash/codeFixAddMissingMember2.ts b/tests/cases/fourslash/codeFixAddMissingMember2.ts index e8a28810a60..a4b7ffb3bfe 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember2.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember2.ts @@ -9,7 +9,6 @@ verify.codeFix({ description: "Add index signature for property 'foo'", index: 1, - // TODO: GH#18445 newFileContent: `class C { [x: string]: number; method() { diff --git a/tests/cases/fourslash/codeFixAddMissingMember3.ts b/tests/cases/fourslash/codeFixAddMissingMember3.ts index 8367e6918cc..82512406985 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember3.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember3.ts @@ -9,7 +9,6 @@ verify.codeFix({ description: "Declare static property 'foo'", index: 0, - // TODO: GH#18445 newFileContent: `class C { static foo: number; static method() { diff --git a/tests/cases/fourslash/codeFixAddMissingMember4.ts b/tests/cases/fourslash/codeFixAddMissingMember4.ts index 5f84b28cde3..58348bca053 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember4.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember4.ts @@ -15,7 +15,6 @@ verify.codeFix({ description: "Initialize property 'foo' in the constructor", index: 0, - // TODO: GH#18445 newFileContent: `class C { constructor() { this.foo = undefined; diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts index 727253f0b9d..64a62b8268a 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember5.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -13,7 +13,6 @@ verify.codeFix({ description: "Initialize static property 'foo'", index: 0, - // TODO: GH#18445 newFileContent: `class C { static method() { ()=>{ this.foo === 10 }; diff --git a/tests/cases/fourslash/codeFixAddMissingMember6.ts b/tests/cases/fourslash/codeFixAddMissingMember6.ts index f418f2c3ebc..902cafdfb24 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember6.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember6.ts @@ -13,7 +13,6 @@ verify.codeFix({ description: "Initialize property 'foo' in the constructor", index: 0, - // TODO: GH#18445 newFileContent: `class C { constructor() { this.foo = undefined; diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts index 8a475ebaf9c..6b80901a7bb 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember7.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -11,7 +11,6 @@ verify.codeFix({ description: "Initialize static property 'foo'", index: 2, - // TODO: GH#18445 newFileContent: `class C { static p = ()=>{ this.foo === 10 }; } diff --git a/tests/cases/fourslash/codeFixAddMissingMember_all.ts b/tests/cases/fourslash/codeFixAddMissingMember_all.ts index 9b9618ecaeb..ae5e957732b 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_all.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_all.ts @@ -11,7 +11,6 @@ verify.codeFixAll({ fixId: "addMissingMember", newFileContent: - // TODO: GH#18445 `class C { x: number; y(): any { diff --git a/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts b/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts index 67a91fd8b93..305b6d87c30 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_all_js.ts @@ -16,7 +16,6 @@ verify.codeFixAll({ fixId: "addMissingMember", newFileContent: - // TODO: GH#18445 `class C { y() { throw new Error("Method not implemented."); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts index aa28f301cc8..9521173ad89 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod_all.ts @@ -8,7 +8,6 @@ verify.codeFixAll({ fixId: "fixClassDoesntImplementInheritedAbstractMember", - // TODO: GH#18445 newFileContent: `abstract class A { abstract m(): void; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts index c1184c083a5..06b9dddcd8a 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPropertyThis.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement inherited abstract class", - // TODO: GH#18445 newFileContent: `abstract class A { abstract x: this; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts index e2472318e10..a150dd07f8d 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement inherited abstract class", - // TODO: GH#18445 newFileContent: `abstract class A { protected abstract x: number; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts index bb9ed1ec9c5..48a023e96fa 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement inherited abstract class", - // TODO: GH#18445 newFileContent: `abstract class A { public abstract x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts b/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts index ee28448f06e..adea74627b8 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassAbstractGettersAndSetters.ts @@ -15,7 +15,6 @@ verify.codeFix({ description: "Implement interface 'A'", - // TODO: GH#18445 newFileContent: `abstract class A { private _a: string; diff --git a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts index 8b749145ec2..115517f4e6d 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement interface 'A'", - // TODO: GH#18445 newFileContent: `class A { f() {} diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts index a2492787bf7..a0b59c6372c 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement interface 'A'", - // TODO: GH#18445 newFileContent: `class A { method(a: number, b: string): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts index 83e531c9ef4..dcd5636428d 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'A'", - // TODO: GH#18445 newFileContent: `class A { method(a: any, b: string): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts index 59d406541a6..7e7a712b60e 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyModifiers.ts @@ -11,7 +11,6 @@ verify.codeFix({ description: "Implement interface 'A'", - // TODO: GH#18445 newFileContent: `abstract class A { abstract x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts index 326ad2b547e..3c34de1e1bf 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts @@ -7,7 +7,6 @@ verify.codeFix({ description: "Implement interface 'A'", - // TODO: GH#18445 newFileContent: `class A { A: typeof A; diff --git a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts index 785ffb80a08..c9a568effbf 100644 --- a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts +++ b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts @@ -50,7 +50,6 @@ verify.codeFix({ description: "Implement interface 'I6'", - // TODO: GH#18445 newFileContent: `// Referenced throughout the inheritance chain. interface I0 { a: number } diff --git a/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts b/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts index e2ffab5a784..8793872ce95 100644 --- a/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts +++ b/tests/cases/fourslash/codeFixClassImplementDefaultClass.ts @@ -5,7 +5,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: number; } export default class implements I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts index 05c5ceaa6bc..c6ad69ffb44 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: number[]; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts index 0340cdf180b..cd9b689736d 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceClassExpression.ts @@ -6,7 +6,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: number; } new class implements I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts index a80dcf0c4b9..793ad944732 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts @@ -20,7 +20,6 @@ verify.codeFix({ description: "Implement interface 'N.I'", - // TODO: GH#18445 newFileContent: `namespace N { /**enum prefix */ diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts index 4e999d38426..daa46c6b2e9 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -11,7 +11,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { ["foo"](o: any): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts index be9f6ddbbec..2bc7a738258 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts @@ -21,7 +21,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { [Symbol.hasInstance](o: any): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts index b52e4d98c38..0a28afd4b5d 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts @@ -13,7 +13,6 @@ verify.codeFix({ description: "Implement interface 'N1.I1'", - // TODO: GH#18445 newFileContent: `namespace N1 { export interface I1 { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts index 011bed12d8b..15fdcdab913 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesBoth.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { [x: number]: I; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts index 5b4a2bb73c0..ede4ed4f568 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts @@ -7,7 +7,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { [x: number]: I; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts index 5f9c943330b..2e2c49d2700 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesString.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { [Ƚ: string]: X; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts index 760d15f1d8f..2a2b4c32c1b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts @@ -7,7 +7,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: keyof X; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts index e4e8c409165..516919b13df 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts @@ -9,7 +9,6 @@ verify.codeFix({ description: "Implement interface 'I1'", - // TODO: GH#18445 newFileContent: `abstract class C1 { } abstract class C2 { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts index 86a979b23df..17f8ccb0bea 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts @@ -7,7 +7,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: { readonly [K in keyof X]: X[K] }; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts index af4c591fd37..722fe51d0a5 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberNestedTypeAlias.ts @@ -9,7 +9,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `type Either = { val: T } | Error; interface I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts index e7d98d4ee1b..9c5bd172e8f 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts @@ -33,7 +33,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `/** asdf */ interface I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts index 87fda6bcd11..6fd8900d51b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberTypeAlias.ts @@ -6,7 +6,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `type MyType = [string, number]; interface I { x: MyType; test(a: MyType): void; } diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index c382b9f6858..4dfeb7cd95b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { f(x: number, y: this): I diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts index 9c916e3f4c6..45bd6096142 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts @@ -9,7 +9,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { f(i: any): i is I; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts index 9b7a91891a7..bc52629e8e9 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts @@ -13,7 +13,6 @@ verify.codeFix({ description: "Implement interface 'I1'", - // TODO: GH#18445 newFileContent: `interface I1 { x: number, diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts index 05b08d6f570..ddfc21615a3 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { method(a: number, b: string): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts index 91f142db5dd..868a48711b2 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { method(a: number, ...b: string[]): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts index ae57831f0ea..29689f17ea7 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { method(a: number, ...b: string[]): boolean; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts index bca3c7b5fe2..a2b20c52f15 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -10,7 +10,6 @@ verify.codeFix({ description: "Implement interface 'N1.I1'", - // TODO: GH#18445 newFileContent: `namespace N1 { export interface I1 { x: number; } diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts index 215d11f1d94..9cb6f477733 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceOptionalProperty.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement interface 'IPerson'", - // TODO: GH#18445 newFileContent: `interface IPerson { name: string; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts index db9bf753ef7..6fc8d8955bb 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts @@ -13,7 +13,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `enum E { a,b,c } interface I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts index 37a35470d53..52d69b466fd 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts @@ -21,7 +21,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { a0: {}; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts index 9ca2894741c..b587d937062 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts @@ -7,7 +7,6 @@ verify.codeFix({ description: "Implement interface 'N.I'", - // TODO: GH#18445 newFileContent: `namespace N { export interface I { y: I; } diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts index 486bea3098a..cf8926ff33e 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts @@ -7,7 +7,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: { y: T, z: T[] }; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts index dde7bc4fc09..88f0d32fe18 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts @@ -5,7 +5,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: T; } class C implements I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts index 4a796bcefc1..504b1684632 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts @@ -5,7 +5,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: T; } class C implements I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts index efe5295d3b3..c189fed4c8c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts @@ -5,7 +5,6 @@ verify.codeFix({ description: "Implement interface 'I'", - // TODO: GH#18445 newFileContent: `interface I { x: T; } class C implements I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts index 5596b091754..70db2b5908c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Implement interface 'I'", newFileContent: - // TODO: GH#18445 `interface I { f(x: T); } diff --git a/tests/cases/fourslash/codeFixClassImplementInterface_all.ts b/tests/cases/fourslash/codeFixClassImplementInterface_all.ts index 641f355be32..cc27e395ed7 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface_all.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface_all.ts @@ -7,7 +7,7 @@ verify.codeFixAll({ fixId: "fixClassIncorrectlyImplementsInterface", - // TODO: GH#20073 GH#18445 + // TODO: GH#20073 newFileContent: `interface I { i(): void; } interface J { j(): void; } diff --git a/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts b/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts index ab0860a4caa..5d1772ba8b8 100644 --- a/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts +++ b/tests/cases/fourslash/codeFixClassSuperMustPrecedeThisAccess.ts @@ -9,7 +9,6 @@ //// super(); //// |]} ////} -// TODO: GH#18445 verify.rangeAfterCodeFix(` super(); this.a = 12; diff --git a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts index 030463345f3..154eda0e084 100644 --- a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts +++ b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall.ts @@ -8,7 +8,6 @@ verify.codeFix({ description: "Add missing 'super()' call", - // TODO: GH#18445 newFileContent: `class Base{ } diff --git a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts index 60e6d1d4599..3833af62de0 100644 --- a/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts +++ b/tests/cases/fourslash/codeFixConstructorForDerivedNeedSuperCall_all.ts @@ -9,7 +9,6 @@ verify.codeFixAll({ fixId: "constructorForDerivedNeedSuperCall", - // TODO: GH#18445 newFileContent: `class C extends Object { constructor() { super(); diff --git a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts index 0a978fab222..0bd4ac3a879 100644 --- a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts +++ b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts @@ -12,7 +12,6 @@ verify.codeFix({ description: "Declare static method 'm1'", index: 0, - // TODO: GH#18445 newRangeContent: ` static m1(arg0: any, arg1: any, arg2: any): any { throw new Error("Method not implemented."); diff --git a/tests/cases/fourslash/codeFixUndeclaredMethod.ts b/tests/cases/fourslash/codeFixUndeclaredMethod.ts index bffa9fb0897..70ed58b995b 100644 --- a/tests/cases/fourslash/codeFixUndeclaredMethod.ts +++ b/tests/cases/fourslash/codeFixUndeclaredMethod.ts @@ -13,7 +13,6 @@ verify.codeFix({ description: "Declare method 'foo1'", index: 0, - // TODO: GH#18445 newRangeContent: ` foo1(arg0: any, arg1: any, arg2: any): any { throw new Error("Method not implemented."); diff --git a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts index 0c3df5d0f23..75c45c2970b 100644 --- a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts +++ b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts @@ -17,7 +17,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import f_o_o from "./a"; import foo from "./a"; f;`, diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index 617e3c5f669..ca9d9579901 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -22,7 +22,6 @@ verify.applyCodeActionFromCompletion("1", { name: "fooBar", source: "/src/foo-bar", description: `Import 'fooBar' from module "./foo-bar"`, - // TODO: GH#18445 newFileContent: `import fooBar from "./foo-bar"; def diff --git a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts index 0daeabf1ec7..0e9edb4d1b2 100644 --- a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts @@ -18,7 +18,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import foo from "./a"; f;`, diff --git a/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts b/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts index 2b3056313e8..45cdf71156e 100644 --- a/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts +++ b/tests/cases/fourslash/completionsImport_default_exportDefaultIdentifier.ts @@ -19,7 +19,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import foo from "./a"; f;`, diff --git a/tests/cases/fourslash/completionsImport_fromAmbientModule.ts b/tests/cases/fourslash/completionsImport_fromAmbientModule.ts index 90806f802ee..43789dea095 100644 --- a/tests/cases/fourslash/completionsImport_fromAmbientModule.ts +++ b/tests/cases/fourslash/completionsImport_fromAmbientModule.ts @@ -12,7 +12,6 @@ verify.applyCodeActionFromCompletion("", { name: "x", source: "m", description: `Import 'x' from module "m"`, - // TODO: GH#18445 newFileContent: `import { x } from "m"; `, diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index e2bc53a94bf..da118826235 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -23,7 +23,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/b", description: `Import 'foo' from module "./b"`, - // TODO: GH#18445 newFileContent: `import { foo } from "./b"; fo`, diff --git a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts index eb8e86194fe..788c9695e45 100644 --- a/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts +++ b/tests/cases/fourslash/completionsImport_named_exportEqualsNamespace.ts @@ -19,7 +19,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import { foo } from "./a"; f;`, diff --git a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts index 112cecba74a..fddd8ae12ca 100644 --- a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts +++ b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts @@ -17,7 +17,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Change 'foo' to 'a.foo'`, - // TODO: GH#18445 newFileContent: `import * as a from "./a"; a.f;`, }); diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index 40889e14033..3951a93a57f 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -29,7 +29,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import { foo } from "./a"; fo`, diff --git a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts index 23938746d25..bc66d485877 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias_preferShortPath.ts @@ -24,7 +24,6 @@ verify.applyCodeActionFromCompletion("", { name: "foo", source: "/foo/lib/foo", description: `Import 'foo' from module "./foo"`, - // TODO: GH#18445 newFileContent: `import { foo } from "./foo"; fo`, diff --git a/tests/cases/fourslash/completionsImport_require.ts b/tests/cases/fourslash/completionsImport_require.ts index 5a0839bfe52..c1830b726a1 100644 --- a/tests/cases/fourslash/completionsImport_require.ts +++ b/tests/cases/fourslash/completionsImport_require.ts @@ -23,7 +23,6 @@ verify.applyCodeActionFromCompletion("b", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import { foo } from "./a"; const a = require("./a"); @@ -40,7 +39,6 @@ verify.applyCodeActionFromCompletion("c", { name: "foo", source: "/a", description: `Import 'foo' from module "./a"`, - // TODO: GH#18445 newFileContent: `import { foo } from "./a"; const a = import("./a"); diff --git a/tests/cases/fourslash/importNameCodeFixReExport.ts b/tests/cases/fourslash/importNameCodeFixReExport.ts index e6e5f21f4ac..c77d32cc458 100644 --- a/tests/cases/fourslash/importNameCodeFixReExport.ts +++ b/tests/cases/fourslash/importNameCodeFixReExport.ts @@ -10,7 +10,6 @@ ////x;|] goTo.file("/b.ts"); -// TODO:GH#18445 verify.rangeAfterCodeFix(`import { x } from "./a"; export { x } from "./a"; diff --git a/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts b/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts index e7da28a2770..0bdd44f6753 100644 --- a/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts +++ b/tests/cases/fourslash/server/convertFunctionToEs6Class-server.ts @@ -14,7 +14,6 @@ verify.applicableRefactorAvailableAtMarker('1'); // NOTE: '// Comment' should be included, but due to incorrect handling of trivia, // it's omitted right now. -// TODO: GH#18445 verify.fileAfterApplyingRefactorAtMarker('1', `class fn {\r constructor() {\r From 13bf7f9c7c392f87419e815bd31447ba168f93d7 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 17 Jan 2018 15:37:05 -0800 Subject: [PATCH 4/7] Ensure getNewLineFromContext never returns undefined --- src/services/refactorProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/refactorProvider.ts b/src/services/refactorProvider.ts index 3d2a60e63e9..b0f5dbab324 100644 --- a/src/services/refactorProvider.ts +++ b/src/services/refactorProvider.ts @@ -21,7 +21,7 @@ namespace ts { export function getNewLineFromContext(context: RefactorOrCodeFixContext) { const formatSettings = context.formatContext.options; - return formatSettings ? formatSettings.newLineCharacter : context.host.getNewLine(); + return (formatSettings && formatSettings.newLineCharacter) || getNewLineOrDefaultFromHost(context.host); } export function toTextChangesContext(context: RefactorOrCodeFixContext): textChanges.TextChangesContext { From 3a38c8ea58c6e42779ac42c0e27fd85836d07865 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 17 Jan 2018 15:43:36 -0800 Subject: [PATCH 5/7] Replace TextChangesContext with RefactorOrCodeFixContext Thanks to @andy-ms for the suggestion! --- src/services/codeFixProvider.ts | 4 ++-- .../addMissingInvocationForDecorator.ts | 2 +- ...correctQualifiedNameToIndexedAccessType.ts | 2 +- .../codefixes/disableJsDiagnostics.ts | 4 ++-- src/services/codefixes/fixAddMissingMember.ts | 8 ++++---- .../codefixes/fixAwaitInSyncFunction.ts | 2 +- ...sDoesntImplementInheritedAbstractMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 2 +- .../fixClassSuperMustPrecedeThisAccess.ts | 2 +- .../fixConstructorForDerivedNeedSuperCall.ts | 2 +- .../fixExtendsInterfaceBecomesImplements.ts | 2 +- .../fixForgottenThisPropertyAccess.ts | 2 +- .../codefixes/fixInvalidImportSyntax.ts | 6 +++--- src/services/codefixes/fixSpelling.ts | 2 +- src/services/codefixes/fixUnusedIdentifier.ts | 4 ++-- src/services/codefixes/importFixes.ts | 18 +++++++++--------- src/services/refactorProvider.ts | 19 +------------------ .../refactors/annotateWithTypeFromJSDoc.ts | 4 ++-- .../refactors/convertFunctionToEs6Class.ts | 2 +- src/services/refactors/convertToEs6Module.ts | 2 +- src/services/refactors/extractSymbol.ts | 4 ++-- src/services/refactors/useDefaultImport.ts | 2 +- src/services/textChanges.ts | 9 +++++++-- 23 files changed, 47 insertions(+), 59 deletions(-) diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 619bcc8813c..502f8457d8c 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -7,7 +7,7 @@ namespace ts { getAllCodeActions?(context: CodeFixAllContext): CombinedCodeActions; } - export interface CodeFixContextBase extends RefactorOrCodeFixContext { + export interface CodeFixContextBase extends textChanges.TextChangesContext { sourceFile: SourceFile; program: Program; cancellationToken: CancellationToken; @@ -83,7 +83,7 @@ namespace ts { export function codeFixAll(context: CodeFixAllContext, errorCodes: number[], use: (changes: textChanges.ChangeTracker, error: Diagnostic, commands: Push) => void): CombinedCodeActions { const commands: CodeActionCommand[] = []; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => + const changes = textChanges.ChangeTracker.with(context, t => eachDiagnostic(context, errorCodes, diag => use(t, diag, commands))); return createCombinedCodeActions(changes, commands.length === 0 ? undefined : commands); } diff --git a/src/services/codefixes/addMissingInvocationForDecorator.ts b/src/services/codefixes/addMissingInvocationForDecorator.ts index 25214f08218..d063df87be4 100644 --- a/src/services/codefixes/addMissingInvocationForDecorator.ts +++ b/src/services/codefixes/addMissingInvocationForDecorator.ts @@ -5,7 +5,7 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions: (context) => { - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => makeChange(t, context.sourceFile, context.span.start)); + const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start)); return [{ description: getLocaleSpecificMessage(Diagnostics.Call_decorator_expression), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts index 076ea6135ae..de4498035be 100644 --- a/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts +++ b/src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts @@ -7,7 +7,7 @@ namespace ts.codefix { getCodeActions(context) { const qualifiedName = getQualifiedName(context.sourceFile, context.span.start); if (!qualifiedName) return undefined; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, context.sourceFile, qualifiedName)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, qualifiedName)); const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Rewrite_as_the_indexed_access_type_0), [`${qualifiedName.left.text}["${qualifiedName.right.text}"]`]); return [{ description, changes, fixId }]; }, diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index cf006a6066c..231b3c1513f 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -15,7 +15,7 @@ namespace ts.codefix { return undefined; } - const newLineCharacter = getNewLineFromContext(context); + const newLineCharacter = textChanges.getNewLineFromContext(context); return [{ description: getLocaleSpecificMessage(Diagnostics.Ignore_this_error_message), @@ -38,7 +38,7 @@ namespace ts.codefix { fixIds: [fixId], // No point applying as a group, doing it once will fix all errors getAllCodeActions: context => codeFixAllWithTextChanges(context, errorCodes, (changes, err) => { if (err.start !== undefined) { - changes.push(getIgnoreCommentLocationForLocation(err.file!, err.start, getNewLineFromContext(context))); + changes.push(getIgnoreCommentLocationForLocation(err.file!, err.start, textChanges.getNewLineFromContext(context))); } }), }); diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 8e45efa09ad..f7f5aa0a22f 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -96,7 +96,7 @@ namespace ts.codefix { } function getActionsForAddMissingMemberInJavaScriptFile(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, tokenName: string, makeStatic: boolean): CodeFixAction | undefined { - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic)); + const changes = textChanges.ChangeTracker.with(context, t => addMissingMemberInJs(t, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic)); if (changes.length === 0) return undefined; const description = formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? Diagnostics.Initialize_static_property_0 : Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]); return { description, changes, fixId }; @@ -144,7 +144,7 @@ namespace ts.codefix { function createAddPropertyDeclarationAction(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, makeStatic: boolean, tokenName: string, typeNode: TypeNode): CodeFixAction { const description = formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0), [tokenName]); - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addPropertyDeclaration(t, classDeclarationSourceFile, classDeclaration, tokenName, typeNode, makeStatic)); + const changes = textChanges.ChangeTracker.with(context, t => addPropertyDeclaration(t, classDeclarationSourceFile, classDeclaration, tokenName, typeNode, makeStatic)); return { description, changes, fixId }; } @@ -176,14 +176,14 @@ namespace ts.codefix { [indexingParameter], typeNode); - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => t.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, indexSignature)); + const changes = textChanges.ChangeTracker.with(context, t => t.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, indexSignature)); // No fixId here because code-fix-all currently only works on adding individual named properties. return { description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_property_0), [tokenName]), changes, fixId: undefined }; } function getActionForMethodDeclaration(context: CodeFixContext, classDeclarationSourceFile: SourceFile, classDeclaration: ClassLikeDeclaration, token: Identifier, callExpression: CallExpression, makeStatic: boolean, inJs: boolean): CodeFixAction | undefined { const description = formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0), [token.text]); - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs)); + const changes = textChanges.ChangeTracker.with(context, t => addMethodDeclaration(t, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs)); return { description, changes, fixId }; } diff --git a/src/services/codefixes/fixAwaitInSyncFunction.ts b/src/services/codefixes/fixAwaitInSyncFunction.ts index 7d09e5f214f..883993e7b51 100644 --- a/src/services/codefixes/fixAwaitInSyncFunction.ts +++ b/src/services/codefixes/fixAwaitInSyncFunction.ts @@ -11,7 +11,7 @@ namespace ts.codefix { const { sourceFile, span } = context; const nodes = getNodes(sourceFile, span.start); if (!nodes) return undefined; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, nodes)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, nodes)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_async_modifier_to_containing_function), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 6e215666ddf..da3685339ab 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -9,7 +9,7 @@ namespace ts.codefix { errorCodes, getCodeActions(context) { const { program, sourceFile, span } = context; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => + const changes = textChanges.ChangeTracker.with(context, t => addMissingMembers(getClass(sourceFile, span.start), sourceFile, program.getTypeChecker(), t)); return changes.length === 0 ? undefined : [{ description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), changes, fixId }]; }, diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 1eb5bfac986..0236b0c79b7 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -10,7 +10,7 @@ namespace ts.codefix { const classDeclaration = getClass(sourceFile, span.start); const checker = program.getTypeChecker(); return mapDefined(getClassImplementsHeritageClauseElements(classDeclaration), implementedTypeNode => { - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, t)); + const changes = textChanges.ChangeTracker.with(context, t => addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, t)); if (changes.length === 0) return undefined; const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); return { description, changes, fixId }; diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 76c1c588097..1595bbf3c13 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -9,7 +9,7 @@ namespace ts.codefix { const nodes = getNodes(sourceFile, span.start); if (!nodes) return undefined; const { constructor, superCall } = nodes; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, constructor, superCall)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, constructor, superCall)); return [{ description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 0b747344e3b..8fe2e8458a8 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -7,7 +7,7 @@ namespace ts.codefix { getCodeActions(context) { const { sourceFile, span } = context; const ctr = getNode(sourceFile, span.start); - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, ctr)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, ctr)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index a4e91410db5..d98ca556f47 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -9,7 +9,7 @@ namespace ts.codefix { const nodes = getNodes(sourceFile, context.span.start); if (!nodes) return undefined; const { extendsToken, heritageClauses } = nodes; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChanges(t, sourceFile, extendsToken, heritageClauses)); + const changes = textChanges.ChangeTracker.with(context, t => doChanges(t, sourceFile, extendsToken, heritageClauses)); return [{ description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index 8c337c16c4f..19610da0b15 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -7,7 +7,7 @@ namespace ts.codefix { getCodeActions(context) { const { sourceFile } = context; const token = getNode(sourceFile, context.span.start); - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, token)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, token)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), changes, fixId }]; }, fixIds: [fixId], diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index 0bfc6a6090d..f98f1eaea7c 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -32,7 +32,7 @@ namespace ts.codefix { createImportClause(namespace.name, /*namedBindings*/ undefined), node.moduleSpecifier ); - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); const changes = changeTracker.getChanges(); variations.push({ @@ -48,7 +48,7 @@ namespace ts.codefix { namespace.name, createExternalModuleReference(node.moduleSpecifier) ); - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); const changes = changeTracker.getChanges(); variations.push({ @@ -86,7 +86,7 @@ namespace ts.codefix { addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); } const propertyAccess = createPropertyAccess(expr, "default"); - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, expr, propertyAccess, {}); const changes = changeTracker.getChanges(); fixes.push({ diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 95159012f48..729f14e9ef9 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -12,7 +12,7 @@ namespace ts.codefix { const info = getInfo(sourceFile, context.span.start, context.program.getTypeChecker()); if (!info) return undefined; const { node, suggestion } = info; - const changes = textChanges.ChangeTracker.with(toTextChangesContext(context), t => doChange(t, sourceFile, node, suggestion)); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestion)); const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]); return [{ description, changes, fixId }]; }, diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 93c8ae80ac9..b7d948b3deb 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -13,13 +13,13 @@ namespace ts.codefix { const token = getToken(sourceFile, context.span.start); const result: CodeFixAction[] = []; - const deletion = textChanges.ChangeTracker.with(toTextChangesContext(context), t => tryDeleteDeclaration(t, sourceFile, token)); + const deletion = textChanges.ChangeTracker.with(context, t => tryDeleteDeclaration(t, sourceFile, token)); if (deletion.length) { const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), [token.getText()]); result.push({ description, changes: deletion, fixId: fixIdDelete }); } - const prefix = textChanges.ChangeTracker.with(toTextChangesContext(context), t => tryPrefixDeclaration(t, context.errorCode, sourceFile, token)); + const prefix = textChanges.ChangeTracker.with(context, t => tryPrefixDeclaration(t, context.errorCode, sourceFile, token)); if (prefix.length) { const description = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Prefix_0_with_an_underscore), [token.getText()]); result.push({ description, changes: prefix, fixId: fixIdPrefix }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 204030e3104..f91d260c81a 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -257,7 +257,7 @@ namespace ts.codefix { } } - function getCodeActionForNewImport(context: SymbolContext & RefactorOrCodeFixContext & { kind: ImportKind }, moduleSpecifier: string): ImportCodeAction { + function getCodeActionForNewImport(context: SymbolContext & textChanges.TextChangesContext & { kind: ImportKind }, moduleSpecifier: string): ImportCodeAction { const { kind, sourceFile, symbolName } = context; const lastImportDeclaration = findLast(sourceFile.statements, isAnyImportSyntax); @@ -275,7 +275,7 @@ namespace ts.codefix { createIdentifier(symbolName), createExternalModuleReference(quotedModuleSpecifier)); - const changes = ChangeTracker.with(toTextChangesContext(context), changeTracker => { + const changes = ChangeTracker.with(context, changeTracker => { if (lastImportDeclaration) { changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl); } @@ -669,33 +669,33 @@ namespace ts.codefix { return expression && isStringLiteral(expression) ? expression.text : undefined; } - function tryUpdateExistingImport(context: SymbolContext & RefactorOrCodeFixContext & { kind: ImportKind }, importClause: ImportClause | ImportEqualsDeclaration): FileTextChanges[] | undefined { + function tryUpdateExistingImport(context: SymbolContext & textChanges.TextChangesContext & { kind: ImportKind }, importClause: ImportClause | ImportEqualsDeclaration): FileTextChanges[] | undefined { const { symbolName, sourceFile, kind } = context; const { name } = importClause; const { namedBindings } = importClause.kind !== SyntaxKind.ImportEqualsDeclaration && importClause; switch (kind) { case ImportKind.Default: - return name ? undefined : ChangeTracker.with(toTextChangesContext(context), t => + return name ? undefined : ChangeTracker.with(context, t => t.replaceNode(sourceFile, importClause, createImportClause(createIdentifier(symbolName), namedBindings))); case ImportKind.Named: { const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(symbolName)); if (namedBindings && namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length !== 0) { // There are already named imports; add another. - return ChangeTracker.with(toTextChangesContext(context), t => t.insertNodeInListAfter( + return ChangeTracker.with(context, t => t.insertNodeInListAfter( sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier)); } if (!namedBindings || namedBindings.kind === SyntaxKind.NamedImports && namedBindings.elements.length === 0) { - return ChangeTracker.with(toTextChangesContext(context), t => + return ChangeTracker.with(context, t => t.replaceNode(sourceFile, importClause, createImportClause(name, createNamedImports([newImportSpecifier])))); } return undefined; } case ImportKind.Namespace: - return namedBindings ? undefined : ChangeTracker.with(toTextChangesContext(context), t => + return namedBindings ? undefined : ChangeTracker.with(context, t => t.replaceNode(sourceFile, importClause, createImportClause(name, createNamespaceImport(createIdentifier(symbolName))))); case ImportKind.Equals: @@ -706,7 +706,7 @@ namespace ts.codefix { } } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext & RefactorOrCodeFixContext, symbolToken: Identifier): ImportCodeAction { + function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext & textChanges.TextChangesContext, symbolToken: Identifier): ImportCodeAction { const { symbolName, sourceFile } = context; /** @@ -720,7 +720,7 @@ namespace ts.codefix { * become "ns.foo" */ // Prefix the node instead of it replacing it, because this may be used for import completions and we don't want the text changes to overlap with the identifier being completed. - const changes = ChangeTracker.with(toTextChangesContext(context), tracker => + const changes = ChangeTracker.with(context, tracker => tracker.changeIdentifierToPropertyAccess(sourceFile, namespacePrefix, symbolToken)); return createCodeAction(Diagnostics.Change_0_to_1, [symbolName, `${namespacePrefix}.${symbolName}`], changes, "CodeChange", /*moduleSpecifier*/ undefined); } diff --git a/src/services/refactorProvider.ts b/src/services/refactorProvider.ts index b0f5dbab324..6177535ee7d 100644 --- a/src/services/refactorProvider.ts +++ b/src/services/refactorProvider.ts @@ -14,24 +14,7 @@ namespace ts { getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined; } - export interface RefactorOrCodeFixContext { - host: LanguageServiceHost; - formatContext: ts.formatting.FormatContext; - } - - export function getNewLineFromContext(context: RefactorOrCodeFixContext) { - const formatSettings = context.formatContext.options; - return (formatSettings && formatSettings.newLineCharacter) || getNewLineOrDefaultFromHost(context.host); - } - - export function toTextChangesContext(context: RefactorOrCodeFixContext): textChanges.TextChangesContext { - return { - newLineCharacter: getNewLineFromContext(context), - formatContext: context.formatContext, - }; - } - - export interface RefactorContext extends RefactorOrCodeFixContext { + export interface RefactorContext extends textChanges.TextChangesContext { file: SourceFile; startPosition: number; endPosition?: number; diff --git a/src/services/refactors/annotateWithTypeFromJSDoc.ts b/src/services/refactors/annotateWithTypeFromJSDoc.ts index a39cdc20c42..d3bf59638b2 100644 --- a/src/services/refactors/annotateWithTypeFromJSDoc.ts +++ b/src/services/refactors/annotateWithTypeFromJSDoc.ts @@ -78,7 +78,7 @@ namespace ts.refactor.annotateWithTypeFromJSDoc { return Debug.fail(`!decl || !jsdocType || decl.type: !${decl} || !${jsdocType} || ${decl.type}`); } - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); const declarationWithType = addType(decl, transformJSDocType(jsdocType) as TypeNode); suppressLeadingAndTrailingTrivia(declarationWithType); changeTracker.replaceRange(sourceFile, { pos: decl.getStart(), end: decl.end }, declarationWithType); @@ -93,7 +93,7 @@ namespace ts.refactor.annotateWithTypeFromJSDoc { const sourceFile = context.file; const token = getTokenAtPosition(sourceFile, context.startPosition, /*includeJsDocComment*/ false); const decl = findAncestor(token, isFunctionLikeDeclaration); - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); const functionWithType = addTypesToFunctionLike(decl); suppressLeadingAndTrailingTrivia(functionWithType); changeTracker.replaceRange(sourceFile, { pos: decl.getStart(), end: decl.end }, functionWithType); diff --git a/src/services/refactors/convertFunctionToEs6Class.ts b/src/services/refactors/convertFunctionToEs6Class.ts index 93e39bc683c..cddf40ae017 100644 --- a/src/services/refactors/convertFunctionToEs6Class.ts +++ b/src/services/refactors/convertFunctionToEs6Class.ts @@ -59,7 +59,7 @@ namespace ts.refactor.convertFunctionToES6Class { } const ctorDeclaration = ctorSymbol.valueDeclaration; - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); let precedingNode: Node; let newClassDeclaration: ClassDeclaration; diff --git a/src/services/refactors/convertToEs6Module.ts b/src/services/refactors/convertToEs6Module.ts index 933797554dd..1046bf90aa6 100644 --- a/src/services/refactors/convertToEs6Module.ts +++ b/src/services/refactors/convertToEs6Module.ts @@ -74,7 +74,7 @@ namespace ts.refactor { Debug.assertEqual(actionName, _actionName); const { file, program } = context; Debug.assert(isSourceFileJavaScript(file)); - const edits = textChanges.ChangeTracker.with(toTextChangesContext(context), changes => { + const edits = textChanges.ChangeTracker.with(context, changes => { const moduleExportsChangedToDefault = convertFileToEs6Module(file, program.getTypeChecker(), changes, program.getCompilerOptions().target); if (moduleExportsChangedToDefault) { for (const importingFile of program.getSourceFiles()) { diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 9a9c30756a4..b3110a0ca36 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -806,7 +806,7 @@ namespace ts.refactor.extractSymbol { ); } - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); const minInsertionPos = (isReadonlyArray(range.range) ? last(range.range) : range.range).end; const nodeToInsertBefore = getNodeToInsertFunctionBefore(minInsertionPos, scope); if (nodeToInsertBefore) { @@ -1011,7 +1011,7 @@ namespace ts.refactor.extractSymbol { const initializer = transformConstantInitializer(node, substitutions); suppressLeadingAndTrailingTrivia(initializer); - const changeTracker = textChanges.ChangeTracker.fromContext(toTextChangesContext(context)); + const changeTracker = textChanges.ChangeTracker.fromContext(context); if (isClassLike(scope)) { Debug.assert(!isJS); // See CannotExtractToJSClass diff --git a/src/services/refactors/useDefaultImport.ts b/src/services/refactors/useDefaultImport.ts index e64eaf0bfcb..a103168f67b 100644 --- a/src/services/refactors/useDefaultImport.ts +++ b/src/services/refactors/useDefaultImport.ts @@ -54,7 +54,7 @@ namespace ts.refactor.installTypesForPackage { const newImportClause = createImportClause(name, /*namedBindings*/ undefined); const newImportStatement = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newImportClause, moduleSpecifier); return { - edits: textChanges.ChangeTracker.with(toTextChangesContext(context), t => t.replaceNode(file, importStatement, newImportStatement)), + edits: textChanges.ChangeTracker.with(context, t => t.replaceNode(file, importStatement, newImportStatement)), renameFilename: undefined, renameLocation: undefined, }; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 467ba6735ca..c176eef24f2 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -187,10 +187,15 @@ namespace ts.textChanges { } export interface TextChangesContext { - newLineCharacter: string; + host: LanguageServiceHost; formatContext: ts.formatting.FormatContext; } + export function getNewLineFromContext(context: TextChangesContext) { + const formatSettings = context.formatContext.options; + return (formatSettings && formatSettings.newLineCharacter) || getNewLineOrDefaultFromHost(context.host); + } + export class ChangeTracker { private readonly changes: Change[] = []; private readonly newLineCharacter: string; @@ -199,7 +204,7 @@ namespace ts.textChanges { private readonly nodesInsertedAtClassStarts = createMap<{ sourceFile: SourceFile, cls: ClassLikeDeclaration, members: ClassElement[] }>(); public static fromContext(context: TextChangesContext): ChangeTracker { - return new ChangeTracker(context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.formatContext); + return new ChangeTracker(getNewLineFromContext(context) === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.formatContext); } public static with(context: TextChangesContext, cb: (tracker: ChangeTracker) => void): FileTextChanges[] { From 50fd4762337d64afde54d79fa9e3ceafeff02615 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Wed, 17 Jan 2018 16:16:22 -0800 Subject: [PATCH 6/7] Make SymbolContext a subtype of TextChangesContext --- src/services/codefixes/importFixes.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index f91d260c81a..7e0aefef139 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -24,15 +24,13 @@ namespace ts.codefix { moduleSpecifier?: string; } - interface SymbolContext { + interface SymbolContext extends textChanges.TextChangesContext { sourceFile: SourceFile; symbolName: string; - formatContext: ts.formatting.FormatContext; } interface ImportCodeFixContext extends SymbolContext { symbolToken: Identifier | undefined; - host: LanguageServiceHost; program: Program; checker: TypeChecker; compilerOptions: CompilerOptions; @@ -257,7 +255,7 @@ namespace ts.codefix { } } - function getCodeActionForNewImport(context: SymbolContext & textChanges.TextChangesContext & { kind: ImportKind }, moduleSpecifier: string): ImportCodeAction { + function getCodeActionForNewImport(context: SymbolContext & { kind: ImportKind }, moduleSpecifier: string): ImportCodeAction { const { kind, sourceFile, symbolName } = context; const lastImportDeclaration = findLast(sourceFile.statements, isAnyImportSyntax); @@ -669,7 +667,7 @@ namespace ts.codefix { return expression && isStringLiteral(expression) ? expression.text : undefined; } - function tryUpdateExistingImport(context: SymbolContext & textChanges.TextChangesContext & { kind: ImportKind }, importClause: ImportClause | ImportEqualsDeclaration): FileTextChanges[] | undefined { + function tryUpdateExistingImport(context: SymbolContext & { kind: ImportKind }, importClause: ImportClause | ImportEqualsDeclaration): FileTextChanges[] | undefined { const { symbolName, sourceFile, kind } = context; const { name } = importClause; const { namedBindings } = importClause.kind !== SyntaxKind.ImportEqualsDeclaration && importClause; @@ -706,7 +704,7 @@ namespace ts.codefix { } } - function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext & textChanges.TextChangesContext, symbolToken: Identifier): ImportCodeAction { + function getCodeActionForUseExistingNamespaceImport(namespacePrefix: string, context: SymbolContext, symbolToken: Identifier): ImportCodeAction { const { symbolName, sourceFile } = context; /** From d97dec85749ce886fcafb9d93082525206b40ec1 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Thu, 18 Jan 2018 13:56:12 -0800 Subject: [PATCH 7/7] Fold newline logic into getNewLineOrDefaultFromHost --- src/services/codefixes/disableJsDiagnostics.ts | 4 ++-- src/services/textChanges.ts | 7 +------ src/services/utilities.ts | 6 ++++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index 231b3c1513f..a887878bac6 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -15,7 +15,7 @@ namespace ts.codefix { return undefined; } - const newLineCharacter = textChanges.getNewLineFromContext(context); + const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options); return [{ description: getLocaleSpecificMessage(Diagnostics.Ignore_this_error_message), @@ -38,7 +38,7 @@ namespace ts.codefix { fixIds: [fixId], // No point applying as a group, doing it once will fix all errors getAllCodeActions: context => codeFixAllWithTextChanges(context, errorCodes, (changes, err) => { if (err.start !== undefined) { - changes.push(getIgnoreCommentLocationForLocation(err.file!, err.start, textChanges.getNewLineFromContext(context))); + changes.push(getIgnoreCommentLocationForLocation(err.file!, err.start, getNewLineOrDefaultFromHost(context.host, context.formatContext.options))); } }), }); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index c176eef24f2..3674cd31b97 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -191,11 +191,6 @@ namespace ts.textChanges { formatContext: ts.formatting.FormatContext; } - export function getNewLineFromContext(context: TextChangesContext) { - const formatSettings = context.formatContext.options; - return (formatSettings && formatSettings.newLineCharacter) || getNewLineOrDefaultFromHost(context.host); - } - export class ChangeTracker { private readonly changes: Change[] = []; private readonly newLineCharacter: string; @@ -204,7 +199,7 @@ namespace ts.textChanges { private readonly nodesInsertedAtClassStarts = createMap<{ sourceFile: SourceFile, cls: ClassLikeDeclaration, members: ClassElement[] }>(); public static fromContext(context: TextChangesContext): ChangeTracker { - return new ChangeTracker(getNewLineFromContext(context) === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.formatContext); + return new ChangeTracker(getNewLineOrDefaultFromHost(context.host, context.formatContext.options) === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.formatContext); } public static with(context: TextChangesContext, cb: (tracker: ChangeTracker) => void): FileTextChanges[] { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 344a44a9f18..9bb35359523 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1259,8 +1259,10 @@ namespace ts { /** * The default is CRLF. */ - export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost) { - return host.getNewLine ? host.getNewLine() : carriageReturnLineFeed; + export function getNewLineOrDefaultFromHost(host: LanguageServiceHost | LanguageServiceShimHost, formatSettings?: FormatCodeSettings) { + return (formatSettings && formatSettings.newLineCharacter) || + (host.getNewLine && host.getNewLine()) || + carriageReturnLineFeed; } export function lineBreakPart() {