File: completionEntryForClassMembers.ts

package info (click to toggle)
node-typescript 4.8.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 523,068 kB
  • sloc: javascript: 1,735,777; makefile: 7; sh: 1
file content (229 lines) | stat: -rw-r--r-- 8,579 bytes parent folder | download
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
///<reference path="fourslash.ts" />

// @noLib: true

////abstract class B {
////    private privateMethod() { }
////    protected protectedMethod() { };
////    static staticMethod() { }
////    abstract getValue(): number;
////    /*abstractClass*/
////}
////class C extends B {
////    /*classThatIsEmptyAndExtendingAnotherClass*/
////}
////class D extends B {
////    /*classThatHasAlreadyImplementedAnotherClassMethod*/
////    getValue() {
////        return 10;
////    }
////    /*classThatHasAlreadyImplementedAnotherClassMethodAfterMethod*/
////}
////class D1 extends B {
////    /*classThatHasDifferentMethodThanBase*/
////    getValue1() {
////        return 10;
////    }
////    /*classThatHasDifferentMethodThanBaseAfterMethod*/
////}
////class D2 extends B {
////    /*classThatHasAlreadyImplementedAnotherClassProtectedMethod*/
////    protectedMethod() {
////    }
////    /*classThatHasDifferentMethodThanBaseAfterProtectedMethod*/
////}
////class D3 extends D1 {
////    /*classThatExtendsClassExtendingAnotherClass*/
////}
////class D4 extends D1 {
////    static /*classThatExtendsClassExtendingAnotherClassAndTypesStatic*/
////}
////class D5 extends D2 {
////    /*classThatExtendsClassExtendingAnotherClassWithOverridingMember*/
////}
////class D6 extends D2 {
////    static /*classThatExtendsClassExtendingAnotherClassWithOverridingMemberAndTypesStatic*/
////}
////class E {
////    /*classThatDoesNotExtendAnotherClass*/
////}
////class F extends B {
////    public /*classThatHasWrittenPublicKeyword*/
////}
////class F2 extends B {
////    private /*classThatHasWrittenPrivateKeyword*/
////}
////class G extends B {
////    static /*classElementContainingStatic*/
////}
////class G2 extends B {
////    private static /*classElementContainingPrivateStatic*/
////}
////class H extends B {
////    prop/*classThatStartedWritingIdentifier*/
////}
//////Class for location verification
////class I extends B {
////    prop0: number
////    /*propDeclarationWithoutSemicolon*/
////    prop: number;
////    /*propDeclarationWithSemicolon*/
////    prop1 = 10;
////    /*propAssignmentWithSemicolon*/
////    prop2 = 10
////    /*propAssignmentWithoutSemicolon*/
////    method(): number
////    /*methodSignatureWithoutSemicolon*/
////    method2(): number;
////    /*methodSignatureWithSemicolon*/
////    method3() {
////        /*InsideMethod*/
////    }
////    /*methodImplementation*/
////    get c()
////    /*accessorSignatureWithoutSemicolon*/
////    set c()
////    {
////    }
////    /*accessorSignatureImplementation*/
////}
////class J extends B {
////    get /*classThatHasWrittenGetKeyword*/
////}
////class K extends B {
////    set /*classThatHasWrittenSetKeyword*/
////}
////class J extends B {
////    get identi/*classThatStartedWritingIdentifierOfGetAccessor*/
////}
////class K extends B {
////    set identi/*classThatStartedWritingIdentifierOfSetAccessor*/
////}
////class L extends B {
////    public identi/*classThatStartedWritingIdentifierAfterModifier*/
////}
////class L2 extends B {
////    private identi/*classThatStartedWritingIdentifierAfterPrivateModifier*/
////}
////class M extends B {
////    static identi/*classThatStartedWritingIdentifierAfterStaticModifier*/
////}
////class M extends B {
////    private static identi/*classThatStartedWritingIdentifierAfterPrivateStaticModifier*/
////}
////class N extends B {
////    async /*classThatHasWrittenAsyncKeyword*/
////}
////class O extends B {
////    constructor(public a) {
////    },
////    /*classElementAfterConstructorSeparatedByComma*/
////}

const getValue: FourSlashInterface.ExpectedCompletionEntry = { name: "getValue", text: "(method) B.getValue(): number" };
const protectedMethod: FourSlashInterface.ExpectedCompletionEntry = { name: "protectedMethod", text: "(method) B.protectedMethod(): void" };
const staticMethod: FourSlashInterface.ExpectedCompletionEntry = { name: "staticMethod", text: "(method) B.staticMethod(): void" };

verify.completions(
    {
        // Not a class element declaration location
        marker: "InsideMethod",
        unsorted: [
            "arguments",
            completion.globalThisEntry,
            "B", "C", "D", "D1", "D2", "D3", "D4", "D5", "D6", "E", "F", "F2", "G", "G2", "H", "I", "J", "K", "L", "L2", "M", "N", "O",
            completion.undefinedVarEntry,
            ...completion.insideMethodKeywords,
        ],
    },
    {
        // Only keywords allowed at this position since they dont extend the class or are private
        marker: [
            "abstractClass",
            "classThatDoesNotExtendAnotherClass",
            "classThatHasWrittenPrivateKeyword",
            "classElementContainingPrivateStatic",
            "classThatStartedWritingIdentifierAfterPrivateModifier",
            "classThatStartedWritingIdentifierAfterPrivateStaticModifier",
        ],
        unsorted: ["private", "protected", "public", "static", "abstract", "async", "constructor", "declare", "get", "readonly", "set", "override"].map(
            name => ({ name, sortText: completion.SortText.GlobalsOrKeywords })
            ),
        isNewIdentifierLocation: true,
    },
    {
        // Instance base members and class member keywords allowed
        marker:[
            "classThatIsEmptyAndExtendingAnotherClass",
            "classThatHasDifferentMethodThanBase",
            "classThatHasDifferentMethodThanBaseAfterMethod",
            "classThatHasWrittenPublicKeyword",
            "classThatStartedWritingIdentifier",
            "propDeclarationWithoutSemicolon",
            "propDeclarationWithSemicolon",
            "propAssignmentWithSemicolon",
            "propAssignmentWithoutSemicolon",
            "methodSignatureWithoutSemicolon",
            "methodSignatureWithSemicolon",
            "methodImplementation",
            "accessorSignatureWithoutSemicolon",
            "accessorSignatureImplementation",
            "classThatHasWrittenGetKeyword",
            "classThatHasWrittenSetKeyword",
            "classThatStartedWritingIdentifierOfGetAccessor",
            "classThatStartedWritingIdentifierOfSetAccessor",
            "classThatStartedWritingIdentifierAfterModifier",
            "classThatHasWrittenAsyncKeyword",
            "classElementAfterConstructorSeparatedByComma",
        ],
        unsorted: [protectedMethod, getValue, ...completion.classElementKeywords],
        isNewIdentifierLocation: true,
    },
    {
        // Static Base members and class member keywords allowed
        marker: ["classElementContainingStatic", "classThatStartedWritingIdentifierAfterStaticModifier"],
        unsorted: [staticMethod, ...completion.classElementKeywords],
        isNewIdentifierLocation: true,
    },
    {
        marker: [
            "classThatHasAlreadyImplementedAnotherClassMethod",
            "classThatHasAlreadyImplementedAnotherClassMethodAfterMethod",
        ],
        unsorted: [protectedMethod, ...completion.classElementKeywords],
        isNewIdentifierLocation: true,
    },
    {
        marker: [
            "classThatHasAlreadyImplementedAnotherClassProtectedMethod",
            "classThatHasDifferentMethodThanBaseAfterProtectedMethod",
        ],
        unsorted: [getValue, ...completion.classElementKeywords],
        isNewIdentifierLocation: true,
    },
    {
        // instance memebers in D1 and base class are shown
        marker: "classThatExtendsClassExtendingAnotherClass",
        unsorted: ["getValue1", "protectedMethod", "getValue", ...completion.classElementKeywords],
        isNewIdentifierLocation: true,
    },
    {
        // instance memebers in D2 and base class are shown
        marker: "classThatExtendsClassExtendingAnotherClassWithOverridingMember",
        unsorted: [
            { name: "protectedMethod", text: "(method) D2.protectedMethod(): void" },
            getValue,
            ...completion.classElementKeywords,
        ],
        isNewIdentifierLocation: true,
    },
    {
        // static base members and class member keywords allowed
        marker: [
            "classThatExtendsClassExtendingAnotherClassAndTypesStatic",
            "classThatExtendsClassExtendingAnotherClassWithOverridingMemberAndTypesStatic"
        ],
        unsorted: [staticMethod, ...completion.classElementKeywords],
        isNewIdentifierLocation: true,
    },
);