From efe2c56b5e0fdd0be06fd79323eb5506e845747f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 17 Nov 2016 15:41:07 -0800 Subject: [PATCH] Disable code fixes for now --- src/services/codefixes/importFixes.ts | 1182 ++++++++--------- .../codefixes/unusedIdentifierFixes.ts | 296 ++--- .../importNameCodeFixExistingImport0.ts | 10 - .../importNameCodeFixExistingImport1.ts | 11 - .../importNameCodeFixExistingImport10.ts | 21 - .../importNameCodeFixExistingImport11.ts | 20 - .../importNameCodeFixExistingImport12.ts | 12 - .../importNameCodeFixExistingImport2.ts | 16 - .../importNameCodeFixExistingImport3.ts | 18 - .../importNameCodeFixExistingImport4.ts | 14 - .../importNameCodeFixExistingImport5.ts | 12 - .../importNameCodeFixExistingImport6.ts | 13 - .../importNameCodeFixExistingImport7.ts | 10 - .../importNameCodeFixExistingImport8.ts | 12 - .../importNameCodeFixExistingImport9.ts | 17 - .../importNameCodeFixExistingImportEquals0.ts | 18 - .../importNameCodeFixNewImportAmbient0.ts | 15 - .../importNameCodeFixNewImportAmbient1.ts | 28 - .../importNameCodeFixNewImportAmbient2.ts | 21 - .../importNameCodeFixNewImportAmbient3.ts | 30 - .../importNameCodeFixNewImportBaseUrl0.ts | 19 - .../importNameCodeFixNewImportDefault0.ts | 12 - .../importNameCodeFixNewImportFile0.ts | 13 - .../importNameCodeFixNewImportFile1.ts | 18 - .../importNameCodeFixNewImportFile2.ts | 13 - .../importNameCodeFixNewImportNodeModules0.ts | 19 - .../importNameCodeFixNewImportNodeModules1.ts | 16 - .../importNameCodeFixNewImportNodeModules2.ts | 25 - .../importNameCodeFixNewImportNodeModules3.ts | 14 - .../importNameCodeFixNewImportPaths0.ts | 22 - .../importNameCodeFixNewImportPaths1.ts | 22 - .../importNameCodeFixNewImportRootDirs0.ts | 23 - .../importNameCodeFixNewImportTypeRoots0.ts | 22 - .../importNameCodeFixOptionalImport0.ts | 20 - .../importNameCodeFixOptionalImport1.ts | 20 - .../fourslash/unusedClassInNamespace1.ts | 10 - .../fourslash/unusedClassInNamespace2.ts | 15 - .../fourslash/unusedClassInNamespace3.ts | 25 - .../fourslash/unusedClassInNamespace4.ts | 27 - .../fourslash/unusedConstantInFunction1.ts | 10 - .../cases/fourslash/unusedEnumInFunction1.ts | 11 - .../cases/fourslash/unusedEnumInNamespace1.ts | 11 - .../fourslash/unusedFunctionInNamespace1.ts | 10 - .../fourslash/unusedFunctionInNamespace2.ts | 14 - .../fourslash/unusedFunctionInNamespace3.ts | 12 - .../fourslash/unusedFunctionInNamespace4.ts | 11 - .../fourslash/unusedFunctionInNamespace5.ts | 28 - tests/cases/fourslash/unusedImports10FS.ts | 16 - tests/cases/fourslash/unusedImports11FS.ts | 14 - tests/cases/fourslash/unusedImports12FS.ts | 13 - tests/cases/fourslash/unusedImports1FS.ts | 12 - tests/cases/fourslash/unusedImports2FS.ts | 19 - tests/cases/fourslash/unusedImports3FS.ts | 24 - tests/cases/fourslash/unusedImports4FS.ts | 24 - tests/cases/fourslash/unusedImports5FS.ts | 24 - tests/cases/fourslash/unusedImports6FS.ts | 20 - tests/cases/fourslash/unusedImports7FS.ts | 16 - tests/cases/fourslash/unusedImports8FS.ts | 24 - tests/cases/fourslash/unusedImports9FS.ts | 20 - .../fourslash/unusedInterfaceInNamespace1.ts | 11 - .../fourslash/unusedInterfaceInNamespace2.ts | 12 - .../fourslash/unusedLocalsInFunction1.ts | 10 - .../fourslash/unusedLocalsInFunction2.ts | 9 - .../fourslash/unusedLocalsInFunction3.ts | 10 - .../fourslash/unusedLocalsInFunction4.ts | 10 - .../fourslash/unusedLocalsInMethodFS1.ts | 12 - .../fourslash/unusedLocalsInMethodFS2.ts | 12 - .../fourslash/unusedLocalsinConstructorFS1.ts | 12 - .../fourslash/unusedLocalsinConstructorFS2.ts | 18 - tests/cases/fourslash/unusedMethodInClass1.ts | 11 - tests/cases/fourslash/unusedMethodInClass2.ts | 15 - tests/cases/fourslash/unusedMethodInClass3.ts | 11 - tests/cases/fourslash/unusedMethodInClass4.ts | 12 - tests/cases/fourslash/unusedMethodInClass5.ts | 8 - tests/cases/fourslash/unusedMethodInClass6.ts | 8 - .../fourslash/unusedNamespaceInNamespace.ts | 13 - .../unusedParameterInConstructor1.ts | 8 - .../unusedParameterInConstructor2.ts | 8 - .../unusedParameterInConstructor3.ts | 8 - .../unusedParameterInConstructor4.ts | 8 - .../fourslash/unusedParameterInFunction1.ts | 7 - .../fourslash/unusedParameterInFunction2.ts | 8 - .../fourslash/unusedParameterInFunction3.ts | 8 - .../fourslash/unusedParameterInFunction4.ts | 9 - .../fourslash/unusedParameterInLambda1.ts | 9 - .../fourslash/unusedTypeAliasInNamespace1.ts | 11 - .../fourslash/unusedTypeParametersInClass1.ts | 7 - .../fourslash/unusedTypeParametersInClass2.ts | 8 - .../fourslash/unusedTypeParametersInClass3.ts | 9 - .../unusedTypeParametersInFunction1.ts | 6 - .../unusedTypeParametersInFunction2.ts | 6 - .../unusedTypeParametersInFunction3.ts | 6 - .../unusedTypeParametersInInterface1.ts | 7 - .../unusedTypeParametersInLambda1.ts | 9 - .../unusedTypeParametersInLambda2.ts | 9 - .../unusedTypeParametersInLambda3.ts | 10 - .../unusedTypeParametersInLambda4.ts | 9 - .../unusedTypeParametersInMethod1.ts | 8 - .../unusedTypeParametersInMethod2.ts | 8 - .../unusedTypeParametersInMethods1.ts | 8 - .../cases/fourslash/unusedVariableInBlocks.ts | 15 - .../cases/fourslash/unusedVariableInClass1.ts | 8 - .../cases/fourslash/unusedVariableInClass2.ts | 9 - .../cases/fourslash/unusedVariableInClass3.ts | 8 - .../fourslash/unusedVariableInForLoop1FS.ts | 11 - .../fourslash/unusedVariableInForLoop2FS.ts | 10 - .../fourslash/unusedVariableInForLoop3FS.ts | 10 - .../fourslash/unusedVariableInForLoop4FS.ts | 10 - .../fourslash/unusedVariableInForLoop6FS.ts | 11 - .../fourslash/unusedVariableInForLoop7FS.ts | 12 - .../fourslash/unusedVariableInModule1.ts | 9 - .../fourslash/unusedVariableInModule2.ts | 10 - .../fourslash/unusedVariableInModule3.ts | 9 - .../fourslash/unusedVariableInModule4.ts | 10 - .../fourslash/unusedVariableInNamespace1.ts | 8 - .../fourslash/unusedVariableInNamespace2.ts | 12 - .../fourslash/unusedVariableInNamespace3.ts | 12 - 117 files changed, 739 insertions(+), 2287 deletions(-) delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport1.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport10.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport11.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport12.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport2.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport3.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport4.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport5.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport6.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport7.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport8.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImport9.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixExistingImportEquals0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportAmbient0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportAmbient1.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportAmbient2.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportAmbient3.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportDefault0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportFile0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportFile1.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportFile2.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportNodeModules0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportNodeModules1.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportNodeModules2.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportNodeModules3.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportPaths0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportPaths1.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportRootDirs0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixNewImportTypeRoots0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixOptionalImport0.ts delete mode 100644 tests/cases/fourslash/importNameCodeFixOptionalImport1.ts delete mode 100644 tests/cases/fourslash/unusedClassInNamespace1.ts delete mode 100644 tests/cases/fourslash/unusedClassInNamespace2.ts delete mode 100644 tests/cases/fourslash/unusedClassInNamespace3.ts delete mode 100644 tests/cases/fourslash/unusedClassInNamespace4.ts delete mode 100644 tests/cases/fourslash/unusedConstantInFunction1.ts delete mode 100644 tests/cases/fourslash/unusedEnumInFunction1.ts delete mode 100644 tests/cases/fourslash/unusedEnumInNamespace1.ts delete mode 100644 tests/cases/fourslash/unusedFunctionInNamespace1.ts delete mode 100644 tests/cases/fourslash/unusedFunctionInNamespace2.ts delete mode 100644 tests/cases/fourslash/unusedFunctionInNamespace3.ts delete mode 100644 tests/cases/fourslash/unusedFunctionInNamespace4.ts delete mode 100644 tests/cases/fourslash/unusedFunctionInNamespace5.ts delete mode 100644 tests/cases/fourslash/unusedImports10FS.ts delete mode 100644 tests/cases/fourslash/unusedImports11FS.ts delete mode 100644 tests/cases/fourslash/unusedImports12FS.ts delete mode 100644 tests/cases/fourslash/unusedImports1FS.ts delete mode 100644 tests/cases/fourslash/unusedImports2FS.ts delete mode 100644 tests/cases/fourslash/unusedImports3FS.ts delete mode 100644 tests/cases/fourslash/unusedImports4FS.ts delete mode 100644 tests/cases/fourslash/unusedImports5FS.ts delete mode 100644 tests/cases/fourslash/unusedImports6FS.ts delete mode 100644 tests/cases/fourslash/unusedImports7FS.ts delete mode 100644 tests/cases/fourslash/unusedImports8FS.ts delete mode 100644 tests/cases/fourslash/unusedImports9FS.ts delete mode 100644 tests/cases/fourslash/unusedInterfaceInNamespace1.ts delete mode 100644 tests/cases/fourslash/unusedInterfaceInNamespace2.ts delete mode 100644 tests/cases/fourslash/unusedLocalsInFunction1.ts delete mode 100644 tests/cases/fourslash/unusedLocalsInFunction2.ts delete mode 100644 tests/cases/fourslash/unusedLocalsInFunction3.ts delete mode 100644 tests/cases/fourslash/unusedLocalsInFunction4.ts delete mode 100644 tests/cases/fourslash/unusedLocalsInMethodFS1.ts delete mode 100644 tests/cases/fourslash/unusedLocalsInMethodFS2.ts delete mode 100644 tests/cases/fourslash/unusedLocalsinConstructorFS1.ts delete mode 100644 tests/cases/fourslash/unusedLocalsinConstructorFS2.ts delete mode 100644 tests/cases/fourslash/unusedMethodInClass1.ts delete mode 100644 tests/cases/fourslash/unusedMethodInClass2.ts delete mode 100644 tests/cases/fourslash/unusedMethodInClass3.ts delete mode 100644 tests/cases/fourslash/unusedMethodInClass4.ts delete mode 100644 tests/cases/fourslash/unusedMethodInClass5.ts delete mode 100644 tests/cases/fourslash/unusedMethodInClass6.ts delete mode 100644 tests/cases/fourslash/unusedNamespaceInNamespace.ts delete mode 100644 tests/cases/fourslash/unusedParameterInConstructor1.ts delete mode 100644 tests/cases/fourslash/unusedParameterInConstructor2.ts delete mode 100644 tests/cases/fourslash/unusedParameterInConstructor3.ts delete mode 100644 tests/cases/fourslash/unusedParameterInConstructor4.ts delete mode 100644 tests/cases/fourslash/unusedParameterInFunction1.ts delete mode 100644 tests/cases/fourslash/unusedParameterInFunction2.ts delete mode 100644 tests/cases/fourslash/unusedParameterInFunction3.ts delete mode 100644 tests/cases/fourslash/unusedParameterInFunction4.ts delete mode 100644 tests/cases/fourslash/unusedParameterInLambda1.ts delete mode 100644 tests/cases/fourslash/unusedTypeAliasInNamespace1.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInClass1.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInClass2.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInClass3.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInFunction1.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInFunction2.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInFunction3.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInInterface1.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda1.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda2.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda3.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda4.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInMethod1.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInMethod2.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInMethods1.ts delete mode 100644 tests/cases/fourslash/unusedVariableInBlocks.ts delete mode 100644 tests/cases/fourslash/unusedVariableInClass1.ts delete mode 100644 tests/cases/fourslash/unusedVariableInClass2.ts delete mode 100644 tests/cases/fourslash/unusedVariableInClass3.ts delete mode 100644 tests/cases/fourslash/unusedVariableInForLoop1FS.ts delete mode 100644 tests/cases/fourslash/unusedVariableInForLoop2FS.ts delete mode 100644 tests/cases/fourslash/unusedVariableInForLoop3FS.ts delete mode 100644 tests/cases/fourslash/unusedVariableInForLoop4FS.ts delete mode 100644 tests/cases/fourslash/unusedVariableInForLoop6FS.ts delete mode 100644 tests/cases/fourslash/unusedVariableInForLoop7FS.ts delete mode 100644 tests/cases/fourslash/unusedVariableInModule1.ts delete mode 100644 tests/cases/fourslash/unusedVariableInModule2.ts delete mode 100644 tests/cases/fourslash/unusedVariableInModule3.ts delete mode 100644 tests/cases/fourslash/unusedVariableInModule4.ts delete mode 100644 tests/cases/fourslash/unusedVariableInNamespace1.ts delete mode 100644 tests/cases/fourslash/unusedVariableInNamespace2.ts delete mode 100644 tests/cases/fourslash/unusedVariableInNamespace3.ts diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 4adda19689d..05f3d661c04 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1,591 +1,591 @@ -/* @internal */ -namespace ts.codefix { - - type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; - interface ImportCodeAction extends CodeAction { - kind: ImportCodeActionKind, - moduleSpecifier?: string - } - - enum ModuleSpecifierComparison { - Better, - Equal, - Worse - } - - class ImportCodeActionMap { - private symbolIdToActionMap = createMap(); - - addAction(symbolId: number, newAction: ImportCodeAction) { - if (!newAction) { - return; - } - - if (!this.symbolIdToActionMap[symbolId]) { - this.symbolIdToActionMap[symbolId] = [newAction]; - return; - } - - if (newAction.kind === "CodeChange") { - this.symbolIdToActionMap[symbolId].push(newAction); - return; - } - - const updatedNewImports: ImportCodeAction[] = []; - for (const existingAction of this.symbolIdToActionMap[symbolId]) { - if (existingAction.kind === "CodeChange") { - // only import actions should compare - updatedNewImports.push(existingAction); - continue; - } - - switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) { - case ModuleSpecifierComparison.Better: - // the new one is not worth considering if it is a new improt. - // However if it is instead a insertion into existing import, the user might want to use - // the module specifier even it is worse by our standards. So keep it. - if (newAction.kind === "NewImport") { - return; - } - case ModuleSpecifierComparison.Equal: - // the current one is safe. But it is still possible that the new one is worse - // than another existing one. For example, you may have new imports from "./foo/bar" - // and "bar", when the new one is "bar/bar2" and the current one is "./foo/bar". The new - // one and the current one are not comparable (one relative path and one absolute path), - // but the new one is worse than the other one, so should not add to the list. - updatedNewImports.push(existingAction); - break; - case ModuleSpecifierComparison.Worse: - // the existing one is worse, remove from the list. - continue; - } - } - // if we reach here, it means the new one is better or equal to all of the existing ones. - updatedNewImports.push(newAction); - this.symbolIdToActionMap[symbolId] = updatedNewImports; - } - - addActions(symbolId: number, newActions: ImportCodeAction[]) { - for (const newAction of newActions) { - this.addAction(symbolId, newAction); - } - } - - getAllActions() { - let result: ImportCodeAction[] = []; - for (const symbolId in this.symbolIdToActionMap) { - result = concatenate(result, this.symbolIdToActionMap[symbolId]); - } - return result; - } - - private compareModuleSpecifiers(moduleSpecifier1: string, moduleSpecifier2: string): ModuleSpecifierComparison { - if (moduleSpecifier1 === moduleSpecifier2) { - return ModuleSpecifierComparison.Equal; - } - - // if moduleSpecifier1 (ms1) is a substring of ms2, then it is better - if (moduleSpecifier2.indexOf(moduleSpecifier1) === 0) { - return ModuleSpecifierComparison.Better; - } - - if (moduleSpecifier1.indexOf(moduleSpecifier2) === 0) { - return ModuleSpecifierComparison.Worse; - } - - // if both are relative paths, and ms1 has fewer levels, then it is better - if (isExternalModuleNameRelative(moduleSpecifier1) && isExternalModuleNameRelative(moduleSpecifier2)) { - const regex = new RegExp(directorySeparator, "g"); - const moduleSpecifier1LevelCount = (moduleSpecifier1.match(regex) || []).length; - const moduleSpecifier2LevelCount = (moduleSpecifier2.match(regex) || []).length; - - return moduleSpecifier1LevelCount < moduleSpecifier2LevelCount - ? ModuleSpecifierComparison.Better - : moduleSpecifier1LevelCount === moduleSpecifier2LevelCount - ? ModuleSpecifierComparison.Equal - : ModuleSpecifierComparison.Worse; - } - - // the equal cases include when the two specifiers are not comparable. - return ModuleSpecifierComparison.Equal; - } - } - - registerCodeFix({ - errorCodes: [Diagnostics.Cannot_find_name_0.code], - getCodeActions: (context: CodeFixContext) => { - const sourceFile = context.sourceFile; - const checker = context.program.getTypeChecker(); - const allSourceFiles = context.program.getSourceFiles(); - const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false; - - const token = getTokenAtPosition(sourceFile, context.span.start); - const name = token.getText(); - const symbolIdActionMap = new ImportCodeActionMap(); - - // this is a module id -> module import declaration map - const cachedImportDeclarations = createMap<(ImportDeclaration | ImportEqualsDeclaration)[]>(); - let cachedNewImportInsertPosition: number; - - const allPotentialModules = checker.getAmbientModules(); - for (const otherSourceFile of allSourceFiles) { - if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); - } - } - - const currentTokenMeaning = getMeaningFromLocation(token); - for (const moduleSymbol of allPotentialModules) { - context.cancellationToken.throwIfCancellationRequested(); - - // check the default export - const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); - if (defaultExport) { - const localSymbol = getLocalSymbolForExportDefault(defaultExport); - if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { - // check if this symbol is already used - const symbolId = getUniqueSymbolId(localSymbol); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefaultExport*/ true)); - } - } - - // check exports with the same name - const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol)); - } - } - - return symbolIdActionMap.getAllActions(); - - function getImportDeclarations(moduleSymbol: Symbol) { - const moduleSymbolId = getUniqueSymbolId(moduleSymbol); - - if (cachedImportDeclarations[moduleSymbolId]) { - return cachedImportDeclarations[moduleSymbolId]; - } - - const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; - for (const importModuleSpecifier of sourceFile.imports) { - const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } - cachedImportDeclarations[moduleSymbolId] = existingDeclarations; - return existingDeclarations; - - function getImportDeclaration(moduleSpecifier: LiteralExpression) { - let node: Node = moduleSpecifier; - while (node) { - if (node.kind === SyntaxKind.ImportDeclaration) { - return node; - } - if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - return node; - } - node = node.parent; - } - return undefined; - } - } - - function getUniqueSymbolId(symbol: Symbol) { - if (symbol.flags & SymbolFlags.Alias) { - return getSymbolId(checker.getAliasedSymbol(symbol)); - } - return getSymbolId(symbol); - } - - function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) { - const declarations = symbol.getDeclarations(); - return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false; - } - - function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean): ImportCodeAction[] { - const existingDeclarations = getImportDeclarations(moduleSymbol); - if (existingDeclarations.length > 0) { - // With an existing import statement, there are more than one actions the user can do. - return getCodeActionsForExistingImport(existingDeclarations); - } - else { - return [getCodeActionForNewImport()]; - } - - - - function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] { - const actions: ImportCodeAction[] = []; - - // It is possible that multiple import statements with the same specifier exist in the file. - // e.g. - // - // import * as ns from "foo"; - // import { member1, member2 } from "foo"; - // - // member3/**/ <-- cusor here - // - // in this case we should provie 2 actions: - // 1. change "member3" to "ns.member3" - // 2. add "member3" to the second import statement's import list - // and it is up to the user to decide which one fits best. - let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration; - let namedImportDeclaration: ImportDeclaration; - let existingModuleSpecifier: string; - for (const declaration of declarations) { - if (declaration.kind === SyntaxKind.ImportDeclaration) { - const namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { - // case: - // import * as ns from "foo" - namespaceImportDeclaration = declaration; - } - else { - // cases: - // import default from "foo" - // import { bar } from "foo" or combination with the first one - // import "foo" - namedImportDeclaration = declaration; - } - existingModuleSpecifier = declaration.moduleSpecifier.getText(); - } - else { - // case: - // import foo = require("foo") - namespaceImportDeclaration = declaration; - existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration); - } - } - - if (namespaceImportDeclaration) { - actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); - } - - if (namedImportDeclaration && namedImportDeclaration.importClause && - (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { - /** - * If the existing import declaration already has a named import list, just - * insert the identifier into that list. - */ - const textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); - const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); - actions.push(createCodeAction( - Diagnostics.Add_0_to_existing_import_declaration_from_1, - [name, moduleSpecifierWithoutQuotes], - textChange.newText, - textChange.span, - sourceFile.fileName, - "InsertingIntoExistingImport", - moduleSpecifierWithoutQuotes - )); - } - else { - // we need to create a new import statement, but the existing module specifier can be reused. - actions.push(getCodeActionForNewImport(existingModuleSpecifier)); - } - return actions; - - function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) { - return declaration.moduleReference.expression.getText(); - } - return declaration.moduleReference.getText(); - } - - function getTextChangeForImportClause(importClause: ImportClause): TextChange { - const newImportText = isDefault ? `default as ${name}` : name; - const importList = importClause.namedBindings; - // case 1: - // original text: import default from "module" - // change to: import default, { name } from "module" - if (!importList && importClause.name) { - const start = importClause.name.getEnd(); - return { - newText: `, { ${newImportText} }`, - span: { start, length: 0 } - }; - } - - // case 2: - // original text: import {} from "module" - // change to: import { name } from "module" - if (importList.elements.length === 0) { - const start = importList.getStart(); - return { - newText: `{ ${newImportText} }`, - span: { start, length: importList.getEnd() - start } - }; - } - - // case 3: - // original text: import { foo, bar } from "module" - // change to: import { foo, bar, name } from "module" - const insertPoint = importList.elements[importList.elements.length - 1].getEnd(); - /** - * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element - * import { - * foo - * } from "./module"; - */ - const startLine = getLineOfLocalPosition(sourceFile, importList.getStart()); - const endLine = getLineOfLocalPosition(sourceFile, importList.getEnd()); - const oneImportPerLine = endLine - startLine > importList.elements.length; - - return { - newText: `,${oneImportPerLine ? context.newLineCharacter : " "}${newImportText}`, - span: { start: insertPoint, length: 0 } - }; - } - - function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { - let namespacePrefix: string; - if (declaration.kind === SyntaxKind.ImportDeclaration) { - namespacePrefix = (declaration.importClause.namedBindings).name.getText(); - } - else { - namespacePrefix = declaration.name.getText(); - } - namespacePrefix = stripQuotes(namespacePrefix); - - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - return createCodeAction( - Diagnostics.Change_0_to_1, - [name, `${namespacePrefix}.${name}`], - `${namespacePrefix}.`, - { start: token.getStart(), length: 0 }, - sourceFile.fileName, - "CodeChange" - ); - } - } - - function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { - if (!cachedNewImportInsertPosition) { - // insert after any existing imports - let lastModuleSpecifierEnd = -1; - for (const moduleSpecifier of sourceFile.imports) { - const end = moduleSpecifier.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; - } - } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); - } - - const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); - const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - const importStatementText = isDefault - ? `import ${name} from "${moduleSpecifierWithoutQuotes}"` - : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; - - // if this file doesn't have any import statements, insert an import statement and then insert a new line - // between the only import statement and user code. Otherwise just insert the statement because chances - // are there are already a new line seperating code and import statements. - const newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? `${importStatementText};${context.newLineCharacter}${context.newLineCharacter}` - : `${context.newLineCharacter}${importStatementText};`; - - return createCodeAction( - Diagnostics.Import_0_from_1, - [name, `"${moduleSpecifierWithoutQuotes}"`], - newText, - { start: cachedNewImportInsertPosition, length: 0 }, - sourceFile.fileName, - "NewImport", - moduleSpecifierWithoutQuotes - ); - - function getModuleSpecifierForNewImport() { - const fileName = sourceFile.path; - const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; - const sourceDirectory = getDirectoryPath(fileName); - const options = context.program.getCompilerOptions(); - - return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || - tryGetModuleNameFromTypeRoots() || - tryGetModuleNameAsNodeModule() || - removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); - - function tryGetModuleNameFromAmbientModule(): string { - if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) { - return moduleSymbol.name; - } - } - - function tryGetModuleNameFromBaseUrl() { - if (!options.baseUrl) { - return undefined; - } - - const normalizedBaseUrl = toPath(options.baseUrl, getDirectoryPath(options.baseUrl), getCanonicalFileName); - let relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); - if (!relativeName) { - return undefined; - } - - relativeName = removeExtensionAndIndexPostFix(relativeName); - - if (options.paths) { - for (const key in options.paths) { - for (const pattern of options.paths[key]) { - const indexOfStar = pattern.indexOf("*"); - if (indexOfStar === 0 && pattern.length === 1) { - continue; - } - else if (indexOfStar !== -1) { - const prefix = pattern.substr(0, indexOfStar); - const suffix = pattern.substr(indexOfStar + 1); - if (relativeName.length >= prefix.length + suffix.length && - startsWith(relativeName, prefix) && - endsWith(relativeName, suffix)) { - const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length); - return key.replace("\*", matchedStar); - } - } - else if (pattern === relativeName) { - return key; - } - } - } - } - - return relativeName; - } - - function tryGetModuleNameFromRootDirs() { - if (options.rootDirs) { - const normalizedRootDirs = map(options.rootDirs, rootDir => toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName)); - const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); - const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); - if (normalizedTargetPath !== undefined) { - const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; - return removeFileExtension(relativePath); - } - } - return undefined; - } - - function tryGetModuleNameFromTypeRoots() { - const typeRoots = getEffectiveTypeRoots(options, context.host); - if (typeRoots) { - const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName)); - for (const typeRoot of normalizedTypeRoots) { - if (startsWith(moduleFileName, typeRoot)) { - let relativeFileName = moduleFileName.substring(typeRoot.length + 1); - return removeExtensionAndIndexPostFix(relativeFileName); - } - } - } - } - - function tryGetModuleNameAsNodeModule() { - if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { - // nothing to do here - return undefined; - } - - const indexOfNodeModules = moduleFileName.indexOf("node_modules"); - if (indexOfNodeModules < 0) { - return undefined; - } - - let relativeFileName: string; - if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) { - // if node_modules folder is in this folder or any of its parent folder, no need to keep it. - relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */); - } - else { - relativeFileName = getRelativePath(moduleFileName, sourceDirectory); - } - - relativeFileName = removeFileExtension(relativeFileName); - if (endsWith(relativeFileName, "/index")) { - relativeFileName = getDirectoryPath(relativeFileName); - } - else { - try { - const moduleDirectory = getDirectoryPath(moduleFileName); - const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json"))); - if (packageJsonContent) { - const mainFile = packageJsonContent.main || packageJsonContent.typings; - if (mainFile) { - const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName); - if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) { - relativeFileName = getDirectoryPath(relativeFileName); - } - } - } - } - catch (e) { } - } - - return relativeFileName; - } - } - - function getPathRelativeToRootDirs(path: Path, rootDirs: Path[]) { - for (const rootDir of rootDirs) { - const relativeName = tryRemoveParentDirectoryName(path, rootDir); - if (relativeName !== undefined) { - return relativeName; - } - } - return undefined; - } - - function removeExtensionAndIndexPostFix(fileName: string) { - fileName = removeFileExtension(fileName); - if (endsWith(fileName, "/index")) { - fileName = fileName.substr(0, fileName.length - 6/* "/index".length */); - } - return fileName; - } - - function getRelativePath(path: string, directoryPath: string) { - const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); - return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; - } - - function tryRemoveParentDirectoryName(path: Path, parentDirectory: Path) { - const index = path.indexOf(parentDirectory); - if (index === 0) { - return endsWith(parentDirectory, directorySeparator) - ? path.substring(parentDirectory.length) - : path.substring(parentDirectory.length + 1); - } - return undefined; - } - } - - } - - function createCodeAction( - description: DiagnosticMessage, - diagnosticArgs: string[], - newText: string, - span: TextSpan, - fileName: string, - kind: ImportCodeActionKind, - moduleSpecifier?: string): ImportCodeAction { - return { - description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName, textChanges: [{ newText, span }] }], - kind, - moduleSpecifier - }; - } - } - }); -} +// /* @internal */ +// namespace ts.codefix { + +// type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; +// interface ImportCodeAction extends CodeAction { +// kind: ImportCodeActionKind, +// moduleSpecifier?: string +// } + +// enum ModuleSpecifierComparison { +// Better, +// Equal, +// Worse +// } + +// class ImportCodeActionMap { +// private symbolIdToActionMap = createMap(); + +// addAction(symbolId: number, newAction: ImportCodeAction) { +// if (!newAction) { +// return; +// } + +// if (!this.symbolIdToActionMap[symbolId]) { +// this.symbolIdToActionMap[symbolId] = [newAction]; +// return; +// } + +// if (newAction.kind === "CodeChange") { +// this.symbolIdToActionMap[symbolId].push(newAction); +// return; +// } + +// const updatedNewImports: ImportCodeAction[] = []; +// for (const existingAction of this.symbolIdToActionMap[symbolId]) { +// if (existingAction.kind === "CodeChange") { +// // only import actions should compare +// updatedNewImports.push(existingAction); +// continue; +// } + +// switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) { +// case ModuleSpecifierComparison.Better: +// // the new one is not worth considering if it is a new improt. +// // However if it is instead a insertion into existing import, the user might want to use +// // the module specifier even it is worse by our standards. So keep it. +// if (newAction.kind === "NewImport") { +// return; +// } +// case ModuleSpecifierComparison.Equal: +// // the current one is safe. But it is still possible that the new one is worse +// // than another existing one. For example, you may have new imports from "./foo/bar" +// // and "bar", when the new one is "bar/bar2" and the current one is "./foo/bar". The new +// // one and the current one are not comparable (one relative path and one absolute path), +// // but the new one is worse than the other one, so should not add to the list. +// updatedNewImports.push(existingAction); +// break; +// case ModuleSpecifierComparison.Worse: +// // the existing one is worse, remove from the list. +// continue; +// } +// } +// // if we reach here, it means the new one is better or equal to all of the existing ones. +// updatedNewImports.push(newAction); +// this.symbolIdToActionMap[symbolId] = updatedNewImports; +// } + +// addActions(symbolId: number, newActions: ImportCodeAction[]) { +// for (const newAction of newActions) { +// this.addAction(symbolId, newAction); +// } +// } + +// getAllActions() { +// let result: ImportCodeAction[] = []; +// for (const symbolId in this.symbolIdToActionMap) { +// result = concatenate(result, this.symbolIdToActionMap[symbolId]); +// } +// return result; +// } + +// private compareModuleSpecifiers(moduleSpecifier1: string, moduleSpecifier2: string): ModuleSpecifierComparison { +// if (moduleSpecifier1 === moduleSpecifier2) { +// return ModuleSpecifierComparison.Equal; +// } + +// // if moduleSpecifier1 (ms1) is a substring of ms2, then it is better +// if (moduleSpecifier2.indexOf(moduleSpecifier1) === 0) { +// return ModuleSpecifierComparison.Better; +// } + +// if (moduleSpecifier1.indexOf(moduleSpecifier2) === 0) { +// return ModuleSpecifierComparison.Worse; +// } + +// // if both are relative paths, and ms1 has fewer levels, then it is better +// if (isExternalModuleNameRelative(moduleSpecifier1) && isExternalModuleNameRelative(moduleSpecifier2)) { +// const regex = new RegExp(directorySeparator, "g"); +// const moduleSpecifier1LevelCount = (moduleSpecifier1.match(regex) || []).length; +// const moduleSpecifier2LevelCount = (moduleSpecifier2.match(regex) || []).length; + +// return moduleSpecifier1LevelCount < moduleSpecifier2LevelCount +// ? ModuleSpecifierComparison.Better +// : moduleSpecifier1LevelCount === moduleSpecifier2LevelCount +// ? ModuleSpecifierComparison.Equal +// : ModuleSpecifierComparison.Worse; +// } + +// // the equal cases include when the two specifiers are not comparable. +// return ModuleSpecifierComparison.Equal; +// } +// } + +// registerCodeFix({ +// errorCodes: [Diagnostics.Cannot_find_name_0.code], +// getCodeActions: (context: CodeFixContext) => { +// const sourceFile = context.sourceFile; +// const checker = context.program.getTypeChecker(); +// const allSourceFiles = context.program.getSourceFiles(); +// const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false; + +// const token = getTokenAtPosition(sourceFile, context.span.start); +// const name = token.getText(); +// const symbolIdActionMap = new ImportCodeActionMap(); + +// // this is a module id -> module import declaration map +// const cachedImportDeclarations = createMap<(ImportDeclaration | ImportEqualsDeclaration)[]>(); +// let cachedNewImportInsertPosition: number; + +// const allPotentialModules = checker.getAmbientModules(); +// for (const otherSourceFile of allSourceFiles) { +// if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { +// allPotentialModules.push(otherSourceFile.symbol); +// } +// } + +// const currentTokenMeaning = getMeaningFromLocation(token); +// for (const moduleSymbol of allPotentialModules) { +// context.cancellationToken.throwIfCancellationRequested(); + +// // check the default export +// const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); +// if (defaultExport) { +// const localSymbol = getLocalSymbolForExportDefault(defaultExport); +// if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { +// // check if this symbol is already used +// const symbolId = getUniqueSymbolId(localSymbol); +// symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefaultExport*/ true)); +// } +// } + +// // check exports with the same name +// const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol); +// if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { +// const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName); +// symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol)); +// } +// } + +// return symbolIdActionMap.getAllActions(); + +// function getImportDeclarations(moduleSymbol: Symbol) { +// const moduleSymbolId = getUniqueSymbolId(moduleSymbol); + +// if (cachedImportDeclarations[moduleSymbolId]) { +// return cachedImportDeclarations[moduleSymbolId]; +// } + +// const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; +// for (const importModuleSpecifier of sourceFile.imports) { +// const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); +// if (importSymbol === moduleSymbol) { +// existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); +// } +// } +// cachedImportDeclarations[moduleSymbolId] = existingDeclarations; +// return existingDeclarations; + +// function getImportDeclaration(moduleSpecifier: LiteralExpression) { +// let node: Node = moduleSpecifier; +// while (node) { +// if (node.kind === SyntaxKind.ImportDeclaration) { +// return node; +// } +// if (node.kind === SyntaxKind.ImportEqualsDeclaration) { +// return node; +// } +// node = node.parent; +// } +// return undefined; +// } +// } + +// function getUniqueSymbolId(symbol: Symbol) { +// if (symbol.flags & SymbolFlags.Alias) { +// return getSymbolId(checker.getAliasedSymbol(symbol)); +// } +// return getSymbolId(symbol); +// } + +// function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) { +// const declarations = symbol.getDeclarations(); +// return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false; +// } + +// function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean): ImportCodeAction[] { +// const existingDeclarations = getImportDeclarations(moduleSymbol); +// if (existingDeclarations.length > 0) { +// // With an existing import statement, there are more than one actions the user can do. +// return getCodeActionsForExistingImport(existingDeclarations); +// } +// else { +// return [getCodeActionForNewImport()]; +// } + + + +// function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] { +// const actions: ImportCodeAction[] = []; + +// // It is possible that multiple import statements with the same specifier exist in the file. +// // e.g. +// // +// // import * as ns from "foo"; +// // import { member1, member2 } from "foo"; +// // +// // member3/**/ <-- cusor here +// // +// // in this case we should provie 2 actions: +// // 1. change "member3" to "ns.member3" +// // 2. add "member3" to the second import statement's import list +// // and it is up to the user to decide which one fits best. +// let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration; +// let namedImportDeclaration: ImportDeclaration; +// let existingModuleSpecifier: string; +// for (const declaration of declarations) { +// if (declaration.kind === SyntaxKind.ImportDeclaration) { +// const namedBindings = declaration.importClause && declaration.importClause.namedBindings; +// if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { +// // case: +// // import * as ns from "foo" +// namespaceImportDeclaration = declaration; +// } +// else { +// // cases: +// // import default from "foo" +// // import { bar } from "foo" or combination with the first one +// // import "foo" +// namedImportDeclaration = declaration; +// } +// existingModuleSpecifier = declaration.moduleSpecifier.getText(); +// } +// else { +// // case: +// // import foo = require("foo") +// namespaceImportDeclaration = declaration; +// existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration); +// } +// } + +// if (namespaceImportDeclaration) { +// actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); +// } + +// if (namedImportDeclaration && namedImportDeclaration.importClause && +// (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { +// /** +// * If the existing import declaration already has a named import list, just +// * insert the identifier into that list. +// */ +// const textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); +// const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); +// actions.push(createCodeAction( +// Diagnostics.Add_0_to_existing_import_declaration_from_1, +// [name, moduleSpecifierWithoutQuotes], +// textChange.newText, +// textChange.span, +// sourceFile.fileName, +// "InsertingIntoExistingImport", +// moduleSpecifierWithoutQuotes +// )); +// } +// else { +// // we need to create a new import statement, but the existing module specifier can be reused. +// actions.push(getCodeActionForNewImport(existingModuleSpecifier)); +// } +// return actions; + +// function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) { +// if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) { +// return declaration.moduleReference.expression.getText(); +// } +// return declaration.moduleReference.getText(); +// } + +// function getTextChangeForImportClause(importClause: ImportClause): TextChange { +// const newImportText = isDefault ? `default as ${name}` : name; +// const importList = importClause.namedBindings; +// // case 1: +// // original text: import default from "module" +// // change to: import default, { name } from "module" +// if (!importList && importClause.name) { +// const start = importClause.name.getEnd(); +// return { +// newText: `, { ${newImportText} }`, +// span: { start, length: 0 } +// }; +// } + +// // case 2: +// // original text: import {} from "module" +// // change to: import { name } from "module" +// if (importList.elements.length === 0) { +// const start = importList.getStart(); +// return { +// newText: `{ ${newImportText} }`, +// span: { start, length: importList.getEnd() - start } +// }; +// } + +// // case 3: +// // original text: import { foo, bar } from "module" +// // change to: import { foo, bar, name } from "module" +// const insertPoint = importList.elements[importList.elements.length - 1].getEnd(); +// /** +// * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element +// * import { +// * foo +// * } from "./module"; +// */ +// const startLine = getLineOfLocalPosition(sourceFile, importList.getStart()); +// const endLine = getLineOfLocalPosition(sourceFile, importList.getEnd()); +// const oneImportPerLine = endLine - startLine > importList.elements.length; + +// return { +// newText: `,${oneImportPerLine ? context.newLineCharacter : " "}${newImportText}`, +// span: { start: insertPoint, length: 0 } +// }; +// } + +// function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { +// let namespacePrefix: string; +// if (declaration.kind === SyntaxKind.ImportDeclaration) { +// namespacePrefix = (declaration.importClause.namedBindings).name.getText(); +// } +// else { +// namespacePrefix = declaration.name.getText(); +// } +// namespacePrefix = stripQuotes(namespacePrefix); + +// /** +// * Cases: +// * import * as ns from "mod" +// * import default, * as ns from "mod" +// * import ns = require("mod") +// * +// * Because there is no import list, we alter the reference to include the +// * namespace instead of altering the import declaration. For example, "foo" would +// * become "ns.foo" +// */ +// return createCodeAction( +// Diagnostics.Change_0_to_1, +// [name, `${namespacePrefix}.${name}`], +// `${namespacePrefix}.`, +// { start: token.getStart(), length: 0 }, +// sourceFile.fileName, +// "CodeChange" +// ); +// } +// } + +// function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { +// if (!cachedNewImportInsertPosition) { +// // insert after any existing imports +// let lastModuleSpecifierEnd = -1; +// for (const moduleSpecifier of sourceFile.imports) { +// const end = moduleSpecifier.getEnd(); +// if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { +// lastModuleSpecifierEnd = end; +// } +// } +// cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); +// } + +// const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); +// const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); +// const importStatementText = isDefault +// ? `import ${name} from "${moduleSpecifierWithoutQuotes}"` +// : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; + +// // if this file doesn't have any import statements, insert an import statement and then insert a new line +// // between the only import statement and user code. Otherwise just insert the statement because chances +// // are there are already a new line seperating code and import statements. +// const newText = cachedNewImportInsertPosition === sourceFile.getStart() +// ? `${importStatementText};${context.newLineCharacter}${context.newLineCharacter}` +// : `${context.newLineCharacter}${importStatementText};`; + +// return createCodeAction( +// Diagnostics.Import_0_from_1, +// [name, `"${moduleSpecifierWithoutQuotes}"`], +// newText, +// { start: cachedNewImportInsertPosition, length: 0 }, +// sourceFile.fileName, +// "NewImport", +// moduleSpecifierWithoutQuotes +// ); + +// function getModuleSpecifierForNewImport() { +// const fileName = sourceFile.path; +// const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; +// const sourceDirectory = getDirectoryPath(fileName); +// const options = context.program.getCompilerOptions(); + +// return tryGetModuleNameFromAmbientModule() || +// tryGetModuleNameFromBaseUrl() || +// tryGetModuleNameFromRootDirs() || +// tryGetModuleNameFromTypeRoots() || +// tryGetModuleNameAsNodeModule() || +// removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); + +// function tryGetModuleNameFromAmbientModule(): string { +// if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) { +// return moduleSymbol.name; +// } +// } + +// function tryGetModuleNameFromBaseUrl() { +// if (!options.baseUrl) { +// return undefined; +// } + +// const normalizedBaseUrl = toPath(options.baseUrl, getDirectoryPath(options.baseUrl), getCanonicalFileName); +// let relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); +// if (!relativeName) { +// return undefined; +// } + +// relativeName = removeExtensionAndIndexPostFix(relativeName); + +// if (options.paths) { +// for (const key in options.paths) { +// for (const pattern of options.paths[key]) { +// const indexOfStar = pattern.indexOf("*"); +// if (indexOfStar === 0 && pattern.length === 1) { +// continue; +// } +// else if (indexOfStar !== -1) { +// const prefix = pattern.substr(0, indexOfStar); +// const suffix = pattern.substr(indexOfStar + 1); +// if (relativeName.length >= prefix.length + suffix.length && +// startsWith(relativeName, prefix) && +// endsWith(relativeName, suffix)) { +// const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length); +// return key.replace("\*", matchedStar); +// } +// } +// else if (pattern === relativeName) { +// return key; +// } +// } +// } +// } + +// return relativeName; +// } + +// function tryGetModuleNameFromRootDirs() { +// if (options.rootDirs) { +// const normalizedRootDirs = map(options.rootDirs, rootDir => toPath(rootDir, /*basePath*/ undefined, getCanonicalFileName)); +// const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); +// const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); +// if (normalizedTargetPath !== undefined) { +// const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; +// return removeFileExtension(relativePath); +// } +// } +// return undefined; +// } + +// function tryGetModuleNameFromTypeRoots() { +// const typeRoots = getEffectiveTypeRoots(options, context.host); +// if (typeRoots) { +// const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName)); +// for (const typeRoot of normalizedTypeRoots) { +// if (startsWith(moduleFileName, typeRoot)) { +// let relativeFileName = moduleFileName.substring(typeRoot.length + 1); +// return removeExtensionAndIndexPostFix(relativeFileName); +// } +// } +// } +// } + +// function tryGetModuleNameAsNodeModule() { +// if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { +// // nothing to do here +// return undefined; +// } + +// const indexOfNodeModules = moduleFileName.indexOf("node_modules"); +// if (indexOfNodeModules < 0) { +// return undefined; +// } + +// let relativeFileName: string; +// if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) { +// // if node_modules folder is in this folder or any of its parent folder, no need to keep it. +// relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */); +// } +// else { +// relativeFileName = getRelativePath(moduleFileName, sourceDirectory); +// } + +// relativeFileName = removeFileExtension(relativeFileName); +// if (endsWith(relativeFileName, "/index")) { +// relativeFileName = getDirectoryPath(relativeFileName); +// } +// else { +// try { +// const moduleDirectory = getDirectoryPath(moduleFileName); +// const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json"))); +// if (packageJsonContent) { +// const mainFile = packageJsonContent.main || packageJsonContent.typings; +// if (mainFile) { +// const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName); +// if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) { +// relativeFileName = getDirectoryPath(relativeFileName); +// } +// } +// } +// } +// catch (e) { } +// } + +// return relativeFileName; +// } +// } + +// function getPathRelativeToRootDirs(path: Path, rootDirs: Path[]) { +// for (const rootDir of rootDirs) { +// const relativeName = tryRemoveParentDirectoryName(path, rootDir); +// if (relativeName !== undefined) { +// return relativeName; +// } +// } +// return undefined; +// } + +// function removeExtensionAndIndexPostFix(fileName: string) { +// fileName = removeFileExtension(fileName); +// if (endsWith(fileName, "/index")) { +// fileName = fileName.substr(0, fileName.length - 6/* "/index".length */); +// } +// return fileName; +// } + +// function getRelativePath(path: string, directoryPath: string) { +// const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); +// return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; +// } + +// function tryRemoveParentDirectoryName(path: Path, parentDirectory: Path) { +// const index = path.indexOf(parentDirectory); +// if (index === 0) { +// return endsWith(parentDirectory, directorySeparator) +// ? path.substring(parentDirectory.length) +// : path.substring(parentDirectory.length + 1); +// } +// return undefined; +// } +// } + +// } + +// function createCodeAction( +// description: DiagnosticMessage, +// diagnosticArgs: string[], +// newText: string, +// span: TextSpan, +// fileName: string, +// kind: ImportCodeActionKind, +// moduleSpecifier?: string): ImportCodeAction { +// return { +// description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), +// changes: [{ fileName, textChanges: [{ newText, span }] }], +// kind, +// moduleSpecifier +// }; +// } +// } +// }); +// } diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 8e14bdcb73e..c44ad515f1b 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -1,167 +1,167 @@ -/* @internal */ -namespace ts.codefix { - registerCodeFix({ - errorCodes: [ - Diagnostics._0_is_declared_but_never_used.code, - Diagnostics.Property_0_is_declared_but_never_used.code - ], - getCodeActions: (context: CodeFixContext) => { - const sourceFile = context.sourceFile; - const start = context.span.start; +// /* @internal */ +// namespace ts.codefix { +// registerCodeFix({ +// errorCodes: [ +// Diagnostics._0_is_declared_but_never_used.code, +// Diagnostics.Property_0_is_declared_but_never_used.code +// ], +// getCodeActions: (context: CodeFixContext) => { +// const sourceFile = context.sourceFile; +// const start = context.span.start; - let token = getTokenAtPosition(sourceFile, start); +// let token = getTokenAtPosition(sourceFile, start); - // this handles var ["computed"] = 12; - if (token.kind === SyntaxKind.OpenBracketToken) { - token = getTokenAtPosition(sourceFile, start + 1); - } +// // this handles var ["computed"] = 12; +// if (token.kind === SyntaxKind.OpenBracketToken) { +// token = getTokenAtPosition(sourceFile, start + 1); +// } - switch (token.kind) { - case ts.SyntaxKind.Identifier: - switch (token.parent.kind) { - case ts.SyntaxKind.VariableDeclaration: - switch (token.parent.parent.parent.kind) { - case SyntaxKind.ForStatement: - const forStatement = token.parent.parent.parent; - const forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); - } - else { - return removeSingleItem(forInitializer.declarations, token); - } +// switch (token.kind) { +// case ts.SyntaxKind.Identifier: +// switch (token.parent.kind) { +// case ts.SyntaxKind.VariableDeclaration: +// switch (token.parent.parent.parent.kind) { +// case SyntaxKind.ForStatement: +// const forStatement = token.parent.parent.parent; +// const forInitializer = forStatement.initializer; +// if (forInitializer.declarations.length === 1) { +// return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); +// } +// else { +// return removeSingleItem(forInitializer.declarations, token); +// } - case SyntaxKind.ForOfStatement: - const forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { - const forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); - } - break; +// case SyntaxKind.ForOfStatement: +// const forOfStatement = token.parent.parent.parent; +// if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { +// const forOfInitializer = forOfStatement.initializer; +// return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); +// } +// break; - case SyntaxKind.ForInStatement: - // There is no valid fix in the case of: - // for .. in - return undefined; +// case SyntaxKind.ForInStatement: +// // There is no valid fix in the case of: +// // for .. in +// return undefined; - case SyntaxKind.CatchClause: - const catchClause = token.parent.parent; - const parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFix("", parameter.pos, parameter.end - parameter.pos); +// case SyntaxKind.CatchClause: +// const catchClause = token.parent.parent; +// const parameter = catchClause.variableDeclaration.getChildren()[0]; +// return createCodeFix("", parameter.pos, parameter.end - parameter.pos); - default: - const variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); - } - else { - const declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); - } - } +// default: +// const variableStatement = token.parent.parent.parent; +// if (variableStatement.declarationList.declarations.length === 1) { +// return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); +// } +// else { +// const declarations = variableStatement.declarationList.declarations; +// return removeSingleItem(declarations, token); +// } +// } - case SyntaxKind.TypeParameter: - const typeParameters = (token.parent.parent).typeParameters; - if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); - } - else { - return removeSingleItem(typeParameters, token); - } +// case SyntaxKind.TypeParameter: +// const typeParameters = (token.parent.parent).typeParameters; +// if (typeParameters.length === 1) { +// return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); +// } +// else { +// return removeSingleItem(typeParameters, token); +// } - case ts.SyntaxKind.Parameter: - const functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else { - return removeSingleItem(functionDeclaration.parameters, token); - } +// case ts.SyntaxKind.Parameter: +// const functionDeclaration = token.parent.parent; +// if (functionDeclaration.parameters.length === 1) { +// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); +// } +// else { +// return removeSingleItem(functionDeclaration.parameters, token); +// } - // handle case where 'import a = A;' - case SyntaxKind.ImportEqualsDeclaration: - const importEquals = findImportDeclaration(token); - return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); +// // handle case where 'import a = A;' +// case SyntaxKind.ImportEqualsDeclaration: +// const importEquals = findImportDeclaration(token); +// return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); - case SyntaxKind.ImportSpecifier: - const namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - const importSpec = findImportDeclaration(token); - return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); - } - else { - return removeSingleItem(namedImports.elements, token); - } +// case SyntaxKind.ImportSpecifier: +// const namedImports = token.parent.parent; +// if (namedImports.elements.length === 1) { +// // Only 1 import and it is unused. So the entire declaration should be removed. +// const importSpec = findImportDeclaration(token); +// return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); +// } +// else { +// return removeSingleItem(namedImports.elements, token); +// } - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' - const importClause = token.parent; - if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| - const importDecl = findImportDeclaration(importClause); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { // import |d,| * as ns from './file' - return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); - } +// // handle case where "import d, * as ns from './file'" +// // or "'import {a, b as ns} from './file'" +// case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' +// const importClause = token.parent; +// if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| +// const importDecl = findImportDeclaration(importClause); +// return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); +// } +// else { // import |d,| * as ns from './file' +// return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); +// } - case SyntaxKind.NamespaceImport: - const namespaceImport = token.parent; - if (namespaceImport.name == token && !(namespaceImport.parent).name) { - const importDecl = findImportDeclaration(namespaceImport); - return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); - } - else { - const start = (namespaceImport.parent).name.end; - return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start); - } - } - break; +// case SyntaxKind.NamespaceImport: +// const namespaceImport = token.parent; +// if (namespaceImport.name == token && !(namespaceImport.parent).name) { +// const importDecl = findImportDeclaration(namespaceImport); +// return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); +// } +// else { +// const start = (namespaceImport.parent).name.end; +// return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start); +// } +// } +// break; - case SyntaxKind.PropertyDeclaration: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); +// case SyntaxKind.PropertyDeclaration: +// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - case SyntaxKind.NamespaceImport: - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - if (isDeclarationName(token)) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); - } - else if (isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); - } - else { - return undefined; - } +// case SyntaxKind.NamespaceImport: +// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); +// } +// if (isDeclarationName(token)) { +// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); +// } +// else if (isLiteralComputedPropertyDeclarationName(token)) { +// return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); +// } +// else { +// return undefined; +// } - function findImportDeclaration(token: Node): Node { - let importDecl = token; - while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) { - importDecl = importDecl.parent; - } +// function findImportDeclaration(token: Node): Node { +// let importDecl = token; +// while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) { +// importDecl = importDecl.parent; +// } - return importDecl; - } +// return importDecl; +// } - function createCodeFix(newText: string, start: number, length: number): CodeAction[] { - return [{ - description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText, span: { start, length } }] - }] - }]; - } +// function createCodeFix(newText: string, start: number, length: number): CodeAction[] { +// return [{ +// description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), +// changes: [{ +// fileName: sourceFile.fileName, +// textChanges: [{ newText, span: { start, length } }] +// }] +// }]; +// } - function removeSingleItem(elements: NodeArray, token: T): CodeAction[] { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } - } - }); -} \ No newline at end of file +// function removeSingleItem(elements: NodeArray, token: T): CodeAction[] { +// if (elements[0] === token.parent) { +// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); +// } +// else { +// return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); +// } +// } +// } +// }); +// } \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport0.ts b/tests/cases/fourslash/importNameCodeFixExistingImport0.ts deleted file mode 100644 index 5e5be220688..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport0.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -//// import [|{ v1 }|] from "./module"; -//// f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; - -verify.importFixAtPosition([`{ v1, f1 }`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport1.ts b/tests/cases/fourslash/importNameCodeFixExistingImport1.ts deleted file mode 100644 index 9571d0fcf57..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport1.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -//// import d, [|{ v1 }|] from "./module"; -//// f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export default var d1 = 6; - -verify.importFixAtPosition([`{ v1, f1 }`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts deleted file mode 100644 index 25246e70123..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -//// import [|{ -//// v1, -//// v2 -//// }|] from "./module"; -//// f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export var v2 = 5; -//// export var v3 = 5; - -verify.importFixAtPosition([ -`{ - v1, - v2, -f1 -}` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts deleted file mode 100644 index 304ffb896df..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -////import [|{ -//// v1, v2, -//// v3 -////}|] from "./module"; -////f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export var v2 = 5; -//// export var v3 = 5; - -verify.importFixAtPosition([ -`{ - v1, v2, - v3, f1 -}` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport12.ts b/tests/cases/fourslash/importNameCodeFixExistingImport12.ts deleted file mode 100644 index e00dee504c5..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport12.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// import [|{}|] from "./module"; -//// f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export var v2 = 5; -//// export var v3 = 5; - -verify.importFixAtPosition([`{ f1 }`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport2.ts b/tests/cases/fourslash/importNameCodeFixExistingImport2.ts deleted file mode 100644 index 6a92976f4ef..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport2.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -//// [|import * as ns from "./module"; -//// f1/*0*/();|] - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; - -verify.importFixAtPosition([ -`import * as ns from "./module"; -import { f1 } from "./module"; -f1();`, -`import * as ns from "./module"; -ns.f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport3.ts b/tests/cases/fourslash/importNameCodeFixExistingImport3.ts deleted file mode 100644 index bc00e8d420a..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport3.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -//// [|import d, * as ns from "./module" ; -//// f1/*0*/();|] - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export default var d1 = 6; - -// Test with some extra spaces before the semicolon -verify.importFixAtPosition([ -`import d, * as ns from "./module" ; -ns.f1();`, -`import d, * as ns from "./module" ; -import { f1 } from "./module"; -f1();`, -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport4.ts b/tests/cases/fourslash/importNameCodeFixExistingImport4.ts deleted file mode 100644 index d93cb73664e..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport4.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// [|import d from "./module"; -//// f1/*0*/();|] - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export default var d1 = 6; - -verify.importFixAtPosition([ -`import d, { f1 } from "./module"; -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport5.ts b/tests/cases/fourslash/importNameCodeFixExistingImport5.ts deleted file mode 100644 index ed9297124d9..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport5.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// [|import "./module"; -//// f1/*0*/();|] - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; - -verify.importFixAtPosition([`import "./module"; -import { f1 } from "./module"; -f1();`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport6.ts b/tests/cases/fourslash/importNameCodeFixExistingImport6.ts deleted file mode 100644 index 7ae157a51ce..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport6.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -//// import [|{ v1 }|] from "fake-module"; -//// f1/*0*/(); - -// @Filename: ../package.json -//// { "dependencies": { "fake-module": "latest" } } - -// @Filename: ../node_modules/fake-module/index.ts -//// export var v1 = 5; -//// export function f1(); - -verify.importFixAtPosition([`{ v1, f1 }`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport7.ts b/tests/cases/fourslash/importNameCodeFixExistingImport7.ts deleted file mode 100644 index 249929eabc7..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport7.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -//// import [|{ v1 }|] from "../other_dir/module"; -//// f1/*0*/(); - -// @Filename: ../other_dir/module.ts -//// export var v1 = 5; -//// export function f1(); - -verify.importFixAtPosition([`{ v1, f1 }`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport8.ts b/tests/cases/fourslash/importNameCodeFixExistingImport8.ts deleted file mode 100644 index da7beaa0a47..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport8.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// import [|{v1, v2, v3,}|] from "./module"; -//// f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; -//// export var v2 = 5; -//// export var v3 = 5; - -verify.importFixAtPosition([`{v1, v2, v3, f1,}`]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts deleted file mode 100644 index 05d17927454..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts +++ /dev/null @@ -1,17 +0,0 @@ -/// - -//// import [|{ -//// v1 -//// }|] from "./module"; -//// f1/*0*/(); - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; - -verify.importFixAtPosition([ -`{ - v1, -f1 -}` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImportEquals0.ts b/tests/cases/fourslash/importNameCodeFixExistingImportEquals0.ts deleted file mode 100644 index f431e6356d1..00000000000 --- a/tests/cases/fourslash/importNameCodeFixExistingImportEquals0.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -//// [|import ns = require("ambient-module"); -//// var x = v1/*0*/ + 5;|] - -// @Filename: ambientModule.ts -//// declare module "ambient-module" { -//// export function f1(); -//// export var v1; -//// } - -verify.importFixAtPosition([ -`import ns = require("ambient-module"); -var x = ns.v1 + 5;`, -`import ns = require("ambient-module"); -import { v1 } from "ambient-module"; -var x = v1 + 5;`, -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportAmbient0.ts b/tests/cases/fourslash/importNameCodeFixNewImportAmbient0.ts deleted file mode 100644 index 1d7b5bc3e7f..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportAmbient0.ts +++ /dev/null @@ -1,15 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: ambientModule.ts -//// declare module "ambient-module" { -//// export function f1(); -//// export var v1; -//// } - -verify.importFixAtPosition([ -`import { f1 } from "ambient-module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportAmbient1.ts b/tests/cases/fourslash/importNameCodeFixNewImportAmbient1.ts deleted file mode 100644 index 60504c89711..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportAmbient1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -//// import d from "other-ambient-module"; -//// [|import * as ns from "yet-another-ambient-module"; -//// var x = v1/*0*/ + 5;|] - -// @Filename: ambientModule.ts -//// declare module "ambient-module" { -//// export function f1(); -//// export var v1; -//// } - -// @Filename: otherAmbientModule.ts -//// declare module "other-ambient-module" { -//// export default function f2(); -//// } - -// @Filename: yetAnotherAmbientModule.ts -//// declare module "yet-another-ambient-module" { -//// export function f3(); -//// export var v3; -//// } - -verify.importFixAtPosition([ -`import * as ns from "yet-another-ambient-module"; -import { v1 } from "ambient-module"; -var x = v1 + 5;` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportAmbient2.ts b/tests/cases/fourslash/importNameCodeFixNewImportAmbient2.ts deleted file mode 100644 index 999da4bffbb..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportAmbient2.ts +++ /dev/null @@ -1,21 +0,0 @@ -/// - -////[|/* -//// * I'm a license or something -//// */ -////f1/*0*/();|] - -// @Filename: ambientModule.ts -//// declare module "ambient-module" { -//// export function f1(); -//// export var v1; -//// } - -verify.importFixAtPosition([ -`/* - * I'm a license or something - */ -import { f1 } from "ambient-module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportAmbient3.ts b/tests/cases/fourslash/importNameCodeFixNewImportAmbient3.ts deleted file mode 100644 index 648293cce2e..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportAmbient3.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - -//// let a = "I am a non-trivial statement that appears before imports"; -//// import d from "other-ambient-module" -//// [|import * as ns from "yet-another-ambient-module" -//// var x = v1/*0*/ + 5;|] - -// @Filename: ambientModule.ts -//// declare module "ambient-module" { -//// export function f1(); -//// export var v1; -//// } - -// @Filename: otherAmbientModule.ts -//// declare module "other-ambient-module" { -//// export default function f2(); -//// } - -// @Filename: yetAnotherAmbientModule.ts -//// declare module "yet-another-ambient-module" { -//// export function f3(); -//// export var v3; -//// } - -// test cases when there are no semicolons at the line end -verify.importFixAtPosition([ -`import * as ns from "yet-another-ambient-module" -import { v1 } from "ambient-module"; -var x = v1 + 5;` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts b/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts deleted file mode 100644 index e15c2cf4399..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportBaseUrl0.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: tsconfig.json -//// { -//// "compilerOptions": { -//// "baseUrl": "./a" -//// } -//// } - -// @Filename: a/b.ts -//// export function f1() { }; - -verify.importFixAtPosition([ -`import { f1 } from "b"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportDefault0.ts b/tests/cases/fourslash/importNameCodeFixNewImportDefault0.ts deleted file mode 100644 index 3efe023e922..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportDefault0.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: module.ts -//// export default function f1() { }; - -verify.importFixAtPosition([ -`import f1 from "./module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportFile0.ts b/tests/cases/fourslash/importNameCodeFixNewImportFile0.ts deleted file mode 100644 index 2372110437a..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportFile0.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; - -verify.importFixAtPosition([ -`import { f1 } from "./module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportFile1.ts b/tests/cases/fourslash/importNameCodeFixNewImportFile1.ts deleted file mode 100644 index 0223d96e018..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportFile1.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -//// [|/// -//// f1/*0*/();|] - -// @Filename: module.ts -//// export function f1() {} -//// export var v1 = 5; - -// @Filename: tripleSlashReference.ts -//// var x = 5;/*dummy*/ - -verify.importFixAtPosition([ -`/// -import { f1 } from "./module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportFile2.ts b/tests/cases/fourslash/importNameCodeFixNewImportFile2.ts deleted file mode 100644 index ca9330e9846..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportFile2.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: ../../other_dir/module.ts -//// export var v1 = 5; -//// export function f1(); - -verify.importFixAtPosition([ -`import { f1 } from "../../other_dir/module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules0.ts b/tests/cases/fourslash/importNameCodeFixNewImportNodeModules0.ts deleted file mode 100644 index 6013f865ddf..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules0.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: ../package.json -//// { "dependencies": { "fake-module": "latest" } } - -// @Filename: ../node_modules/fake-module/index.ts -//// export var v1 = 5; -//// export function f1(); - -// @Filename: ../node_modules/fake-module/package.json -//// {} - -verify.importFixAtPosition([ -`import { f1 } from "fake-module"; - -f1();` -]); diff --git a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules1.ts b/tests/cases/fourslash/importNameCodeFixNewImportNodeModules1.ts deleted file mode 100644 index 6bffe41b27a..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules1.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: ../package.json -//// { "dependencies": { "fake-module": "latest" } } - -// @Filename: ../node_modules/fake-module/nested.ts -//// export var v1 = 5; -//// export function f1(); - -verify.importFixAtPosition([ -`import { f1 } from "fake-module/nested"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules2.ts b/tests/cases/fourslash/importNameCodeFixNewImportNodeModules2.ts deleted file mode 100644 index ff48fbe182c..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules2.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -//// [|f1/*0*/();|] - -// @Filename: ../package.json -//// { "dependencies": { "fake-module": "latest" } } - -// @Filename: ../node_modules/fake-module/notindex.d.ts -//// export var v1 = 5; -//// export function f1(); - -// @Filename: ../node_modules/fake-module/notindex.js -//// module.exports = { -//// v1: 5, -//// f1: function () {} -//// }; - -// @Filename: ../node_modules/fake-module/package.json -//// { "main":"./notindex.js", "typings":"./notindex.d.ts" } - -verify.importFixAtPosition([ -`import { f1 } from "fake-module"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules3.ts b/tests/cases/fourslash/importNameCodeFixNewImportNodeModules3.ts deleted file mode 100644 index b1143cb4b41..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportNodeModules3.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -// @Filename: /a.ts -//// [|f1/*0*/();|] - -// @Filename: /node_modules/@types/random/index.d.ts -//// export var v1 = 5; -//// export function f1(); - -verify.importFixAtPosition([ -`import { f1 } from "random"; - -f1();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportPaths0.ts b/tests/cases/fourslash/importNameCodeFixNewImportPaths0.ts deleted file mode 100644 index 93cd6f92ef5..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportPaths0.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -//// [|foo/*0*/();|] - -// @Filename: folder_a/f2.ts -//// export function foo() {}; - -// @Filename: tsconfig.json -//// { -//// "compilerOptions": { -//// "baseUrl": ".", -//// "paths": { -//// "a": [ "folder_a/f2" ] -//// } -//// } -//// } - -verify.importFixAtPosition([ -`import { foo } from "a"; - -foo();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportPaths1.ts b/tests/cases/fourslash/importNameCodeFixNewImportPaths1.ts deleted file mode 100644 index bb0f1e6705a..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportPaths1.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -//// [|foo/*0*/();|] - -// @Filename: folder_b/f2.ts -//// export function foo() {}; - -// @Filename: tsconfig.json -//// { -//// "compilerOptions": { -//// "baseUrl": ".", -//// "paths": { -//// "b/*": [ "folder_b/*" ] -//// } -//// } -//// } - -verify.importFixAtPosition([ -`import { foo } from "b/f2"; - -foo();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportRootDirs0.ts b/tests/cases/fourslash/importNameCodeFixNewImportRootDirs0.ts deleted file mode 100644 index ae8ef03ccac..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportRootDirs0.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// - -// @Filename: a/f1.ts -//// [|foo/*0*/();|] - -// @Filename: b/c/f2.ts -//// export function foo() {}; - -// @Filename: tsconfig.json -//// { -//// "compilerOptions": { -//// "rootDirs": [ -//// "a", -//// "b/c" -//// ] -//// } -//// } - -verify.importFixAtPosition([ -`import { foo } from "./f2"; - -foo();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots0.ts b/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots0.ts deleted file mode 100644 index a6eb6a90759..00000000000 --- a/tests/cases/fourslash/importNameCodeFixNewImportTypeRoots0.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -// @Filename: a/f1.ts -//// [|foo/*0*/();|] - -// @Filename: types/random/index.ts -//// export function foo() {}; - -// @Filename: tsconfig.json -//// { -//// "compilerOptions": { -//// "typeRoots": [ -//// "./types" -//// ] -//// } -//// } - -verify.importFixAtPosition([ -`import { foo } from "random"; - -foo();` -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixOptionalImport0.ts b/tests/cases/fourslash/importNameCodeFixOptionalImport0.ts deleted file mode 100644 index 30b482a94d7..00000000000 --- a/tests/cases/fourslash/importNameCodeFixOptionalImport0.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -// @Filename: a/f1.ts -//// [|import * as ns from "./foo"; -//// foo/*0*/();|] - -// @Filename: a/foo/bar.ts -//// export function foo() {}; - -// @Filename: a/foo.ts -//// export { foo } from "./foo/bar"; - -verify.importFixAtPosition([ -`import * as ns from "./foo"; -import { foo } from "./foo"; -foo();`, - -`import * as ns from "./foo"; -ns.foo();`, -]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixOptionalImport1.ts b/tests/cases/fourslash/importNameCodeFixOptionalImport1.ts deleted file mode 100644 index 343b0692260..00000000000 --- a/tests/cases/fourslash/importNameCodeFixOptionalImport1.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -// @Filename: a/f1.ts -//// [|foo/*0*/();|] - -// @Filename: a/node_modules/bar/index.ts -//// export function foo() {}; - -// @Filename: a/foo.ts -//// export { foo } from "bar"; - -verify.importFixAtPosition([ -`import { foo } from "./foo"; - -foo();`, - -`import { foo } from "bar"; - -foo();`, -]); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts deleted file mode 100644 index 586202ab0c7..00000000000 --- a/tests/cases/fourslash/unusedClassInNamespace1.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// class class1 { -//// } -//// } |] - -verify.codeFixAtPosition(`namespace greeter { -}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts deleted file mode 100644 index c182f4e3655..00000000000 --- a/tests/cases/fourslash/unusedClassInNamespace2.ts +++ /dev/null @@ -1,15 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// export class class2 { -//// } -//// class class1 { -//// } -//// } |] - -verify.codeFixAtPosition(`namespace greeter { - export class class2 { - } -}`); - diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts deleted file mode 100644 index 391c5e833ef..00000000000 --- a/tests/cases/fourslash/unusedClassInNamespace3.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true -//// [| namespace Validation { -//// class c1 { -//// -//// } -//// -//// export class c2 { -//// -//// } -//// -//// class c3 extends c1 { -//// -//// } -////} |] - -verify.codeFixAtPosition(`namespace Validation { - class c1 { - } - - export class c2 { - } -}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts deleted file mode 100644 index 5db5b1aefa6..00000000000 --- a/tests/cases/fourslash/unusedClassInNamespace4.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true -//// [| namespace Validation { -//// class c1 { -//// -//// } -//// -//// export class c2 { -//// -//// } -//// -//// class c3 { -//// public x: c1; -//// } -////} |] - -verify.codeFixAtPosition(`namespace Validation { - class c1 { - - } - - export class c2 { - - } -}`); diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts deleted file mode 100644 index df373257809..00000000000 --- a/tests/cases/fourslash/unusedConstantInFunction1.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| function f1 () { -//// const x: string = "x"; -//// } |] - -verify.codeFixAtPosition(`function f1 () { -}`); - diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts deleted file mode 100644 index 1d88f07ebf7..00000000000 --- a/tests/cases/fourslash/unusedEnumInFunction1.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| function f1 () { -//// enum Directions { Up, Down} -//// } |] - -verify.codeFixAtPosition(`function f1 () { -} -`); - diff --git a/tests/cases/fourslash/unusedEnumInNamespace1.ts b/tests/cases/fourslash/unusedEnumInNamespace1.ts deleted file mode 100644 index 88e8e32d5f8..00000000000 --- a/tests/cases/fourslash/unusedEnumInNamespace1.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// enum enum1 { -//// Monday -//// } -//// } |] - -verify.codeFixAtPosition(`namespace greeter { -}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts deleted file mode 100644 index e0f6b2e18ac..00000000000 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// function function1() { -//// }/*1*/ -//// } |] - -verify.codeFixAtPosition(`namespace greeter { -}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts deleted file mode 100644 index c823777048e..00000000000 --- a/tests/cases/fourslash/unusedFunctionInNamespace2.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// export function function2() { -//// } -//// function function1() { -//// } -////} |] - -verify.codeFixAtPosition(`namespace greeter { - export function function2() { - } -}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts deleted file mode 100644 index 144e9f325b4..00000000000 --- a/tests/cases/fourslash/unusedFunctionInNamespace3.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true - -//// [| namespace Validation { -//// function function1() { -//// } -////} |] - -verify.codeFixAtPosition(`namespace Validation { -}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts deleted file mode 100644 index 5b5995da9c7..00000000000 --- a/tests/cases/fourslash/unusedFunctionInNamespace4.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true -//// [| namespace Validation { -//// var function1 = function() { -//// } -////} |] - -verify.codeFixAtPosition(`namespace Validation { -}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts deleted file mode 100644 index b839d9dcd97..00000000000 --- a/tests/cases/fourslash/unusedFunctionInNamespace5.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true -////namespace Validation { -//// var function1 = function() { -//// } -//// -//// export function function2() { -//// -//// } -//// -//// [| function function3() { -//// function1(); -//// } -//// -//// function function4() { -//// -//// } -//// -//// export let a = function3; |] -////} - -verify.codeFixAtPosition(`function function3() { - function1(); - } - - export let a = function3;`); diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts deleted file mode 100644 index f9d38e4cfb0..00000000000 --- a/tests/cases/fourslash/unusedImports10FS.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -// @noUnusedLocals: true -//// module A { -//// export class Calculator { -//// public handelChar() { -//// } -//// } -//// } - -//// module B { -//// [|import a = A;|] -//// } - -verify.codeFixAtPosition(""); - diff --git a/tests/cases/fourslash/unusedImports11FS.ts b/tests/cases/fourslash/unusedImports11FS.ts deleted file mode 100644 index a18a4634d71..00000000000 --- a/tests/cases/fourslash/unusedImports11FS.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [| import f1, * as s from "./file1"; |] -//// s.f2('hello'); - -// @Filename: file1.ts -//// export var v1; -//// export function f1(n: number){} -//// export function f2(s: string){}; -//// export default f1; - -verify.codeFixAtPosition('import * as s from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports12FS.ts b/tests/cases/fourslash/unusedImports12FS.ts deleted file mode 100644 index 4d8243eb4ab..00000000000 --- a/tests/cases/fourslash/unusedImports12FS.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [| import f1, * as s from "./file1"; |] -//// f1(42); - -// @Filename: file1.ts -//// export function f1(n: number){} -//// export function f2(s: string){}; -//// export default f1; - -verify.codeFixAtPosition('import f1 from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts deleted file mode 100644 index d9fc17a2448..00000000000 --- a/tests/cases/fourslash/unusedImports1FS.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [|import { Calculator } from "./file1" |] - -// @Filename: file1.ts -//// export class Calculator { -//// -//// } - -verify.codeFixAtPosition(''); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts deleted file mode 100644 index 6e3d9527c52..00000000000 --- a/tests/cases/fourslash/unusedImports2FS.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [|import {Calculator} from "./file1" -//// import {test} from "./file1"|] - -//// var x = new Calculator(); -//// x.handleChar(); - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() {} -//// } -//// export function test() { -//// -//// } - -verify.codeFixAtPosition(`import {Calculator} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts deleted file mode 100644 index 205666e971d..00000000000 --- a/tests/cases/fourslash/unusedImports3FS.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -////[| import {Calculator, test, test2} from "./file1" |] - -//// test(); -//// test2(); - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() {} -//// } - -//// export function test() { -//// -//// } - -//// export function test2() { -//// -//// } - -verify.codeFixAtPosition(`import {test, test2} from "./file1"`); - diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts deleted file mode 100644 index 302007748f4..00000000000 --- a/tests/cases/fourslash/unusedImports4FS.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [| import {Calculator, test, test2} from "./file1" |] -//// -//// var x = new Calculator(); -//// x.handleChar(); -//// test2(); - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() {} -//// } -//// -//// export function test() { -//// -//// } -//// -//// export function test2() { -//// -//// } - -verify.codeFixAtPosition(`import {Calculator, test2} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts deleted file mode 100644 index 1d68f6ae643..00000000000 --- a/tests/cases/fourslash/unusedImports5FS.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [| import {Calculator, test, test2} from "./file1" |] -//// -//// var x = new Calculator(); -//// x.handleChar(); -//// test(); - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() {} -//// } -//// -//// export function test() { -//// -//// } -//// -//// export function test2() { -//// -//// } - -verify.codeFixAtPosition(`import {Calculator, test} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts deleted file mode 100644 index a5c6744855a..00000000000 --- a/tests/cases/fourslash/unusedImports6FS.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [| import d from "./file1" |] - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() { } -//// } - -//// export function test() { -//// -//// } - -//// export default function test2() { -//// -//// } - -verify.codeFixAtPosition(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts deleted file mode 100644 index 23066ef538d..00000000000 --- a/tests/cases/fourslash/unusedImports7FS.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [| import * as n from "./file1" |] - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() { } -//// } -//// export function test() { -//// } -//// export default function test2() { -//// } - -verify.codeFixAtPosition(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts deleted file mode 100644 index 02564e35989..00000000000 --- a/tests/cases/fourslash/unusedImports8FS.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [|import {Calculator as calc, test as t1, test2 as t2} from "./file1"|] -//// -//// var x = new calc(); -//// x.handleChar(); -//// t1(); - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() { } -//// } - -//// export function test() { -//// -//// } - -//// export function test2() { -//// -//// } - -verify.codeFixAtPosition(`import {Calculator as calc, test as t1} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts deleted file mode 100644 index 324d57a1928..00000000000 --- a/tests/cases/fourslash/unusedImports9FS.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -// @noUnusedLocals: true -// @Filename: file2.ts -//// [|import c = require('./file1')|] - -// @Filename: file1.ts -//// export class Calculator { -//// handleChar() { } -//// } -//// -//// export function test() { -//// -//// } -//// -//// export function test2() { -//// -//// } - -verify.codeFixAtPosition(""); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts deleted file mode 100644 index 8d07a8c7912..00000000000 --- a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// interface interface1 { -//// } -////} |] - -verify.codeFixAtPosition(` -namespace greeter { -}`); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts deleted file mode 100644 index baa46c65a0c..00000000000 --- a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -////namespace greeter { -//// [| export interface interface2 { -//// } -//// interface interface1 { -//// } |] -////} - -verify.codeFixAtPosition(`export interface interface2 { -}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts deleted file mode 100644 index 2edd7c176e7..00000000000 --- a/tests/cases/fourslash/unusedLocalsInFunction1.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| function greeter() { -//// var x = 0; -////} |] - -verify.codeFixAtPosition(` -function greeter() { -}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts deleted file mode 100644 index b7094328041..00000000000 --- a/tests/cases/fourslash/unusedLocalsInFunction2.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -////function greeter() { -//// [| var x, y = 0; |] -//// x+1; -////} - -verify.codeFixAtPosition("var x;"); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts deleted file mode 100644 index 906517ee0a7..00000000000 --- a/tests/cases/fourslash/unusedLocalsInFunction3.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -////function greeter() { -//// [| var x, y = 0,z = 1; |] -//// x+1; -//// z+1; -////} - -verify.codeFixAtPosition("var x,z = 1;", 6133); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts deleted file mode 100644 index 54d3223f236..00000000000 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -////function greeter() { -//// [| var x,y = 0,z = 1; |] -//// y++; -//// z++; -////} - -verify.codeFixAtPosition("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts deleted file mode 100644 index 43b782ce266..00000000000 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -////class greeter { -//// public function1() { -//// [| var /*0*/x,/*1*/ y = 10; |] -//// y++; -//// } -////} - -verify.codeFixAtPosition("var y = 10;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts deleted file mode 100644 index 322cfad3940..00000000000 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -////class greeter { -//// public function1() { -//// [| var x, y; |] -//// y = 1; -//// } -////} - -verify.codeFixAtPosition("var y;"); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts deleted file mode 100644 index 412b599b780..00000000000 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true -////class greeter { -//// [| constructor() { -//// var unused = 20; -//// } |] -////} - -verify.codeFixAtPosition(`constructor() { -}`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts deleted file mode 100644 index eff9b7c8d54..00000000000 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -////class greeter { -//// [|constructor() { -//// var unused = 20; -//// var used = "dummy"; -//// used = used + "second part"; -//// }|] -////} - -verify.codeFixAtPosition(` - constructor() { - var used = "dummy"; - used = used + "second part"; - } -`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts deleted file mode 100644 index 7795a4d1530..00000000000 --- a/tests/cases/fourslash/unusedMethodInClass1.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -////[| class greeter { -//// private function1() { -//// } -////} |] - -verify.codeFixAtPosition(` -class greeter { -}`); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts deleted file mode 100644 index 24b6fe155ef..00000000000 --- a/tests/cases/fourslash/unusedMethodInClass2.ts +++ /dev/null @@ -1,15 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| class greeter { -//// public function2() { -//// } -//// private function1() { -//// } -////} |] - -verify.codeFixAtPosition(` -class greeter { - public function2() { - } -}`); diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts deleted file mode 100644 index eab535fb5af..00000000000 --- a/tests/cases/fourslash/unusedMethodInClass3.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -////[|class greeter { -//// private function1 = function() { -//// } -////} |] - -verify.codeFixAtPosition(` -class greeter { -}`); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts deleted file mode 100644 index ee27ec331eb..00000000000 --- a/tests/cases/fourslash/unusedMethodInClass4.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -////class greeter { -//// [|public function2(){ -//// } -//// private function1 = function() { -//// } |] -////} - -verify.codeFixAtPosition(`public function2(){ -}`); diff --git a/tests/cases/fourslash/unusedMethodInClass5.ts b/tests/cases/fourslash/unusedMethodInClass5.ts deleted file mode 100644 index 36ef3670cac..00000000000 --- a/tests/cases/fourslash/unusedMethodInClass5.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [|class C { -//// private ["string"] (){} -//// }|] - -verify.codeFixAtPosition("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass6.ts b/tests/cases/fourslash/unusedMethodInClass6.ts deleted file mode 100644 index 71fcb92d037..00000000000 --- a/tests/cases/fourslash/unusedMethodInClass6.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [|class C { -//// private "string" (){} -//// }|] - -verify.codeFixAtPosition("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts deleted file mode 100644 index 41fe162ef15..00000000000 --- a/tests/cases/fourslash/unusedNamespaceInNamespace.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [|namespace A { -//// namespace B { -//// } -//// }|] - -verify.codeFixAtPosition(` -namespace A { -} -`); - diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts deleted file mode 100644 index f53c6d3e8bd..00000000000 --- a/tests/cases/fourslash/unusedParameterInConstructor1.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class C1 { -//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; } -//// } - -verify.codeFixAtPosition("constructor(public p2: boolean, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor2.ts b/tests/cases/fourslash/unusedParameterInConstructor2.ts deleted file mode 100644 index bd5f66ff966..00000000000 --- a/tests/cases/fourslash/unusedParameterInConstructor2.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class C1 { -//// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; } -//// } - -verify.codeFixAtPosition("constructor(public p1: string, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor3.ts b/tests/cases/fourslash/unusedParameterInConstructor3.ts deleted file mode 100644 index 173e00113d8..00000000000 --- a/tests/cases/fourslash/unusedParameterInConstructor3.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class C1 { -//// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; } -//// } - -verify.codeFixAtPosition("constructor(public p1: string, public p2: boolean, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor4.ts b/tests/cases/fourslash/unusedParameterInConstructor4.ts deleted file mode 100644 index 6d0223dc5f4..00000000000 --- a/tests/cases/fourslash/unusedParameterInConstructor4.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class C1 { -//// [|constructor(private readonly p2: boolean, p5)|] { p5; } -//// } - -verify.codeFixAtPosition("constructor(p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts deleted file mode 100644 index 2243af9f5f5..00000000000 --- a/tests/cases/fourslash/unusedParameterInFunction1.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// - -// @noUnusedParameters: true -////function [|greeter( x)|] { -////} - -verify.codeFixAtPosition("greeter()"); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts deleted file mode 100644 index 493eafc5722..00000000000 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedParameters: true -////function [|greeter(x,y)|] { -//// x++; -////} - -verify.codeFixAtPosition("greeter(x)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts deleted file mode 100644 index 6d79ba071b4..00000000000 --- a/tests/cases/fourslash/unusedParameterInFunction3.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedParameters: true -////function [|greeter(x,y)|] { -//// y++; -////} - -verify.codeFixAtPosition("greeter(y)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts deleted file mode 100644 index b536543fb6d..00000000000 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedParameters: true -////[|function greeter(x,y,z) |] { -//// x++; -//// z++; -////} - -verify.codeFixAtPosition("function greeter(x,z)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts deleted file mode 100644 index c462b742569..00000000000 --- a/tests/cases/fourslash/unusedParameterInLambda1.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// function f1() { -//// [|return (x:number) => {}|] -//// } - -verify.codeFixAtPosition("return () => {}"); diff --git a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts deleted file mode 100644 index 593c0fe8cf4..00000000000 --- a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// type hw = "Hello" |"world"; -//// export type nw = "No" | "Way"; -//// } |] - -verify.codeFixAtPosition(`namespace greeter { - export type nw = "No" | "Way"; -}`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts deleted file mode 100644 index ab654a5150e..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInClass1.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// - -// @noUnusedLocals: true -////[|class greeter |] { -////} - -verify.codeFixAtPosition("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts deleted file mode 100644 index 8e860c10e04..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInClass2.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -////[|class greeter |] { -//// public a: X; -////} - -verify.codeFixAtPosition("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts deleted file mode 100644 index 75ae98f53e0..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInClass3.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -////[|class greeter |] { -//// public a: X; -//// public b: Z; -////} - -verify.codeFixAtPosition("class greeter"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts deleted file mode 100644 index 7177ed41c84..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [|function f1() {}|] - -verify.codeFixAtPosition("function f1() {}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts deleted file mode 100644 index 344ae303c75..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [|function f1(a: X) {a}|] - -verify.codeFixAtPosition("function f1(a: X) {a}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts deleted file mode 100644 index 746b174db18..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts +++ /dev/null @@ -1,6 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [|function f1(a: X) {a;var b:Z;b}|] - -verify.codeFixAtPosition("function f1(a: X) {a;var b:Z;b}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts deleted file mode 100644 index 70d8bc7800c..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts +++ /dev/null @@ -1,7 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// [|interface I {}|] - -verify.codeFixAtPosition("interface I {}"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts deleted file mode 100644 index 73d70672368..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// function f1() { -//// [|return (x:number) => {x}|] -//// } - -verify.codeFixAtPosition("return (x:number) => {x}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts deleted file mode 100644 index 77c802f5c44..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// var x : { -//// [|new (a: T): void;|] -//// } - -verify.codeFixAtPosition("new (a: T): void;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts deleted file mode 100644 index 0ecb0338be2..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// class A { public x: Dummy } -//// var x : { -//// [|new (a: T): A;|] -//// } - -verify.codeFixAtPosition("new (a: T): A;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts deleted file mode 100644 index 5a226fc9005..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class A { -//// public x: T; -//// } -//// [|var y: new (a:T)=>void;|] - -verify.codeFixAtPosition("var y: new (a:T)=>void;"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts deleted file mode 100644 index 7a9f04147d6..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class C1 { -//// [|f1()|] {} -//// } - -verify.codeFixAtPosition("f1()"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts deleted file mode 100644 index 3650cfbad98..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class C1 { -//// [|f1(a: U)|] {a;} -//// } - -verify.codeFixAtPosition("f1(a: U)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts deleted file mode 100644 index cb9b965ca4d..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -//// class A { -//// [|public f1(a: X)|] { a; var b: Z; b } -//// } - -verify.codeFixAtPosition("public f1(a: X)"); diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts deleted file mode 100644 index e9dedaef31e..00000000000 --- a/tests/cases/fourslash/unusedVariableInBlocks.ts +++ /dev/null @@ -1,15 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// [|let x = 10; -//// { -//// let x = 11; -//// } -//// x;|] -//// } - -verify.codeFixAtPosition(`let x = 10; - { - } - x;`); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts deleted file mode 100644 index 82bb99016ef..00000000000 --- a/tests/cases/fourslash/unusedVariableInClass1.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -////class greeter { -//// [|private greeting: string;|] -////} - -verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts deleted file mode 100644 index c971092584a..00000000000 --- a/tests/cases/fourslash/unusedVariableInClass2.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -////class greeter { -//// [|public greeting1; -//// private greeting: string;|] -////} - -verify.codeFixAtPosition("public greeting1;"); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts deleted file mode 100644 index 8d2a62e7175..00000000000 --- a/tests/cases/fourslash/unusedVariableInClass3.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -////class greeter {[| -//// private X = function() {}; -////|]} - -verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts deleted file mode 100644 index 0ee02ab4363..00000000000 --- a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// [|for(var i = 0; ;) |]{ -//// -//// } -//// } - -verify.codeFixAtPosition("for(; ;)"); - diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts deleted file mode 100644 index 1b1a0798c04..00000000000 --- a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// [|for(var i = 0, j= 0; ;i++)|] { -//// -//// } -//// } - -verify.codeFixAtPosition("for(var i = 0; ;i++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts deleted file mode 100644 index 4eed9599b15..00000000000 --- a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// [|for(var i = 0, j= 0, k=0; ;i++, k++)|] { -//// -//// } -//// } - -verify.codeFixAtPosition("for(var i = 0, k=0; ;i++,k++)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts deleted file mode 100644 index 76e551612ba..00000000000 --- a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// [|for(var i = 0, j= 0, k=0; ;j++, k++) |]{ -//// -//// } -//// } - -verify.codeFixAtPosition("for(var j = 0, k=0; ;j++,k++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts deleted file mode 100644 index 4187c3141b5..00000000000 --- a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// for ([|const elem of|] ["a", "b", "c"]) { -//// -//// } -//// } - -verify.codeFixAtPosition("const {} of "); - diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts deleted file mode 100644 index 8fd0fee735e..00000000000 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -//// function f1 () { -//// for (const elem of ["a", "b", "c"]) { -//// elem; -//// [|var x = 20;|] -//// } -////} -//// - -verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts deleted file mode 100644 index 011434ce098..00000000000 --- a/tests/cases/fourslash/unusedVariableInModule1.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// export {} -//// [|var x: string;|] -//// export var y: string; - -verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts deleted file mode 100644 index db4519c8faa..00000000000 --- a/tests/cases/fourslash/unusedVariableInModule2.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// export {} -//// [|var x: string, z: number;|] -//// z; -//// export var y: string; - -verify.codeFixAtPosition("var z: number;"); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts deleted file mode 100644 index bffffc768d3..00000000000 --- a/tests/cases/fourslash/unusedVariableInModule3.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// export {} -//// [|var x = function f1() {}|] -//// export var y: string; - -verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts deleted file mode 100644 index 6a1be9fe5b8..00000000000 --- a/tests/cases/fourslash/unusedVariableInModule4.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// export {} -//// [|var x = function f1(m: number) {}|] -//// x; -//// export var y: string; - -verify.codeFixAtPosition(`var x = function f1() {}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts deleted file mode 100644 index caf778bc0da..00000000000 --- a/tests/cases/fourslash/unusedVariableInNamespace1.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// - -// @noUnusedLocals: true -////namespace greeter { -//// [|let a = "dummy entry";|] -////} - -verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts deleted file mode 100644 index fbb9e2d6a0c..00000000000 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -////namespace greeter { -//// [|let a = "dummy entry", b, c = 0;|] -//// export function function1() { -//// a = "dummy"; -//// c++; -//// } -////} - -verify.codeFixAtPosition(`let a = "dummy entry", c = 0;`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts deleted file mode 100644 index 33e501d0c0d..00000000000 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// @noUnusedLocals: true -////namespace greeter { -//// [|let a = "dummy entry", b, c = 0;|] -//// export function function1() { -//// a = "dummy"; -//// b = 0; -//// } -////} - -verify.codeFixAtPosition(`let a = "dummy entry", b;`);