Skip to content

Commit 81a60c4

Browse files
author
Andy
authored
Merge pull request #10831 from Microsoft/quick_info_is_parameters
Simplify parameters of `quickInfoIs`
2 parents f91ad39 + 4bd6a60 commit 81a60c4

10 files changed

+46
-52
lines changed

src/harness/fourslash.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -954,26 +954,20 @@ namespace FourSlash {
954954
assert.equal(actual, expected);
955955
}
956956

957-
public verifyQuickInfoString(negative: boolean, expectedText?: string, expectedDocumentation?: string) {
957+
public verifyQuickInfoString(negative: boolean, expectedText: string, expectedDocumentation?: string) {
958958
const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition);
959959
const actualQuickInfoText = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.displayParts) : "";
960960
const actualQuickInfoDocumentation = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.documentation) : "";
961961

962962
if (negative) {
963-
if (expectedText !== undefined) {
964-
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
965-
}
966-
// TODO: should be '==='?
967-
if (expectedDocumentation != undefined) {
963+
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
964+
if (expectedDocumentation !== undefined) {
968965
assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment"));
969966
}
970967
}
971968
else {
972-
if (expectedText !== undefined) {
973-
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
974-
}
975-
// TODO: should be '==='?
976-
if (expectedDocumentation != undefined) {
969+
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
970+
if (expectedDocumentation !== undefined) {
977971
assert.equal(actualQuickInfoDocumentation, expectedDocumentation, this.assertionMessageAtLastKnownMarker("quick info doc"));
978972
}
979973
}
@@ -2969,7 +2963,7 @@ namespace FourSlashInterface {
29692963
this.state.verifyErrorExistsAfterMarker(markerName, !this.negative, /*after*/ false);
29702964
}
29712965

2972-
public quickInfoIs(expectedText?: string, expectedDocumentation?: string) {
2966+
public quickInfoIs(expectedText: string, expectedDocumentation?: string) {
29732967
this.state.verifyQuickInfoString(this.negative, expectedText, expectedDocumentation);
29742968
}
29752969

tests/cases/fourslash/commentsLinePreservation.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,55 +107,55 @@
107107
////function /*l*/l(param1: string) { /*9*/param1 = "hello"; }
108108

109109
goTo.marker('a');
110-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line");
110+
verify.quickInfoIs("var a: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line");
111111

112112
goTo.marker('b');
113-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line");
113+
verify.quickInfoIs("var b: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line");
114114

115115
goTo.marker('c');
116-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line");
116+
verify.quickInfoIs("var c: string", "This is firstLine\nThis is second Line\n\nThis is fourth Line");
117117

118118
goTo.marker('d');
119-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
119+
verify.quickInfoIs("function d(param: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line");
120120
goTo.marker('1');
121-
verify.quickInfoIs(undefined, "");
121+
verify.quickInfoIs("(parameter) param: string", "");
122122

123123
goTo.marker('e');
124-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
124+
verify.quickInfoIs("function e(param: string): void", "This is firstLine\nThis is second Line");
125125
goTo.marker('2');
126-
verify.quickInfoIs(undefined, "");
126+
verify.quickInfoIs("(parameter) param: string", "");
127127

128128
goTo.marker('f');
129-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
129+
verify.quickInfoIs("function f(param1: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line");
130130
goTo.marker('3');
131-
verify.quickInfoIs(undefined, "first line of param\n\nparam information third line");
131+
verify.quickInfoIs("(parameter) param1: string", "first line of param\n\nparam information third line");
132132

133133
goTo.marker('g');
134-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
134+
verify.quickInfoIs("function g(param1: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line");
135135
goTo.marker('4');
136-
verify.quickInfoIs(undefined, "param information first line");
136+
verify.quickInfoIs("(parameter) param1: string", "param information first line");
137137

138138
goTo.marker('h');
139-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line");
139+
verify.quickInfoIs("function h(param1: string): void", "This is firstLine\nThis is second Line\n@random tag This should be third line");
140140
goTo.marker('5');
141-
verify.quickInfoIs(undefined, "param information first line\n\nparam information third line");
141+
verify.quickInfoIs("(parameter) param1: string", "param information first line\n\nparam information third line");
142142

143143
goTo.marker('i');
144-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
144+
verify.quickInfoIs("function i(param1: string): void", "This is firstLine\nThis is second Line");
145145
goTo.marker('6');
146-
verify.quickInfoIs(undefined, "param information first line\n\nparam information third line");
146+
verify.quickInfoIs("(parameter) param1: string", "param information first line\n\nparam information third line");
147147

148148
goTo.marker('j');
149-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
149+
verify.quickInfoIs("function j(param1: string): void", "This is firstLine\nThis is second Line");
150150
goTo.marker('7');
151-
verify.quickInfoIs(undefined, "param information first line\n\nparam information third line");
151+
verify.quickInfoIs("(parameter) param1: string", "param information first line\n\nparam information third line");
152152

153153
goTo.marker('k');
154-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@randomtag \n\n random information first line\n\n random information third line");
154+
verify.quickInfoIs("function k(param1: string): void", "This is firstLine\nThis is second Line\n@randomtag \n\n random information first line\n\n random information third line");
155155
goTo.marker('8');
156-
verify.quickInfoIs(undefined, "hello ");
156+
verify.quickInfoIs("(parameter) param1: string", "hello ");
157157

158158
goTo.marker('l');
159-
verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line");
159+
verify.quickInfoIs("function l(param1: string): void", "This is firstLine\nThis is second Line");
160160
goTo.marker('9');
161-
verify.quickInfoIs(undefined, "first Line text\nblank line that shouldnt be shown when starting this \nsecond time information about the param again");
161+
verify.quickInfoIs("(parameter) param1: string", "first Line text\nblank line that shouldnt be shown when starting this \nsecond time information about the param again");

tests/cases/fourslash/contextuallyTypedFunctionExpressionGeneric1.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
////var max2: Comparer = (x/*1*/x, y/*2*/y) => { return x/*3*/x.compareTo(y/*4*/y) };
1111

1212
goTo.marker('1');
13-
verify.quickInfoIs('(parameter) xx: any', null);
13+
verify.quickInfoIs('(parameter) xx: any');
1414

1515
goTo.marker('2');
16-
verify.quickInfoIs('(parameter) yy: any', null);
16+
verify.quickInfoIs('(parameter) yy: any');
1717

1818
goTo.marker('3');
19-
verify.quickInfoIs('(parameter) xx: any', null);
19+
verify.quickInfoIs('(parameter) xx: any');
2020

2121
goTo.marker('4');
22-
verify.quickInfoIs('(parameter) yy: any', null);
22+
verify.quickInfoIs('(parameter) yy: any');

tests/cases/fourslash/fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ declare namespace FourSlashInterface {
130130
errorExistsBetweenMarkers(startMarker: string, endMarker: string): void;
131131
errorExistsAfterMarker(markerName?: string): void;
132132
errorExistsBeforeMarker(markerName?: string): void;
133-
quickInfoIs(expectedText?: string, expectedDocumentation?: string): void;
133+
quickInfoIs(expectedText: string, expectedDocumentation?: string): void;
134134
quickInfoExists(): void;
135135
typeDefinitionCountIs(expectedCount: number): void;
136136
isValidBraceCompletionAtPosition(openingBrace?: string): void;

tests/cases/fourslash/genericFunctionWithGenericParams1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
////};
77

88
goTo.marker();
9-
verify.quickInfoIs('(local var) xx: T', null);
9+
verify.quickInfoIs('(local var) xx: T');

tests/cases/fourslash/genericInterfacesWithConstraints1.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
////var v/*3*/3: G<G<A, B>, C>; // Ok
1313

1414
goTo.marker('1');
15-
verify.quickInfoIs('var v1: G<A, C>', null);
15+
verify.quickInfoIs('var v1: G<A, C>');
1616
goTo.marker('2');
17-
verify.quickInfoIs('var v2: G<{\n a: string;\n}, C>', null);
17+
verify.quickInfoIs('var v2: G<{\n a: string;\n}, C>');
1818
goTo.marker('3');
19-
verify.quickInfoIs('var v3: G<G<A, B>, C>', null);
19+
verify.quickInfoIs('var v3: G<G<A, B>, C>');

tests/cases/fourslash/genericTypeParamUnrelatedToArguments1.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
////var f/*6*/6: Foo<number> = new Foo<number>(3);
1212

1313
goTo.marker('1');
14-
verify.quickInfoIs('var f1: Foo<number>', null);
14+
verify.quickInfoIs('var f1: Foo<number>');
1515

1616
goTo.marker('2');
17-
verify.quickInfoIs('var f2: Foo<number>', null);
17+
verify.quickInfoIs('var f2: Foo<number>');
1818

1919
goTo.marker('3');
20-
verify.quickInfoIs('var f3: any', null);
20+
verify.quickInfoIs('var f3: any');
2121

2222
goTo.marker('4');
23-
verify.quickInfoIs('var f4: Foo<number>', null);
23+
verify.quickInfoIs('var f4: Foo<number>');
2424

2525
goTo.marker('5');
26-
verify.quickInfoIs('var f5: any', null);
26+
verify.quickInfoIs('var f5: any');
2727

2828
goTo.marker('6');
29-
verify.quickInfoIs('var f6: Foo<number>', null);
29+
verify.quickInfoIs('var f6: Foo<number>');

tests/cases/fourslash/quickInfoOnGenericClass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
////}
66

77
goTo.marker();
8-
verify.quickInfoIs('class Container<T>', null);
8+
verify.quickInfoIs('class Container<T>');

tests/cases/fourslash/quickInfoOnGenericWithConstraints1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
////interface Fo/*1*/o<T/*2*/T extends Date> {}
44

55
goTo.marker('1');
6-
verify.quickInfoIs('interface Foo<TT extends Date>', null);
6+
verify.quickInfoIs('interface Foo<TT extends Date>');
77

88
goTo.marker('2');
9-
verify.quickInfoIs('(type parameter) TT in Foo<TT extends Date>', null);
9+
verify.quickInfoIs('(type parameter) TT in Foo<TT extends Date>');

tests/cases/fourslash/recursiveObjectLiteral.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
////var a = { f: /**/a
44

55
goTo.marker();
6-
verify.quickInfoIs("var a: any", null);
6+
verify.quickInfoIs("var a: any");

0 commit comments

Comments
 (0)