Skip to content

Commit 53bc018

Browse files
author
Andy Hanson
committed
Support completions that require changing from dot to bracket access
1 parent 5e5b770 commit 53bc018

8 files changed

+249
-254
lines changed

src/compiler/diagnosticMessages.json

+4
Original file line numberDiff line numberDiff line change
@@ -3890,5 +3890,9 @@
38903890
"Install '{0}'": {
38913891
"category": "Message",
38923892
"code": 95014
3893+
},
3894+
"Use bracket notation instead of dot notation": {
3895+
"category": "Message",
3896+
"code": 95015
38933897
}
38943898
}

src/services/completions.ts

+209-160
Large diffs are not rendered by default.

tests/cases/fourslash/completionListInvalidMemberNames.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@
1111
//// "\u0031\u0062": "invalid unicode identifer name (1b)"
1212
////};
1313
////
14-
////x./*a*/;
14+
////[|x./*a*/;|]
1515
////x["/*b*/"];
1616

17-
verify.completionsAt("a", ["bar", "break", "any", "$", "b"]);
18-
verify.completionsAt("b", ["foo ", "bar", "break", "any", "#", "$", "b", "\u0031\u0062"]);
17+
verify.completionsAt("b", ["foo ", "bar", "break", "any", "#", "$", "b", "1b"]);
18+
19+
verify.completionsAt("a", ["foo ", "bar", "break", "any", "#", "$", "b", "1b"]);
20+
verify.applyCodeActionFromCompletion("a", {
21+
name: "foo ",
22+
description: "Use bracket notation instead of dot notation",
23+
newRangeContent: 'x[""];',
24+
});
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
/// <reference path='fourslash.ts' />
22

3-
////enum Foo {
4-
//// X, Y, '☆'
3+
// TODO: we should probably support this like we do in completionListInvalidMemberNames.ts
4+
5+
////declare var Symbol: SymbolConstructor;
6+
////interface SymbolConstructor {
7+
//// readonly hasInstance: symbol;
8+
////}
9+
////interface Function {
10+
//// [Symbol.hasInstance](value: any): boolean;
11+
////}
12+
////interface SomeInterface {
13+
//// (value: number): any;
514
////}
6-
////Foo./*a*/;
7-
////Foo["/*b*/"];
15+
////var _ : SomeInterface;
16+
////_./**/
817

9-
verify.completionsAt("a", ["X", "Y"]);
10-
verify.completionsAt("b", ["X", "Y", "☆"]);
18+
goTo.marker();
19+
verify.not.completionListContains("[Symbol.hasInstance]");

tests/cases/fourslash/completionListInvalidMemberNames3.ts

-71
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////declare const x: { "foo ": "space in the name", };
4+
////[|x.fo/**/;|]
5+
6+
verify.completionsAt("", ["foo "]);
7+
verify.applyCodeActionFromCompletion("", {
8+
name: "foo ",
9+
description: "Use bracket notation instead of dot notation",
10+
newRangeContent: 'x["fo"];',
11+
});

tests/cases/fourslash/completion_enum-members-with-invalid-identifiers-should-not-show-in-completion.ts

-13
This file was deleted.

tests/cases/fourslash/jsdocTypedefTagTypeExpressionCompletion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//// /**
1212
//// * @param {string} foo A value.
1313
//// * @returns {number} Another value
14-
//// * @mytag
14+
//// * @mytag
1515
//// */
1616
//// method4(foo: string) { return 3; }
1717
//// }

0 commit comments

Comments
 (0)