Merge pull request #3698 from Microsoft/noObjectBindingBuilder

Don't show a builder for property names in object binding patterns
This commit is contained in:
Daniel Rosenwasser
2015-07-06 16:37:43 -07:00
12 changed files with 35 additions and 14 deletions
+12 -3
View File
@@ -3013,21 +3013,30 @@ namespace ts {
let objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken);
let jsxContainer = tryGetContainingJsxElement(contextToken);
if (objectLikeContainer) {
// Object literal expression, look up possible property names from contextual type
// We're looking up possible property names from contextual/inferred/declared type.
isMemberCompletion = true;
isNewIdentifierLocation = true;
let typeForObject: Type;
let existingMembers: Declaration[];
if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) {
// We are completing on contextual types, but may also include properties
// other than those within the declared type.
isNewIdentifierLocation = true;
typeForObject = typeChecker.getContextualType(<ObjectLiteralExpression>objectLikeContainer);
existingMembers = (<ObjectLiteralExpression>objectLikeContainer).properties;
}
else {
else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) {
// We are *only* completing on properties from the type being destructured.
isNewIdentifierLocation = false;
typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer);
existingMembers = (<BindingPattern>objectLikeContainer).elements;
}
else {
Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind);
}
if (!typeForObject) {
return false;
@@ -10,4 +10,5 @@
goTo.marker();
verify.completionListContains("property1");
verify.completionListContains("property2");
verify.completionListContains("property2");
verify.not.completionListAllowsNewIdentifier();
@@ -10,4 +10,5 @@
goTo.marker();
verify.completionListContains("property2");
verify.not.completionListContains("property1");
verify.not.completionListContains("property1");
verify.not.completionListAllowsNewIdentifier();
@@ -10,4 +10,5 @@
goTo.marker();
verify.completionListContains("property1");
verify.completionListContains("property2");
verify.completionListContains("property2");
verify.not.completionListAllowsNewIdentifier();
@@ -9,4 +9,5 @@
////var { property1/**/ } = foo;
goTo.marker();
verify.completionListContains("property1");
verify.completionListContains("property1");
verify.not.completionListAllowsNewIdentifier();
@@ -15,4 +15,5 @@
goTo.marker();
verify.completionListContains("propertyOfI_1");
verify.completionListContains("propertyOfI_2");
verify.not.completionListContains("property2");
verify.not.completionListContains("property2");
verify.not.completionListAllowsNewIdentifier();
@@ -15,4 +15,5 @@
goTo.marker();
verify.completionListContains("propertyOfI_2");
verify.not.completionListContains("propertyOfI_1");
verify.not.completionListContains("property2");
verify.not.completionListContains("property2");
verify.not.completionListAllowsNewIdentifier();
@@ -16,4 +16,5 @@ goTo.marker();
verify.completionListContains("property2");
verify.not.completionListContains("property1");
verify.not.completionListContains("propertyOfI_2");
verify.not.completionListContains("propertyOfI_1");
verify.not.completionListContains("propertyOfI_1");
verify.not.completionListAllowsNewIdentifier();
@@ -17,7 +17,9 @@ verify.completionListContains("property2");
verify.not.completionListContains("property1");
verify.not.completionListContains("propertyOfI_2");
verify.not.completionListContains("propertyOfI_1");
verify.not.completionListAllowsNewIdentifier();
goTo.marker("2");
verify.completionListContains("property1");
verify.completionListContains("property2");
verify.completionListContains("property2");
verify.not.completionListAllowsNewIdentifier();
@@ -10,4 +10,5 @@
goTo.marker("");
verify.completionListContains("property2");
verify.not.completionListContains("property1");
verify.not.completionListContains("prop1");
verify.not.completionListContains("prop1");
verify.not.completionListAllowsNewIdentifier();
@@ -10,4 +10,5 @@
goTo.marker("");
verify.completionListContains("property2");
verify.not.completionListContains("property1");
verify.not.completionListContains("property1");
verify.not.completionListAllowsNewIdentifier();
@@ -16,4 +16,5 @@
goTo.marker();
verify.completionListContains("x");
verify.completionListContains("y");
verify.not.completionListContains("z");
verify.not.completionListContains("z");
verify.not.completionListAllowsNewIdentifier();