Skip to content

Commit

Permalink
Merge pull request #1767 from Microsoft/LessAggresiveCompletionList
Browse files Browse the repository at this point in the history
This adds a builder property to the completion list; this allows us to show the completion list in more places and keep support for alternative completion keys, like space and dot.

Note this required changes on the visual studio side too, so the complete experience won't be available until those are released.

This fixes #1629, #1505, #1428 and negates #315.
  • Loading branch information
paulvanbrenk committed Feb 5, 2015
2 parents 87dfd01 + 40824ed commit 6184c15
Show file tree
Hide file tree
Showing 20 changed files with 331 additions and 66 deletions.
9 changes: 9 additions & 0 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,16 @@ module FourSlash {

Harness.IO.log(errorMsg);
this.raiseError("Completion list is not empty at Caret");
}
}

public verifyCompletionListAllowsNewIdentifier(negative: boolean) {
var completions = this.getCompletionListAtCaret();

if ((completions && !completions.isNewIdentifierLocation) && !negative) {
this.raiseError("Expected builder completion entry");
} else if ((completions && completions.isNewIdentifierLocation) && negative) {
this.raiseError("Un-expected builder completion entry");
}
}

Expand Down
192 changes: 143 additions & 49 deletions src/services/services.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/baselines/reference/APISample_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ declare module "typescript" {
}
interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean;
entries: CompletionEntry[];
}
interface CompletionEntry {
Expand Down
3 changes: 3 additions & 0 deletions tests/baselines/reference/APISample_compile.types
Original file line number Diff line number Diff line change
Expand Up @@ -5464,6 +5464,9 @@ declare module "typescript" {
isMemberCompletion: boolean;
>isMemberCompletion : boolean

isNewIdentifierLocation: boolean;
>isNewIdentifierLocation : boolean

entries: CompletionEntry[];
>entries : CompletionEntry[]
>CompletionEntry : CompletionEntry
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/APISample_linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ declare module "typescript" {
}
interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean;
entries: CompletionEntry[];
}
interface CompletionEntry {
Expand Down
3 changes: 3 additions & 0 deletions tests/baselines/reference/APISample_linter.types
Original file line number Diff line number Diff line change
Expand Up @@ -5594,6 +5594,9 @@ declare module "typescript" {
isMemberCompletion: boolean;
>isMemberCompletion : boolean

isNewIdentifierLocation: boolean;
>isNewIdentifierLocation : boolean

entries: CompletionEntry[];
>entries : CompletionEntry[]
>CompletionEntry : CompletionEntry
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/APISample_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ declare module "typescript" {
}
interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean;
entries: CompletionEntry[];
}
interface CompletionEntry {
Expand Down
3 changes: 3 additions & 0 deletions tests/baselines/reference/APISample_transform.types
Original file line number Diff line number Diff line change
Expand Up @@ -5542,6 +5542,9 @@ declare module "typescript" {
isMemberCompletion: boolean;
>isMemberCompletion : boolean

isNewIdentifierLocation: boolean;
>isNewIdentifierLocation : boolean

entries: CompletionEntry[];
>entries : CompletionEntry[]
>CompletionEntry : CompletionEntry
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/APISample_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,7 @@ declare module "typescript" {
}
interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean;
entries: CompletionEntry[];
}
interface CompletionEntry {
Expand Down
3 changes: 3 additions & 0 deletions tests/baselines/reference/APISample_watcher.types
Original file line number Diff line number Diff line change
Expand Up @@ -5720,6 +5720,9 @@ declare module "typescript" {
isMemberCompletion: boolean;
>isMemberCompletion : boolean

isNewIdentifierLocation: boolean;
>isNewIdentifierLocation : boolean

entries: CompletionEntry[];
>entries : CompletionEntry[]
>CompletionEntry : CompletionEntry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />

////interface A</*genericName1*/

////class A</*genericName2*/

////class B<T, /*genericName3*/

////class A{
//// f</*genericName4*/

////function A</*genericName5*/


test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference path='fourslash.ts' />

//// var [x/*variable1*/

//// var [x, y/*variable2*/

//// var [./*variable3*/

//// var [x, ...z/*variable4*/

//// var {x/*variable5*/

//// var {x, y/*variable6*/

//// function func1({ a/*parameter1*/

//// function func2({ a, b/*parameter2*/

test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,17 @@

////function testFunction(a, b/*parameterName4*/

////class bar1{ constructor(/*constructorParamter1*/
////class bar5{ constructor(public /*constructorParamter1*/

////class bar2{ constructor(a/*constructorParamter2*/
////class bar6{ constructor(public a/*constructorParamter2*/

////class bar3{ constructor(a, /*constructorParamter3*/
////class bar7{ constructor(protected a/*constructorParamter3*/

////class bar4{ constructor(a, b/*constructorParamter4*/
////class bar8{ constructor(private a/*constructorParamter4*/

////class bar5{ constructor(public /*constructorParamter5*/
////class bar9{ constructor(.../*constructorParamter5*/

////class bar6{ constructor(public a/*constructorParamter6*/

////class bar7{ constructor(private a/*constructorParamter7*/

////class bar8{ constructor(.../*constructorParamter8*/

////class bar9{ constructor(...a/*constructorParamter9*/
////class bar10{ constructor(...a/*constructorParamter6*/


test.markers().forEach((m) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference path='fourslash.ts' />

////var aa = 1;

////class A1 {
//// /*property1*/
////}

////class A2 {
//// p/*property2*/
////}

////class A3 {
//// public s/*property3*/
////}

////class A4 {
//// a/*property4*/
////}

////class A5 {
//// public a/*property5*/
////}

////class A6 {
//// protected a/*property6*/
////}

////class A7 {
//// private a/*property7*/
////}

test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier();
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

////var a2, a/*varName4*/

debugger;
test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
Expand Down
13 changes: 13 additions & 0 deletions tests/cases/fourslash/completionListBuilderLocations_Modules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />

////module A/*moduleName1*/


////module A./*moduleName2*/


test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference path='fourslash.ts' />

////var x = a/*var1*/

////var x = (b/*var2*/

////var x = (c, d/*var3*/

//// var y : any = "", x = a/*var4*/

//// var y : any = "", x = (a/*var5*/

////class C{}
////var y = new C(

//// class C{}
//// var y = new C(0, /*var7*/

////var y = [/*var8*/

////var y = [0, /*var9*/

////var y = `${/*var10*/

////var y = `${10} dd ${ /*var11*/

////var y = 10; y=/*var12*/

test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListAllowsNewIdentifier();
});


22 changes: 22 additions & 0 deletions tests/cases/fourslash/completionListBuilderLocations_parameters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference path='fourslash.ts' />

////var aa = 1;

////class bar1{ constructor(/*constructorParamter1*/

////class bar2{ constructor(a/*constructorParamter2*/

////class bar3{ constructor(a, /*constructorParamter3*/

////class bar4{ constructor(a, b/*constructorParamter4*/

////class bar6{ constructor(public a, /*constructorParamter5*/

////class bar7{ constructor(private a, /*constructorParamter6*/


test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.not.completionListIsEmpty();
verify.completionListAllowsNewIdentifier();
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

////var aa = 1;

////module /*moduleName1*/

////module a/*moduleName2*/
////class A1 {
//// public static /*property1*/
////}

////class A2 {
//// public static a/*property2*/
////}

test.markers().forEach((m) => {
goTo.position(m.position, m.fileName);
verify.completionListIsEmpty();
});
});
4 changes: 4 additions & 0 deletions tests/cases/fourslash/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ module FourSlashInterface {
FourSlash.currentTestState.verifyCompletionListIsEmpty(this.negative);
}

public completionListAllowsNewIdentifier() {
FourSlash.currentTestState.verifyCompletionListAllowsNewIdentifier(this.negative);
}

public memberListIsEmpty() {
FourSlash.currentTestState.verifyMemberListIsEmpty(this.negative);
}
Expand Down

0 comments on commit 6184c15

Please sign in to comment.