brighterscript 0.66.0-alpha.4 → 0.66.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/DiagnosticMessages.d.ts +6 -1
  3. package/dist/DiagnosticMessages.js +5 -0
  4. package/dist/DiagnosticMessages.js.map +1 -1
  5. package/dist/LanguageServer.d.ts +1 -0
  6. package/dist/LanguageServer.js +8 -5
  7. package/dist/LanguageServer.js.map +1 -1
  8. package/dist/Program.d.ts +3 -8
  9. package/dist/Program.js +3 -51
  10. package/dist/Program.js.map +1 -1
  11. package/dist/ProgramBuilder.js +14 -2
  12. package/dist/ProgramBuilder.js.map +1 -1
  13. package/dist/Scope.d.ts +1 -13
  14. package/dist/Scope.js +10 -65
  15. package/dist/Scope.js.map +1 -1
  16. package/dist/SymbolTable.d.ts +12 -10
  17. package/dist/SymbolTable.js +33 -24
  18. package/dist/SymbolTable.js.map +1 -1
  19. package/dist/astUtils/creators.js +5 -3
  20. package/dist/astUtils/creators.js.map +1 -1
  21. package/dist/astUtils/reflection.d.ts +3 -1
  22. package/dist/astUtils/reflection.js +12 -1
  23. package/dist/astUtils/reflection.js.map +1 -1
  24. package/dist/astUtils/reflection.spec.js +2 -1
  25. package/dist/astUtils/reflection.spec.js.map +1 -1
  26. package/dist/bscPlugin/CallExpressionInfo.d.ts +3 -3
  27. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  28. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +39 -1
  29. package/dist/bscPlugin/completions/CompletionsProcessor.js +305 -3
  30. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  31. package/dist/bscPlugin/completions/CompletionsProcessor.spec.d.ts +1 -0
  32. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +1369 -0
  33. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  34. package/dist/bscPlugin/hover/HoverProcessor.d.ts +9 -4
  35. package/dist/bscPlugin/hover/HoverProcessor.js +64 -67
  36. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  37. package/dist/bscPlugin/hover/HoverProcessor.spec.js +107 -4
  38. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  39. package/dist/bscPlugin/validation/BrsFileValidator.js +18 -15
  40. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  41. package/dist/bscPlugin/validation/ScopeValidator.d.ts +10 -1
  42. package/dist/bscPlugin/validation/ScopeValidator.js +85 -42
  43. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  44. package/dist/bscPlugin/validation/ScopeValidator.spec.js +276 -0
  45. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
  46. package/dist/diagnosticUtils.d.ts +7 -2
  47. package/dist/diagnosticUtils.js +43 -15
  48. package/dist/diagnosticUtils.js.map +1 -1
  49. package/dist/files/BrsFile.Class.spec.js +10 -8
  50. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  51. package/dist/files/BrsFile.d.ts +3 -20
  52. package/dist/files/BrsFile.js +7 -355
  53. package/dist/files/BrsFile.js.map +1 -1
  54. package/dist/files/BrsFile.spec.js +2 -248
  55. package/dist/files/BrsFile.spec.js.map +1 -1
  56. package/dist/files/XmlFile.d.ts +1 -6
  57. package/dist/files/XmlFile.js +0 -13
  58. package/dist/files/XmlFile.js.map +1 -1
  59. package/dist/files/XmlFile.spec.js +0 -36
  60. package/dist/files/XmlFile.spec.js.map +1 -1
  61. package/dist/interfaces.d.ts +8 -1
  62. package/dist/interfaces.js.map +1 -1
  63. package/dist/lexer/Lexer.d.ts +12 -0
  64. package/dist/lexer/Lexer.js +27 -2
  65. package/dist/lexer/Lexer.js.map +1 -1
  66. package/dist/lexer/Lexer.spec.js +40 -0
  67. package/dist/lexer/Lexer.spec.js.map +1 -1
  68. package/dist/lexer/Token.d.ts +4 -0
  69. package/dist/lexer/Token.js.map +1 -1
  70. package/dist/lexer/TokenKind.d.ts +4 -0
  71. package/dist/lexer/TokenKind.js +10 -1
  72. package/dist/lexer/TokenKind.js.map +1 -1
  73. package/dist/parser/AstNode.d.ts +8 -1
  74. package/dist/parser/AstNode.js +16 -0
  75. package/dist/parser/AstNode.js.map +1 -1
  76. package/dist/parser/Expression.d.ts +16 -1
  77. package/dist/parser/Expression.js +43 -1
  78. package/dist/parser/Expression.js.map +1 -1
  79. package/dist/parser/Parser.d.ts +7 -0
  80. package/dist/parser/Parser.js +46 -6
  81. package/dist/parser/Parser.js.map +1 -1
  82. package/dist/parser/Parser.spec.js +327 -3
  83. package/dist/parser/Parser.spec.js.map +1 -1
  84. package/dist/parser/SGTypes.d.ts +1 -1
  85. package/dist/parser/Statement.d.ts +16 -3
  86. package/dist/parser/Statement.js +53 -15
  87. package/dist/parser/Statement.js.map +1 -1
  88. package/dist/parser/tests/Parser.spec.js +2 -1
  89. package/dist/parser/tests/Parser.spec.js.map +1 -1
  90. package/dist/parser/tests/controlFlow/For.spec.js +16 -8
  91. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  92. package/dist/parser/tests/controlFlow/ForEach.spec.js +12 -6
  93. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  94. package/dist/parser/tests/controlFlow/While.spec.js +8 -4
  95. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  96. package/dist/parser/tests/expression/Call.spec.js +4 -4
  97. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  98. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +13 -13
  99. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  100. package/dist/parser/tests/statement/ConstStatement.spec.js +0 -33
  101. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  102. package/dist/parser/tests/statement/Enum.spec.js +1 -257
  103. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  104. package/dist/parser/tests/statement/PrintStatement.spec.js +6 -3
  105. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  106. package/dist/parser/tests/statement/ReturnStatement.spec.js +5 -3
  107. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  108. package/dist/parser/tests/statement/Set.spec.js +26 -13
  109. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  110. package/dist/roku-types/data.json +158 -137
  111. package/dist/roku-types/index.d.ts +3 -38
  112. package/dist/types/ArrayType.d.ts +3 -1
  113. package/dist/types/ArrayType.js +42 -6
  114. package/dist/types/ArrayType.js.map +1 -1
  115. package/dist/types/ArrayType.spec.js +21 -2
  116. package/dist/types/ArrayType.spec.js.map +1 -1
  117. package/dist/types/BooleanType.d.ts +0 -3
  118. package/dist/types/BooleanType.js +5 -6
  119. package/dist/types/BooleanType.js.map +1 -1
  120. package/dist/types/BscType.d.ts +6 -2
  121. package/dist/types/BscType.js +20 -4
  122. package/dist/types/BscType.js.map +1 -1
  123. package/dist/types/BuiltInInterfaceAdder.d.ts +15 -0
  124. package/dist/types/BuiltInInterfaceAdder.js +93 -0
  125. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  126. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  127. package/dist/types/BuiltInInterfaceAdder.spec.js +109 -0
  128. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  129. package/dist/types/ClassType.d.ts +4 -0
  130. package/dist/types/ClassType.js +25 -1
  131. package/dist/types/ClassType.js.map +1 -1
  132. package/dist/types/DoubleType.d.ts +1 -4
  133. package/dist/types/DoubleType.js +5 -6
  134. package/dist/types/DoubleType.js.map +1 -1
  135. package/dist/types/DynamicType.js +2 -0
  136. package/dist/types/DynamicType.js.map +1 -1
  137. package/dist/types/EnumType.d.ts +1 -3
  138. package/dist/types/EnumType.js +6 -5
  139. package/dist/types/EnumType.js.map +1 -1
  140. package/dist/types/FloatType.d.ts +1 -4
  141. package/dist/types/FloatType.js +5 -6
  142. package/dist/types/FloatType.js.map +1 -1
  143. package/dist/types/FunctionType.js +5 -1
  144. package/dist/types/FunctionType.js.map +1 -1
  145. package/dist/types/IntegerType.d.ts +1 -4
  146. package/dist/types/IntegerType.js +5 -6
  147. package/dist/types/IntegerType.js.map +1 -1
  148. package/dist/types/InterfaceType.js +2 -1
  149. package/dist/types/InterfaceType.js.map +1 -1
  150. package/dist/types/InvalidType.d.ts +1 -1
  151. package/dist/types/InvalidType.js +5 -1
  152. package/dist/types/InvalidType.js.map +1 -1
  153. package/dist/types/LongIntegerType.d.ts +1 -4
  154. package/dist/types/LongIntegerType.js +5 -6
  155. package/dist/types/LongIntegerType.js.map +1 -1
  156. package/dist/types/ObjectType.js +2 -0
  157. package/dist/types/ObjectType.js.map +1 -1
  158. package/dist/types/ReferenceType.d.ts +12 -0
  159. package/dist/types/ReferenceType.js +69 -12
  160. package/dist/types/ReferenceType.js.map +1 -1
  161. package/dist/types/ReferenceType.spec.js +15 -0
  162. package/dist/types/ReferenceType.spec.js.map +1 -1
  163. package/dist/types/StringType.d.ts +1 -4
  164. package/dist/types/StringType.js +4 -5
  165. package/dist/types/StringType.js.map +1 -1
  166. package/dist/types/TypedFunctionType.js +9 -2
  167. package/dist/types/TypedFunctionType.js.map +1 -1
  168. package/dist/types/UnionType.d.ts +2 -0
  169. package/dist/types/UnionType.js +22 -1
  170. package/dist/types/UnionType.js.map +1 -1
  171. package/dist/types/UnionType.spec.js +43 -17
  172. package/dist/types/UnionType.spec.js.map +1 -1
  173. package/dist/types/VoidType.d.ts +1 -1
  174. package/dist/types/VoidType.js +5 -1
  175. package/dist/types/VoidType.js.map +1 -1
  176. package/dist/types/helpers.d.ts +1 -0
  177. package/dist/types/helpers.js +18 -3
  178. package/dist/types/helpers.js.map +1 -1
  179. package/dist/util.d.ts +10 -1
  180. package/dist/util.js +77 -1
  181. package/dist/util.js.map +1 -1
  182. package/package.json +1 -1
@@ -0,0 +1,1369 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const chai_config_spec_1 = require("../../chai-config.spec");
4
+ const Program_1 = require("../../Program");
5
+ const util_1 = require("../../util");
6
+ const vscode_languageserver_1 = require("vscode-languageserver");
7
+ const sinon_1 = require("sinon");
8
+ const testHelpers_spec_1 = require("../../testHelpers.spec");
9
+ const XmlFile_1 = require("../../files/XmlFile");
10
+ const TokenKind_1 = require("../../lexer/TokenKind");
11
+ const CompletionsProcessor_1 = require("./CompletionsProcessor");
12
+ const pick = require("object.pick");
13
+ const BrsFile_1 = require("../../files/BrsFile");
14
+ const fsExtra = require("fs-extra");
15
+ describe('CompletionsProcessor', () => {
16
+ let program;
17
+ let sinon = (0, sinon_1.createSandbox)();
18
+ beforeEach(() => {
19
+ fsExtra.emptyDirSync(testHelpers_spec_1.tempDir);
20
+ fsExtra.ensureDirSync(testHelpers_spec_1.rootDir);
21
+ fsExtra.ensureDirSync(testHelpers_spec_1.stagingDir);
22
+ program = new Program_1.Program({ rootDir: testHelpers_spec_1.rootDir });
23
+ });
24
+ afterEach(() => {
25
+ sinon.restore();
26
+ program.dispose();
27
+ });
28
+ describe('getCompletions - Program.spec', () => {
29
+ it('includes `for each` variable', () => {
30
+ program.setFile('source/main.brs', `
31
+ sub main()
32
+ items = [1, 2, 3]
33
+ for each thing in items
34
+ t =
35
+ end for
36
+ end sub
37
+ `);
38
+ program.validate();
39
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(4, 28)).map(x => x.label);
40
+ (0, chai_config_spec_1.expect)(completions).to.include('thing');
41
+ });
42
+ it('includes `for` variable', () => {
43
+ program.setFile('source/main.brs', `
44
+ sub main()
45
+ for i = 0 to 10
46
+ t =
47
+ end for
48
+ end sub
49
+ `);
50
+ program.validate();
51
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 28)).map(x => x.label);
52
+ (0, chai_config_spec_1.expect)(completions).to.include('i');
53
+ });
54
+ it('should include first-level namespace names for brighterscript files', () => {
55
+ program.setFile('source/main.bs', `
56
+ namespace NameA.NameB.NameC
57
+ sub DoSomething()
58
+ end sub
59
+ end namespace
60
+ sub main()
61
+ print
62
+ end sub
63
+ `);
64
+ program.validate();
65
+ // print |
66
+ const completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(6, 25));
67
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(completions, [{
68
+ label: 'NameA',
69
+ kind: vscode_languageserver_1.CompletionItemKind.Module
70
+ }]);
71
+ (0, testHelpers_spec_1.expectCompletionsExcludes)(completions, [{
72
+ label: 'NameB',
73
+ kind: vscode_languageserver_1.CompletionItemKind.Module
74
+ }, {
75
+ label: 'NameA.NameB',
76
+ kind: vscode_languageserver_1.CompletionItemKind.Module
77
+ }, {
78
+ label: 'NameA.NameB.NameC',
79
+ kind: vscode_languageserver_1.CompletionItemKind.Module
80
+ }, {
81
+ label: 'NameA.NameB.NameC.DoSomething',
82
+ kind: vscode_languageserver_1.CompletionItemKind.Module
83
+ }]);
84
+ });
85
+ it('resolves completions for namespaces with next namespace part for brighterscript file', () => {
86
+ program.setFile('source/main.bs', `
87
+ namespace NameA.NameB.NameC
88
+ sub DoSomething()
89
+ end sub
90
+ end namespace
91
+ sub main()
92
+ NameA.
93
+ end sub
94
+ `);
95
+ program.validate();
96
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(6, 26)).map(x => x.label);
97
+ (0, chai_config_spec_1.expect)(completions).to.include('NameB');
98
+ (0, chai_config_spec_1.expect)(completions).not.to.include('NameA');
99
+ (0, chai_config_spec_1.expect)(completions).not.to.include('NameA.NameB');
100
+ (0, chai_config_spec_1.expect)(completions).not.to.include('NameA.NameB.NameC');
101
+ (0, chai_config_spec_1.expect)(completions).not.to.include('NameA.NameB.NameC.DoSomething');
102
+ });
103
+ it('finds namespace members for brighterscript file', () => {
104
+ program.setFile('source/main.bs', `
105
+ sub main()
106
+ NameA.
107
+ NameA.NameB.
108
+ NameA.NameB.NameC.
109
+ end sub
110
+ namespace NameA
111
+ sub alertA()
112
+ end sub
113
+ end namespace
114
+ namespace NameA
115
+ sub info()
116
+ end sub
117
+ end namespace
118
+ namespace NameA.NameB
119
+ sub alertB()
120
+ end sub
121
+ end namespace
122
+ namespace NameA.NameB.NameC
123
+ sub alertC()
124
+ end sub
125
+ end namespace
126
+ `);
127
+ program.validate();
128
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 26)).map(x => x.label).sort()).to.eql(['NameB', 'alertA', 'info']);
129
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(3, 32)).map(x => x.label).sort()).to.eql(['NameC', 'alertB']);
130
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(4, 38)).map(x => x.label).sort()).to.eql(['alertC']);
131
+ });
132
+ it('finds namespace members for classes', () => {
133
+ program.setFile('source/main.bs', `
134
+ sub main()
135
+ NameA.
136
+ NameA.NameB.
137
+ NameA.NameB.NameC.
138
+ end sub
139
+ namespace NameA
140
+ sub alertA()
141
+ end sub
142
+ end namespace
143
+ namespace NameA
144
+ sub info()
145
+ end sub
146
+ class MyClassA
147
+ end class
148
+ end namespace
149
+ namespace NameA.NameB
150
+ sub alertB()
151
+ end sub
152
+ class MyClassB
153
+ end class
154
+ end namespace
155
+ namespace NameA.NameB.NameC
156
+ sub alertC()
157
+ end sub
158
+ end namespace
159
+ `);
160
+ program.validate();
161
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 26)).map(x => x.label).sort()).to.eql(['MyClassA', 'NameB', 'alertA', 'info']);
162
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(3, 32)).map(x => x.label).sort()).to.eql(['MyClassB', 'NameC', 'alertB']);
163
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(4, 38)).map(x => x.label).sort()).to.eql(['alertC']);
164
+ });
165
+ it('finds only namespaces that have classes, when new keyword is used', () => {
166
+ program.setFile('source/main.bs', `
167
+ sub main()
168
+ a = new NameA.
169
+ b = new NameA.NameB.
170
+ c = new NameA.NameB.NameC.
171
+ end sub
172
+ namespace NameA
173
+ sub alertA()
174
+ end sub
175
+ end namespace
176
+ namespace NameA
177
+ sub info()
178
+ end sub
179
+ class MyClassA
180
+ end class
181
+ end namespace
182
+ namespace NameA.NoClassA
183
+ end namespace
184
+ namespace NameA.NoClassB
185
+ end namespace
186
+ namespace NameA.NameB
187
+ sub alertB()
188
+ end sub
189
+ class MyClassB
190
+ end class
191
+ end namespace
192
+ namespace NameA.NameB.NoClass
193
+ end namespace
194
+ namespace NameA.NameB.NameC
195
+ sub alertC()
196
+ end sub
197
+ end namespace
198
+ `);
199
+ program.validate();
200
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 34)).map(x => x.label).sort()).to.eql(['MyClassA', 'NameB']);
201
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(3, 40)).map(x => x.label).sort()).to.eql(['MyClassB']);
202
+ (0, chai_config_spec_1.expect)(program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(4, 46)).map(x => x.label).sort()).to.be.empty;
203
+ });
204
+ //Bron.. pain to get this working.. do we realy need this? seems moot with ropm..
205
+ it.skip('should include translated namespace function names for brightscript files', () => {
206
+ program.setFile('source/main.bs', `
207
+ namespace NameA.NameB.NameC
208
+ sub DoSomething()
209
+ end sub
210
+ end namespace
211
+ `);
212
+ program.setFile('source/lib.brs', `
213
+ sub test()
214
+
215
+ end sub
216
+ `);
217
+ program.validate();
218
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/lib.brs`, vscode_languageserver_1.Position.create(2, 23));
219
+ (0, chai_config_spec_1.expect)(completions.map(x => x.label)).to.include('NameA_NameB_NameC_DoSomething');
220
+ });
221
+ it('includes global completions for file with no scope', () => {
222
+ program.setFile('source/main.brs', `
223
+ function Main()
224
+ age = 1
225
+ end function
226
+ `);
227
+ program.validate();
228
+ let completions = program.getCompletions('source/main.brs', vscode_languageserver_1.Position.create(2, 21));
229
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label.toLowerCase() === 'abs')).to.be.lengthOf(1);
230
+ });
231
+ it('filters out text results for top-level function statements', () => {
232
+ program.setFile('source/main.brs', `
233
+ function Main()
234
+ age = 1
235
+ end function
236
+ `);
237
+ program.validate();
238
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 21));
239
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'Main')).to.be.lengthOf(1);
240
+ });
241
+ it('does not filter text results for object properties used in conditional statements', () => {
242
+ program.setFile('source/main.brs', `
243
+ sub Main()
244
+ p.
245
+ end sub
246
+ sub SayHello()
247
+ person = {}
248
+ if person.isAlive then
249
+ print "Hello"
250
+ end if
251
+ end sub
252
+ `);
253
+ program.validate();
254
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 22));
255
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'isAlive')).to.be.lengthOf(1);
256
+ });
257
+ it('does not filter text results for object properties used in assignments', () => {
258
+ program.setFile('source/main.brs', `
259
+ sub Main()
260
+ p.
261
+ end sub
262
+ sub SayHello()
263
+ person = {}
264
+ localVar = person.name
265
+ end sub
266
+ `);
267
+ program.validate();
268
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 22));
269
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'name')).to.be.lengthOf(1);
270
+ });
271
+ it('does not filter text results for object properties', () => {
272
+ program.setFile('source/main.brs', `
273
+ sub Main()
274
+ p.
275
+ end sub
276
+ sub SayHello()
277
+ person = {}
278
+ person.name = "bob"
279
+ end sub
280
+ `);
281
+ program.validate();
282
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 22));
283
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'name')).to.be.lengthOf(1);
284
+ });
285
+ it('filters out text results for local vars used in conditional statements', () => {
286
+ program.setFile('source/main.brs', `
287
+ sub Main()
288
+
289
+ end sub
290
+ sub SayHello()
291
+ isTrue = true
292
+ if isTrue then
293
+ print "is true"
294
+ end if
295
+ end sub
296
+ `);
297
+ program.validate();
298
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 10));
299
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'isTrue')).to.be.lengthOf(0);
300
+ });
301
+ it('filters out text results for local variable assignments', () => {
302
+ program.setFile('source/main.brs', `
303
+ sub Main()
304
+
305
+ end sub
306
+ sub SayHello()
307
+ message = "Hello"
308
+ end sub
309
+ `);
310
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 10));
311
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'message')).to.be.lengthOf(0);
312
+ });
313
+ it('filters out text results for local variables used in assignments', () => {
314
+ program.setFile('source/main.brs', `
315
+ sub Main()
316
+
317
+ end sub
318
+ sub SayHello()
319
+ message = "Hello"
320
+ otherVar = message
321
+ end sub
322
+ `);
323
+ program.validate();
324
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 10));
325
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.label === 'message')).to.be.lengthOf(0);
326
+ });
327
+ it('does not suggest local variables when initiated to the right of a period', () => {
328
+ program.setFile('source/main.brs', `
329
+ function Main()
330
+ helloMessage = "jack"
331
+ person.hello
332
+ end function
333
+ `);
334
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 32));
335
+ (0, chai_config_spec_1.expect)(completions.filter(x => x.kind === vscode_languageserver_1.CompletionItemKind.Variable).map(x => x.label)).not.to.contain('helloMessage');
336
+ });
337
+ it('finds all file paths when initiated on xml uri', () => {
338
+ let xmlPath = (0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/component1.xml`;
339
+ program.setFile('components/component1.xml', (0, testHelpers_spec_1.trim) `
340
+ <?xml version="1.0" encoding="utf-8" ?>
341
+ <component name="HeroScene" extends="Scene">
342
+ <script type="text/brightscript" uri="" />
343
+ </component>
344
+ `);
345
+ program.setFile('components/component1.brs', '');
346
+ program.validate();
347
+ let completions = program.getCompletions(xmlPath, vscode_languageserver_1.Position.create(2, 42));
348
+ (0, chai_config_spec_1.expect)(completions[0]).to.include({
349
+ kind: vscode_languageserver_1.CompletionItemKind.File,
350
+ label: 'component1.brs'
351
+ });
352
+ (0, chai_config_spec_1.expect)(completions[1]).to.include({
353
+ kind: vscode_languageserver_1.CompletionItemKind.File,
354
+ label: 'pkg:/components/component1.brs'
355
+ });
356
+ //it should NOT include the global methods
357
+ (0, chai_config_spec_1.expect)(completions).to.be.lengthOf(2);
358
+ });
359
+ it('get all functions and properties in scope when doing any dotted get on non m ', () => {
360
+ program.setFile('source/main.bs', `
361
+ sub main()
362
+ thing.anonPropA = "foo"
363
+ thing.anonPropB = "bar"
364
+ thing.person
365
+ end sub
366
+ class MyClassA
367
+ personName = "rafa"
368
+ personAName = "rafaA"
369
+ function personAMethodA()
370
+ end function
371
+ function personAMethodB()
372
+ end function
373
+ end class
374
+ namespace NameA
375
+ sub alertA()
376
+ end sub
377
+ end namespace
378
+ namespace NameA.NameB
379
+ sub alertB()
380
+ end sub
381
+ class MyClassB
382
+ personName = "roger"
383
+ personBName = "rogerB"
384
+ function personAMethodC()
385
+ end function
386
+ function personBMethodA()
387
+ end function
388
+ function personBMethodB()
389
+ end function
390
+ end class
391
+ end namespace
392
+ namespace NameA.NameB.NameC
393
+ sub alertC()
394
+ end sub
395
+ end namespace
396
+ `);
397
+ program.validate();
398
+ //note - we let the vscode extension do the filtering, so we still return everything; otherwise it exhibits strange behaviour in the IDE
399
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(4, 32))).map(x => x.label).sort()).to.eql(['anonPropA', 'anonPropB', 'person', 'personAMethodA', 'personAMethodB', 'personAMethodC', 'personAName', 'personBMethodA', 'personBMethodB', 'personBName', 'personName']);
400
+ });
401
+ it('get all functions and properties relevant for m ', () => {
402
+ program.setFile('source/main.bs', `
403
+ class MyClassA
404
+ function new()
405
+ m.
406
+ end function
407
+ personName = "rafa"
408
+ personAName = "rafaA"
409
+ function personAMethodA()
410
+ end function
411
+ function personAMethodB()
412
+ end function
413
+ end class
414
+ class MyClassB
415
+ personName = "roger"
416
+ personBName = "rogerB"
417
+ function personAMethodC()
418
+ end function
419
+ function personBMethodA()
420
+ end function
421
+ function personBMethodB()
422
+ end function
423
+ end class
424
+ class MyClassC extends MyClassA
425
+ function new()
426
+ m.
427
+ end function
428
+ personCName = "rogerC"
429
+ function personCMethodC()
430
+ end function
431
+ function personCMethodA()
432
+ end function
433
+ function personCMethodB()
434
+ end function
435
+ end class
436
+ sub alertC()
437
+ end sub
438
+ `);
439
+ program.validate();
440
+ const myClassACompletions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(3, 26));
441
+ // remove completions with sortText (they are built in methods), then sort the remaining labels
442
+ const myClassACompletionsSorted = myClassACompletions.filter(x => !x.sortText).map(x => x.label).sort();
443
+ (0, chai_config_spec_1.expect)(myClassACompletionsSorted).to.eql(['personAMethodA', 'personAMethodB', 'personAName', 'personName']);
444
+ const myClassCCompletions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(24, 26));
445
+ // remove completions with sortText (they are built in methods), then sort the remaining labels
446
+ const myClassCCompletionsSorted = myClassCCompletions.filter(x => !x.sortText).map(x => x.label).sort();
447
+ (0, chai_config_spec_1.expect)(myClassCCompletionsSorted).to.eql(['personAMethodA', 'personAMethodB', 'personAName', 'personCMethodA', 'personCMethodB', 'personCMethodC', 'personCName', 'personName']);
448
+ });
449
+ it.skip('include non-namespaced classes in the list of general output', () => {
450
+ program.setFile('source/main.bs', `
451
+ function regularFunc()
452
+ MyClass
453
+ end function
454
+ sub alertC()
455
+ end sub
456
+ class MyClassA
457
+ end class
458
+ class MyClassB
459
+ end class
460
+ class MyClassC extends MyClassA
461
+ end class
462
+ `);
463
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(3, 26))).map(x => x.label).sort()).to.include.members(['MyClassA', 'MyClassB', 'MyClassC']);
464
+ });
465
+ it('only include classes when using new keyword', () => {
466
+ program.setFile('source/main.bs', `
467
+ class MyClassA
468
+ end class
469
+ class MyClassB
470
+ end class
471
+ class MyClassC extends MyClassA
472
+ end class
473
+ function regularFunc()
474
+ new MyClass
475
+ end function
476
+ sub alertC()
477
+ end sub
478
+ `);
479
+ program.validate();
480
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(8, 29))).map(x => x.label).sort()).to.eql(['MyClassA', 'MyClassB', 'MyClassC']);
481
+ });
482
+ it('gets completions when using callfunc inovation', () => {
483
+ program.setFile('source/main.bs', `
484
+ function main()
485
+ myNode@.sayHello(arg1)
486
+ end function
487
+ `);
488
+ program.setFile('components/MyNode.bs', `
489
+ function sayHello(text, text2)
490
+ end function
491
+ `);
492
+ program.setFile('components/MyNode.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
493
+ <component name="Component1" extends="Scene">
494
+ <script type="text/brightscript" uri="pkg:/components/MyNode.bs" />
495
+ <interface>
496
+ <function name="sayHello"/>
497
+ </interface>
498
+ </component>`);
499
+ program.validate();
500
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 30))).map(x => x.label).sort()).to.eql(['sayHello']);
501
+ });
502
+ it('gets completions for callfunc invocation with multiple nodes', () => {
503
+ program.setFile('source/main.bs', `
504
+ function main()
505
+ myNode@.sayHello(arg1)
506
+ end function
507
+ `);
508
+ program.setFile('components/MyNode.bs', `
509
+ function sayHello(text, text2)
510
+ end function
511
+ function sayHello2(text, text2)
512
+ end function
513
+ `);
514
+ program.setFile('components/MyNode.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
515
+ <component name="Component1" extends="Scene">
516
+ <script type="text/brightscript" uri="pkg:/components/MyNode.bs" />
517
+ <interface>
518
+ <function name="sayHello"/>
519
+ <function name="sayHello2"/>
520
+ </interface>
521
+ </component>`);
522
+ program.setFile('components/MyNode2.bs', `
523
+ function sayHello3(text, text2)
524
+ end function
525
+ function sayHello4(text, text2)
526
+ end function
527
+ `);
528
+ program.setFile('components/MyNode2.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
529
+ <component name="Component2" extends="Scene">
530
+ <script type="text/brightscript" uri="pkg:/components/MyNode2.bs" />
531
+ <interface>
532
+ <function name="sayHello3"/>
533
+ <function name="sayHello4"/>
534
+ </interface>
535
+ </component>`);
536
+ program.validate();
537
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 30))).map(x => x.label).sort()).to.eql(['sayHello', 'sayHello2', 'sayHello3', 'sayHello4']);
538
+ });
539
+ it('gets completions for callfunc invocation with multiple nodes and validates single code completion results', () => {
540
+ program.setFile('source/main.bs', `
541
+ function main()
542
+ ParentNode@.sayHello(arg1)
543
+ end function
544
+ `);
545
+ program.setFile('components/ParentNode.bs', `
546
+ function sayHello(text, text2)
547
+ end function
548
+ `);
549
+ program.setFile('components/ParentNode.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
550
+ <component name="ParentNode" extends="Scene">
551
+ <script type="text/brightscript" uri="pkg:/components/ParentNode.bs" />
552
+ <interface>
553
+ <function name="sayHello"/>
554
+ </interface>
555
+ </component>`);
556
+ program.setFile('components/ChildNode.bs', `
557
+ function sayHello(text, text2)
558
+ end function
559
+ `);
560
+ program.setFile('components/ChildNode.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
561
+ <component name="ChildNode" extends="ParentNode">
562
+ <script type="text/brightscript" uri="pkg:/components/ChildNode.bs" />
563
+ </component>`);
564
+ program.validate();
565
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 31))).map(x => x.label).sort()).to.eql(['sayHello']);
566
+ });
567
+ it('gets completions for extended nodes with callfunc invocation - ensure overridden methods included', () => {
568
+ program.setFile('source/main.bs', `
569
+ function main()
570
+ myNode@.sayHello(arg1)
571
+ end function
572
+ `);
573
+ program.setFile('components/MyNode.bs', `
574
+ function sayHello(text, text2)
575
+ end function
576
+ function sayHello2(text, text2)
577
+ end function
578
+ `);
579
+ program.setFile('components/MyNode.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
580
+ <component name="Component1" extends="Scene">
581
+ <script type="text/brightscript" uri="pkg:/components/MyNode.bs" />
582
+ <interface>
583
+ <function name="sayHello"/>
584
+ <function name="sayHello2"/>
585
+ </interface>
586
+ </component>`);
587
+ program.setFile('components/MyNode2.bs', `
588
+ function sayHello3(text, text2)
589
+ end function
590
+ function sayHello2(text, text2)
591
+ end function
592
+ function sayHello4(text, text2)
593
+ end function
594
+ `);
595
+ program.setFile('components/MyNode2.xml', (0, testHelpers_spec_1.trim) `<?xml version="1.0" encoding="utf-8" ?>
596
+ <component name="Component2" extends="Component1">
597
+ <script type="text/brightscript" uri="pkg:/components/MyNode2.bs" />
598
+ <interface>
599
+ <function name="sayHello3"/>
600
+ <function name="sayHello4"/>
601
+ </interface>
602
+ </component>`);
603
+ program.validate();
604
+ (0, chai_config_spec_1.expect)((program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 30))).map(x => x.label).sort()).to.eql(['sayHello', 'sayHello2', 'sayHello3', 'sayHello4']);
605
+ });
606
+ describe('getCompletions', () => {
607
+ it('returns all functions in scope', () => {
608
+ program.setFile('source/main.brs', `
609
+ sub Main()
610
+
611
+ end sub
612
+
613
+ sub ActionA()
614
+ end sub
615
+ `);
616
+ program.setFile('source/lib.brs', `
617
+ sub ActionB()
618
+ end sub
619
+ `);
620
+ program.validate();
621
+ let completions = program
622
+ //get completions
623
+ .getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, util_1.default.createPosition(2, 10))
624
+ //only keep the label property for this test
625
+ .map(x => pick(x, 'label'));
626
+ (0, chai_config_spec_1.expect)(completions).to.deep.include({ label: 'Main' });
627
+ (0, chai_config_spec_1.expect)(completions).to.deep.include({ label: 'ActionA' });
628
+ (0, chai_config_spec_1.expect)(completions).to.deep.include({ label: 'ActionB' });
629
+ });
630
+ it('returns all variables in scope', () => {
631
+ program.setFile('source/main.brs', `
632
+ sub Main()
633
+ name = "bob"
634
+ age = 20
635
+ shoeSize = 12.5
636
+ end sub
637
+ sub ActionA()
638
+ end sub
639
+ `);
640
+ program.setFile('source/lib.brs', `
641
+ sub ActionB()
642
+ end sub
643
+ `);
644
+ program.validate();
645
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, util_1.default.createPosition(2, 24));
646
+ let labels = completions.map(x => pick(x, 'label'));
647
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'Main' });
648
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'ActionA' });
649
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'ActionB' });
650
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'name' });
651
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'age' });
652
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'shoeSize' });
653
+ });
654
+ it('returns empty set when out of range', () => {
655
+ const position = util_1.default.createPosition(99, 99);
656
+ const mainFile = program.setFile('source/main.brs', '');
657
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, position);
658
+ const completionProcessor = new CompletionsProcessor_1.CompletionsProcessor({
659
+ program: program,
660
+ file: mainFile,
661
+ position: position,
662
+ scopes: [],
663
+ completions: []
664
+ });
665
+ program.validate();
666
+ //get the name of all global completions
667
+ const globalCompletions = program.globalScope.getAllFiles().flatMap(x => completionProcessor.getBrsFileCompletions(position, x, program.globalScope)).map(x => x.label);
668
+ //filter out completions from global scope
669
+ completions = completions.filter(x => !globalCompletions.includes(x.label));
670
+ (0, chai_config_spec_1.expect)(completions).to.be.empty;
671
+ });
672
+ it('finds parameters', () => {
673
+ program.setFile('source/main.brs', `
674
+ sub Main(count = 1)
675
+ firstName = "bob"
676
+ age = 21
677
+ shoeSize = 10
678
+ end sub
679
+ `);
680
+ program.validate();
681
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 10));
682
+ let labels = completions.map(x => pick(x, 'label'));
683
+ (0, chai_config_spec_1.expect)(labels).to.deep.include({ label: 'count' });
684
+ });
685
+ });
686
+ });
687
+ describe('getCompletions - BrsFile.spec', () => {
688
+ it('does not crash for callfunc on a function call', () => {
689
+ const file = program.setFile('source/main.brs', `
690
+ sub main()
691
+ getManager()@.
692
+ end sub
693
+ `);
694
+ program.validate();
695
+ (0, chai_config_spec_1.expect)(() => {
696
+ program.getCompletions(file.srcPath, util_1.default.createPosition(2, 34));
697
+ }).not.to.throw;
698
+ });
699
+ it('suggests pkg paths in strings that match that criteria', () => {
700
+ program.setFile('source/main.brs', `
701
+ sub main()
702
+ print "pkg:"
703
+ end sub
704
+ `);
705
+ program.validate();
706
+ const result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 31));
707
+ const names = result.map(x => x.label);
708
+ (0, chai_config_spec_1.expect)(names.sort()).to.eql([
709
+ 'pkg:/source/main.brs'
710
+ ]);
711
+ });
712
+ it('suggests libpkg paths in strings that match that criteria', () => {
713
+ program.setFile('source/main.brs', `
714
+ sub main()
715
+ print "libpkg:"
716
+ end sub
717
+ `);
718
+ program.validate();
719
+ const result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 31));
720
+ const names = result.map(x => x.label);
721
+ (0, chai_config_spec_1.expect)(names.sort()).to.eql([
722
+ 'libpkg:/source/main.brs'
723
+ ]);
724
+ });
725
+ it('suggests pkg paths in template strings', () => {
726
+ program.setFile('source/main.brs', `
727
+ sub main()
728
+ print \`pkg:\`
729
+ end sub
730
+ `);
731
+ program.validate();
732
+ const result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 31));
733
+ const names = result.map(x => x.label);
734
+ (0, chai_config_spec_1.expect)(names.sort()).to.eql([
735
+ 'pkg:/source/main.brs'
736
+ ]);
737
+ });
738
+ it('waits for the file to be processed before collecting completions', () => {
739
+ //eslint-disable-next-line @typescript-eslint/no-floating-promises
740
+ program.setFile('source/main.brs', `
741
+ sub Main()
742
+ print "hello"
743
+ Say
744
+ end sub
745
+
746
+ sub SayHello()
747
+ end sub
748
+ `);
749
+ program.validate();
750
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 23));
751
+ let names = result.map(x => x.label);
752
+ (0, chai_config_spec_1.expect)(names).to.includes('Main');
753
+ (0, chai_config_spec_1.expect)(names).to.includes('SayHello');
754
+ });
755
+ it('includes every type of item at base level', () => {
756
+ program.setFile('source/main.bs', `
757
+ sub main()
758
+ print
759
+ end sub
760
+ sub speak()
761
+ end sub
762
+ namespace stuff
763
+ end namespace
764
+ class Person
765
+ end class
766
+ enum Direction
767
+ end enum
768
+ `);
769
+ program.validate();
770
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 26)), [{
771
+ label: 'main',
772
+ kind: vscode_languageserver_1.CompletionItemKind.Function
773
+ }, {
774
+ label: 'speak',
775
+ kind: vscode_languageserver_1.CompletionItemKind.Function
776
+ }, {
777
+ label: 'stuff',
778
+ kind: vscode_languageserver_1.CompletionItemKind.Module
779
+ }, {
780
+ label: 'Person',
781
+ kind: vscode_languageserver_1.CompletionItemKind.Class
782
+ }, {
783
+ label: 'Direction',
784
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
785
+ }]);
786
+ });
787
+ describe('namespaces', () => {
788
+ it('gets full namespace completions at any point through the leading identifier', () => {
789
+ program.setFile('source/main.bs', `
790
+ sub main()
791
+ foo.bar
792
+ end sub
793
+
794
+ namespace foo.bar
795
+ end namespace
796
+
797
+ class Person
798
+ end class
799
+ `);
800
+ program.validate();
801
+ const result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(2, 24)).map(x => x.label);
802
+ (0, chai_config_spec_1.expect)(result).includes('main');
803
+ (0, chai_config_spec_1.expect)(result).includes('foo');
804
+ (0, chai_config_spec_1.expect)(result).includes('Person');
805
+ });
806
+ it('gets namespace completions', () => {
807
+ program.setFile('source/main.bs', `
808
+ namespace foo.bar
809
+ function sayHello()
810
+ end function
811
+ end namespace
812
+
813
+ sub Main()
814
+ print "hello"
815
+ foo.ba
816
+ foo.bar.
817
+ end sub
818
+ `);
819
+ program.validate();
820
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(8, 30));
821
+ let names = result.map(x => x.label);
822
+ (0, chai_config_spec_1.expect)(names).to.includes('bar');
823
+ result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.bs`, vscode_languageserver_1.Position.create(9, 32));
824
+ names = result.map(x => x.label);
825
+ (0, chai_config_spec_1.expect)(names).to.includes('sayHello');
826
+ });
827
+ });
828
+ it('always includes `m`', () => {
829
+ program.setFile('source/main.brs', `
830
+ sub Main()
831
+
832
+ end sub
833
+ `);
834
+ program.validate();
835
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
836
+ let names = result.map(x => x.label);
837
+ (0, chai_config_spec_1.expect)(names).to.contain('m');
838
+ });
839
+ it('does not fail for missing previousToken', () => {
840
+ //add a single character to the file, and get completions after it
841
+ program.setFile('source/main.brs', `i`);
842
+ program.validate();
843
+ (0, chai_config_spec_1.expect)(() => {
844
+ program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(0, 1)).map(x => x.label);
845
+ }).not.to.throw;
846
+ });
847
+ it.skip('includes all keywords`', () => {
848
+ program.setFile('source/main.brs', `
849
+ sub Main()
850
+
851
+ end sub
852
+ `);
853
+ program.validate();
854
+ let keywords = Object.keys(TokenKind_1.Keywords).filter(x => !x.includes(' '));
855
+ //inside the function
856
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
857
+ let names = result.map(x => x.label);
858
+ for (let keyword of keywords) {
859
+ (0, chai_config_spec_1.expect)(names).to.include(keyword);
860
+ }
861
+ //outside the function
862
+ result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(4, 8));
863
+ names = result.map(x => x.label);
864
+ for (let keyword of keywords) {
865
+ (0, chai_config_spec_1.expect)(names).to.include(keyword);
866
+ }
867
+ });
868
+ it('does not provide completions within a comment', () => {
869
+ program.setFile('source/main.brs', `
870
+ sub Main()
871
+ 'some comment
872
+ end sub
873
+ `);
874
+ program.validate();
875
+ //inside the function
876
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 33));
877
+ (0, chai_config_spec_1.expect)(result).to.be.lengthOf(0);
878
+ });
879
+ it('does not provide duplicate entries for variables', () => {
880
+ program.setFile('source/main.brs', `
881
+ sub Main()
882
+ name = "bob"
883
+ age = 12
884
+ name = "john"
885
+ end sub
886
+ `);
887
+ program.validate();
888
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 23));
889
+ let count = result.reduce((total, x) => {
890
+ return x.label === 'name' ? total + 1 : total;
891
+ }, 0);
892
+ (0, chai_config_spec_1.expect)(count).to.equal(1);
893
+ });
894
+ it('does not include `as` and `string` text options when used in function params', () => {
895
+ program.setFile('source/main.brs', `
896
+ sub Main(name as string)
897
+
898
+ end sub
899
+ `);
900
+ program.validate();
901
+ let result = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 23));
902
+ (0, chai_config_spec_1.expect)(result.filter(x => x.kind === vscode_languageserver_1.CompletionItemKind.Text)).not.to.contain('as');
903
+ (0, chai_config_spec_1.expect)(result.filter(x => x.kind === vscode_languageserver_1.CompletionItemKind.Text)).not.to.contain('string');
904
+ });
905
+ it('does not provide intellisense results when inside a comment', () => {
906
+ program.setFile('source/main.brs', `
907
+ sub Main(name as string)
908
+ 'this is a comment
909
+ end sub
910
+ `);
911
+ program.validate();
912
+ let results = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(2, 30));
913
+ (0, chai_config_spec_1.expect)(results).to.be.empty;
914
+ });
915
+ it('does provide intellisence for labels only after a goto keyword', () => {
916
+ var _a;
917
+ program.setFile('source/main.brs', `
918
+ sub Main(name as string)
919
+ something:
920
+ goto \nend sub
921
+ `);
922
+ program.validate();
923
+ let results = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 25));
924
+ (0, chai_config_spec_1.expect)(results.length).to.equal(1);
925
+ (0, chai_config_spec_1.expect)((_a = results[0]) === null || _a === void 0 ? void 0 : _a.label).to.equal('something');
926
+ });
927
+ });
928
+ describe('getCompletions - XmlFile.spec', () => {
929
+ it('formats completion paths with proper slashes', () => {
930
+ let scriptPath = (0, util_1.standardizePath) `C:/app/components/component1/component1.brs`;
931
+ program.files[scriptPath] = new BrsFile_1.BrsFile(scriptPath, (0, util_1.standardizePath) `components/component1/component1.brs`, program);
932
+ let xmlFile = new XmlFile_1.XmlFile((0, util_1.standardizePath) `${testHelpers_spec_1.rootDir}/components/component1/component1.xml`, (0, util_1.standardizePath) `components/component1/component1.xml`, program);
933
+ xmlFile.parser.references.scriptTagImports.push({
934
+ pkgPath: (0, util_1.standardizePath) `components/component1/component1.brs`,
935
+ text: 'component1.brs',
936
+ filePathRange: vscode_languageserver_1.Range.create(1, 1, 1, 1)
937
+ });
938
+ const processesor = new CompletionsProcessor_1.CompletionsProcessor(null);
939
+ const completions = processesor.getXmlFileCompletions(vscode_languageserver_1.Position.create(1, 1), xmlFile);
940
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(completions, [{
941
+ label: 'component1.brs',
942
+ kind: vscode_languageserver_1.CompletionItemKind.File
943
+ }, {
944
+ label: 'pkg:/components/component1/component1.brs',
945
+ kind: vscode_languageserver_1.CompletionItemKind.File
946
+ }]);
947
+ });
948
+ //TODO - refine this test once cdata scripts are supported
949
+ it('prevents scope completions entirely', () => {
950
+ program.setFile('components/component1.brs', ``);
951
+ let xmlFile = program.setFile('components/component1.xml', (0, testHelpers_spec_1.trim) `
952
+ <?xml version="1.0" encoding="utf-8" ?>
953
+ <component name="ParentScene" extends="GrandparentScene">
954
+ <script type="text/brightscript" uri="./Component1.brs" />
955
+ </component>
956
+ `);
957
+ program.validate();
958
+ (0, chai_config_spec_1.expect)(program.getCompletions(xmlFile.srcPath, vscode_languageserver_1.Position.create(1, 1))).to.be.empty;
959
+ });
960
+ });
961
+ describe('documentation', () => {
962
+ it('returns documentation when possible', () => {
963
+ program.setFile('source/main.brs', `
964
+ sub Main()
965
+ print "hello"
966
+ Say
967
+ end sub
968
+
969
+ ' Says hello to the world
970
+ sub SayHello()
971
+ end sub
972
+ `);
973
+ program.validate();
974
+ // Say|
975
+ let completions = program.getCompletions(`${testHelpers_spec_1.rootDir}/source/main.brs`, vscode_languageserver_1.Position.create(3, 22));
976
+ //it should find the completions for the global scope
977
+ (0, chai_config_spec_1.expect)(completions).to.be.length.greaterThan(0);
978
+ //it should find documentation for completions
979
+ (0, chai_config_spec_1.expect)(completions.filter(x => !!x.documentation)).to.have.length.greaterThan(0);
980
+ });
981
+ });
982
+ describe('getPartialVariableName', () => {
983
+ let entry = {
984
+ src: `${testHelpers_spec_1.rootDir}/source/lib.brs`,
985
+ dest: `source/lib.brs`
986
+ };
987
+ it('creates proper tokens', () => {
988
+ const file = program.setFile(entry, `call(ModuleA.ModuleB.ModuleC.`);
989
+ (0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[7])).to.equal('ModuleA.ModuleB.ModuleC.');
990
+ (0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[6])).to.equal('ModuleA.ModuleB.ModuleC');
991
+ (0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[5])).to.equal('ModuleA.ModuleB.');
992
+ (0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[4])).to.equal('ModuleA.ModuleB');
993
+ (0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[3])).to.equal('ModuleA.');
994
+ (0, chai_config_spec_1.expect)(file['getPartialVariableName'](file.parser.tokens[2])).to.equal('ModuleA');
995
+ });
996
+ });
997
+ describe('const completions', () => {
998
+ it('shows up in standard completions', () => {
999
+ program.setFile('source/main.bs', `
1000
+ const API_KEY = "123"
1001
+ sub log(message)
1002
+ log()
1003
+ end sub
1004
+ `);
1005
+ program.validate();
1006
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(
1007
+ // log(|)
1008
+ program.getCompletions('source/main.bs', util_1.default.createPosition(3, 24)), [{
1009
+ label: 'API_KEY',
1010
+ kind: vscode_languageserver_1.CompletionItemKind.Constant
1011
+ }]);
1012
+ });
1013
+ it('shows up in namespace completions', () => {
1014
+ program.setFile('source/main.bs', `
1015
+ namespace constants
1016
+ const API_KEY = "123"
1017
+ end namespace
1018
+ sub log(message)
1019
+ log(constants.)
1020
+ end sub
1021
+ `);
1022
+ program.validate();
1023
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(
1024
+ // log(|)
1025
+ program.getCompletions('source/main.bs', util_1.default.createPosition(5, 34)), [{
1026
+ label: 'API_KEY',
1027
+ kind: vscode_languageserver_1.CompletionItemKind.Constant
1028
+ }]);
1029
+ });
1030
+ });
1031
+ describe('enum completions', () => {
1032
+ it('does not crash when completing enum members with unsupported values', () => {
1033
+ program.setFile('source/main.bs', `
1034
+ sub Main()
1035
+ direction.obj
1036
+ end sub
1037
+ enum Direction
1038
+ up
1039
+ down
1040
+ obj = {}
1041
+ end enum
1042
+ `);
1043
+ program.validate();
1044
+ // direction.|obj
1045
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 30)), [{
1046
+ label: 'up',
1047
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1048
+ }, {
1049
+ label: 'down',
1050
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1051
+ }, {
1052
+ label: 'obj',
1053
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1054
+ }]);
1055
+ });
1056
+ it('gets enum statement completions from global enum', () => {
1057
+ program.setFile('source/main.bs', `
1058
+ sub Main()
1059
+ direction.down
1060
+ end sub
1061
+ enum Direction
1062
+ up
1063
+ down
1064
+ end enum
1065
+ `);
1066
+ program.validate();
1067
+ // |direction.down
1068
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 20)), [{
1069
+ label: 'Direction',
1070
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1071
+ }]);
1072
+ // dire|ction.down
1073
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 24)), [{
1074
+ label: 'Direction',
1075
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1076
+ }]);
1077
+ // direction|.down
1078
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 29)), [{
1079
+ label: 'Direction',
1080
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1081
+ }]);
1082
+ });
1083
+ it('gets enum member completions from global enum', () => {
1084
+ program.setFile('source/main.bs', `
1085
+ sub Main()
1086
+ direction.down
1087
+ end sub
1088
+ enum Direction
1089
+ up
1090
+ down
1091
+ end enum
1092
+ `);
1093
+ program.validate();
1094
+ // direction.|down
1095
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 30)), [{
1096
+ label: 'up',
1097
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1098
+ }, {
1099
+ label: 'down',
1100
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1101
+ }]);
1102
+ // direction.do|wn
1103
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 32)), [{
1104
+ label: 'up',
1105
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1106
+ }, {
1107
+ label: 'down',
1108
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1109
+ }]);
1110
+ // direction.down|
1111
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 34)), [{
1112
+ label: 'up',
1113
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1114
+ }, {
1115
+ label: 'down',
1116
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1117
+ }]);
1118
+ });
1119
+ it('gets enum statement completions from namespaced enum', () => {
1120
+ program.setFile('source/main.bs', `
1121
+ sub Main()
1122
+ enums.direction.down
1123
+ end sub
1124
+ namespace enums
1125
+ enum Direction
1126
+ up
1127
+ down
1128
+ end enum
1129
+ end namespace
1130
+ `);
1131
+ program.validate();
1132
+ // enums.|direction.down
1133
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 26)), [{
1134
+ label: 'Direction',
1135
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1136
+ }]);
1137
+ // enums.dire|ction.down
1138
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 30)), [{
1139
+ label: 'Direction',
1140
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1141
+ }]);
1142
+ // enums.direction|.down
1143
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 35)), [{
1144
+ label: 'Direction',
1145
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1146
+ }]);
1147
+ });
1148
+ it('gets enum member completions from namespaced enum', () => {
1149
+ program.setFile('source/main.bs', `
1150
+ sub Main()
1151
+ enums.direction.down
1152
+ end sub
1153
+ namespace enums
1154
+ enum Direction
1155
+ up
1156
+ down
1157
+ end enum
1158
+ end namespace
1159
+ `);
1160
+ program.validate();
1161
+ // enums.direction.|down
1162
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 36)), [{
1163
+ label: 'up',
1164
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1165
+ }, {
1166
+ label: 'down',
1167
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1168
+ }]);
1169
+ // enums.direction.do|wn
1170
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 38)), [{
1171
+ label: 'up',
1172
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1173
+ }, {
1174
+ label: 'down',
1175
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1176
+ }]);
1177
+ // enums.direction.down|
1178
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 40)), [{
1179
+ label: 'up',
1180
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1181
+ }, {
1182
+ label: 'down',
1183
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1184
+ }]);
1185
+ });
1186
+ it('excludes enum member completions from namespace enum', () => {
1187
+ program.setFile('source/main.bs', `
1188
+ sub Main()
1189
+ direction.ba
1190
+ end sub
1191
+ namespace enums
1192
+ enum Direction
1193
+ up
1194
+ down
1195
+ end enum
1196
+ end namespace
1197
+ `);
1198
+ program.validate();
1199
+ //should NOT find Direction because it's not directly available at the top level (you need to go through `enums.` to get at it)
1200
+ // dire|ction.down
1201
+ (0, testHelpers_spec_1.expectCompletionsExcludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 24)), [{
1202
+ label: 'Direction',
1203
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1204
+ }]);
1205
+ });
1206
+ it('infers namespace for enum statement completions', () => {
1207
+ program.setFile('source/main.bs', `
1208
+ namespace enums
1209
+ sub Main()
1210
+ direction.down
1211
+ end sub
1212
+ enum Direction
1213
+ up
1214
+ down
1215
+ end enum
1216
+ end namespace
1217
+ enum Logic
1218
+ yes
1219
+ no
1220
+ end enum
1221
+ `);
1222
+ program.validate();
1223
+ // dire|ction.down
1224
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(3, 33)), [{
1225
+ label: 'Direction',
1226
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1227
+ }, {
1228
+ label: 'Logic',
1229
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1230
+ }]);
1231
+ });
1232
+ it('infers namespace for enum member completions', () => {
1233
+ program.setFile('source/main.bs', `
1234
+ namespace enums
1235
+ sub Main()
1236
+ direction.down
1237
+ end sub
1238
+ enum Direction
1239
+ up
1240
+ down
1241
+ end enum
1242
+ end namespace
1243
+ `);
1244
+ program.validate();
1245
+ // direction.do|wn
1246
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(3, 36)), [{
1247
+ label: 'up',
1248
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1249
+ }, {
1250
+ label: 'down',
1251
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1252
+ }]);
1253
+ });
1254
+ it('supports explicit namespace for enum statement completions', () => {
1255
+ program.setFile('source/main.bs', `
1256
+ namespace enums
1257
+ sub Main()
1258
+ enums.direction.down
1259
+ end sub
1260
+ enum Direction
1261
+ up
1262
+ down
1263
+ end enum
1264
+ end namespace
1265
+ `);
1266
+ program.validate();
1267
+ // enums.dire|ction.down
1268
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(3, 38)), [{
1269
+ label: 'Direction',
1270
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1271
+ }]);
1272
+ });
1273
+ it('supports explicit namespace for enum statement completions', () => {
1274
+ program.setFile('source/main.bs', `
1275
+ namespace logger
1276
+ sub log()
1277
+ enums.direction.down
1278
+ end sub
1279
+ end namespace
1280
+ namespace enums
1281
+ enum Direction
1282
+ up
1283
+ down
1284
+ end enum
1285
+ end namespace
1286
+ `);
1287
+ program.validate();
1288
+ // enums.dire|ction.down
1289
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(3, 38)), [{
1290
+ label: 'Direction',
1291
+ kind: vscode_languageserver_1.CompletionItemKind.Enum
1292
+ }]);
1293
+ });
1294
+ it('gives completions for underlying types on enum members', () => {
1295
+ program.setFile('source/main.bs', `
1296
+ enum Direction
1297
+ up = "up"
1298
+ down = "down"
1299
+ end enum
1300
+
1301
+ sub goAway(dir as Direction)
1302
+ print dir.
1303
+ end sub
1304
+
1305
+ `);
1306
+ program.validate();
1307
+ // print dir.|
1308
+ const completions = program.getCompletions('source/main.bs', util_1.default.createPosition(7, 31));
1309
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(completions, [{
1310
+ label: 'Trim',
1311
+ kind: vscode_languageserver_1.CompletionItemKind.Method
1312
+ }]);
1313
+ });
1314
+ it('gives completions for underlying types on enum members on future enum declaration', () => {
1315
+ program.setFile('source/main.bs', `
1316
+ sub goAway(dir as Direction)
1317
+ print dir.
1318
+ end sub
1319
+
1320
+ enum Direction
1321
+ up = "up"
1322
+ down = "down"
1323
+ end enum
1324
+ `);
1325
+ program.validate();
1326
+ // print dir.|
1327
+ const completions = program.getCompletions('source/main.bs', util_1.default.createPosition(2, 31));
1328
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(completions, [{
1329
+ label: 'Trim',
1330
+ kind: vscode_languageserver_1.CompletionItemKind.Method
1331
+ }]);
1332
+ });
1333
+ it('does not give other members on enum member completion', () => {
1334
+ program.setFile('source/main.bs', `
1335
+ sub goAway(dir as Direction)
1336
+ print dir.
1337
+ end sub
1338
+
1339
+ enum Direction
1340
+ up = "up"
1341
+ down = "down"
1342
+ end enum
1343
+ `);
1344
+ program.validate();
1345
+ // print dir.|
1346
+ const completions = program.getCompletions('source/main.bs', util_1.default.createPosition(2, 31));
1347
+ (0, testHelpers_spec_1.expectCompletionsExcludes)(completions, [{
1348
+ label: 'down',
1349
+ kind: vscode_languageserver_1.CompletionItemKind.EnumMember
1350
+ }]);
1351
+ });
1352
+ });
1353
+ describe('built in type members', () => {
1354
+ it('finds built in members', () => {
1355
+ program.setFile('source/main.bs', `
1356
+ sub foo(name as string)
1357
+ print name.
1358
+ end sub
1359
+ `);
1360
+ program.validate();
1361
+ // print name|.
1362
+ (0, testHelpers_spec_1.expectCompletionsIncludes)(program.getCompletions('source/main.bs', util_1.default.createPosition(2, 32)), [{
1363
+ label: 'Replace',
1364
+ kind: vscode_languageserver_1.CompletionItemKind.Method
1365
+ }]);
1366
+ });
1367
+ });
1368
+ });
1369
+ //# sourceMappingURL=CompletionsProcessor.spec.js.map