Disable code fixes for now

This commit is contained in:
Mohamed Hegazy
2016-11-17 15:41:07 -08:00
parent 7da6391ca8
commit efe2c56b5e
117 changed files with 739 additions and 2287 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,167 +1,167 @@
/* @internal */
namespace ts.codefix {
registerCodeFix({
errorCodes: [
Diagnostics._0_is_declared_but_never_used.code,
Diagnostics.Property_0_is_declared_but_never_used.code
],
getCodeActions: (context: CodeFixContext) => {
const sourceFile = context.sourceFile;
const start = context.span.start;
// /* @internal */
// namespace ts.codefix {
// registerCodeFix({
// errorCodes: [
// Diagnostics._0_is_declared_but_never_used.code,
// Diagnostics.Property_0_is_declared_but_never_used.code
// ],
// getCodeActions: (context: CodeFixContext) => {
// const sourceFile = context.sourceFile;
// const start = context.span.start;
let token = getTokenAtPosition(sourceFile, start);
// let token = getTokenAtPosition(sourceFile, start);
// this handles var ["computed"] = 12;
if (token.kind === SyntaxKind.OpenBracketToken) {
token = getTokenAtPosition(sourceFile, start + 1);
}
// // this handles var ["computed"] = 12;
// if (token.kind === SyntaxKind.OpenBracketToken) {
// token = getTokenAtPosition(sourceFile, start + 1);
// }
switch (token.kind) {
case ts.SyntaxKind.Identifier:
switch (token.parent.kind) {
case ts.SyntaxKind.VariableDeclaration:
switch (token.parent.parent.parent.kind) {
case SyntaxKind.ForStatement:
const forStatement = <ForStatement>token.parent.parent.parent;
const forInitializer = <VariableDeclarationList>forStatement.initializer;
if (forInitializer.declarations.length === 1) {
return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos);
}
else {
return removeSingleItem(forInitializer.declarations, token);
}
// switch (token.kind) {
// case ts.SyntaxKind.Identifier:
// switch (token.parent.kind) {
// case ts.SyntaxKind.VariableDeclaration:
// switch (token.parent.parent.parent.kind) {
// case SyntaxKind.ForStatement:
// const forStatement = <ForStatement>token.parent.parent.parent;
// const forInitializer = <VariableDeclarationList>forStatement.initializer;
// if (forInitializer.declarations.length === 1) {
// return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos);
// }
// else {
// return removeSingleItem(forInitializer.declarations, token);
// }
case SyntaxKind.ForOfStatement:
const forOfStatement = <ForOfStatement>token.parent.parent.parent;
if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
const forOfInitializer = <VariableDeclarationList>forOfStatement.initializer;
return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos);
}
break;
// case SyntaxKind.ForOfStatement:
// const forOfStatement = <ForOfStatement>token.parent.parent.parent;
// if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
// const forOfInitializer = <VariableDeclarationList>forOfStatement.initializer;
// return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos);
// }
// break;
case SyntaxKind.ForInStatement:
// There is no valid fix in the case of:
// for .. in
return undefined;
// case SyntaxKind.ForInStatement:
// // There is no valid fix in the case of:
// // for .. in
// return undefined;
case SyntaxKind.CatchClause:
const catchClause = <CatchClause>token.parent.parent;
const parameter = catchClause.variableDeclaration.getChildren()[0];
return createCodeFix("", parameter.pos, parameter.end - parameter.pos);
// case SyntaxKind.CatchClause:
// const catchClause = <CatchClause>token.parent.parent;
// const parameter = catchClause.variableDeclaration.getChildren()[0];
// return createCodeFix("", parameter.pos, parameter.end - parameter.pos);
default:
const variableStatement = <VariableStatement>token.parent.parent.parent;
if (variableStatement.declarationList.declarations.length === 1) {
return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos);
}
else {
const declarations = variableStatement.declarationList.declarations;
return removeSingleItem(declarations, token);
}
}
// default:
// const variableStatement = <VariableStatement>token.parent.parent.parent;
// if (variableStatement.declarationList.declarations.length === 1) {
// return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos);
// }
// else {
// const declarations = variableStatement.declarationList.declarations;
// return removeSingleItem(declarations, token);
// }
// }
case SyntaxKind.TypeParameter:
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
if (typeParameters.length === 1) {
return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2);
}
else {
return removeSingleItem(typeParameters, token);
}
// case SyntaxKind.TypeParameter:
// const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
// if (typeParameters.length === 1) {
// return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2);
// }
// else {
// return removeSingleItem(typeParameters, token);
// }
case ts.SyntaxKind.Parameter:
const functionDeclaration = <FunctionDeclaration>token.parent.parent;
if (functionDeclaration.parameters.length === 1) {
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
}
else {
return removeSingleItem(functionDeclaration.parameters, token);
}
// case ts.SyntaxKind.Parameter:
// const functionDeclaration = <FunctionDeclaration>token.parent.parent;
// if (functionDeclaration.parameters.length === 1) {
// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
// }
// else {
// return removeSingleItem(functionDeclaration.parameters, token);
// }
// handle case where 'import a = A;'
case SyntaxKind.ImportEqualsDeclaration:
const importEquals = findImportDeclaration(token);
return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos);
// // handle case where 'import a = A;'
// case SyntaxKind.ImportEqualsDeclaration:
// const importEquals = findImportDeclaration(token);
// return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos);
case SyntaxKind.ImportSpecifier:
const namedImports = <NamedImports>token.parent.parent;
if (namedImports.elements.length === 1) {
// Only 1 import and it is unused. So the entire declaration should be removed.
const importSpec = findImportDeclaration(token);
return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos);
}
else {
return removeSingleItem(namedImports.elements, token);
}
// case SyntaxKind.ImportSpecifier:
// const namedImports = <NamedImports>token.parent.parent;
// if (namedImports.elements.length === 1) {
// // Only 1 import and it is unused. So the entire declaration should be removed.
// const importSpec = findImportDeclaration(token);
// return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos);
// }
// else {
// return removeSingleItem(namedImports.elements, token);
// }
// handle case where "import d, * as ns from './file'"
// or "'import {a, b as ns} from './file'"
case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *'
const importClause = <ImportClause>token.parent;
if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'|
const importDecl = findImportDeclaration(importClause);
return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
}
else { // import |d,| * as ns from './file'
return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos);
}
// // handle case where "import d, * as ns from './file'"
// // or "'import {a, b as ns} from './file'"
// case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *'
// const importClause = <ImportClause>token.parent;
// if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'|
// const importDecl = findImportDeclaration(importClause);
// return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
// }
// else { // import |d,| * as ns from './file'
// return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos);
// }
case SyntaxKind.NamespaceImport:
const namespaceImport = <NamespaceImport>token.parent;
if (namespaceImport.name == token && !(<ImportClause>namespaceImport.parent).name) {
const importDecl = findImportDeclaration(namespaceImport);
return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
}
else {
const start = (<ImportClause>namespaceImport.parent).name.end;
return createCodeFix("", start, (<ImportClause>namespaceImport.parent).namedBindings.end - start);
}
}
break;
// case SyntaxKind.NamespaceImport:
// const namespaceImport = <NamespaceImport>token.parent;
// if (namespaceImport.name == token && !(<ImportClause>namespaceImport.parent).name) {
// const importDecl = findImportDeclaration(namespaceImport);
// return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos);
// }
// else {
// const start = (<ImportClause>namespaceImport.parent).name.end;
// return createCodeFix("", start, (<ImportClause>namespaceImport.parent).namedBindings.end - start);
// }
// }
// break;
case SyntaxKind.PropertyDeclaration:
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
// case SyntaxKind.PropertyDeclaration:
// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
case SyntaxKind.NamespaceImport:
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
}
if (isDeclarationName(token)) {
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
}
else if (isLiteralComputedPropertyDeclarationName(token)) {
return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos);
}
else {
return undefined;
}
// case SyntaxKind.NamespaceImport:
// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
// }
// if (isDeclarationName(token)) {
// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
// }
// else if (isLiteralComputedPropertyDeclarationName(token)) {
// return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos);
// }
// else {
// return undefined;
// }
function findImportDeclaration(token: Node): Node {
let importDecl = token;
while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) {
importDecl = importDecl.parent;
}
// function findImportDeclaration(token: Node): Node {
// let importDecl = token;
// while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) {
// importDecl = importDecl.parent;
// }
return importDecl;
}
// return importDecl;
// }
function createCodeFix(newText: string, start: number, length: number): CodeAction[] {
return [{
description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers),
changes: [{
fileName: sourceFile.fileName,
textChanges: [{ newText, span: { start, length } }]
}]
}];
}
// function createCodeFix(newText: string, start: number, length: number): CodeAction[] {
// return [{
// description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers),
// changes: [{
// fileName: sourceFile.fileName,
// textChanges: [{ newText, span: { start, length } }]
// }]
// }];
// }
function removeSingleItem<T extends Node>(elements: NodeArray<T>, token: T): CodeAction[] {
if (elements[0] === token.parent) {
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1);
}
else {
return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
}
}
}
});
}
// function removeSingleItem<T extends Node>(elements: NodeArray<T>, token: T): CodeAction[] {
// if (elements[0] === token.parent) {
// return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1);
// }
// else {
// return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1);
// }
// }
// }
// });
// }

View File

@@ -1,10 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{ v1 }|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([`{ v1, f1 }`]);

View File

@@ -1,11 +0,0 @@
/// <reference path="fourslash.ts" />
//// import d, [|{ v1 }|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export default var d1 = 6;
verify.importFixAtPosition([`{ v1, f1 }`]);

View File

@@ -1,21 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{
//// v1,
//// v2
//// }|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export var v2 = 5;
//// export var v3 = 5;
verify.importFixAtPosition([
`{
v1,
v2,
f1
}`
]);

View File

@@ -1,20 +0,0 @@
/// <reference path="fourslash.ts" />
////import [|{
//// v1, v2,
//// v3
////}|] from "./module";
////f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export var v2 = 5;
//// export var v3 = 5;
verify.importFixAtPosition([
`{
v1, v2,
v3, f1
}`
]);

View File

@@ -1,12 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{}|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export var v2 = 5;
//// export var v3 = 5;
verify.importFixAtPosition([`{ f1 }`]);

View File

@@ -1,16 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|import * as ns from "./module";
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([
`import * as ns from "./module";
import { f1 } from "./module";
f1();`,
`import * as ns from "./module";
ns.f1();`
]);

View File

@@ -1,18 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|import d, * as ns from "./module" ;
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export default var d1 = 6;
// Test with some extra spaces before the semicolon
verify.importFixAtPosition([
`import d, * as ns from "./module" ;
ns.f1();`,
`import d, * as ns from "./module" ;
import { f1 } from "./module";
f1();`,
]);

View File

@@ -1,14 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|import d from "./module";
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export default var d1 = 6;
verify.importFixAtPosition([
`import d, { f1 } from "./module";
f1();`
]);

View File

@@ -1,12 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|import "./module";
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([`import "./module";
import { f1 } from "./module";
f1();`]);

View File

@@ -1,13 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{ v1 }|] from "fake-module";
//// f1/*0*/();
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/index.ts
//// export var v1 = 5;
//// export function f1();
verify.importFixAtPosition([`{ v1, f1 }`]);

View File

@@ -1,10 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{ v1 }|] from "../other_dir/module";
//// f1/*0*/();
// @Filename: ../other_dir/module.ts
//// export var v1 = 5;
//// export function f1();
verify.importFixAtPosition([`{ v1, f1 }`]);

View File

@@ -1,12 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{v1, v2, v3,}|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
//// export var v2 = 5;
//// export var v3 = 5;
verify.importFixAtPosition([`{v1, v2, v3, f1,}`]);

View File

@@ -1,17 +0,0 @@
/// <reference path="fourslash.ts" />
//// import [|{
//// v1
//// }|] from "./module";
//// f1/*0*/();
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([
`{
v1,
f1
}`
]);

View File

@@ -1,18 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|import ns = require("ambient-module");
//// var x = v1/*0*/ + 5;|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
verify.importFixAtPosition([
`import ns = require("ambient-module");
var x = ns.v1 + 5;`,
`import ns = require("ambient-module");
import { v1 } from "ambient-module";
var x = v1 + 5;`,
]);

View File

@@ -1,15 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
verify.importFixAtPosition([
`import { f1 } from "ambient-module";
f1();`
]);

View File

@@ -1,28 +0,0 @@
/// <reference path="fourslash.ts" />
//// import d from "other-ambient-module";
//// [|import * as ns from "yet-another-ambient-module";
//// var x = v1/*0*/ + 5;|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
// @Filename: otherAmbientModule.ts
//// declare module "other-ambient-module" {
//// export default function f2();
//// }
// @Filename: yetAnotherAmbientModule.ts
//// declare module "yet-another-ambient-module" {
//// export function f3();
//// export var v3;
//// }
verify.importFixAtPosition([
`import * as ns from "yet-another-ambient-module";
import { v1 } from "ambient-module";
var x = v1 + 5;`
]);

View File

@@ -1,21 +0,0 @@
/// <reference path="fourslash.ts" />
////[|/*
//// * I'm a license or something
//// */
////f1/*0*/();|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
verify.importFixAtPosition([
`/*
* I'm a license or something
*/
import { f1 } from "ambient-module";
f1();`
]);

View File

@@ -1,30 +0,0 @@
/// <reference path="fourslash.ts" />
//// let a = "I am a non-trivial statement that appears before imports";
//// import d from "other-ambient-module"
//// [|import * as ns from "yet-another-ambient-module"
//// var x = v1/*0*/ + 5;|]
// @Filename: ambientModule.ts
//// declare module "ambient-module" {
//// export function f1();
//// export var v1;
//// }
// @Filename: otherAmbientModule.ts
//// declare module "other-ambient-module" {
//// export default function f2();
//// }
// @Filename: yetAnotherAmbientModule.ts
//// declare module "yet-another-ambient-module" {
//// export function f3();
//// export var v3;
//// }
// test cases when there are no semicolons at the line end
verify.importFixAtPosition([
`import * as ns from "yet-another-ambient-module"
import { v1 } from "ambient-module";
var x = v1 + 5;`
]);

View File

@@ -1,19 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": "./a"
//// }
//// }
// @Filename: a/b.ts
//// export function f1() { };
verify.importFixAtPosition([
`import { f1 } from "b";
f1();`
]);

View File

@@ -1,12 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: module.ts
//// export default function f1() { };
verify.importFixAtPosition([
`import f1 from "./module";
f1();`
]);

View File

@@ -1,13 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
verify.importFixAtPosition([
`import { f1 } from "./module";
f1();`
]);

View File

@@ -1,18 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|/// <reference path="./tripleSlashReference.ts" />
//// f1/*0*/();|]
// @Filename: module.ts
//// export function f1() {}
//// export var v1 = 5;
// @Filename: tripleSlashReference.ts
//// var x = 5;/*dummy*/
verify.importFixAtPosition([
`/// <reference path="./tripleSlashReference.ts" />
import { f1 } from "./module";
f1();`
]);

View File

@@ -1,13 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ../../other_dir/module.ts
//// export var v1 = 5;
//// export function f1();
verify.importFixAtPosition([
`import { f1 } from "../../other_dir/module";
f1();`
]);

View File

@@ -1,19 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/index.ts
//// export var v1 = 5;
//// export function f1();
// @Filename: ../node_modules/fake-module/package.json
//// {}
verify.importFixAtPosition([
`import { f1 } from "fake-module";
f1();`
]);

View File

@@ -1,16 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/nested.ts
//// export var v1 = 5;
//// export function f1();
verify.importFixAtPosition([
`import { f1 } from "fake-module/nested";
f1();`
]);

View File

@@ -1,25 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|f1/*0*/();|]
// @Filename: ../package.json
//// { "dependencies": { "fake-module": "latest" } }
// @Filename: ../node_modules/fake-module/notindex.d.ts
//// export var v1 = 5;
//// export function f1();
// @Filename: ../node_modules/fake-module/notindex.js
//// module.exports = {
//// v1: 5,
//// f1: function () {}
//// };
// @Filename: ../node_modules/fake-module/package.json
//// { "main":"./notindex.js", "typings":"./notindex.d.ts" }
verify.importFixAtPosition([
`import { f1 } from "fake-module";
f1();`
]);

View File

@@ -1,14 +0,0 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.ts
//// [|f1/*0*/();|]
// @Filename: /node_modules/@types/random/index.d.ts
//// export var v1 = 5;
//// export function f1();
verify.importFixAtPosition([
`import { f1 } from "random";
f1();`
]);

View File

@@ -1,22 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|foo/*0*/();|]
// @Filename: folder_a/f2.ts
//// export function foo() {};
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": ".",
//// "paths": {
//// "a": [ "folder_a/f2" ]
//// }
//// }
//// }
verify.importFixAtPosition([
`import { foo } from "a";
foo();`
]);

View File

@@ -1,22 +0,0 @@
/// <reference path="fourslash.ts" />
//// [|foo/*0*/();|]
// @Filename: folder_b/f2.ts
//// export function foo() {};
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "baseUrl": ".",
//// "paths": {
//// "b/*": [ "folder_b/*" ]
//// }
//// }
//// }
verify.importFixAtPosition([
`import { foo } from "b/f2";
foo();`
]);

View File

@@ -1,23 +0,0 @@
/// <reference path="fourslash.ts" />
// @Filename: a/f1.ts
//// [|foo/*0*/();|]
// @Filename: b/c/f2.ts
//// export function foo() {};
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "rootDirs": [
//// "a",
//// "b/c"
//// ]
//// }
//// }
verify.importFixAtPosition([
`import { foo } from "./f2";
foo();`
]);

View File

@@ -1,22 +0,0 @@
/// <reference path="fourslash.ts" />
// @Filename: a/f1.ts
//// [|foo/*0*/();|]
// @Filename: types/random/index.ts
//// export function foo() {};
// @Filename: tsconfig.json
//// {
//// "compilerOptions": {
//// "typeRoots": [
//// "./types"
//// ]
//// }
//// }
verify.importFixAtPosition([
`import { foo } from "random";
foo();`
]);

View File

@@ -1,20 +0,0 @@
/// <reference path="fourslash.ts" />
// @Filename: a/f1.ts
//// [|import * as ns from "./foo";
//// foo/*0*/();|]
// @Filename: a/foo/bar.ts
//// export function foo() {};
// @Filename: a/foo.ts
//// export { foo } from "./foo/bar";
verify.importFixAtPosition([
`import * as ns from "./foo";
import { foo } from "./foo";
foo();`,
`import * as ns from "./foo";
ns.foo();`,
]);

View File

@@ -1,20 +0,0 @@
/// <reference path="fourslash.ts" />
// @Filename: a/f1.ts
//// [|foo/*0*/();|]
// @Filename: a/node_modules/bar/index.ts
//// export function foo() {};
// @Filename: a/foo.ts
//// export { foo } from "bar";
verify.importFixAtPosition([
`import { foo } from "./foo";
foo();`,
`import { foo } from "bar";
foo();`,
]);

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// class class1 {
//// }
//// } |]
verify.codeFixAtPosition(`namespace greeter {
}`);

View File

@@ -1,15 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// export class class2 {
//// }
//// class class1 {
//// }
//// } |]
verify.codeFixAtPosition(`namespace greeter {
export class class2 {
}
}`);

View File

@@ -1,25 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// class c1 {
////
//// }
////
//// export class c2 {
////
//// }
////
//// class c3 extends c1 {
////
//// }
////} |]
verify.codeFixAtPosition(`namespace Validation {
class c1 {
}
export class c2 {
}
}`);

View File

@@ -1,27 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// class c1 {
////
//// }
////
//// export class c2 {
////
//// }
////
//// class c3 {
//// public x: c1;
//// }
////} |]
verify.codeFixAtPosition(`namespace Validation {
class c1 {
}
export class c2 {
}
}`);

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| function f1 () {
//// const x: string = "x";
//// } |]
verify.codeFixAtPosition(`function f1 () {
}`);

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| function f1 () {
//// enum Directions { Up, Down}
//// } |]
verify.codeFixAtPosition(`function f1 () {
}
`);

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// enum enum1 {
//// Monday
//// }
//// } |]
verify.codeFixAtPosition(`namespace greeter {
}`);

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// function function1() {
//// }/*1*/
//// } |]
verify.codeFixAtPosition(`namespace greeter {
}`);

View File

@@ -1,14 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// export function function2() {
//// }
//// function function1() {
//// }
////} |]
verify.codeFixAtPosition(`namespace greeter {
export function function2() {
}
}`);

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// function function1() {
//// }
////} |]
verify.codeFixAtPosition(`namespace Validation {
}`);

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// var function1 = function() {
//// }
////} |]
verify.codeFixAtPosition(`namespace Validation {
}`);

View File

@@ -1,28 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
////namespace Validation {
//// var function1 = function() {
//// }
////
//// export function function2() {
////
//// }
////
//// [| function function3() {
//// function1();
//// }
////
//// function function4() {
////
//// }
////
//// export let a = function3; |]
////}
verify.codeFixAtPosition(`function function3() {
function1();
}
export let a = function3;`);

View File

@@ -1,16 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// module A {
//// export class Calculator {
//// public handelChar() {
//// }
//// }
//// }
//// module B {
//// [|import a = A;|]
//// }
verify.codeFixAtPosition("");

View File

@@ -1,14 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import f1, * as s from "./file1"; |]
//// s.f2('hello');
// @Filename: file1.ts
//// export var v1;
//// export function f1(n: number){}
//// export function f2(s: string){};
//// export default f1;
verify.codeFixAtPosition('import * as s from "./file1";');

View File

@@ -1,13 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import f1, * as s from "./file1"; |]
//// f1(42);
// @Filename: file1.ts
//// export function f1(n: number){}
//// export function f2(s: string){};
//// export default f1;
verify.codeFixAtPosition('import f1 from "./file1";');

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [|import { Calculator } from "./file1" |]
// @Filename: file1.ts
//// export class Calculator {
////
//// }
verify.codeFixAtPosition('');

View File

@@ -1,19 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [|import {Calculator} from "./file1"
//// import {test} from "./file1"|]
//// var x = new Calculator();
//// x.handleChar();
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() {}
//// }
//// export function test() {
////
//// }
verify.codeFixAtPosition(`import {Calculator} from "./file1"`);

View File

@@ -1,24 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
////[| import {Calculator, test, test2} from "./file1" |]
//// test();
//// test2();
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() {}
//// }
//// export function test() {
////
//// }
//// export function test2() {
////
//// }
verify.codeFixAtPosition(`import {test, test2} from "./file1"`);

View File

@@ -1,24 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import {Calculator, test, test2} from "./file1" |]
////
//// var x = new Calculator();
//// x.handleChar();
//// test2();
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() {}
//// }
////
//// export function test() {
////
//// }
////
//// export function test2() {
////
//// }
verify.codeFixAtPosition(`import {Calculator, test2} from "./file1"`);

View File

@@ -1,24 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import {Calculator, test, test2} from "./file1" |]
////
//// var x = new Calculator();
//// x.handleChar();
//// test();
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() {}
//// }
////
//// export function test() {
////
//// }
////
//// export function test2() {
////
//// }
verify.codeFixAtPosition(`import {Calculator, test} from "./file1"`);

View File

@@ -1,20 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import d from "./file1" |]
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() { }
//// }
//// export function test() {
////
//// }
//// export default function test2() {
////
//// }
verify.codeFixAtPosition('');

View File

@@ -1,16 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [| import * as n from "./file1" |]
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() { }
//// }
//// export function test() {
//// }
//// export default function test2() {
//// }
verify.codeFixAtPosition('');

View File

@@ -1,24 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [|import {Calculator as calc, test as t1, test2 as t2} from "./file1"|]
////
//// var x = new calc();
//// x.handleChar();
//// t1();
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() { }
//// }
//// export function test() {
////
//// }
//// export function test2() {
////
//// }
verify.codeFixAtPosition(`import {Calculator as calc, test as t1} from "./file1"`);

View File

@@ -1,20 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @Filename: file2.ts
//// [|import c = require('./file1')|]
// @Filename: file1.ts
//// export class Calculator {
//// handleChar() { }
//// }
////
//// export function test() {
////
//// }
////
//// export function test2() {
////
//// }
verify.codeFixAtPosition("");

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// interface interface1 {
//// }
////} |]
verify.codeFixAtPosition(`
namespace greeter {
}`);

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////namespace greeter {
//// [| export interface interface2 {
//// }
//// interface interface1 {
//// } |]
////}
verify.codeFixAtPosition(`export interface interface2 {
}`);

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| function greeter() {
//// var x = 0;
////} |]
verify.codeFixAtPosition(`
function greeter() {
}`);

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////function greeter() {
//// [| var x, y = 0; |]
//// x+1;
////}
verify.codeFixAtPosition("var x;");

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////function greeter() {
//// [| var x, y = 0,z = 1; |]
//// x+1;
//// z+1;
////}
verify.codeFixAtPosition("var x,z = 1;", 6133);

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////function greeter() {
//// [| var x,y = 0,z = 1; |]
//// y++;
//// z++;
////}
verify.codeFixAtPosition("var y = 0,z = 1;");

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////class greeter {
//// public function1() {
//// [| var /*0*/x,/*1*/ y = 10; |]
//// y++;
//// }
////}
verify.codeFixAtPosition("var y = 10;");

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////class greeter {
//// public function1() {
//// [| var x, y; |]
//// y = 1;
//// }
////}
verify.codeFixAtPosition("var y;");

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters:true
////class greeter {
//// [| constructor() {
//// var unused = 20;
//// } |]
////}
verify.codeFixAtPosition(`constructor() {
}`);

View File

@@ -1,18 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
////class greeter {
//// [|constructor() {
//// var unused = 20;
//// var used = "dummy";
//// used = used + "second part";
//// }|]
////}
verify.codeFixAtPosition(`
constructor() {
var used = "dummy";
used = used + "second part";
}
`);

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[| class greeter {
//// private function1() {
//// }
////} |]
verify.codeFixAtPosition(`
class greeter {
}`);

View File

@@ -1,15 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| class greeter {
//// public function2() {
//// }
//// private function1() {
//// }
////} |]
verify.codeFixAtPosition(`
class greeter {
public function2() {
}
}`);

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[|class greeter {
//// private function1 = function() {
//// }
////} |]
verify.codeFixAtPosition(`
class greeter {
}`);

View File

@@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////class greeter {
//// [|public function2(){
//// }
//// private function1 = function() {
//// } |]
////}
verify.codeFixAtPosition(`public function2(){
}`);

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|class C {
//// private ["string"] (){}
//// }|]
verify.codeFixAtPosition("class C { }");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|class C {
//// private "string" (){}
//// }|]
verify.codeFixAtPosition("class C { }");

View File

@@ -1,13 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|namespace A {
//// namespace B {
//// }
//// }|]
verify.codeFixAtPosition(`
namespace A {
}
`);

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class C1 {
//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; }
//// }
verify.codeFixAtPosition("constructor(public p2: boolean, public p3: any, p5)");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class C1 {
//// [|constructor(public p1: string, private p2: boolean, public p3: any, p5)|] { p5; }
//// }
verify.codeFixAtPosition("constructor(public p1: string, public p3: any, p5)");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class C1 {
//// [|constructor(public p1: string, public p2: boolean, private p3: any, p5)|] { p5; }
//// }
verify.codeFixAtPosition("constructor(public p1: string, public p2: boolean, p5)");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class C1 {
//// [|constructor(private readonly p2: boolean, p5)|] { p5; }
//// }
verify.codeFixAtPosition("constructor(p5)");

View File

@@ -1,7 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////function [|greeter( x)|] {
////}
verify.codeFixAtPosition("greeter()");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////function [|greeter(x,y)|] {
//// x++;
////}
verify.codeFixAtPosition("greeter(x)");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////function [|greeter(x,y)|] {
//// y++;
////}
verify.codeFixAtPosition("greeter(y)");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedParameters: true
////[|function greeter(x,y,z) |] {
//// x++;
//// z++;
////}
verify.codeFixAtPosition("function greeter(x,z)");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// function f1() {
//// [|return (x:number) => {}|]
//// }
verify.codeFixAtPosition("return () => {}");

View File

@@ -1,11 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [| namespace greeter {
//// type hw = "Hello" |"world";
//// export type nw = "No" | "Way";
//// } |]
verify.codeFixAtPosition(`namespace greeter {
export type nw = "No" | "Way";
}`);

View File

@@ -1,7 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[|class greeter<T> |] {
////}
verify.codeFixAtPosition("class greeter");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[|class greeter<X, Y> |] {
//// public a: X;
////}
verify.codeFixAtPosition("class greeter<X>");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
////[|class greeter<X, Y, Z> |] {
//// public a: X;
//// public b: Z;
////}
verify.codeFixAtPosition("class greeter<X, Z>");

View File

@@ -1,6 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|function f1<T>() {}|]
verify.codeFixAtPosition("function f1() {}");

View File

@@ -1,6 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|function f1<X, Y>(a: X) {a}|]
verify.codeFixAtPosition("function f1<X>(a: X) {a}");

View File

@@ -1,6 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// [|function f1<X, Y, Z>(a: X) {a;var b:Z;b}|]
verify.codeFixAtPosition("function f1<X, Z>(a: X) {a;var b:Z;b}");

View File

@@ -1,7 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// [|interface I<T> {}|]
verify.codeFixAtPosition("interface I {}");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// function f1() {
//// [|return <T>(x:number) => {x}|]
//// }
verify.codeFixAtPosition("return (x:number) => {x}");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// var x : {
//// [|new <T, U>(a: T): void;|]
//// }
verify.codeFixAtPosition("new <T>(a: T): void;");

View File

@@ -1,10 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
// @noUnusedParameters: true
//// class A<Dummy> { public x: Dummy }
//// var x : {
//// [|new <T, U, K>(a: T): A<U>;|]
//// }
verify.codeFixAtPosition("new <T, U>(a: T): A<U>;");

View File

@@ -1,9 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class A<T> {
//// public x: T;
//// }
//// [|var y: new <T,U>(a:T)=>void;|]
verify.codeFixAtPosition("var y: new <T>(a:T)=>void;");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class C1 {
//// [|f1<T extends number>()|] {}
//// }
verify.codeFixAtPosition("f1()");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class C1 {
//// [|f1<T extends number, U>(a: U)|] {a;}
//// }
verify.codeFixAtPosition("f1<U>(a: U)");

View File

@@ -1,8 +0,0 @@
/// <reference path='fourslash.ts' />
// @noUnusedLocals: true
//// class A {
//// [|public f1<X, Y, Z>(a: X)|] { a; var b: Z; b }
//// }
verify.codeFixAtPosition("public f1<X, Z>(a: X)");

Some files were not shown because too many files have changed in this diff Show More