From 5de728d8ac93687ba676369d8c9062ab8ba00f30 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 9 Jul 2015 19:06:21 -0700 Subject: [PATCH 1/5] Added failing test. --- .../fourslash/completionListInImportClause03.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/cases/fourslash/completionListInImportClause03.ts diff --git a/tests/cases/fourslash/completionListInImportClause03.ts b/tests/cases/fourslash/completionListInImportClause03.ts new file mode 100644 index 00000000000..7461c83022b --- /dev/null +++ b/tests/cases/fourslash/completionListInImportClause03.ts @@ -0,0 +1,16 @@ +/// + +////declare module "M1" { +//// export var abc: number; +//// export var def: string; +////} +//// +////declare module "M2" { +//// import { abc/**/ } from "M1"; +////} + +// Ensure we don't filter out the current item. +goTo.marker(); +verify.completionListContains("abc"); +verify.completionListContains("def"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file From 1b0b4344229a32d72d528b661edcf8a792ecec86 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 9 Jul 2015 19:22:28 -0700 Subject: [PATCH 2/5] Don't filter out the current item. --- src/services/services.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index 3f656fe75ff..7675b310715 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3463,6 +3463,11 @@ namespace ts { importDeclaration.importClause.namedBindings.kind === SyntaxKind.NamedImports) { forEach((importDeclaration.importClause.namedBindings).elements, el => { + // If this is the current item we are editing right now, do not filter it out + if (el.getStart() <= position && position <= el.getEnd()) { + return; + } + let name = el.propertyName || el.name; exisingImports[name.text] = true; }); From fc4521905863faa67b5fddfb9541eb02b7334da7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 9 Jul 2015 19:50:17 -0700 Subject: [PATCH 3/5] Spacing. --- src/services/services.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 7675b310715..e5a5266e116 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3524,16 +3524,16 @@ namespace ts { } } - function filterJsxAttributes(attributes: NodeArray, symbols: Symbol[]): Symbol[] { + function filterJsxAttributes(attributes: NodeArray, symbols: Symbol[]): Symbol[] { let seenNames: Map = {}; - for(let attr of attributes) { - if(attr.kind === SyntaxKind.JsxAttribute) { + for (let attr of attributes) { + if (attr.kind === SyntaxKind.JsxAttribute) { seenNames[(attr).name.text] = true; } } let result: Symbol[] = []; - for(let sym of symbols) { - if(!seenNames[sym.name]) { + for (let sym of symbols) { + if (!seenNames[sym.name]) { result.push(sym); } } From fdc504a19ff236733b5e10a3197ff662dd3727f8 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 9 Jul 2015 19:57:56 -0700 Subject: [PATCH 4/5] Added failing test. --- tests/cases/fourslash/tsxCompletion5.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/cases/fourslash/tsxCompletion5.ts diff --git a/tests/cases/fourslash/tsxCompletion5.ts b/tests/cases/fourslash/tsxCompletion5.ts new file mode 100644 index 00000000000..2de6d9a4132 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletion5.ts @@ -0,0 +1,15 @@ +/// + +//@Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// div: { ONE: string; TWO: number; } +//// } +//// } +//// var x =
; + +goTo.marker(); +verify.completionListContains("ONE"); +verify.completionListContains("TWO"); +verify.not.completionListAllowsNewIdentifier(); \ No newline at end of file From 1daf49c0674c622d9723be46d1f30a80c36425d0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 9 Jul 2015 20:02:51 -0700 Subject: [PATCH 5/5] Don't filter out JSX attributes. --- src/services/services.ts | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e5a5266e116..94a3345af1f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3522,23 +3522,29 @@ namespace ts { return filteredMembers; } + + function filterJsxAttributes(attributes: NodeArray, symbols: Symbol[]): Symbol[] { + let seenNames: Map = {}; + for (let attr of attributes) { + // If this is the current item we are editing right now, do not filter it out + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + + if (attr.kind === SyntaxKind.JsxAttribute) { + seenNames[(attr).name.text] = true; + } + } + let result: Symbol[] = []; + for (let sym of symbols) { + if (!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } } - function filterJsxAttributes(attributes: NodeArray, symbols: Symbol[]): Symbol[] { - let seenNames: Map = {}; - for (let attr of attributes) { - if (attr.kind === SyntaxKind.JsxAttribute) { - seenNames[(attr).name.text] = true; - } - } - let result: Symbol[] = []; - for (let sym of symbols) { - if (!seenNames[sym.name]) { - result.push(sym); - } - } - return result; - } function getCompletionsAtPosition(fileName: string, position: number): CompletionInfo { synchronizeHostData();