From e8a1f16e623cfabe593a765cf5f147ea94fb7e44 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 12:20:20 -0700 Subject: [PATCH 1/2] Added tests for index signature completion builders. --- .../completionListInIndexSignature01.ts | 20 +++++++++++++++++++ .../completionListInIndexSignature02.ts | 19 ++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/cases/fourslash/completionListInIndexSignature01.ts create mode 100644 tests/cases/fourslash/completionListInIndexSignature02.ts diff --git a/tests/cases/fourslash/completionListInIndexSignature01.ts b/tests/cases/fourslash/completionListInIndexSignature01.ts new file mode 100644 index 00000000000..2db28505b3e --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature01.ts @@ -0,0 +1,20 @@ +/// + +////interface I { +//// [/*1*/]: T; +//// [/*2*/]: T; +////} +//// +////class C { +//// [/*3*/]: string; +//// [str/*4*/: string]: number; +////} +//// +////type T = { +//// [x/*5*/yz: number]: boolean; +//// [/*6*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.completionListAllowsNewIdentifier(); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionListInIndexSignature02.ts b/tests/cases/fourslash/completionListInIndexSignature02.ts new file mode 100644 index 00000000000..d3b65dc7759 --- /dev/null +++ b/tests/cases/fourslash/completionListInIndexSignature02.ts @@ -0,0 +1,19 @@ +/// + +////interface I { +//// [x: /*1*/]: T; +//// [: /*2*/]: T +////} +//// +////class C { +//// [a: /*3*/]: string; +//// [str: string/*4*/]: number; +////} +//// +////type T = { +//// [xyz: /*5*/ + +for (let marker of test.markers()) { + goTo.position(marker.position); + verify.not.completionListAllowsNewIdentifier(); +} \ No newline at end of file From 7abe8a155021df917f50509303c989ad2f264a55 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 2 Jul 2015 12:22:07 -0700 Subject: [PATCH 2/2] Add builder in computed properties and index signatures. --- src/services/services.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index b3eb58bdcb3..159b1b817b1 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3062,7 +3062,7 @@ namespace ts { } return true; } - else if(jsxContainer) { + else if (jsxContainer) { let attrsType: Type; if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { // Cursor is inside a JSX self-closing element or opening element @@ -3162,7 +3162,7 @@ namespace ts { switch (previousToken.kind) { case SyntaxKind.CommaToken: return containingNodeKind === SyntaxKind.CallExpression // func( a, | - || containingNodeKind === SyntaxKind.Constructor // constructor( a, | public, protected, private keywords are allowed here, so show completion + || containingNodeKind === SyntaxKind.Constructor // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ || containingNodeKind === SyntaxKind.NewExpression // new C(a, | || containingNodeKind === SyntaxKind.ArrayLiteralExpression // [a, | || containingNodeKind === SyntaxKind.BinaryExpression // let x = (a, | @@ -3173,10 +3173,12 @@ namespace ts { || containingNodeKind === SyntaxKind.Constructor // constructor( | || containingNodeKind === SyntaxKind.NewExpression // new C(a| || containingNodeKind === SyntaxKind.ParenthesizedExpression // let x = (a| - || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + || containingNodeKind === SyntaxKind.ParenthesizedType; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case SyntaxKind.OpenBracketToken: - return containingNodeKind === SyntaxKind.ArrayLiteralExpression; // [ | + return containingNodeKind === SyntaxKind.ArrayLiteralExpression // [ | + || containingNodeKind === SyntaxKind.IndexSignature // [ | : string ] + || containingNodeKind === SyntaxKind.ComputedPropertyName // [ | /* this can become an index signature */ case SyntaxKind.ModuleKeyword: // module | case SyntaxKind.NamespaceKeyword: // namespace |