brighterscript 1.0.0-alpha.26 → 1.0.0-alpha.28
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.
- package/CHANGELOG.md +82 -5
- package/README.md +1 -1
- package/dist/AstValidationSegmenter.d.ts +1 -1
- package/dist/AstValidationSegmenter.js +4 -5
- package/dist/AstValidationSegmenter.js.map +1 -1
- package/dist/DiagnosticFilterer.d.ts +7 -4
- package/dist/DiagnosticFilterer.js +67 -37
- package/dist/DiagnosticFilterer.js.map +1 -1
- package/dist/DiagnosticMessages.d.ts +1 -3
- package/dist/DiagnosticMessages.js +5 -8
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/PluginInterface.js +1 -1
- package/dist/PluginInterface.js.map +1 -1
- package/dist/Program.d.ts +1 -1
- package/dist/Program.js +34 -31
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +7 -34
- package/dist/Scope.js +45 -305
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +1 -8
- package/dist/SymbolTable.js +1 -10
- package/dist/SymbolTable.js.map +1 -1
- package/dist/SymbolTypeFlag.d.ts +8 -0
- package/dist/SymbolTypeFlag.js +13 -0
- package/dist/SymbolTypeFlag.js.map +1 -0
- package/dist/XmlScope.d.ts +0 -8
- package/dist/XmlScope.js +6 -84
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/CachedLookups.d.ts +1 -2
- package/dist/astUtils/CachedLookups.js +4 -19
- package/dist/astUtils/CachedLookups.js.map +1 -1
- package/dist/astUtils/creators.d.ts +1 -0
- package/dist/astUtils/creators.js +48 -8
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/creators.spec.js +0 -10
- package/dist/astUtils/creators.spec.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +3 -2
- package/dist/astUtils/reflection.js +11 -7
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +11 -16
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +1 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +1 -5
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.d.ts +2 -1
- package/dist/bscPlugin/BscPlugin.js +4 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/SignatureHelpUtil.js +4 -3
- package/dist/bscPlugin/SignatureHelpUtil.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +1 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.js +46 -29
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +39 -0
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.d.ts +1 -0
- package/dist/bscPlugin/hover/HoverProcessor.js +30 -10
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +125 -7
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/references/ReferencesProvider.d.ts +12 -0
- package/dist/bscPlugin/references/ReferencesProvider.js +56 -0
- package/dist/bscPlugin/references/ReferencesProvider.js.map +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.d.ts +1 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js +51 -0
- package/dist/bscPlugin/references/ReferencesProvider.spec.js.map +1 -0
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -3
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +25 -31
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +34 -1
- package/dist/bscPlugin/validation/ScopeValidator.js +435 -27
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +178 -10
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/diagnosticUtils.d.ts +1 -1
- package/dist/files/BrsFile.Class.spec.js +15 -7
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +14 -5
- package/dist/files/BrsFile.js +83 -150
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +429 -162
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +2 -3
- package/dist/files/XmlFile.js +1 -3
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +117 -85
- package/dist/interfaces.js +9 -9
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/Lexer.d.ts +9 -3
- package/dist/lexer/Lexer.js +36 -15
- package/dist/lexer/Lexer.js.map +1 -1
- package/dist/lexer/Lexer.spec.js +76 -38
- package/dist/lexer/Lexer.spec.js.map +1 -1
- package/dist/lexer/Token.js +1 -1
- package/dist/lexer/Token.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +4 -1
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/AstNode.d.ts +1 -2
- package/dist/parser/AstNode.js +0 -1
- package/dist/parser/AstNode.js.map +1 -1
- package/dist/parser/BrsTranspileState.d.ts +1 -1
- package/dist/parser/Expression.d.ts +153 -135
- package/dist/parser/Expression.js +204 -114
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +15 -16
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.d.ts +8 -4
- package/dist/parser/Parser.js +108 -149
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +48 -72
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/SGParser.js +49 -35
- package/dist/parser/SGParser.js.map +1 -1
- package/dist/parser/SGTypes.d.ts +36 -24
- package/dist/parser/SGTypes.js +31 -60
- package/dist/parser/SGTypes.js.map +1 -1
- package/dist/parser/Statement.d.ts +214 -207
- package/dist/parser/Statement.js +248 -169
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +0 -13
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/TranspileState.d.ts +17 -8
- package/dist/parser/TranspileState.js +64 -6
- package/dist/parser/TranspileState.js.map +1 -1
- package/dist/parser/tests/Parser.spec.d.ts +1 -1
- package/dist/parser/tests/Parser.spec.js +1 -2
- package/dist/parser/tests/Parser.spec.js.map +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js +1 -1
- package/dist/parser/tests/controlFlow/If.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +1 -3
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +44 -0
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TemplateStringExpression.spec.js +6 -6
- package/dist/parser/tests/expression/TernaryExpression.spec.js +47 -0
- package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
- package/dist/parser/tests/expression/TypeExpression.spec.js +8 -9
- package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -1
- package/dist/parser/tests/statement/ConstStatement.spec.js +2 -2
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +8 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Misc.spec.js +25 -5
- package/dist/parser/tests/statement/Misc.spec.js.map +1 -1
- package/dist/parser/tests/statement/TryCatch.spec.js +9 -2
- package/dist/parser/tests/statement/TryCatch.spec.js.map +1 -1
- package/dist/preprocessor/Chunk.js +1 -2
- package/dist/preprocessor/Chunk.js.map +1 -1
- package/dist/preprocessor/PreprocessorParser.js +2 -1
- package/dist/preprocessor/PreprocessorParser.js.map +1 -1
- package/dist/roku-types/data.json +70 -52
- package/dist/roku-types/index.d.ts +43 -21
- package/dist/types/ArrayType.js +1 -2
- package/dist/types/ArrayType.js.map +1 -1
- package/dist/types/ArrayType.spec.js +7 -8
- package/dist/types/ArrayType.spec.js.map +1 -1
- package/dist/types/AssociativeArrayType.d.ts +3 -0
- package/dist/types/AssociativeArrayType.js +10 -2
- package/dist/types/AssociativeArrayType.js.map +1 -1
- package/dist/types/BscType.d.ts +1 -1
- package/dist/types/BscType.js +3 -3
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.js +7 -8
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +31 -32
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -1
- package/dist/types/ClassType.spec.js +10 -11
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +2 -1
- package/dist/types/ComponentType.js.map +1 -1
- package/dist/types/EnumType.js +2 -3
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/InheritableType.js +3 -4
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/InterfaceType.js +2 -3
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/InterfaceType.spec.js +3 -4
- package/dist/types/InterfaceType.spec.js.map +1 -1
- package/dist/types/ObjectType.js +1 -2
- package/dist/types/ObjectType.js.map +1 -1
- package/dist/types/ReferenceType.d.ts +1 -1
- package/dist/types/ReferenceType.spec.js +21 -22
- package/dist/types/ReferenceType.spec.js.map +1 -1
- package/dist/types/UnionType.js +3 -3
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/UnionType.spec.js +37 -38
- package/dist/types/UnionType.spec.js.map +1 -1
- package/dist/types/helper.spec.js +4 -5
- package/dist/types/helper.spec.js.map +1 -1
- package/dist/util.d.ts +21 -11
- package/dist/util.js +116 -37
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.d.ts +0 -9
- package/dist/validators/ClassValidator.js +3 -46
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +6 -3
package/dist/interfaces.d.ts
CHANGED
|
@@ -3,13 +3,12 @@ import type { Range, Diagnostic, CodeAction, SemanticTokenTypes, SemanticTokenMo
|
|
|
3
3
|
import type { Scope } from './Scope';
|
|
4
4
|
import type { BrsFile } from './files/BrsFile';
|
|
5
5
|
import type { XmlFile } from './files/XmlFile';
|
|
6
|
-
import type { FunctionScope } from './FunctionScope';
|
|
7
6
|
import type { TypedFunctionType } from './types/TypedFunctionType';
|
|
8
7
|
import type { ParseMode } from './parser/Parser';
|
|
9
8
|
import type { Program } from './Program';
|
|
10
9
|
import type { ProgramBuilder } from './ProgramBuilder';
|
|
11
10
|
import type { ClassStatement, ConstStatement, EnumStatement, FunctionStatement, NamespaceStatement } from './parser/Statement';
|
|
12
|
-
import type { AstNode, Expression, Statement } from './parser/AstNode';
|
|
11
|
+
import type { AstNode, AstNodeKind, Expression, Statement } from './parser/AstNode';
|
|
13
12
|
import type { TranspileState } from './parser/TranspileState';
|
|
14
13
|
import type { SourceNode } from 'source-map';
|
|
15
14
|
import type { BscType } from './types/BscType';
|
|
@@ -18,8 +17,8 @@ import type { Identifier, Token } from './lexer/Token';
|
|
|
18
17
|
import type { BscFile } from './files/BscFile';
|
|
19
18
|
import type { FileFactory } from './files/Factory';
|
|
20
19
|
import type { LazyFileData } from './files/LazyFileData';
|
|
21
|
-
import type { SymbolTable
|
|
22
|
-
import type {
|
|
20
|
+
import type { SymbolTable } from './SymbolTable';
|
|
21
|
+
import type { SymbolTypeFlag } from './SymbolTypeFlag';
|
|
23
22
|
export interface BsDiagnostic extends Diagnostic {
|
|
24
23
|
file: BscFile;
|
|
25
24
|
/**
|
|
@@ -73,28 +72,6 @@ export interface Callable {
|
|
|
73
72
|
*/
|
|
74
73
|
functionStatement: FunctionStatement;
|
|
75
74
|
}
|
|
76
|
-
export interface FunctionCall {
|
|
77
|
-
/**
|
|
78
|
-
* The full range of this function call (from the start of the function name to its closing paren)
|
|
79
|
-
*/
|
|
80
|
-
range: Range;
|
|
81
|
-
expression: CallExpression;
|
|
82
|
-
functionScope: FunctionScope;
|
|
83
|
-
file: BscFile;
|
|
84
|
-
name: string;
|
|
85
|
-
args: CallableArg[];
|
|
86
|
-
nameRange: Range;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* An argument for an expression call.
|
|
90
|
-
*/
|
|
91
|
-
export interface CallableArg {
|
|
92
|
-
text: string;
|
|
93
|
-
type: BscType;
|
|
94
|
-
typeToken: Token;
|
|
95
|
-
range: Range;
|
|
96
|
-
expression: Expression;
|
|
97
|
-
}
|
|
98
75
|
export interface CallableParam {
|
|
99
76
|
name: string;
|
|
100
77
|
type: BscType;
|
|
@@ -182,71 +159,71 @@ export interface CompilerPlugin {
|
|
|
182
159
|
/**
|
|
183
160
|
* Called before a new program is created
|
|
184
161
|
*/
|
|
185
|
-
beforeProgramCreate
|
|
162
|
+
beforeProgramCreate?(event: BeforeProgramCreateEvent): any;
|
|
186
163
|
/**
|
|
187
164
|
* Called after a new program is created
|
|
188
165
|
*/
|
|
189
|
-
afterProgramCreate
|
|
166
|
+
afterProgramCreate?(event: AfterProgramCreateEvent): any;
|
|
190
167
|
/**
|
|
191
168
|
* Called before the program gets prepared for building
|
|
192
169
|
*/
|
|
193
|
-
beforePrepareProgram
|
|
170
|
+
beforePrepareProgram?(event: BeforePrepareProgramEvent): any;
|
|
194
171
|
/**
|
|
195
172
|
* Called when the program gets prepared for building
|
|
196
173
|
*/
|
|
197
|
-
prepareProgram
|
|
174
|
+
prepareProgram?(event: PrepareProgramEvent): any;
|
|
198
175
|
/**
|
|
199
176
|
* Called after the program gets prepared for building
|
|
200
177
|
*/
|
|
201
|
-
afterPrepareProgram
|
|
178
|
+
afterPrepareProgram?(event: AfterPrepareProgramEvent): any;
|
|
202
179
|
/**
|
|
203
180
|
* Called before the entire program is validated
|
|
204
181
|
*/
|
|
205
|
-
beforeProgramValidate
|
|
182
|
+
beforeProgramValidate?(event: BeforeProgramValidateEvent): any;
|
|
206
183
|
/**
|
|
207
184
|
* Called before the entire program is validated
|
|
208
185
|
*/
|
|
209
|
-
onProgramValidate
|
|
186
|
+
onProgramValidate?(event: OnProgramValidateEvent): any;
|
|
210
187
|
/**
|
|
211
188
|
* Called after the program has been validated
|
|
212
189
|
*/
|
|
213
|
-
afterProgramValidate
|
|
190
|
+
afterProgramValidate?(event: AfterProgramValidateEvent): any;
|
|
214
191
|
/**
|
|
215
192
|
* Called right before the program is disposed/destroyed
|
|
216
193
|
*/
|
|
217
|
-
beforeProgramDispose
|
|
194
|
+
beforeProgramDispose?(event: BeforeProgramDisposeEvent): any;
|
|
218
195
|
/**
|
|
219
196
|
* Emitted before the program starts collecting completions
|
|
220
197
|
*/
|
|
221
|
-
beforeProvideCompletions
|
|
198
|
+
beforeProvideCompletions?(event: BeforeProvideCompletionsEvent): any;
|
|
222
199
|
/**
|
|
223
200
|
* Use this event to contribute completions
|
|
224
201
|
*/
|
|
225
|
-
provideCompletions
|
|
202
|
+
provideCompletions?(event: ProvideCompletionsEvent): any;
|
|
226
203
|
/**
|
|
227
204
|
* Emitted after the program has finished collecting completions, but before they are sent to the client
|
|
228
205
|
*/
|
|
229
|
-
afterProvideCompletions
|
|
206
|
+
afterProvideCompletions?(event: AfterProvideCompletionsEvent): any;
|
|
230
207
|
/**
|
|
231
208
|
* Called before the `provideHover` hook. Use this if you need to prepare any of the in-memory objects before the `provideHover` gets called
|
|
232
209
|
*/
|
|
233
|
-
beforeProvideHover
|
|
210
|
+
beforeProvideHover?(event: BeforeProvideHoverEvent): any;
|
|
234
211
|
/**
|
|
235
212
|
* Called when bsc looks for hover information. Use this if your plugin wants to contribute hover information.
|
|
236
213
|
*/
|
|
237
|
-
provideHover
|
|
214
|
+
provideHover?(event: ProvideHoverEvent): any;
|
|
238
215
|
/**
|
|
239
216
|
* Called after the `provideHover` hook. Use this if you want to intercept or sanitize the hover data (even from other plugins) before it gets sent to the client.
|
|
240
217
|
*/
|
|
241
|
-
afterProvideHover
|
|
218
|
+
afterProvideHover?(event: AfterProvideHoverEvent): any;
|
|
242
219
|
/**
|
|
243
220
|
* Called after a scope was created
|
|
244
221
|
*/
|
|
245
|
-
afterScopeCreate
|
|
246
|
-
beforeScopeDispose
|
|
247
|
-
onScopeDispose
|
|
248
|
-
afterScopeDispose
|
|
249
|
-
beforeScopeValidate
|
|
222
|
+
afterScopeCreate?(event: AfterScopeCreateEvent): any;
|
|
223
|
+
beforeScopeDispose?(event: BeforeScopeDisposeEvent): any;
|
|
224
|
+
onScopeDispose?(event: OnScopeDisposeEvent): any;
|
|
225
|
+
afterScopeDispose?(event: AfterScopeDisposeEvent): any;
|
|
226
|
+
beforeScopeValidate?(event: BeforeScopeValidateEvent): any;
|
|
250
227
|
/**
|
|
251
228
|
* Called before the `provideDefinition` hook
|
|
252
229
|
*/
|
|
@@ -261,120 +238,133 @@ export interface CompilerPlugin {
|
|
|
261
238
|
* @param event
|
|
262
239
|
*/
|
|
263
240
|
afterProvideDefinition?(event: AfterProvideDefinitionEvent): any;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
241
|
+
/**
|
|
242
|
+
* Called before the `provideReferences` hook
|
|
243
|
+
*/
|
|
244
|
+
beforeProvideReferences?(event: BeforeProvideReferencesEvent): any;
|
|
245
|
+
/**
|
|
246
|
+
* Provide all of the `Location`s where the symbol at the given position is located
|
|
247
|
+
* @param event
|
|
248
|
+
*/
|
|
249
|
+
provideReferences?(event: ProvideReferencesEvent): any;
|
|
250
|
+
/**
|
|
251
|
+
* Called after `provideReferences`. Use this if you want to intercept or sanitize the references data provided by bsc or other plugins
|
|
252
|
+
* @param event
|
|
253
|
+
*/
|
|
254
|
+
afterProvideReferences?(event: AfterProvideReferencesEvent): any;
|
|
255
|
+
onScopeValidate?(event: OnScopeValidateEvent): any;
|
|
256
|
+
afterScopeValidate?(event: BeforeScopeValidateEvent): any;
|
|
257
|
+
onGetCodeActions?(event: OnGetCodeActionsEvent): any;
|
|
258
|
+
onGetSemanticTokens?(event: OnGetSemanticTokensEvent): any;
|
|
268
259
|
/**
|
|
269
260
|
* Called before plugins are asked to provide files to the program. (excludes virtual files produced by `provideFile` events).
|
|
270
261
|
* Call the `setFileData()` method to override the file contents.
|
|
271
262
|
*/
|
|
272
|
-
beforeProvideFile
|
|
263
|
+
beforeProvideFile?(event: BeforeProvideFileEvent): any;
|
|
273
264
|
/**
|
|
274
265
|
* Give plugins the opportunity to handle processing a file. (excludes virtual files produced by `provideFile` events)
|
|
275
266
|
*/
|
|
276
|
-
provideFile
|
|
267
|
+
provideFile?(event: ProvideFileEvent): any;
|
|
277
268
|
/**
|
|
278
269
|
* Called after a file was added to the program. (excludes virtual files produced by `provideFile` events)
|
|
279
270
|
*/
|
|
280
|
-
afterProvideFile
|
|
271
|
+
afterProvideFile?(event: AfterProvideFileEvent): any;
|
|
281
272
|
/**
|
|
282
273
|
* Called before a file is added to the program.
|
|
283
274
|
* Includes physical files as well as any virtual files produced by `provideFile` events
|
|
284
275
|
*/
|
|
285
|
-
beforeFileAdd
|
|
276
|
+
beforeFileAdd?(event: BeforeFileAddEvent): any;
|
|
286
277
|
/**
|
|
287
278
|
* Called after a file has been added to the program.
|
|
288
279
|
* Includes physical files as well as any virtual files produced by `provideFile` events
|
|
289
280
|
*/
|
|
290
|
-
afterFileAdd
|
|
281
|
+
afterFileAdd?(event: AfterFileAddEvent): any;
|
|
291
282
|
/**
|
|
292
283
|
* Called before a file is removed from the program. This includes physical and virtual files
|
|
293
284
|
*/
|
|
294
|
-
beforeFileRemove
|
|
285
|
+
beforeFileRemove?(event: BeforeFileRemoveEvent): any;
|
|
295
286
|
/**
|
|
296
287
|
* Called after a file has been removed from the program. This includes physical and virtual files
|
|
297
288
|
*/
|
|
298
|
-
afterFileRemove
|
|
289
|
+
afterFileRemove?(event: AfterFileRemoveEvent): any;
|
|
299
290
|
/**
|
|
300
291
|
* Called before each file is validated
|
|
301
292
|
*/
|
|
302
|
-
beforeFileValidate
|
|
293
|
+
beforeFileValidate?(event: BeforeFileValidateEvent): any;
|
|
303
294
|
/**
|
|
304
295
|
* Called during the file validation process. If your plugin contributes file validations, this is a good place to contribute them.
|
|
305
296
|
*/
|
|
306
|
-
onFileValidate
|
|
297
|
+
onFileValidate?(event: OnFileValidateEvent): any;
|
|
307
298
|
/**
|
|
308
299
|
* Called after each file is validated
|
|
309
300
|
*/
|
|
310
|
-
afterFileValidate
|
|
301
|
+
afterFileValidate?(event: AfterFileValidateEvent): any;
|
|
311
302
|
/**
|
|
312
303
|
* Called right before the program builds (i.e. generates the code and puts it in the stagingDir
|
|
313
304
|
*/
|
|
314
|
-
beforeBuildProgram
|
|
305
|
+
beforeBuildProgram?(event: BeforeBuildProgramEvent): any;
|
|
315
306
|
/**
|
|
316
307
|
* Called right after the program builds (i.e. generates the code and puts it in the stagingDir
|
|
317
308
|
*/
|
|
318
|
-
afterBuildProgram
|
|
309
|
+
afterBuildProgram?(event: AfterBuildProgramEvent): any;
|
|
319
310
|
/**
|
|
320
311
|
* Before preparing the file for building
|
|
321
312
|
*/
|
|
322
|
-
beforePrepareFile
|
|
313
|
+
beforePrepareFile?(event: BeforePrepareFileEvent): any;
|
|
323
314
|
/**
|
|
324
315
|
* Prepare the file for building
|
|
325
316
|
*/
|
|
326
|
-
prepareFile
|
|
317
|
+
prepareFile?(event: PrepareFileEvent): any;
|
|
327
318
|
/**
|
|
328
319
|
* After preparing the file for building
|
|
329
320
|
*/
|
|
330
|
-
afterPrepareFile
|
|
321
|
+
afterPrepareFile?(event: AfterPrepareFileEvent): any;
|
|
331
322
|
/**
|
|
332
323
|
* Before the program turns all file objects into their final buffers
|
|
333
324
|
*/
|
|
334
|
-
beforeSerializeProgram
|
|
325
|
+
beforeSerializeProgram?(event: BeforeSerializeProgramEvent): any;
|
|
335
326
|
/**
|
|
336
327
|
* Emitted right at the start of the program turning all file objects into their final buffers
|
|
337
328
|
*/
|
|
338
|
-
onSerializeProgram
|
|
329
|
+
onSerializeProgram?(event: OnSerializeProgramEvent): any;
|
|
339
330
|
/**
|
|
340
331
|
* After the program turns all file objects into their final buffers
|
|
341
332
|
*/
|
|
342
|
-
afterSerializeProgram
|
|
333
|
+
afterSerializeProgram?(event: AfterSerializeProgramEvent): any;
|
|
343
334
|
/**
|
|
344
335
|
* Before turning the file into its final contents
|
|
345
336
|
*/
|
|
346
|
-
beforeSerializeFile
|
|
337
|
+
beforeSerializeFile?(event: BeforeSerializeFileEvent): any;
|
|
347
338
|
/**
|
|
348
339
|
* Turn the file into its final contents (i.e. transpile a bs file, compress a jpeg, etc)
|
|
349
340
|
*/
|
|
350
|
-
serializeFile
|
|
341
|
+
serializeFile?(event: SerializeFileEvent): any;
|
|
351
342
|
/**
|
|
352
343
|
* After turning the file into its final contents
|
|
353
344
|
*/
|
|
354
|
-
afterSerializeFile
|
|
345
|
+
afterSerializeFile?(event: AfterSerializeFileEvent): any;
|
|
355
346
|
/**
|
|
356
347
|
* Called before any files are written
|
|
357
348
|
*/
|
|
358
|
-
beforeWriteProgram
|
|
349
|
+
beforeWriteProgram?(event: BeforeWriteProgramEvent): any;
|
|
359
350
|
/**
|
|
360
351
|
* Called after all files are written
|
|
361
352
|
*/
|
|
362
|
-
afterWriteProgram
|
|
353
|
+
afterWriteProgram?(event: AfterWriteProgramEvent): any;
|
|
363
354
|
/**
|
|
364
355
|
* Before a file is written to disk. These are raw files that contain the final output. One `File` may produce several of these
|
|
365
356
|
*/
|
|
366
|
-
beforeWriteFile
|
|
357
|
+
beforeWriteFile?(event: BeforeWriteFileEvent): any;
|
|
367
358
|
/**
|
|
368
359
|
* Called when a file should be persisted (usually writing to storage). These are raw files that contain the final output. One `File` may produce several of these.
|
|
369
360
|
* When a plugin has handled a file, it should be pushed to the `handledFiles` set so future plugins don't write the file multiple times
|
|
370
361
|
*/
|
|
371
|
-
writeFile
|
|
362
|
+
writeFile?(event: WriteFileEvent): any;
|
|
372
363
|
/**
|
|
373
364
|
* Before a file is written to disk. These are raw files that contain the final output. One `File` may produce several of these
|
|
374
365
|
*/
|
|
375
|
-
afterWriteFile
|
|
366
|
+
afterWriteFile?(event: AfterWriteFileEvent): any;
|
|
376
367
|
}
|
|
377
|
-
export declare type PluginHandler<T, R = void> = (event: T) => R;
|
|
378
368
|
export interface OnGetCodeActionsEvent<TFile extends BscFile = BscFile> {
|
|
379
369
|
program: Program;
|
|
380
370
|
file: TFile;
|
|
@@ -486,6 +476,23 @@ export interface ProvideDefinitionEvent<TFile = BscFile> {
|
|
|
486
476
|
}
|
|
487
477
|
export declare type BeforeProvideDefinitionEvent<TFile = BscFile> = ProvideDefinitionEvent<TFile>;
|
|
488
478
|
export declare type AfterProvideDefinitionEvent<TFile = BscFile> = ProvideDefinitionEvent<TFile>;
|
|
479
|
+
export interface ProvideReferencesEvent<TFile = BscFile> {
|
|
480
|
+
program: Program;
|
|
481
|
+
/**
|
|
482
|
+
* The file that the getDefinition request was invoked in
|
|
483
|
+
*/
|
|
484
|
+
file: TFile;
|
|
485
|
+
/**
|
|
486
|
+
* The position in the text document where the getDefinition request was invoked
|
|
487
|
+
*/
|
|
488
|
+
position: Position;
|
|
489
|
+
/**
|
|
490
|
+
* The list of locations for where the item at the file and position was defined
|
|
491
|
+
*/
|
|
492
|
+
references: Location[];
|
|
493
|
+
}
|
|
494
|
+
export declare type BeforeProvideReferencesEvent<TFile = BscFile> = ProvideReferencesEvent<TFile>;
|
|
495
|
+
export declare type AfterProvideReferencesEvent<TFile = BscFile> = ProvideReferencesEvent<TFile>;
|
|
489
496
|
export interface OnGetSemanticTokensEvent<T extends BscFile = BscFile> {
|
|
490
497
|
/**
|
|
491
498
|
* The program this file is from
|
|
@@ -696,9 +703,15 @@ export interface SemanticToken {
|
|
|
696
703
|
tokenModifiers?: SemanticTokenModifiers[];
|
|
697
704
|
}
|
|
698
705
|
export interface TypedefProvider {
|
|
699
|
-
getTypedef(state: TranspileState):
|
|
706
|
+
getTypedef(state: TranspileState): TranspileResult;
|
|
700
707
|
}
|
|
701
|
-
export declare type TranspileResult = Array<(string | SourceNode)>;
|
|
708
|
+
export declare type TranspileResult = Array<(string | SourceNode | TranspileResult)>;
|
|
709
|
+
/**
|
|
710
|
+
* This is the type that the SourceNode class is declared as taking in its constructor.
|
|
711
|
+
* The actual type that SourceNode accepts is the more permissive TranspileResult, but
|
|
712
|
+
* we need to use this declared type for some type casts.
|
|
713
|
+
*/
|
|
714
|
+
export declare type FlattenedTranspileResult = Array<string | SourceNode>;
|
|
702
715
|
export declare type FileResolver = (srcPath: string) => string | Buffer | undefined | Thenable<string | Buffer | undefined> | void;
|
|
703
716
|
export interface ExpressionInfo {
|
|
704
717
|
expressions: Expression[];
|
|
@@ -724,15 +737,24 @@ export interface GetTypeOptions {
|
|
|
724
737
|
ignoreCall?: boolean;
|
|
725
738
|
onlyCacheResolvedTypes?: boolean;
|
|
726
739
|
ignoreCacheForRetrieval?: boolean;
|
|
740
|
+
isExistenceTest?: boolean;
|
|
727
741
|
}
|
|
728
742
|
export declare class TypeChainEntry {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
743
|
+
constructor(options: {
|
|
744
|
+
name: string;
|
|
745
|
+
type: BscType;
|
|
746
|
+
data: ExtraSymbolData;
|
|
747
|
+
range: Range;
|
|
748
|
+
separatorToken?: Token;
|
|
749
|
+
kind?: AstNodeKind;
|
|
750
|
+
});
|
|
735
751
|
get isResolved(): boolean;
|
|
752
|
+
readonly name: string;
|
|
753
|
+
readonly type: BscType;
|
|
754
|
+
readonly data: ExtraSymbolData;
|
|
755
|
+
readonly range: Range;
|
|
756
|
+
readonly separatorToken: Token;
|
|
757
|
+
kind: AstNodeKind;
|
|
736
758
|
}
|
|
737
759
|
export interface TypeChainProcessResult {
|
|
738
760
|
itemName: string;
|
|
@@ -773,3 +795,13 @@ export interface NamespaceContainer {
|
|
|
773
795
|
namespaces?: Map<string, NamespaceContainer>;
|
|
774
796
|
symbolTable: SymbolTable;
|
|
775
797
|
}
|
|
798
|
+
/**
|
|
799
|
+
* Use Writable<T> to remove readonly flag from properties in T
|
|
800
|
+
* Be careful!
|
|
801
|
+
*/
|
|
802
|
+
export declare type Writeable<T> = {
|
|
803
|
+
-readonly [P in keyof T]: T[P];
|
|
804
|
+
};
|
|
805
|
+
export declare type DeepWriteable<T> = {
|
|
806
|
+
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
807
|
+
};
|
package/dist/interfaces.js
CHANGED
|
@@ -11,15 +11,15 @@ var DiagnosticOrigin;
|
|
|
11
11
|
DiagnosticOrigin["ASTSegment"] = "AstSegment";
|
|
12
12
|
})(DiagnosticOrigin = exports.DiagnosticOrigin || (exports.DiagnosticOrigin = {}));
|
|
13
13
|
class TypeChainEntry {
|
|
14
|
-
constructor(
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
this
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
constructor(options) {
|
|
15
|
+
var _a;
|
|
16
|
+
this.name = options.name;
|
|
17
|
+
// make a copy of this data
|
|
18
|
+
this.data = Object.assign({}, options.data);
|
|
19
|
+
this.type = options.type;
|
|
20
|
+
this.range = options.range;
|
|
21
|
+
this.separatorToken = (_a = options.separatorToken) !== null && _a !== void 0 ? _a : (0, creators_1.createToken)(TokenKind_1.TokenKind.Dot);
|
|
22
|
+
this.kind = options.kind;
|
|
23
23
|
}
|
|
24
24
|
get isResolved() {
|
|
25
25
|
var _a;
|
package/dist/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAoBA,kDAAkD;AAClD,iDAA8C;AAU9C,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,uCAAmB,CAAA;IACnB,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,6CAAyB,CAAA;AAC7B,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAkyBD,MAAa,cAAc;IACvB,YAAY,OAOX;;QACG,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,2BAA2B;QAC3B,IAAI,CAAC,IAAI,qBAAQ,OAAO,CAAC,IAAI,CAAE,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,IAAA,sBAAW,EAAC,qBAAS,CAAC,GAAG,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC7B,CAAC;IACD,IAAI,UAAU;;QACV,OAAO,MAAA,IAAI,CAAC,IAAI,0CAAE,YAAY,EAAE,CAAC;IACrC,CAAC;CAQJ;AA3BD,wCA2BC"}
|
package/dist/lexer/Lexer.d.ts
CHANGED
|
@@ -205,14 +205,20 @@ export declare class Lexer {
|
|
|
205
205
|
*/
|
|
206
206
|
private sync;
|
|
207
207
|
/**
|
|
208
|
-
* Creates a `
|
|
209
|
-
* @returns the range of `text`
|
|
208
|
+
* Creates a `Range` at the lexer's current position
|
|
209
|
+
* @returns the range of `text`
|
|
210
210
|
*/
|
|
211
211
|
private rangeOf;
|
|
212
212
|
}
|
|
213
213
|
export interface ScanOptions {
|
|
214
214
|
/**
|
|
215
215
|
* If true, the whitespace tokens are included. If false, they are discarded
|
|
216
|
+
* @default false
|
|
216
217
|
*/
|
|
217
|
-
includeWhitespace
|
|
218
|
+
includeWhitespace?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Should locations be tracked. If false, the `range` property will be omitted
|
|
221
|
+
* @default true
|
|
222
|
+
*/
|
|
223
|
+
trackLocations?: boolean;
|
|
218
224
|
}
|
package/dist/lexer/Lexer.js
CHANGED
|
@@ -56,7 +56,9 @@ class Lexer {
|
|
|
56
56
|
kind: TokenKind_1.TokenKind.Eof,
|
|
57
57
|
isReserved: false,
|
|
58
58
|
text: '',
|
|
59
|
-
range:
|
|
59
|
+
range: this.options.trackLocations
|
|
60
|
+
? util_1.default.createRange(this.lineBegin, this.columnBegin, this.lineEnd, this.columnEnd + 1)
|
|
61
|
+
: undefined,
|
|
60
62
|
leadingWhitespace: this.leadingWhitespace,
|
|
61
63
|
leadingTrivia: this.leadingTrivia
|
|
62
64
|
});
|
|
@@ -73,7 +75,11 @@ class Lexer {
|
|
|
73
75
|
* Fill in missing/invalid options with defaults
|
|
74
76
|
*/
|
|
75
77
|
sanitizeOptions(options) {
|
|
76
|
-
|
|
78
|
+
var _a, _b;
|
|
79
|
+
options !== null && options !== void 0 ? options : (options = {});
|
|
80
|
+
(_a = options.includeWhitespace) !== null && _a !== void 0 ? _a : (options.includeWhitespace = false);
|
|
81
|
+
(_b = options.trackLocations) !== null && _b !== void 0 ? _b : (options.trackLocations = true);
|
|
82
|
+
return options;
|
|
77
83
|
}
|
|
78
84
|
/**
|
|
79
85
|
* Determines whether or not the lexer as reached the end of its input.
|
|
@@ -595,12 +601,16 @@ class Lexer {
|
|
|
595
601
|
*/
|
|
596
602
|
preProcessedConditional() {
|
|
597
603
|
this.advance(); // advance past the leading #
|
|
604
|
+
//consume whitespace
|
|
605
|
+
while (this.check(' ', '\t')) {
|
|
606
|
+
this.advance();
|
|
607
|
+
}
|
|
598
608
|
while ((0, Characters_1.isAlphaNumeric)(this.peek())) {
|
|
599
609
|
this.advance();
|
|
600
610
|
}
|
|
601
611
|
let text = this.source.slice(this.start, this.current).toLowerCase();
|
|
602
|
-
// some identifiers can be split into two words, so check the "next" word and see what we get
|
|
603
|
-
if ((text
|
|
612
|
+
// some identifiers can be split into two words (`#end if`, `#else if`), so check the "next" word and see what we get
|
|
613
|
+
if ((text.endsWith('end') || text.endsWith('else')) && this.check(' ', '\t')) {
|
|
604
614
|
let endOfFirstWord = this.current;
|
|
605
615
|
//skip past whitespace
|
|
606
616
|
while (this.check(' ', '\t')) {
|
|
@@ -610,18 +620,18 @@ class Lexer {
|
|
|
610
620
|
this.advance();
|
|
611
621
|
} // read the next word
|
|
612
622
|
let twoWords = this.source.slice(this.start, this.current).toLowerCase();
|
|
613
|
-
switch (twoWords.replace(
|
|
614
|
-
case '#
|
|
623
|
+
switch (twoWords.replace(/\s+/g, '')) {
|
|
624
|
+
case '#elseif':
|
|
615
625
|
this.addToken(TokenKind_1.TokenKind.HashElseIf);
|
|
616
626
|
return;
|
|
617
|
-
case '#
|
|
627
|
+
case '#endif':
|
|
618
628
|
this.addToken(TokenKind_1.TokenKind.HashEndIf);
|
|
619
629
|
return;
|
|
620
630
|
}
|
|
621
631
|
// reset if the last word and the current word didn't form a multi-word TokenKind
|
|
622
632
|
this.current = endOfFirstWord;
|
|
623
633
|
}
|
|
624
|
-
switch (text) {
|
|
634
|
+
switch (text.replace(/\s+/g, '')) {
|
|
625
635
|
case '#if':
|
|
626
636
|
this.addToken(TokenKind_1.TokenKind.HashIf);
|
|
627
637
|
return;
|
|
@@ -644,11 +654,15 @@ class Lexer {
|
|
|
644
654
|
if (this.check(' ', '\t')) {
|
|
645
655
|
this.whitespace();
|
|
646
656
|
}
|
|
647
|
-
|
|
657
|
+
let hasErrorMessage = false;
|
|
658
|
+
while (!this.isAtEnd() && !this.check('\r') && !this.check('\n')) {
|
|
659
|
+
hasErrorMessage = true;
|
|
648
660
|
this.advance();
|
|
649
661
|
}
|
|
650
|
-
|
|
651
|
-
|
|
662
|
+
if (hasErrorMessage) {
|
|
663
|
+
// grab all text since we found #error as one token
|
|
664
|
+
this.addToken(TokenKind_1.TokenKind.HashErrorMessage);
|
|
665
|
+
}
|
|
652
666
|
this.start = this.current;
|
|
653
667
|
return;
|
|
654
668
|
default:
|
|
@@ -737,7 +751,9 @@ class Lexer {
|
|
|
737
751
|
this.leadingTrivia = [];
|
|
738
752
|
}
|
|
739
753
|
this.leadingWhitespace = '';
|
|
740
|
-
|
|
754
|
+
if (kind !== TokenKind_1.TokenKind.Comment) {
|
|
755
|
+
this.tokens.push(token);
|
|
756
|
+
}
|
|
741
757
|
this.sync();
|
|
742
758
|
return token;
|
|
743
759
|
}
|
|
@@ -750,11 +766,16 @@ class Lexer {
|
|
|
750
766
|
this.columnBegin = this.columnEnd;
|
|
751
767
|
}
|
|
752
768
|
/**
|
|
753
|
-
* Creates a `
|
|
754
|
-
* @returns the range of `text`
|
|
769
|
+
* Creates a `Range` at the lexer's current position
|
|
770
|
+
* @returns the range of `text`
|
|
755
771
|
*/
|
|
756
772
|
rangeOf() {
|
|
757
|
-
|
|
773
|
+
if (this.options.trackLocations) {
|
|
774
|
+
return util_1.default.createRange(this.lineBegin, this.columnBegin, this.lineEnd, this.columnEnd);
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
return undefined;
|
|
778
|
+
}
|
|
758
779
|
}
|
|
759
780
|
}
|
|
760
781
|
exports.Lexer = Lexer;
|