stubbing extra completions

This commit is contained in:
Arthur Ozga 2016-11-29 14:33:20 -06:00
parent bf48564cc8
commit ba80ce63ad
7 changed files with 161 additions and 0 deletions

View File

@ -28,6 +28,7 @@ namespace ts.codefix {
}
const node = declarations[0];
const visibility = getVisibilityPrefix(getModifierFlags(node));
let getOrSetPrefix: string = undefined;
switch (node.kind) {
case SyntaxKind.PropertySignature:
case SyntaxKind.PropertyDeclaration:
@ -44,6 +45,20 @@ namespace ts.codefix {
const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call);
return `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`;
case SyntaxKind.GetAccessor:
getOrSetPrefix = "get";
case SyntaxKind.SetAccessor:
getOrSetPrefix = getOrSetPrefix ? getOrSetPrefix : "set";
throw new Error('Not implemented, getter and setter.');
case SyntaxKind.ComputedPropertyName:
if (hasDynamicName(node)) {
return "";
}
throw new Error('Not implemented, computed property name.');
case SyntaxKind.IndexSignature:
throw new Error('Not implemented.');
default:
return "";
}

View File

@ -0,0 +1,44 @@
/// <reference path='fourslash.ts' />
//// namespace N1 {
//// export interface I1 {
//// f1():string;
//// }
//// }
//// interface I1 {
//// f1();
//// }
////
//// class C1 implements N1.I1 {[|
//// |]}
let passcode = "secret passcode";
abstract class A {
private _a: string;
abstract get a(): string;
abstract set a(newName: string);
}
class B extends A {
a: string;
}
abstract class AA {
private _a: string;
abstract get a(): string {
return this._a;
}
abstract set a(newName: string) {
this._a = newName;
}
}
verify.rangeAfterCodeFix(`f1(): string{
throw new Error('Method not implemented.');
}
`);

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
//// namespace N1 {
//// export interface I1 {
//// f1():string;
//// }
//// }
//// interface I1 {
//// f1();
//// }
////
//// class C1 implements N1.I1 {[|
//// |]}
verify.rangeAfterCodeFix(`f1(): string{
throw new Error('Method not implemented.');
}
`);

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
//// namespace N1 {
//// export interface I1 {
//// f1():string;
//// }
//// }
//// interface I1 {
//// f1();
//// }
////
//// class C1 implements N1.I1 {[|
//// |]}
verify.rangeAfterCodeFix(`f1(): string{
throw new Error('Method not implemented.');
}
`);

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
//// namespace N1 {
//// export interface I1 {
//// f1():string;
//// }
//// }
//// interface I1 {
//// f1();
//// }
////
//// class C1 implements N1.I1 {[|
//// |]}
verify.rangeAfterCodeFix(`f1(): string{
throw new Error('Method not implemented.');
}
`);

View File

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
//// namespace N1 {
//// export interface I1 {
//// f1():string;
//// }
//// }
//// interface I1 {
//// f1();
//// }
////
//// class C1 implements N1.I1 {[|
//// |]}
verify.rangeAfterCodeFix(`f1(): string{
throw new Error('Method not implemented.');
}
`);

View File

@ -0,0 +1,30 @@
/// <reference path='fourslash.ts' />
//// namespace N1 {
//// export interface I1 {
//// f1():string;
//// }
//// }
//// interface I1 {
//// f1();
//// }
////
//// class C1 implements N1.I1 {[|
//// |]}
//// interface I {
//// method(a: number, b: string): boolean;
//// method(a: string, b: number): Function;
//// method(a: string): Function;
//// }
////
//// class C implements I {[| |]}
verify.rangeAfterCodeFix(`
method(a: number, b: string): boolean;
method(a: string, b: number): Function;
method(a: string): Function;
method(a: number | string, b?: string | number): boolean | Function {
throw new Error("Method not implemented");
}
`);