1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
|
///<reference path="fourslash.ts" />
////interface I {
//// methodOfInterface(): number;
////}
////interface I2 {
//// methodOfInterface2(): number;
////}
////interface I3 {
//// getValue(): string;
//// method(): string;
////}
////interface I4 {
//// staticMethod(): void;
//// method(): string;
////}
////class B0 {
//// private privateMethod() { }
//// protected protectedMethod() { }
//// static staticMethod() { }
//// getValue(): string | boolean { return "hello"; }
//// private privateMethod1() { }
//// protected protectedMethod1() { }
//// static staticMethod1() { }
//// getValue1(): string | boolean { return "hello"; }
////}
////interface I5 extends B0 {
//// methodOfInterface5(): number;
////}
////interface I6 extends B0 {
//// methodOfInterface6(): number;
//// staticMethod(): void;
////}
////interface I7 extends I {
//// methodOfInterface7(): number;
////}
////class B {
//// private privateMethod() { }
//// protected protectedMethod() { }
//// static staticMethod() { }
//// getValue(): string | boolean { return "hello"; }
////}
////class C0 implements I, I2 {
//// /*implementsIAndI2*/
////}
////class C00 implements I, I2 {
//// static /*implementsIAndI2AndWritingStatic*/
////}
////class C001 implements I, I2 {
//// methodOfInterface/*implementsIAndI2AndWritingMethodNameOfI*/
////}
////class C extends B implements I, I2 {
//// /*extendsBAndImplementsIAndI2*/
////}
////class C1 extends B implements I, I2 {
//// static /*extendsBAndImplementsIAndI2AndWritingStatic*/
////}
////class D extends B implements I, I2 {
//// /*extendsBAndImplementsIAndI2WithMethodFromB*/
//// protected protectedMethod() {
//// return "protected";
//// }
////}
////class E extends B implements I, I2 {
//// /*extendsBAndImplementsIAndI2WithMethodFromI*/
//// methodOfInterface() {
//// return 1;
//// }
////}
////class F extends B implements I, I2 {
//// /*extendsBAndImplementsIAndI2WithMethodFromBAndI*/
//// protected protectedMethod() {
//// return "protected"
//// }
//// methodOfInterface() {
//// return 1;
//// }
////}
////class F2 extends B implements I, I2 {
//// protected protectedMethod() {
//// return "protected"
//// }
//// methodOfInterface() {
//// return 1;
//// }
//// static /*extendsBAndImplementsIAndI2WithMethodFromBAndIAndTypesStatic*/
////}
////class G extends B implements I3 {
//// /*extendsBAndImplementsI3WithSameNameMembers*/
////}
////class H extends B implements I3 {
//// /*extendsBAndImplementsI3WithSameNameMembersAndHasImplementedTheMember*/
//// getValue() {
//// return "hello";
//// }
////}
////class J extends B0 implements I4 {
//// /*extendsB0ThatExtendsAndImplementsI4WithStaticMethod*/
////}
////class L extends B0 implements I4 {
//// /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethod*/
//// staticMethod2() {
//// return "hello";
//// }
////}
////class K extends B0 implements I4 {
//// /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethod*/
//// staticMethod() {
//// return "hello";
//// }
////}
////class M extends B0 implements I4 {
//// /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStatic*/
//// static staticMethod() {
//// return "hello";
//// }
////}
////class N extends B0 implements I4 {
//// /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBoth*/
//// staticMethod() {
//// return "hello";
//// }
//// static staticMethod() {
//// return "hello";
//// }
////}
////class J1 extends B0 implements I4 {
//// static /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodWritingStatic*/
////}
////class L1 extends B0 implements I4 {
//// staticMethod2() {
//// return "hello";
//// }
//// static /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethodWritingStatic*/
////}
////class K1 extends B0 implements I4 {
//// staticMethod() {
//// return "hello";
//// }
//// static /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodWritingStatic*/
////}
////class M1 extends B0 implements I4 {
//// static staticMethod() {
//// return "hello";
//// }
//// static /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStaticWritingStatic*/
////}
////class N1 extends B0 implements I4 {
//// staticMethod() {
//// return "hello";
//// }
//// static staticMethod() {
//// return "hello";
//// }
//// static /*extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBothWritingStatic*/
////}
////class O implements I7 {
//// /*implementsI7whichExtendsI*/
////}
////class P implements I7, I {
//// /*implementsI7whichExtendsIAndAlsoImplementsI*/
////}
////class Q implements I, I7 {
//// /*implementsIAndAlsoImplementsI7whichExtendsI*/
////}
////class R implements I5 {
//// /*implementsI5ThatExtendsB0*/
////}
////class S implements I6 {
//// /*implementsI6ThatExtendsB0AndHasStaticMethodOfB0*/
////}
////class T extends B0 implements I5 {
//// /*extendsB0AndImplementsI5ThatExtendsB0*/
////}
////class U extends B0 implements I6 {
//// /*extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0*/
////}
////class R1 implements I5 {
//// static /*implementsI5ThatExtendsB0TypesStatic*/
////}
////class S1 implements I6 {
//// static /*implementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic*/
////}
////class T1 extends B0 implements I5 {
//// static /*extendsB0AndImplementsI5ThatExtendsB0TypesStatic*/
////}
////class U1 extends B0 implements I6 {
//// static /*extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic*/
////}
const validInstanceMembersOfBaseClassB: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "protectedMethod", text: "(method) B.protectedMethod(): void", kindModifiers: "protected" },
{ name: "getValue", text: "(method) B.getValue(): string | boolean" },
];
const validStaticMembersOfBaseClassB: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "staticMethod", text: "(method) B.staticMethod(): void", kindModifiers: "static" },
];
const privateMembersOfBaseClassB: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "privateMethod", text: "(method) B.privateMethod(): void" },
];
const protectedPropertiesOfBaseClassB0: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "protectedMethod", text: "(method) B0.protectedMethod(): void", kindModifiers: "protected" },
{ name: "protectedMethod1", text: "(method) B0.protectedMethod1(): void", kindModifiers: "protected" },
];
const publicPropertiesOfBaseClassB0: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "getValue", text: "(method) B0.getValue(): string | boolean" },
{ name: "getValue1", text: "(method) B0.getValue1(): string | boolean" },
];
const validInstanceMembersOfBaseClassB0: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = protectedPropertiesOfBaseClassB0.concat(publicPropertiesOfBaseClassB0);
const validInstanceMembersOfBaseClassB0_2 : ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
protectedPropertiesOfBaseClassB0[0],
publicPropertiesOfBaseClassB0[0],
protectedPropertiesOfBaseClassB0[1],
publicPropertiesOfBaseClassB0[1],
];
const validStaticMembersOfBaseClassB0: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "staticMethod", text: "(method) B0.staticMethod(): void", kindModifiers: "static" },
{ name: "staticMethod1", text: "(method) B0.staticMethod1(): void", kindModifiers: "static" },
];
const privateMembersOfBaseClassB0: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "privateMethod", text: "(method) B0.privateMethod(): void", kindModifiers: "private" },
{ name: "privateMethod1", text: "(method) B0.privateMethod1(): void", kindModifiers: "private" },
];
const membersOfI: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "methodOfInterface", text: "(method) I.methodOfInterface(): number" },
];
const membersOfI2: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "methodOfInterface2", text: "(method) I2.methodOfInterface2(): number" },
];
const membersOfI3: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "getValue", text: "(method) I3.getValue(): string" },
{ name: "method", text: "(method) I3.method(): string" },
];
const membersOfI4: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "staticMethod", text: "(method) I4.staticMethod(): void" },
{ name: "method", text: "(method) I4.method(): string" },
];
const membersOfI5: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = publicPropertiesOfBaseClassB0.concat([
{ name: "methodOfInterface5", text: "(method) I5.methodOfInterface5(): number" },
]);
const membersOfJustI5: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "methodOfInterface5", text: "(method) I5.methodOfInterface5(): number" },
];
const membersOfI6: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = publicPropertiesOfBaseClassB0.concat([
{ name: "staticMethod", text: "(method) I6.staticMethod(): void" },
{ name: "methodOfInterface6", text: "(method) I6.methodOfInterface6(): number" },
]);
const membersOfI7: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
{ name: "methodOfInterface7", text: "(method) I7.methodOfInterface7(): number" },
...membersOfI,
];
const membersOfI7_2: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [
...membersOfI,
{ name: "methodOfInterface7", text: "(method) I7.methodOfInterface7(): number" },
];
const noMembers: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> = [];
const membersOfIAndI2 = [...membersOfI, ...membersOfI2];
const invalidMembersOfBAtInstanceLocation = privateMembersOfBaseClassB.concat(validStaticMembersOfBaseClassB);
const allInstanceBAndIAndI2 = [...validInstanceMembersOfBaseClassB, ...membersOfIAndI2];
const invalidMembersOfB0AtInstanceSide = [...privateMembersOfBaseClassB0, ...validStaticMembersOfBaseClassB0];
const invalidMembersOfB0AtStaticSide = [...privateMembersOfBaseClassB0, validInstanceMembersOfBaseClassB0];
const invalidMembersOfB0AtInstanceSideFromInterfaceExtendingB0 = invalidMembersOfB0AtInstanceSide;
const tests: ReadonlyArray<{ readonly marker: string | ReadonlyArray<string>, readonly members: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntryObject> }> = [
// members of I and I2
{ marker: ["implementsIAndI2", "implementsIAndI2AndWritingMethodNameOfI"], members: membersOfIAndI2 },
// Static location so no members of I and I2
{ marker: "implementsIAndI2AndWritingStatic", members: [] },
// members of instance B, I and I2
{ marker: "extendsBAndImplementsIAndI2", members: allInstanceBAndIAndI2 },
// static location so only static members of B and no members of instance B, I and I2
{
marker: [
"extendsBAndImplementsIAndI2AndWritingStatic",
"extendsBAndImplementsIAndI2WithMethodFromBAndIAndTypesStatic"
],
members: validStaticMembersOfBaseClassB,
},
// instance members of B without protectedMethod, I and I2
{ marker: "extendsBAndImplementsIAndI2WithMethodFromB",members: [validInstanceMembersOfBaseClassB[1], ...membersOfIAndI2] }, //TODO:NEATER
// instance members of B, members of T without methodOfInterface and I2
{ marker: "extendsBAndImplementsIAndI2WithMethodFromI", members: [...validInstanceMembersOfBaseClassB, ...membersOfI2] },
// instance members of B without protectedMethod, members of T without methodOfInterface and I2
{ marker: "extendsBAndImplementsIAndI2WithMethodFromBAndI", members: [validInstanceMembersOfBaseClassB[1], ...membersOfI2] },
// members of B and members of I3 that are not same as name of method in B
{ marker: "extendsBAndImplementsI3WithSameNameMembers", members: [...validInstanceMembersOfBaseClassB, membersOfI3[1]] }, //TODO:NEATER
// members of B (without getValue since its implemented) and members of I3 that are not same as name of method in B
{ marker: "extendsBAndImplementsI3WithSameNameMembersAndHasImplementedTheMember", members: [validInstanceMembersOfBaseClassB[0], membersOfI3[1]] }, //TODO:NEATER
// members of B0 and members of I4
{
marker: [
"extendsB0ThatExtendsAndImplementsI4WithStaticMethod",
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethod",
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStatic",
],
members: [...validInstanceMembersOfBaseClassB0_2, ...membersOfI4],
},
// members of B0 and members of I4 that are not staticMethod
{
marker: [
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethod",
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBoth",
],
members: [...validInstanceMembersOfBaseClassB0_2, membersOfI4[1]], //TODO:NEATER
},
// static members of B0
{
marker: [
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodWritingStatic",
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedAnotherMethodWritingStatic",
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodWritingStatic",
],
members: validStaticMembersOfBaseClassB0,
},
// static members of B0 without staticMethod
{
marker: [
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsStaticWritingStatic",
"extendsB0ThatExtendsAndImplementsI4WithStaticMethodAndImplementedThatMethodAsBothWritingStatic",
],
members: [validStaticMembersOfBaseClassB0[1]] // TODO:NEATER
},
// members of I7 extends I
{
marker: [
"implementsI7whichExtendsI",
"implementsI7whichExtendsIAndAlsoImplementsI",
],
members: membersOfI7,
},
{
marker: "implementsIAndAlsoImplementsI7whichExtendsI",
members: membersOfI7_2,
},
// members of I5 extends B0
{
marker: "implementsI5ThatExtendsB0",
members: [...membersOfJustI5, protectedPropertiesOfBaseClassB0[0], publicPropertiesOfBaseClassB0[0], protectedPropertiesOfBaseClassB0[1], publicPropertiesOfBaseClassB0[1]], //TODO:NEATER
},
// members of I6 extends B0
{
marker: "implementsI6ThatExtendsB0AndHasStaticMethodOfB0",
//TODO:NEATER
members:[
membersOfI6[3],
membersOfI6[2],
protectedPropertiesOfBaseClassB0[0],
membersOfI6[0],
protectedPropertiesOfBaseClassB0[1],
membersOfI6[1],
],
},
// members of B0 and I5 that extends B0
{
marker: "extendsB0AndImplementsI5ThatExtendsB0",
members: [
protectedPropertiesOfBaseClassB0[0],
membersOfI5[0],
protectedPropertiesOfBaseClassB0[1],
membersOfI5[1],
membersOfI5[2],
],
},
// members of B0 and I6 that extends B0
{
marker: "extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0",
members: [
protectedPropertiesOfBaseClassB0[0],
membersOfI6[0],
protectedPropertiesOfBaseClassB0[1],
membersOfI6[1],
membersOfI6[3],
membersOfI6[2],
],
},
// nothing on static side as these do not extend any other class
{
marker: [
"implementsI5ThatExtendsB0TypesStatic",
"implementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic",
],
members: [],
},
{
marker: [
"extendsB0AndImplementsI5ThatExtendsB0TypesStatic",
"extendsB0AndImplementsI6ThatExtendsB0AndHasStaticMethodOfB0TypesStatic",
],
// statics of base B but nothing from instance side
members: validStaticMembersOfBaseClassB0,
},
];
verify.completions(...tests.map(({ marker, members }): FourSlashInterface.CompletionsOptions => ({
marker,
unsorted: [...members.map(m => ({ ...m, kind: "method" })), ...completion.classElementKeywords],
isNewIdentifierLocation: true,
})));
|