Add more testcases and simplify

This commit is contained in:
Paul van Brenk
2016-11-01 16:31:23 -07:00
parent d4b99d66e0
commit b59714ea7e
7 changed files with 54 additions and 66 deletions

View File

@@ -54,14 +54,6 @@ namespace ts.codefix {
}
}
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.PropertyDeclaration:
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
case SyntaxKind.TypeParameter:
const typeParameters = (<DeclarationWithTypeParameters>token.parent.parent).typeParameters;
if (typeParameters.length === 1) {
@@ -105,6 +97,12 @@ namespace ts.codefix {
case SyntaxKind.EnumDeclaration:
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
default:
if (isDeclarationName(token)) {
return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos);
}
break;
}
break;

View File

@@ -5,8 +5,21 @@
//// [| namespace Validation {
//// class c1 {
////
//// }/*1*/
//// } |]
//// }
////
//// export class c2 {
////
//// }
////
//// class c3 extends c1 {
////
//// }
////} |]
verify.codeFixAtPosition(`namespace Validation {
}`);
class c1 {
}
export class c2 {
}
}`);

View File

@@ -2,7 +2,6 @@
// @noUnusedLocals: true
// @noUnusedParameters:true
//// [| namespace Validation {
//// class c1 {
////
@@ -11,9 +10,18 @@
//// export class c2 {
////
//// }
//// } |]
////
//// class c3 {
//// public x: c1;
//// }
////} |]
verify.codeFixAtPosition(`namespace Validation {
class c1 {
}
export class c2 {
}
}`);

View File

@@ -1,26 +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

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

View File

@@ -0,0 +1,11 @@
/// <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";
}`);