From f17a612de81433002c06e521c876a35b18f23afe Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 6 Jun 2017 13:13:46 -0700 Subject: [PATCH 1/9] rename codeFix --- src/harness/tsconfig.json | 2 +- .../{unusedIdentifierFixes.ts => fixUnusedIdentifier.ts} | 0 src/services/codefixes/fixes.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/services/codefixes/{unusedIdentifierFixes.ts => fixUnusedIdentifier.ts} (100%) diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 6553f3667a7..7366df94ef6 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -80,7 +80,7 @@ "../services/codefixes/fixConstructorForDerivedNeedSuperCall.ts", "../services/codefixes/helpers.ts", "../services/codefixes/importFixes.ts", - "../services/codefixes/unusedIdentifierFixes.ts", + "../services/codefixes/fixUnusedIdentifier.ts", "../services/codefixes/disableJsDiagnostics.ts", "harness.ts", diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/fixUnusedIdentifier.ts similarity index 100% rename from src/services/codefixes/unusedIdentifierFixes.ts rename to src/services/codefixes/fixUnusedIdentifier.ts diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index c2e2509a28e..c38820231b0 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -6,7 +6,7 @@ /// /// /// -/// +/// /// /// /// From 5c91798d564e2ba8ff9881a4db55adab4e5d7925 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 6 Jun 2017 14:10:34 -0700 Subject: [PATCH 2/9] add tests --- .../unusedClassInNamespace1AddUnderscore.ts | 11 +++++++++++ .../unusedFunctionInNamespac4AddUnderscore.ts | 13 +++++++++++++ ...usedLocalsinConstructorFS2AddUnderscore.ts | 19 +++++++++++++++++++ ...usedTypeParametersInClass3AddUnderscore.ts | 9 +++++++++ 4 files changed, 52 insertions(+) create mode 100644 tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts create mode 100644 tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts create mode 100644 tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts diff --git a/tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts b/tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts new file mode 100644 index 00000000000..8f8ceab8615 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// class class1 { +//// } +//// } |] + +verify.rangeAfterCodeFix(`namespace greeter { + class _class1 { } +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts b/tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts new file mode 100644 index 00000000000..a017fd81f1f --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +//// [| namespace Validation { +//// var function1 = function() { +//// } +////} |] + +verify.rangeAfterCodeFix(`namespace Validation { + var _function1 = function() { + } +} `, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts new file mode 100644 index 00000000000..ecad94397c8 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts @@ -0,0 +1,19 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// [|constructor() { +//// var unused = 20; +//// var used = "dummy"; +//// used = used + "second part"; +//// } |] +////} + +verify.rangeAfterCodeFix(` + constructor() { + var _unused = 20; + var used = "dummy"; + used = used + "second part"; + } +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts b/tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts new file mode 100644 index 00000000000..b1bf52d3043 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////[|class greeter |] { +//// public a: X; +//// public b: Z; +////} + +verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); From 7c22e50269fb965568053e4cbf438f017eb90a27 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 6 Jun 2017 14:11:11 -0700 Subject: [PATCH 3/9] update existing tests --- tests/cases/fourslash/unusedClassInNamespace1.ts | 2 +- tests/cases/fourslash/unusedClassInNamespace2.ts | 2 +- tests/cases/fourslash/unusedClassInNamespace3.ts | 2 +- tests/cases/fourslash/unusedClassInNamespace4.ts | 2 +- tests/cases/fourslash/unusedConstantInFunction1.ts | 2 +- tests/cases/fourslash/unusedEnumInFunction1.ts | 2 +- tests/cases/fourslash/unusedEnumInNamespace1.ts | 2 +- tests/cases/fourslash/unusedFunctionInNamespace1.ts | 2 +- tests/cases/fourslash/unusedFunctionInNamespace2.ts | 2 +- tests/cases/fourslash/unusedFunctionInNamespace3.ts | 2 +- tests/cases/fourslash/unusedFunctionInNamespace4.ts | 2 +- tests/cases/fourslash/unusedFunctionInNamespace5.ts | 2 +- tests/cases/fourslash/unusedImports10FS.ts | 2 +- tests/cases/fourslash/unusedImports11FS.ts | 2 +- tests/cases/fourslash/unusedImports12FS.ts | 2 +- tests/cases/fourslash/unusedImports1FS.ts | 2 +- tests/cases/fourslash/unusedImports2FS.ts | 2 +- tests/cases/fourslash/unusedImports3FS.ts | 2 +- tests/cases/fourslash/unusedImports4FS.ts | 2 +- tests/cases/fourslash/unusedImports5FS.ts | 2 +- tests/cases/fourslash/unusedImports6FS.ts | 2 +- tests/cases/fourslash/unusedImports7FS.ts | 2 +- tests/cases/fourslash/unusedImports8FS.ts | 2 +- tests/cases/fourslash/unusedImports9FS.ts | 2 +- tests/cases/fourslash/unusedInterfaceInNamespace1.ts | 2 +- tests/cases/fourslash/unusedInterfaceInNamespace2.ts | 2 +- tests/cases/fourslash/unusedLocalsInFunction1.ts | 2 +- tests/cases/fourslash/unusedLocalsInFunction2.ts | 2 +- tests/cases/fourslash/unusedLocalsInFunction3.ts | 2 +- tests/cases/fourslash/unusedLocalsInFunction4.ts | 2 +- tests/cases/fourslash/unusedLocalsInMethodFS1.ts | 2 +- tests/cases/fourslash/unusedLocalsInMethodFS2.ts | 2 +- tests/cases/fourslash/unusedLocalsinConstructorFS1.ts | 2 +- tests/cases/fourslash/unusedLocalsinConstructorFS2.ts | 2 +- tests/cases/fourslash/unusedMethodInClass1.ts | 2 +- tests/cases/fourslash/unusedMethodInClass2.ts | 2 +- tests/cases/fourslash/unusedMethodInClass3.ts | 2 +- tests/cases/fourslash/unusedMethodInClass4.ts | 2 +- tests/cases/fourslash/unusedMethodInClass5.ts | 2 +- tests/cases/fourslash/unusedMethodInClass6.ts | 2 +- tests/cases/fourslash/unusedNamespaceInNamespace.ts | 2 +- tests/cases/fourslash/unusedParameterInConstructor1.ts | 2 +- tests/cases/fourslash/unusedParameterInConstructor2.ts | 2 +- tests/cases/fourslash/unusedParameterInConstructor3.ts | 2 +- tests/cases/fourslash/unusedParameterInConstructor4.ts | 2 +- tests/cases/fourslash/unusedParameterInFunction1.ts | 2 +- tests/cases/fourslash/unusedParameterInFunction2.ts | 2 +- tests/cases/fourslash/unusedParameterInFunction3.ts | 2 +- tests/cases/fourslash/unusedParameterInFunction4.ts | 2 +- tests/cases/fourslash/unusedParameterInLambda1.ts | 2 +- tests/cases/fourslash/unusedTypeAliasInNamespace1.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInClass1.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInClass2.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInClass3.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInFunction1.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInFunction2.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInFunction3.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInInterface1.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInLambda1.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInLambda2.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInLambda3.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInLambda4.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInMethod1.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInMethod2.ts | 2 +- tests/cases/fourslash/unusedTypeParametersInMethods1.ts | 2 +- tests/cases/fourslash/unusedVariableInBlocks.ts | 2 +- tests/cases/fourslash/unusedVariableInClass1.ts | 2 +- tests/cases/fourslash/unusedVariableInClass2.ts | 2 +- tests/cases/fourslash/unusedVariableInClass3.ts | 2 +- tests/cases/fourslash/unusedVariableInForLoop1FS.ts | 2 +- tests/cases/fourslash/unusedVariableInForLoop2FS.ts | 2 +- tests/cases/fourslash/unusedVariableInForLoop3FS.ts | 2 +- tests/cases/fourslash/unusedVariableInForLoop4FS.ts | 2 +- tests/cases/fourslash/unusedVariableInForLoop5FS.ts | 5 ++--- tests/cases/fourslash/unusedVariableInForLoop6FS.ts | 2 +- tests/cases/fourslash/unusedVariableInForLoop7FS.ts | 2 +- tests/cases/fourslash/unusedVariableInModule1.ts | 2 +- tests/cases/fourslash/unusedVariableInModule2.ts | 2 +- tests/cases/fourslash/unusedVariableInModule3.ts | 2 +- tests/cases/fourslash/unusedVariableInModule4.ts | 2 +- tests/cases/fourslash/unusedVariableInNamespace1.ts | 2 +- tests/cases/fourslash/unusedVariableInNamespace2.ts | 2 +- tests/cases/fourslash/unusedVariableInNamespace3.ts | 2 +- 83 files changed, 84 insertions(+), 85 deletions(-) diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts index e13c889d327..6b70adffb7c 100644 --- a/tests/cases/fourslash/unusedClassInNamespace1.ts +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -7,4 +7,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts index 0b6b7504633..54de4886bbd 100644 --- a/tests/cases/fourslash/unusedClassInNamespace2.ts +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -11,5 +11,5 @@ verify.rangeAfterCodeFix(`namespace greeter { export class class2 { } -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts index 95e691d3ee1..7f4b00fc3b8 100644 --- a/tests/cases/fourslash/unusedClassInNamespace3.ts +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -22,4 +22,4 @@ verify.rangeAfterCodeFix(`namespace Validation { export class c2 { } -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts index 8b856379acb..ab7cd44cc42 100644 --- a/tests/cases/fourslash/unusedClassInNamespace4.ts +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -24,4 +24,4 @@ verify.rangeAfterCodeFix(`namespace Validation { export class c2 { } -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts index b0fe913e722..14868d34f65 100644 --- a/tests/cases/fourslash/unusedConstantInFunction1.ts +++ b/tests/cases/fourslash/unusedConstantInFunction1.ts @@ -6,5 +6,5 @@ //// } |] verify.rangeAfterCodeFix(`function f1 () { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts index ae72b7b3da6..84f03ef488e 100644 --- a/tests/cases/fourslash/unusedEnumInFunction1.ts +++ b/tests/cases/fourslash/unusedEnumInFunction1.ts @@ -7,5 +7,5 @@ verify.rangeAfterCodeFix(`function f1 () { } -`); +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedEnumInNamespace1.ts b/tests/cases/fourslash/unusedEnumInNamespace1.ts index e856a084bfe..1f2998c466e 100644 --- a/tests/cases/fourslash/unusedEnumInNamespace1.ts +++ b/tests/cases/fourslash/unusedEnumInNamespace1.ts @@ -8,4 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index 7a63ff13caa..fe394fbccd1 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -8,4 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts index 5a2ac44d3d0..d32e9848772 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace2.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -11,4 +11,4 @@ verify.rangeAfterCodeFix(`namespace greeter { export function function2() { } -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts index 69df15cb3c7..1d8b5e74376 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace3.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -9,4 +9,4 @@ ////} |] verify.rangeAfterCodeFix(`namespace Validation { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts index 36ceb319ff9..f59169ed729 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace4.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -8,4 +8,4 @@ ////} |] verify.rangeAfterCodeFix(`namespace Validation { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts index 3c2f20ce082..85c638aaa43 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace5.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -25,4 +25,4 @@ verify.rangeAfterCodeFix(`function function3() { function1(); } - export let a = function3;`); + export let a = function3;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts index ea016b73cc2..9c12c576329 100644 --- a/tests/cases/fourslash/unusedImports10FS.ts +++ b/tests/cases/fourslash/unusedImports10FS.ts @@ -12,5 +12,5 @@ //// [|import a = A;|] //// } -verify.rangeAfterCodeFix(""); +verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedImports11FS.ts b/tests/cases/fourslash/unusedImports11FS.ts index c29b5612e88..9747279d4db 100644 --- a/tests/cases/fourslash/unusedImports11FS.ts +++ b/tests/cases/fourslash/unusedImports11FS.ts @@ -11,4 +11,4 @@ //// export function f2(s: string){}; //// export default f1; -verify.rangeAfterCodeFix('import * as s from "./file1";'); \ No newline at end of file +verify.rangeAfterCodeFix('import * as s from "./file1";', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports12FS.ts b/tests/cases/fourslash/unusedImports12FS.ts index d86bc98c6cf..54e12bf2f18 100644 --- a/tests/cases/fourslash/unusedImports12FS.ts +++ b/tests/cases/fourslash/unusedImports12FS.ts @@ -10,4 +10,4 @@ //// export function f2(s: string){}; //// export default f1; -verify.rangeAfterCodeFix('import f1 from "./file1";'); \ No newline at end of file +verify.rangeAfterCodeFix('import f1 from "./file1";', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts index 0fc2d36aac7..4c02cabc4ba 100644 --- a/tests/cases/fourslash/unusedImports1FS.ts +++ b/tests/cases/fourslash/unusedImports1FS.ts @@ -9,4 +9,4 @@ //// //// } -verify.rangeAfterCodeFix(''); +verify.rangeAfterCodeFix('', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts index 8865dea56a6..5dff4dc9237 100644 --- a/tests/cases/fourslash/unusedImports2FS.ts +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -16,4 +16,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ undefined); +verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ 0, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts index 6926f97bb4f..9cc53839f17 100644 --- a/tests/cases/fourslash/unusedImports3FS.ts +++ b/tests/cases/fourslash/unusedImports3FS.ts @@ -20,5 +20,5 @@ //// //// } -verify.rangeAfterCodeFix(`import {/*some comments*/ test, test2} from "./file1"`); +verify.rangeAfterCodeFix(`import {/*some comments*/ test, test2} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts index 4f7e8882429..a923bd389c9 100644 --- a/tests/cases/fourslash/unusedImports4FS.ts +++ b/tests/cases/fourslash/unusedImports4FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator, test2} from "./file1"`); \ No newline at end of file +verify.rangeAfterCodeFix(`import {Calculator, test2} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts index 15262df01fd..11def13df4d 100644 --- a/tests/cases/fourslash/unusedImports5FS.ts +++ b/tests/cases/fourslash/unusedImports5FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator, test} from "./file1"`); \ No newline at end of file +verify.rangeAfterCodeFix(`import {Calculator, test} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts index 1d6a9a3232e..36ef2813ee0 100644 --- a/tests/cases/fourslash/unusedImports6FS.ts +++ b/tests/cases/fourslash/unusedImports6FS.ts @@ -17,4 +17,4 @@ //// //// } -verify.rangeAfterCodeFix(''); \ No newline at end of file +verify.rangeAfterCodeFix('', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts index 1a23ea85925..bacca3a06a8 100644 --- a/tests/cases/fourslash/unusedImports7FS.ts +++ b/tests/cases/fourslash/unusedImports7FS.ts @@ -13,4 +13,4 @@ //// export default function test2() { //// } -verify.rangeAfterCodeFix(''); \ No newline at end of file +verify.rangeAfterCodeFix('', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts index 81bdeda36ac..3b01b54a342 100644 --- a/tests/cases/fourslash/unusedImports8FS.ts +++ b/tests/cases/fourslash/unusedImports8FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator as calc, test as t1} from "./file1"`); \ No newline at end of file +verify.rangeAfterCodeFix(`import {Calculator as calc, test as t1} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts index f81f9a9f5ae..bea5517574d 100644 --- a/tests/cases/fourslash/unusedImports9FS.ts +++ b/tests/cases/fourslash/unusedImports9FS.ts @@ -17,4 +17,4 @@ //// //// } -verify.rangeAfterCodeFix(""); \ No newline at end of file +verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts index f979069690b..b9410f41a58 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(` namespace greeter { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts index 7737f9ce247..0155b851f93 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -9,4 +9,4 @@ ////} verify.rangeAfterCodeFix(`export interface interface2 { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts index e74f5dbd962..cf165184671 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction1.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -7,4 +7,4 @@ verify.rangeAfterCodeFix(` function greeter() { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts index 83816e68038..2da97abea20 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction2.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -6,4 +6,4 @@ //// x+1; ////} -verify.rangeAfterCodeFix("var x;"); +verify.rangeAfterCodeFix("var x;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts index 0164873acd8..ba3f73b5bd0 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction3.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -7,4 +7,4 @@ //// z+1; ////} -verify.rangeAfterCodeFix("var x,z = 1;", /*includeWhiteSpace*/ undefined, 6133); +verify.rangeAfterCodeFix("var x,z = 1;", /*includeWhiteSpace*/ undefined, /*errorCode*/ 6133, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index a458d6d824c..62cbf589d76 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -7,4 +7,4 @@ //// z++; ////} -verify.rangeAfterCodeFix("var y = 0,z = 1;"); +verify.rangeAfterCodeFix("var y = 0,z = 1;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index dc73ab86663..8ed3e080143 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix("var y = 10;"); +verify.rangeAfterCodeFix("var y = 10;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 012bf87a222..9104ba3973a 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix("var y;"); +verify.rangeAfterCodeFix("var y;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts index 4ed58d3142d..c091562f8a4 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -9,4 +9,4 @@ ////} verify.rangeAfterCodeFix(`constructor() { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts index eeaf66050d4..764f380e49b 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -15,4 +15,4 @@ verify.rangeAfterCodeFix(` var used = "dummy"; used = used + "second part"; } -`); \ No newline at end of file +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts index a5e3789c8af..43cc2d192c2 100644 --- a/tests/cases/fourslash/unusedMethodInClass1.ts +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(` class greeter { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts index cce621236d4..51db9367deb 100644 --- a/tests/cases/fourslash/unusedMethodInClass2.ts +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -12,4 +12,4 @@ verify.rangeAfterCodeFix(` class greeter { public function2() { } -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts index ccf98c4bbc5..f07f0f4a892 100644 --- a/tests/cases/fourslash/unusedMethodInClass3.ts +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(` class greeter { -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts index 962b80f5bc1..19ad173e76b 100644 --- a/tests/cases/fourslash/unusedMethodInClass4.ts +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -9,4 +9,4 @@ ////} verify.rangeAfterCodeFix(`public function2(){ -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedMethodInClass5.ts b/tests/cases/fourslash/unusedMethodInClass5.ts index 806e619817f..ac27874bafe 100644 --- a/tests/cases/fourslash/unusedMethodInClass5.ts +++ b/tests/cases/fourslash/unusedMethodInClass5.ts @@ -5,4 +5,4 @@ //// private ["string"] (){} //// }|] -verify.rangeAfterCodeFix("class C { }"); \ No newline at end of file +verify.rangeAfterCodeFix("class C { }", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass6.ts b/tests/cases/fourslash/unusedMethodInClass6.ts index d223b3d6857..b8c65c56fa1 100644 --- a/tests/cases/fourslash/unusedMethodInClass6.ts +++ b/tests/cases/fourslash/unusedMethodInClass6.ts @@ -5,4 +5,4 @@ //// private "string" (){} //// }|] -verify.rangeAfterCodeFix("class C { }"); \ No newline at end of file +verify.rangeAfterCodeFix("class C { }", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts index 802336454c6..5f1892e1a2f 100644 --- a/tests/cases/fourslash/unusedNamespaceInNamespace.ts +++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts @@ -9,5 +9,5 @@ verify.rangeAfterCodeFix(` namespace A { } -`); +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts index 36539e6649b..33fe34c7e61 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor1.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor1.ts @@ -5,4 +5,4 @@ //// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; } //// } -verify.rangeAfterCodeFix("constructor(public p2: boolean, public p3: any, p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(public p2: boolean, public p3: any, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor2.ts b/tests/cases/fourslash/unusedParameterInConstructor2.ts index e822a2f248d..71595a9c81c 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor2.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor2.ts @@ -5,4 +5,4 @@ //// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; } //// } -verify.rangeAfterCodeFix("constructor(public p1: string, public p3: any, p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(public p1: string, public p3: any, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor3.ts b/tests/cases/fourslash/unusedParameterInConstructor3.ts index 1a9682aece3..3da0e85407f 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor3.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor3.ts @@ -5,4 +5,4 @@ //// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; } //// } -verify.rangeAfterCodeFix("constructor(public p1: string, public p2: boolean, p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(public p1: string, public p2: boolean, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInConstructor4.ts b/tests/cases/fourslash/unusedParameterInConstructor4.ts index 01df43718da..860a7befa9b 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor4.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor4.ts @@ -5,4 +5,4 @@ //// [|constructor(private readonly p2: boolean, p5)|] { p5; } //// } -verify.rangeAfterCodeFix("constructor(p5)"); \ No newline at end of file +verify.rangeAfterCodeFix("constructor(p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts index baaccbbd20f..bc6f081ecaa 100644 --- a/tests/cases/fourslash/unusedParameterInFunction1.ts +++ b/tests/cases/fourslash/unusedParameterInFunction1.ts @@ -4,4 +4,4 @@ ////function [|greeter( x)|] { ////} -verify.rangeAfterCodeFix("greeter()"); +verify.rangeAfterCodeFix("greeter()", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts index 0e448c98fcc..81e73450622 100644 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -5,4 +5,4 @@ //// x++; ////} -verify.rangeAfterCodeFix("greeter(x)"); \ No newline at end of file +verify.rangeAfterCodeFix("greeter(x)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts index 23f45475950..dcbe53163db 100644 --- a/tests/cases/fourslash/unusedParameterInFunction3.ts +++ b/tests/cases/fourslash/unusedParameterInFunction3.ts @@ -5,4 +5,4 @@ //// y++; ////} -verify.rangeAfterCodeFix("greeter(y)"); \ No newline at end of file +verify.rangeAfterCodeFix("greeter(y)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts index 1f98238d647..4ea96b3bd18 100644 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -6,4 +6,4 @@ //// z++; ////} -verify.rangeAfterCodeFix("function greeter(x,z)"); \ No newline at end of file +verify.rangeAfterCodeFix("function greeter(x,z)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts index 166d250fee7..a5f735c7016 100644 --- a/tests/cases/fourslash/unusedParameterInLambda1.ts +++ b/tests/cases/fourslash/unusedParameterInLambda1.ts @@ -6,4 +6,4 @@ //// [|return (x:number) => {}|] //// } -verify.rangeAfterCodeFix("return () => {}"); +verify.rangeAfterCodeFix("return () => {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts index 2314ebbe447..bd7c914a614 100644 --- a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts +++ b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(`namespace greeter { export type nw = "No" | "Way"; -}`); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts index 322921ab471..ba31e053727 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -4,4 +4,4 @@ ////[|class greeter |] { ////} -verify.rangeAfterCodeFix("class greeter"); \ No newline at end of file +verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts index feaf9d3a14b..a56f1cf827b 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -5,4 +5,4 @@ //// public a: X; ////} -verify.rangeAfterCodeFix("class greeter"); \ No newline at end of file +verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts index b1151265fe3..e5f90dd4066 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -6,4 +6,4 @@ //// public b: Z; ////} -verify.rangeAfterCodeFix("class greeter"); +verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts index a11156badaa..d5755275a5a 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1() {}|] -verify.rangeAfterCodeFix("function f1() {}"); +verify.rangeAfterCodeFix("function f1() {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts index a011f093dab..f20010402a8 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1(a: X) {a}|] -verify.rangeAfterCodeFix("function f1(a: X) {a}"); +verify.rangeAfterCodeFix("function f1(a: X) {a}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts index 6dc56ccc7cb..5e46ca56aff 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1(a: X) {a;var b:Z;b}|] -verify.rangeAfterCodeFix("function f1(a: X) {a;var b:Z;b}"); +verify.rangeAfterCodeFix("function f1(a: X) {a;var b:Z;b}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts index b5363b369be..6ce19679fce 100644 --- a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts @@ -4,4 +4,4 @@ // @noUnusedParameters: true //// [|interface I {}|] -verify.rangeAfterCodeFix("interface I {}"); \ No newline at end of file +verify.rangeAfterCodeFix("interface I {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts index 01c1ebd24f5..8f094b73170 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts @@ -6,4 +6,4 @@ //// [|return (x:number) => {x}|] //// } -verify.rangeAfterCodeFix("return (x:number) => {x}"); +verify.rangeAfterCodeFix("return (x:number) => {x}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts index e5a4acc31c5..fc9ccc80f8f 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts @@ -6,4 +6,4 @@ //// [|new (a: T): void;|] //// } -verify.rangeAfterCodeFix("new (a: T): void;"); +verify.rangeAfterCodeFix("new (a: T): void;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts index e6d866dcb6a..1d2fb9af8d6 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts @@ -7,4 +7,4 @@ //// [|new (a: T): A;|] //// } -verify.rangeAfterCodeFix("new (a: T): A;"); +verify.rangeAfterCodeFix("new (a: T): A;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts index 04bd7c7e9be..a34e344d17d 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts @@ -6,4 +6,4 @@ //// } //// [|var y: new (a:T)=>void;|] -verify.rangeAfterCodeFix("var y: new (a:T)=>void;"); \ No newline at end of file +verify.rangeAfterCodeFix("var y: new (a:T)=>void;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts index bc14952eca9..36a124fc424 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts @@ -5,4 +5,4 @@ //// [|f1()|] {} //// } -verify.rangeAfterCodeFix("f1()"); \ No newline at end of file +verify.rangeAfterCodeFix("f1()", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts index c12fd53f66b..1d7203f86ac 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts @@ -5,4 +5,4 @@ //// [|f1(a: U)|] {a;} //// } -verify.rangeAfterCodeFix("f1(a: U)"); \ No newline at end of file +verify.rangeAfterCodeFix("f1(a: U)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts index d0b170491f5..2a4822628ce 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts @@ -5,4 +5,4 @@ //// [|public f1(a: X)|] { a; var b: Z; b } //// } -verify.rangeAfterCodeFix("public f1(a: X)"); +verify.rangeAfterCodeFix("public f1(a: X)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts index 2a33d0c4cf5..51deb5c313d 100644 --- a/tests/cases/fourslash/unusedVariableInBlocks.ts +++ b/tests/cases/fourslash/unusedVariableInBlocks.ts @@ -12,4 +12,4 @@ verify.rangeAfterCodeFix(`let x = 10; { } - x;`); + x;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts index 8b0ca0db727..177cf7f0197 100644 --- a/tests/cases/fourslash/unusedVariableInClass1.ts +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -5,4 +5,4 @@ //// [|private greeting: string;|] ////} -verify.rangeAfterCodeFix(""); +verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts index 6503dd02872..2f5cf2e3278 100644 --- a/tests/cases/fourslash/unusedVariableInClass2.ts +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -6,4 +6,4 @@ //// private greeting: string;|] ////} -verify.rangeAfterCodeFix("public greeting1;"); +verify.rangeAfterCodeFix("public greeting1;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts index 3ac306170a2..1e05c00f0a1 100644 --- a/tests/cases/fourslash/unusedVariableInClass3.ts +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -5,4 +5,4 @@ //// private X = function() {}; ////|]} -verify.rangeAfterCodeFix(""); +verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts index 760d8487b34..15727ab70a7 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts @@ -7,5 +7,5 @@ //// } //// } -verify.rangeAfterCodeFix("for(; ;)"); +verify.rangeAfterCodeFix("for(; ;)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts index a16f21e8417..5a06ad036f4 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix("for(var i = 0; ;i++)"); +verify.rangeAfterCodeFix("for(var i = 0; ;i++)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts index 07d13307ca7..32bb54c2241 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix("for(var i = 0, k=0; ;i++,k++)"); \ No newline at end of file +verify.rangeAfterCodeFix("for(var i = 0, k=0; ;i++,k++)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts index d54f8baaa3d..c5589366245 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix("for(var j = 0, k=0; ;j++,k++)"); +verify.rangeAfterCodeFix("for(var j = 0, k=0; ;j++,k++)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts index 23df03480e3..fdcc51f696f 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts @@ -2,10 +2,9 @@ // @noUnusedLocals: true //// function f1 () { -//// for (const elem in ["a", "b", "c"]) { +//// [|for (const elem in ["a", "b", "c"]) |]{ //// //// } //// } -verify.not.codeFixAvailable(); - +verify.rangeAfterCodeFix(`for (const _elem in ["a", "b", "c"])`, /*includeWhiteSpace*/ true, /*errorCode*/ 0, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts index a7b8fbfb7c8..fa1948438bc 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts @@ -7,5 +7,5 @@ //// } //// } -verify.rangeAfterCodeFix("const {} of "); +verify.rangeAfterCodeFix("const {} of ", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 7f99863ba46..94f4defca01 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -13,4 +13,4 @@ verify.rangeAfterCodeFix(`{ for (const elem of ["a", "b", "c"]) { elem; } -}`, /*includeWhiteSpace*/ true); +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts index e9fe9515e6d..115af8bc15d 100644 --- a/tests/cases/fourslash/unusedVariableInModule1.ts +++ b/tests/cases/fourslash/unusedVariableInModule1.ts @@ -6,4 +6,4 @@ //// [|var x: string; //// export var y: string;|] -verify.rangeAfterCodeFix("export var y: string;"); +verify.rangeAfterCodeFix("export var y: string;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts index ac6e7120d8b..d2aeea0e82b 100644 --- a/tests/cases/fourslash/unusedVariableInModule2.ts +++ b/tests/cases/fourslash/unusedVariableInModule2.ts @@ -7,4 +7,4 @@ //// z; //// export var y: string; -verify.rangeAfterCodeFix("var z: number;"); +verify.rangeAfterCodeFix("var z: number;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts index 0185b89e3a6..f7d565dd50b 100644 --- a/tests/cases/fourslash/unusedVariableInModule3.ts +++ b/tests/cases/fourslash/unusedVariableInModule3.ts @@ -6,4 +6,4 @@ //// [|var x = function f1() {} //// export var y: string;|] -verify.rangeAfterCodeFix("export var y: string;"); +verify.rangeAfterCodeFix("export var y: string;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts index 8f23d56b03c..6d80d59c2ce 100644 --- a/tests/cases/fourslash/unusedVariableInModule4.ts +++ b/tests/cases/fourslash/unusedVariableInModule4.ts @@ -7,4 +7,4 @@ //// x; //// export var y: string; -verify.rangeAfterCodeFix(`var x = function f1() {}`); +verify.rangeAfterCodeFix(`var x = function f1() {}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts index c9f38473a51..d90b7e50603 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace1.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -5,4 +5,4 @@ //// [|let a = "dummy entry";|] ////} -verify.rangeAfterCodeFix(""); +verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index 992c229014a..664d76130b4 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix(`let a = "dummy entry", c = 0;`); +verify.rangeAfterCodeFix(`let a = "dummy entry", c = 0;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index 0039036b2f8..4de5c0f1534 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix(`let a = "dummy entry", b;`); +verify.rangeAfterCodeFix(`let a = "dummy entry", b;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); From d9a68e3fb0b3b013c8ae01d3d5a2091cdc0a0825 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 6 Jun 2017 14:22:11 -0700 Subject: [PATCH 4/9] add tests for trivia --- .../fourslash/unusedClassInNamespaceWithTrivia.ts | 11 +++++++++++ ...nusedClassInNamespaceWithTriviaAddUnderscore.ts | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts create mode 100644 tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts diff --git a/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts b/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts new file mode 100644 index 00000000000..d491ad24d7a --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// /* comment1 */ +//// class /* comment2 */ class1 { +//// } +//// } |] + +verify.rangeAfterCodeFix(`namespace greeter { +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts b/tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts new file mode 100644 index 00000000000..524b0abebc9 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts @@ -0,0 +1,14 @@ +/// + +// @noUnusedLocals: true +//// [| namespace greeter { +//// /* comment1 */ +//// class /* comment2 */ class1 { +//// } +//// } |] + +verify.rangeAfterCodeFix(`namespace greeter { + /* comment1 */ + class /* comment2 */ _class1 { + } +}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); From ce5f7072a10bdaa8ea85dee0ed3b551b6bde5998 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 6 Jun 2017 14:24:06 -0700 Subject: [PATCH 5/9] prefix identifiers --- src/compiler/diagnosticMessages.json | 4 ++ src/services/codefixes/fixUnusedIdentifier.ts | 64 +++++++++++-------- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 70efe50143e..fda9cd8a153 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3621,6 +3621,10 @@ "category": "Message", "code": 90024 }, + "Prefix '{0}' with an underscore.": { + "category": "Message", + "code": 90025 + }, "Convert function to an ES2015 class": { "category": "Message", diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index 5d85979fcf9..c3e7e2bb4f2 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -18,7 +18,9 @@ namespace ts.codefix { switch (token.kind) { case ts.SyntaxKind.Identifier: - return deleteIdentifier(); + let actions = deleteIdentifier(token); + (actions || (actions = [])).push(prefixIdentifierWithUnderscore(token)); + return actions; case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: @@ -40,58 +42,68 @@ namespace ts.codefix { } } - function deleteIdentifier(): CodeAction[] | undefined { - switch (token.parent.kind) { + function prefixIdentifierWithUnderscore(identifier: Identifier): CodeAction { + // TODO: make sure this work with prefixing trivia. + const startPosition = identifier.getStart(sourceFile, /*includeJsDocComment*/ false); + return { + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Prefix_0_with_an_underscore), { 0: token.getText() }), + changes: [{ + fileName: sourceFile.path, + textChanges: [{ + span: { start: startPosition, length: 0 }, + newText: "_" + }] + }] + }; + } + + function deleteIdentifier(identifier: Identifier): CodeAction[] | undefined { + const parent = identifier.parent; + switch (parent.kind) { case ts.SyntaxKind.VariableDeclaration: - return deleteVariableDeclaration(token.parent); + return deleteVariableDeclaration(parent); case SyntaxKind.TypeParameter: - const typeParameters = (token.parent.parent).typeParameters; + const typeParameters = (parent.parent).typeParameters; if (typeParameters.length === 1) { const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1, /*includeJsDocComment*/ false); - if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) { - return deleteRange(typeParameters); - } const nextToken = getTokenAtPosition(sourceFile, typeParameters.end, /*includeJsDocComment*/ false); - if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) { - return deleteRange(typeParameters); - } + Debug.assert(previousToken.kind === SyntaxKind.LessThanToken); + Debug.assert(nextToken.kind === SyntaxKind.GreaterThanToken); + return deleteNodeRange(previousToken, nextToken); } else { - return deleteNodeInList(token.parent); + return deleteNodeInList(parent); } case ts.SyntaxKind.Parameter: - const functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return deleteNode(token.parent); - } - else { - return deleteNodeInList(token.parent); - } + const functionDeclaration = parent.parent; + return functionDeclaration.parameters.length === 1 ? + deleteNode(parent) : + deleteNodeInList(parent); // handle case where 'import a = A;' case SyntaxKind.ImportEqualsDeclaration: - const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration); + const importEquals = getAncestor(identifier, SyntaxKind.ImportEqualsDeclaration); return deleteNode(importEquals); case SyntaxKind.ImportSpecifier: - const namedImports = token.parent.parent; + const namedImports = parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. - const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration); + const importSpec = getAncestor(identifier, SyntaxKind.ImportDeclaration); return deleteNode(importSpec); } else { // delete import specifier - return deleteNodeInList(token.parent); + return deleteNodeInList(parent); } // 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; + const importClause = parent; if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); return deleteNode(importDecl); @@ -110,8 +122,8 @@ namespace ts.codefix { } case SyntaxKind.NamespaceImport: - const namespaceImport = token.parent; - if (namespaceImport.name === token && !(namespaceImport.parent).name) { + const namespaceImport = parent; + if (namespaceImport.name === identifier && !(namespaceImport.parent).name) { const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); return deleteNode(importDecl); } From b9885eed5a2df9713f703774d63e65d3d4342f56 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 8 Jun 2017 18:43:02 -0700 Subject: [PATCH 6/9] Only add underscore in * for-in * for-of * parameters --- src/services/codefixes/fixUnusedIdentifier.ts | 68 +++++++++---------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index c3e7e2bb4f2..cbe2ba5b1c5 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -18,16 +18,14 @@ namespace ts.codefix { switch (token.kind) { case ts.SyntaxKind.Identifier: - let actions = deleteIdentifier(token); - (actions || (actions = [])).push(prefixIdentifierWithUnderscore(token)); - return actions; + return deleteIdentifierOrPrefixWithUnderscore(token); case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: - return deleteNode(token.parent); + return [deleteNode(token.parent)]; default: - return deleteDefault(); + return [deleteDefault()]; } function deleteDefault() { @@ -43,7 +41,6 @@ namespace ts.codefix { } function prefixIdentifierWithUnderscore(identifier: Identifier): CodeAction { - // TODO: make sure this work with prefixing trivia. const startPosition = identifier.getStart(sourceFile, /*includeJsDocComment*/ false); return { description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Prefix_0_with_an_underscore), { 0: token.getText() }), @@ -57,11 +54,11 @@ namespace ts.codefix { }; } - function deleteIdentifier(identifier: Identifier): CodeAction[] | undefined { + function deleteIdentifierOrPrefixWithUnderscore(identifier: Identifier): CodeAction[] | undefined { const parent = identifier.parent; switch (parent.kind) { case ts.SyntaxKind.VariableDeclaration: - return deleteVariableDeclaration(parent); + return deleteVariableDeclarationOrPrefixWithUnderscore(identifier, parent); case SyntaxKind.TypeParameter: const typeParameters = (parent.parent).typeParameters; @@ -71,33 +68,32 @@ namespace ts.codefix { Debug.assert(previousToken.kind === SyntaxKind.LessThanToken); Debug.assert(nextToken.kind === SyntaxKind.GreaterThanToken); - return deleteNodeRange(previousToken, nextToken); + return [deleteNodeRange(previousToken, nextToken)]; } else { - return deleteNodeInList(parent); + return [deleteNodeInList(parent)]; } case ts.SyntaxKind.Parameter: const functionDeclaration = parent.parent; - return functionDeclaration.parameters.length === 1 ? - deleteNode(parent) : - deleteNodeInList(parent); + return [functionDeclaration.parameters.length === 1 ? deleteNode(parent) : deleteNodeInList(parent), + prefixIdentifierWithUnderscore(identifier)]; // handle case where 'import a = A;' case SyntaxKind.ImportEqualsDeclaration: const importEquals = getAncestor(identifier, SyntaxKind.ImportEqualsDeclaration); - return deleteNode(importEquals); + return [deleteNode(importEquals)]; case SyntaxKind.ImportSpecifier: const namedImports = parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. const importSpec = getAncestor(identifier, SyntaxKind.ImportDeclaration); - return deleteNode(importSpec); + return [deleteNode(importSpec)]; } else { // delete import specifier - return deleteNodeInList(parent); + return [deleteNodeInList(parent)]; } // handle case where "import d, * as ns from './file'" @@ -106,7 +102,7 @@ namespace ts.codefix { const importClause = parent; if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); - return deleteNode(importDecl); + return [deleteNode(importDecl)]; } else { // import |d,| * as ns from './file' @@ -114,10 +110,10 @@ namespace ts.codefix { const nextToken = getTokenAtPosition(sourceFile, importClause.name.end, /*includeJsDocComment*/ false); if (nextToken && nextToken.kind === SyntaxKind.CommaToken) { // shift first non-whitespace position after comma to the start position of the node - return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) }); + return [deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) })]; } else { - return deleteNode(importClause.name); + return [deleteNode(importClause.name)]; } } @@ -125,53 +121,51 @@ namespace ts.codefix { const namespaceImport = parent; if (namespaceImport.name === identifier && !(namespaceImport.parent).name) { const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); - return deleteNode(importDecl); + return [deleteNode(importDecl)]; } else { const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1, /*includeJsDocComment*/ false); if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart); - return deleteRange({ pos: startPosition, end: namespaceImport.end }); + return [deleteRange({ pos: startPosition, end: namespaceImport.end })]; } - return deleteRange(namespaceImport); + return [deleteRange(namespaceImport)]; } default: - return deleteDefault(); + return [deleteDefault()]; } } // token.parent is a variableDeclaration - function deleteVariableDeclaration(varDecl: ts.VariableDeclaration): CodeAction[] | undefined { + function deleteVariableDeclarationOrPrefixWithUnderscore(identifier: Identifier, varDecl: ts.VariableDeclaration): CodeAction[] | undefined { switch (varDecl.parent.parent.kind) { case SyntaxKind.ForStatement: const forStatement = varDecl.parent.parent; const forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return deleteNode(forInitializer); - } - else { - return deleteNodeInList(varDecl); - } + return [forInitializer.declarations.length === 1 ? deleteNode(forInitializer) : deleteNodeInList(varDecl)]; case SyntaxKind.ForOfStatement: const forOfStatement = varDecl.parent.parent; Debug.assert(forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList); const forOfInitializer = forOfStatement.initializer; - return replaceNode(forOfInitializer.declarations[0], createObjectLiteral()); + return [ + replaceNode(forOfInitializer.declarations[0], createObjectLiteral()), + prefixIdentifierWithUnderscore(identifier) + ]; case SyntaxKind.ForInStatement: // There is no valid fix in the case of: // for .. in - return undefined; + return [prefixIdentifierWithUnderscore(identifier)]; default: const variableStatement = varDecl.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return deleteNode(variableStatement); + return [deleteNode(variableStatement)]; } else { - return deleteNodeInList(varDecl); + return [deleteNodeInList(varDecl)]; } } } @@ -196,11 +190,11 @@ namespace ts.codefix { return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); } - function makeChange(changeTracker: textChanges.ChangeTracker) { - return [{ + function makeChange(changeTracker: textChanges.ChangeTracker): CodeAction { + return { description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), changes: changeTracker.getChanges() - }]; + }; } } }); From ab8e0d53d0f4cb26318c134dbf4130934651af81 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 8 Jun 2017 18:59:30 -0700 Subject: [PATCH 7/9] revert test changes --- .../fourslash/unusedClassInNamespace1.ts | 2 +- .../unusedClassInNamespace1AddUnderscore.ts | 11 ----------- .../fourslash/unusedClassInNamespace2.ts | 2 +- .../fourslash/unusedClassInNamespace3.ts | 2 +- .../fourslash/unusedClassInNamespace4.ts | 2 +- .../unusedClassInNamespaceWithTrivia.ts | 2 +- ...ClassInNamespaceWithTriviaAddUnderscore.ts | 14 -------------- .../fourslash/unusedConstantInFunction1.ts | 2 +- .../cases/fourslash/unusedEnumInFunction1.ts | 2 +- .../cases/fourslash/unusedEnumInNamespace1.ts | 2 +- .../unusedFunctionInNamespac4AddUnderscore.ts | 13 ------------- .../fourslash/unusedFunctionInNamespace1.ts | 2 +- .../fourslash/unusedFunctionInNamespace2.ts | 2 +- .../fourslash/unusedFunctionInNamespace3.ts | 2 +- .../fourslash/unusedFunctionInNamespace4.ts | 2 +- .../fourslash/unusedFunctionInNamespace5.ts | 2 +- tests/cases/fourslash/unusedImports10FS.ts | 2 +- tests/cases/fourslash/unusedImports11FS.ts | 2 +- tests/cases/fourslash/unusedImports12FS.ts | 2 +- tests/cases/fourslash/unusedImports1FS.ts | 2 +- tests/cases/fourslash/unusedImports2FS.ts | 2 +- tests/cases/fourslash/unusedImports3FS.ts | 2 +- tests/cases/fourslash/unusedImports4FS.ts | 2 +- tests/cases/fourslash/unusedImports5FS.ts | 2 +- tests/cases/fourslash/unusedImports6FS.ts | 2 +- tests/cases/fourslash/unusedImports7FS.ts | 2 +- tests/cases/fourslash/unusedImports8FS.ts | 2 +- tests/cases/fourslash/unusedImports9FS.ts | 2 +- .../fourslash/unusedInterfaceInNamespace1.ts | 2 +- .../fourslash/unusedInterfaceInNamespace2.ts | 2 +- .../fourslash/unusedLocalsInFunction1.ts | 2 +- .../fourslash/unusedLocalsInFunction2.ts | 2 +- .../fourslash/unusedLocalsInFunction3.ts | 2 +- .../fourslash/unusedLocalsInFunction4.ts | 2 +- .../fourslash/unusedLocalsInMethodFS1.ts | 2 +- .../fourslash/unusedLocalsInMethodFS2.ts | 2 +- .../fourslash/unusedLocalsinConstructorFS1.ts | 2 +- .../fourslash/unusedLocalsinConstructorFS2.ts | 2 +- ...usedLocalsinConstructorFS2AddUnderscore.ts | 19 ------------------- tests/cases/fourslash/unusedMethodInClass1.ts | 2 +- tests/cases/fourslash/unusedMethodInClass2.ts | 2 +- tests/cases/fourslash/unusedMethodInClass3.ts | 2 +- tests/cases/fourslash/unusedMethodInClass4.ts | 2 +- tests/cases/fourslash/unusedMethodInClass5.ts | 2 +- tests/cases/fourslash/unusedMethodInClass6.ts | 2 +- .../fourslash/unusedNamespaceInNamespace.ts | 2 +- .../fourslash/unusedTypeAliasInNamespace1.ts | 2 +- .../fourslash/unusedTypeParametersInClass1.ts | 2 +- .../fourslash/unusedTypeParametersInClass2.ts | 2 +- .../fourslash/unusedTypeParametersInClass3.ts | 2 +- ...usedTypeParametersInClass3AddUnderscore.ts | 9 --------- .../unusedTypeParametersInFunction1.ts | 2 +- .../unusedTypeParametersInFunction2.ts | 2 +- .../unusedTypeParametersInFunction3.ts | 2 +- .../unusedTypeParametersInInterface1.ts | 2 +- .../unusedTypeParametersInLambda1.ts | 2 +- .../unusedTypeParametersInLambda2.ts | 2 +- .../unusedTypeParametersInLambda3.ts | 2 +- .../unusedTypeParametersInLambda4.ts | 2 +- .../unusedTypeParametersInMethod1.ts | 2 +- .../unusedTypeParametersInMethod2.ts | 2 +- .../unusedTypeParametersInMethods1.ts | 2 +- .../cases/fourslash/unusedVariableInBlocks.ts | 2 +- .../cases/fourslash/unusedVariableInClass1.ts | 2 +- .../cases/fourslash/unusedVariableInClass2.ts | 2 +- .../cases/fourslash/unusedVariableInClass3.ts | 2 +- .../fourslash/unusedVariableInForLoop1FS.ts | 2 +- .../fourslash/unusedVariableInForLoop2FS.ts | 2 +- .../fourslash/unusedVariableInForLoop3FS.ts | 2 +- .../fourslash/unusedVariableInForLoop4FS.ts | 2 +- .../fourslash/unusedVariableInForLoop5FS.ts | 2 +- .../fourslash/unusedVariableInForLoop7FS.ts | 2 +- .../fourslash/unusedVariableInModule1.ts | 2 +- .../fourslash/unusedVariableInModule2.ts | 2 +- .../fourslash/unusedVariableInModule3.ts | 2 +- .../fourslash/unusedVariableInNamespace1.ts | 2 +- .../fourslash/unusedVariableInNamespace2.ts | 2 +- .../fourslash/unusedVariableInNamespace3.ts | 2 +- 78 files changed, 73 insertions(+), 139 deletions(-) delete mode 100644 tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts delete mode 100644 tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts delete mode 100644 tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts delete mode 100644 tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts delete mode 100644 tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts index 6b70adffb7c..e13c889d327 100644 --- a/tests/cases/fourslash/unusedClassInNamespace1.ts +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -7,4 +7,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts b/tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts deleted file mode 100644 index 8f8ceab8615..00000000000 --- a/tests/cases/fourslash/unusedClassInNamespace1AddUnderscore.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// class class1 { -//// } -//// } |] - -verify.rangeAfterCodeFix(`namespace greeter { - class _class1 { } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts index 54de4886bbd..0b6b7504633 100644 --- a/tests/cases/fourslash/unusedClassInNamespace2.ts +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -11,5 +11,5 @@ verify.rangeAfterCodeFix(`namespace greeter { export class class2 { } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts index 7f4b00fc3b8..95e691d3ee1 100644 --- a/tests/cases/fourslash/unusedClassInNamespace3.ts +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -22,4 +22,4 @@ verify.rangeAfterCodeFix(`namespace Validation { export class c2 { } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts index ab7cd44cc42..8b856379acb 100644 --- a/tests/cases/fourslash/unusedClassInNamespace4.ts +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -24,4 +24,4 @@ verify.rangeAfterCodeFix(`namespace Validation { export class c2 { } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts b/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts index d491ad24d7a..cae0c52ac79 100644 --- a/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts +++ b/tests/cases/fourslash/unusedClassInNamespaceWithTrivia.ts @@ -8,4 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts b/tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts deleted file mode 100644 index 524b0abebc9..00000000000 --- a/tests/cases/fourslash/unusedClassInNamespaceWithTriviaAddUnderscore.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -// @noUnusedLocals: true -//// [| namespace greeter { -//// /* comment1 */ -//// class /* comment2 */ class1 { -//// } -//// } |] - -verify.rangeAfterCodeFix(`namespace greeter { - /* comment1 */ - class /* comment2 */ _class1 { - } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts index 14868d34f65..b0fe913e722 100644 --- a/tests/cases/fourslash/unusedConstantInFunction1.ts +++ b/tests/cases/fourslash/unusedConstantInFunction1.ts @@ -6,5 +6,5 @@ //// } |] verify.rangeAfterCodeFix(`function f1 () { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts index 84f03ef488e..ae72b7b3da6 100644 --- a/tests/cases/fourslash/unusedEnumInFunction1.ts +++ b/tests/cases/fourslash/unusedEnumInFunction1.ts @@ -7,5 +7,5 @@ verify.rangeAfterCodeFix(`function f1 () { } -`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +`); diff --git a/tests/cases/fourslash/unusedEnumInNamespace1.ts b/tests/cases/fourslash/unusedEnumInNamespace1.ts index 1f2998c466e..e856a084bfe 100644 --- a/tests/cases/fourslash/unusedEnumInNamespace1.ts +++ b/tests/cases/fourslash/unusedEnumInNamespace1.ts @@ -8,4 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts b/tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts deleted file mode 100644 index a017fd81f1f..00000000000 --- a/tests/cases/fourslash/unusedFunctionInNamespac4AddUnderscore.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters:true -//// [| namespace Validation { -//// var function1 = function() { -//// } -////} |] - -verify.rangeAfterCodeFix(`namespace Validation { - var _function1 = function() { - } -} `, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index fe394fbccd1..7a63ff13caa 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -8,4 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts index d32e9848772..5a2ac44d3d0 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace2.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -11,4 +11,4 @@ verify.rangeAfterCodeFix(`namespace greeter { export function function2() { } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts index 1d8b5e74376..69df15cb3c7 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace3.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -9,4 +9,4 @@ ////} |] verify.rangeAfterCodeFix(`namespace Validation { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts index f59169ed729..36ceb319ff9 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace4.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -8,4 +8,4 @@ ////} |] verify.rangeAfterCodeFix(`namespace Validation { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts index 85c638aaa43..3c2f20ce082 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace5.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -25,4 +25,4 @@ verify.rangeAfterCodeFix(`function function3() { function1(); } - export let a = function3;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + export let a = function3;`); diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts index 9c12c576329..ea016b73cc2 100644 --- a/tests/cases/fourslash/unusedImports10FS.ts +++ b/tests/cases/fourslash/unusedImports10FS.ts @@ -12,5 +12,5 @@ //// [|import a = A;|] //// } -verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedImports11FS.ts b/tests/cases/fourslash/unusedImports11FS.ts index 9747279d4db..c29b5612e88 100644 --- a/tests/cases/fourslash/unusedImports11FS.ts +++ b/tests/cases/fourslash/unusedImports11FS.ts @@ -11,4 +11,4 @@ //// export function f2(s: string){}; //// export default f1; -verify.rangeAfterCodeFix('import * as s from "./file1";', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix('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 index 54e12bf2f18..d86bc98c6cf 100644 --- a/tests/cases/fourslash/unusedImports12FS.ts +++ b/tests/cases/fourslash/unusedImports12FS.ts @@ -10,4 +10,4 @@ //// export function f2(s: string){}; //// export default f1; -verify.rangeAfterCodeFix('import f1 from "./file1";', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix('import f1 from "./file1";'); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts index 4c02cabc4ba..0fc2d36aac7 100644 --- a/tests/cases/fourslash/unusedImports1FS.ts +++ b/tests/cases/fourslash/unusedImports1FS.ts @@ -9,4 +9,4 @@ //// //// } -verify.rangeAfterCodeFix('', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(''); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts index 5dff4dc9237..ec3f2056e36 100644 --- a/tests/cases/fourslash/unusedImports2FS.ts +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -16,4 +16,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ 0, /*index*/ 0); +verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ 0); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts index 9cc53839f17..6926f97bb4f 100644 --- a/tests/cases/fourslash/unusedImports3FS.ts +++ b/tests/cases/fourslash/unusedImports3FS.ts @@ -20,5 +20,5 @@ //// //// } -verify.rangeAfterCodeFix(`import {/*some comments*/ test, test2} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(`import {/*some comments*/ test, test2} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts index a923bd389c9..4f7e8882429 100644 --- a/tests/cases/fourslash/unusedImports4FS.ts +++ b/tests/cases/fourslash/unusedImports4FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator, test2} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix(`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 index 11def13df4d..15262df01fd 100644 --- a/tests/cases/fourslash/unusedImports5FS.ts +++ b/tests/cases/fourslash/unusedImports5FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator, test} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix(`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 index 36ef2813ee0..1d6a9a3232e 100644 --- a/tests/cases/fourslash/unusedImports6FS.ts +++ b/tests/cases/fourslash/unusedImports6FS.ts @@ -17,4 +17,4 @@ //// //// } -verify.rangeAfterCodeFix('', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts index bacca3a06a8..1a23ea85925 100644 --- a/tests/cases/fourslash/unusedImports7FS.ts +++ b/tests/cases/fourslash/unusedImports7FS.ts @@ -13,4 +13,4 @@ //// export default function test2() { //// } -verify.rangeAfterCodeFix('', /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix(''); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts index 3b01b54a342..81bdeda36ac 100644 --- a/tests/cases/fourslash/unusedImports8FS.ts +++ b/tests/cases/fourslash/unusedImports8FS.ts @@ -21,4 +21,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator as calc, test as t1} from "./file1"`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix(`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 index bea5517574d..f81f9a9f5ae 100644 --- a/tests/cases/fourslash/unusedImports9FS.ts +++ b/tests/cases/fourslash/unusedImports9FS.ts @@ -17,4 +17,4 @@ //// //// } -verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix(""); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts index b9410f41a58..f979069690b 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(` namespace greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts index 0155b851f93..7737f9ce247 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -9,4 +9,4 @@ ////} verify.rangeAfterCodeFix(`export interface interface2 { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts index cf165184671..e74f5dbd962 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction1.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -7,4 +7,4 @@ verify.rangeAfterCodeFix(` function greeter() { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts index 2da97abea20..83816e68038 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction2.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -6,4 +6,4 @@ //// x+1; ////} -verify.rangeAfterCodeFix("var x;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("var x;"); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts index ba3f73b5bd0..ec5d72d83b6 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction3.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -7,4 +7,4 @@ //// z+1; ////} -verify.rangeAfterCodeFix("var x,z = 1;", /*includeWhiteSpace*/ undefined, /*errorCode*/ 6133, /*index*/ 0); +verify.rangeAfterCodeFix("var x,z = 1;", /*includeWhiteSpace*/ undefined, /*errorCode*/ 6133); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index 62cbf589d76..a458d6d824c 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -7,4 +7,4 @@ //// z++; ////} -verify.rangeAfterCodeFix("var y = 0,z = 1;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index 8ed3e080143..dc73ab86663 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix("var y = 10;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("var y = 10;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 9104ba3973a..012bf87a222 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix("var y;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("var y;"); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts index c091562f8a4..4ed58d3142d 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -9,4 +9,4 @@ ////} verify.rangeAfterCodeFix(`constructor() { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts index 764f380e49b..eeaf66050d4 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -15,4 +15,4 @@ verify.rangeAfterCodeFix(` var used = "dummy"; used = used + "second part"; } -`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts deleted file mode 100644 index ecad94397c8..00000000000 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2AddUnderscore.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -////class greeter { -//// [|constructor() { -//// var unused = 20; -//// var used = "dummy"; -//// used = used + "second part"; -//// } |] -////} - -verify.rangeAfterCodeFix(` - constructor() { - var _unused = 20; - var used = "dummy"; - used = used + "second part"; - } -`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts index 43cc2d192c2..a5e3789c8af 100644 --- a/tests/cases/fourslash/unusedMethodInClass1.ts +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(` class greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts index 51db9367deb..cce621236d4 100644 --- a/tests/cases/fourslash/unusedMethodInClass2.ts +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -12,4 +12,4 @@ verify.rangeAfterCodeFix(` class greeter { public function2() { } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts index f07f0f4a892..ccf98c4bbc5 100644 --- a/tests/cases/fourslash/unusedMethodInClass3.ts +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(` class greeter { -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts index 19ad173e76b..962b80f5bc1 100644 --- a/tests/cases/fourslash/unusedMethodInClass4.ts +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -9,4 +9,4 @@ ////} verify.rangeAfterCodeFix(`public function2(){ -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass5.ts b/tests/cases/fourslash/unusedMethodInClass5.ts index ac27874bafe..806e619817f 100644 --- a/tests/cases/fourslash/unusedMethodInClass5.ts +++ b/tests/cases/fourslash/unusedMethodInClass5.ts @@ -5,4 +5,4 @@ //// private ["string"] (){} //// }|] -verify.rangeAfterCodeFix("class C { }", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass6.ts b/tests/cases/fourslash/unusedMethodInClass6.ts index b8c65c56fa1..d223b3d6857 100644 --- a/tests/cases/fourslash/unusedMethodInClass6.ts +++ b/tests/cases/fourslash/unusedMethodInClass6.ts @@ -5,4 +5,4 @@ //// private "string" (){} //// }|] -verify.rangeAfterCodeFix("class C { }", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("class C { }"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts index 5f1892e1a2f..802336454c6 100644 --- a/tests/cases/fourslash/unusedNamespaceInNamespace.ts +++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts @@ -9,5 +9,5 @@ verify.rangeAfterCodeFix(` namespace A { } -`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +`); diff --git a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts index bd7c914a614..2314ebbe447 100644 --- a/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts +++ b/tests/cases/fourslash/unusedTypeAliasInNamespace1.ts @@ -8,4 +8,4 @@ verify.rangeAfterCodeFix(`namespace greeter { export type nw = "No" | "Way"; -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts index ba31e053727..322921ab471 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -4,4 +4,4 @@ ////[|class greeter |] { ////} -verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts index a56f1cf827b..feaf9d3a14b 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -5,4 +5,4 @@ //// public a: X; ////} -verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts index e5f90dd4066..b1151265fe3 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -6,4 +6,4 @@ //// public b: Z; ////} -verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("class greeter"); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts b/tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts deleted file mode 100644 index b1bf52d3043..00000000000 --- a/tests/cases/fourslash/unusedTypeParametersInClass3AddUnderscore.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -////[|class greeter |] { -//// public a: X; -//// public b: Z; -////} - -verify.rangeAfterCodeFix("class greeter", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts index d5755275a5a..a11156badaa 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1() {}|] -verify.rangeAfterCodeFix("function f1() {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("function f1() {}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts index f20010402a8..a011f093dab 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1(a: X) {a}|] -verify.rangeAfterCodeFix("function f1(a: X) {a}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("function f1(a: X) {a}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts index 5e46ca56aff..6dc56ccc7cb 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts @@ -3,4 +3,4 @@ // @noUnusedLocals: true //// [|function f1(a: X) {a;var b:Z;b}|] -verify.rangeAfterCodeFix("function f1(a: X) {a;var b:Z;b}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("function f1(a: X) {a;var b:Z;b}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts index 6ce19679fce..b5363b369be 100644 --- a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts @@ -4,4 +4,4 @@ // @noUnusedParameters: true //// [|interface I {}|] -verify.rangeAfterCodeFix("interface I {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("interface I {}"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts index 8f094b73170..01c1ebd24f5 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts @@ -6,4 +6,4 @@ //// [|return (x:number) => {x}|] //// } -verify.rangeAfterCodeFix("return (x:number) => {x}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("return (x:number) => {x}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts index fc9ccc80f8f..e5a4acc31c5 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts @@ -6,4 +6,4 @@ //// [|new (a: T): void;|] //// } -verify.rangeAfterCodeFix("new (a: T): void;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("new (a: T): void;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts index 1d2fb9af8d6..e6d866dcb6a 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts @@ -7,4 +7,4 @@ //// [|new (a: T): A;|] //// } -verify.rangeAfterCodeFix("new (a: T): A;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("new (a: T): A;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts index a34e344d17d..04bd7c7e9be 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts @@ -6,4 +6,4 @@ //// } //// [|var y: new (a:T)=>void;|] -verify.rangeAfterCodeFix("var y: new (a:T)=>void;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("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 index 36a124fc424..bc14952eca9 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts @@ -5,4 +5,4 @@ //// [|f1()|] {} //// } -verify.rangeAfterCodeFix("f1()", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("f1()"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts index 1d7203f86ac..c12fd53f66b 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts @@ -5,4 +5,4 @@ //// [|f1(a: U)|] {a;} //// } -verify.rangeAfterCodeFix("f1(a: U)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("f1(a: U)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts index 2a4822628ce..d0b170491f5 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts @@ -5,4 +5,4 @@ //// [|public f1(a: X)|] { a; var b: Z; b } //// } -verify.rangeAfterCodeFix("public f1(a: X)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("public f1(a: X)"); diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts index 51deb5c313d..2a33d0c4cf5 100644 --- a/tests/cases/fourslash/unusedVariableInBlocks.ts +++ b/tests/cases/fourslash/unusedVariableInBlocks.ts @@ -12,4 +12,4 @@ verify.rangeAfterCodeFix(`let x = 10; { } - x;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + x;`); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts index 177cf7f0197..8b0ca0db727 100644 --- a/tests/cases/fourslash/unusedVariableInClass1.ts +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -5,4 +5,4 @@ //// [|private greeting: string;|] ////} -verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts index 2f5cf2e3278..6503dd02872 100644 --- a/tests/cases/fourslash/unusedVariableInClass2.ts +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -6,4 +6,4 @@ //// private greeting: string;|] ////} -verify.rangeAfterCodeFix("public greeting1;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("public greeting1;"); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts index 1e05c00f0a1..3ac306170a2 100644 --- a/tests/cases/fourslash/unusedVariableInClass3.ts +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -5,4 +5,4 @@ //// private X = function() {}; ////|]} -verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts index 15727ab70a7..760d8487b34 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts @@ -7,5 +7,5 @@ //// } //// } -verify.rangeAfterCodeFix("for(; ;)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("for(; ;)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts index 5a06ad036f4..a16f21e8417 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix("for(var i = 0; ;i++)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("for(var i = 0; ;i++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts index 32bb54c2241..07d13307ca7 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix("for(var i = 0, k=0; ;i++,k++)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file +verify.rangeAfterCodeFix("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 index c5589366245..d54f8baaa3d 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix("for(var j = 0, k=0; ;j++,k++)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("for(var j = 0, k=0; ;j++,k++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts index fdcc51f696f..2948bfab207 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts @@ -7,4 +7,4 @@ //// } //// } -verify.rangeAfterCodeFix(`for (const _elem in ["a", "b", "c"])`, /*includeWhiteSpace*/ true, /*errorCode*/ 0, /*index*/ 0); +verify.rangeAfterCodeFix(`for (const _elem in ["a", "b", "c"])`, /*includeWhiteSpace*/ true, /*errorCode*/ 0); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 94f4defca01..95dee56acf9 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -13,4 +13,4 @@ verify.rangeAfterCodeFix(`{ for (const elem of ["a", "b", "c"]) { elem; } -}`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +}`); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts index 115af8bc15d..e9fe9515e6d 100644 --- a/tests/cases/fourslash/unusedVariableInModule1.ts +++ b/tests/cases/fourslash/unusedVariableInModule1.ts @@ -6,4 +6,4 @@ //// [|var x: string; //// export var y: string;|] -verify.rangeAfterCodeFix("export var y: string;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("export var y: string;"); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts index d2aeea0e82b..ac6e7120d8b 100644 --- a/tests/cases/fourslash/unusedVariableInModule2.ts +++ b/tests/cases/fourslash/unusedVariableInModule2.ts @@ -7,4 +7,4 @@ //// z; //// export var y: string; -verify.rangeAfterCodeFix("var z: number;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("var z: number;"); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts index f7d565dd50b..0185b89e3a6 100644 --- a/tests/cases/fourslash/unusedVariableInModule3.ts +++ b/tests/cases/fourslash/unusedVariableInModule3.ts @@ -6,4 +6,4 @@ //// [|var x = function f1() {} //// export var y: string;|] -verify.rangeAfterCodeFix("export var y: string;", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix("export var y: string;"); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts index d90b7e50603..c9f38473a51 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace1.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -5,4 +5,4 @@ //// [|let a = "dummy entry";|] ////} -verify.rangeAfterCodeFix("", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(""); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index 664d76130b4..992c229014a 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix(`let a = "dummy entry", c = 0;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(`let a = "dummy entry", c = 0;`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index 4de5c0f1534..0039036b2f8 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -9,4 +9,4 @@ //// } ////} -verify.rangeAfterCodeFix(`let a = "dummy entry", b;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); +verify.rangeAfterCodeFix(`let a = "dummy entry", b;`); From 8a3aaefff477be708ad5296b5616d9df22f9a396 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 8 Jun 2017 19:00:08 -0700 Subject: [PATCH 8/9] add tests --- .../unusedParameterInConstructor1AddUnderscore.ts | 8 ++++++++ .../unusedParameterInFunction1AddUnderscore.ts | 7 +++++++ .../unusedParameterInLambda1AddUnderscore.ts | 9 +++++++++ .../unusedVariableInForLoop6FSAddUnderscore.ts | 11 +++++++++++ 4 files changed, 35 insertions(+) create mode 100644 tests/cases/fourslash/unusedParameterInConstructor1AddUnderscore.ts create mode 100644 tests/cases/fourslash/unusedParameterInFunction1AddUnderscore.ts create mode 100644 tests/cases/fourslash/unusedParameterInLambda1AddUnderscore.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop6FSAddUnderscore.ts diff --git a/tests/cases/fourslash/unusedParameterInConstructor1AddUnderscore.ts b/tests/cases/fourslash/unusedParameterInConstructor1AddUnderscore.ts new file mode 100644 index 00000000000..31882978951 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInConstructor1AddUnderscore.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5) |] { p5; } +//// } + +verify.rangeAfterCodeFix("constructor(private _p1: string, public p2: boolean, public p3: any, p5)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction1AddUnderscore.ts b/tests/cases/fourslash/unusedParameterInFunction1AddUnderscore.ts new file mode 100644 index 00000000000..137625869c8 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction1AddUnderscore.ts @@ -0,0 +1,7 @@ +/// + +// @noUnusedParameters: true +////function [|greeter( x) |] { +////} + +verify.rangeAfterCodeFix("greeter( _x)", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedParameterInLambda1AddUnderscore.ts b/tests/cases/fourslash/unusedParameterInLambda1AddUnderscore.ts new file mode 100644 index 00000000000..916c32d82eb --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInLambda1AddUnderscore.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// function f1() { +//// [|return (x:number) => {} |] +//// } + +verify.rangeAfterCodeFix("return (_x:number) => {}", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FSAddUnderscore.ts b/tests/cases/fourslash/unusedVariableInForLoop6FSAddUnderscore.ts new file mode 100644 index 00000000000..4faa6893b7f --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop6FSAddUnderscore.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for ([|const elem of |]["a", "b", "c"]) { +//// +//// } +//// } + +verify.rangeAfterCodeFix("const _elem of", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); + From a6e8cd7bcb574f3833d32c2d53e04a50a4c32ade Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 8 Jun 2017 19:22:23 -0700 Subject: [PATCH 9/9] rename tests --- tests/cases/fourslash/unusedImports2FS.ts | 2 +- ...ForLoop5FS.ts => unusedVariableInForLoop5FSAddUnderscore.ts} | 0 tests/cases/fourslash/unusedVariableInForLoop7FS.ts | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename tests/cases/fourslash/{unusedVariableInForLoop5FS.ts => unusedVariableInForLoop5FSAddUnderscore.ts} (100%) diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts index ec3f2056e36..8865dea56a6 100644 --- a/tests/cases/fourslash/unusedImports2FS.ts +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -16,4 +16,4 @@ //// //// } -verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ 0); +verify.rangeAfterCodeFix(`import {Calculator} from "./file1"`, /*includeWhiteSpace*/ true, /*errorCode*/ undefined); diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FSAddUnderscore.ts similarity index 100% rename from tests/cases/fourslash/unusedVariableInForLoop5FS.ts rename to tests/cases/fourslash/unusedVariableInForLoop5FSAddUnderscore.ts diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 95dee56acf9..7f99863ba46 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -13,4 +13,4 @@ verify.rangeAfterCodeFix(`{ for (const elem of ["a", "b", "c"]) { elem; } -}`); +}`, /*includeWhiteSpace*/ true);