brighterscript 0.57.2 → 0.58.0
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 +19 -0
- package/README.md +2 -0
- package/dist/Program.d.ts +7 -1
- package/dist/Program.js +49 -18
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +2 -1
- package/dist/Scope.js +8 -8
- package/dist/Scope.js.map +1 -1
- package/dist/astUtils/AstEditor.d.ts +2 -3
- package/dist/astUtils/AstEditor.js.map +1 -1
- package/dist/astUtils/creators.d.ts +4 -4
- package/dist/astUtils/creators.js +6 -6
- package/dist/astUtils/creators.js.map +1 -1
- package/dist/astUtils/reflection.d.ts +65 -64
- package/dist/astUtils/reflection.js.map +1 -1
- package/dist/astUtils/reflection.spec.js +3 -3
- package/dist/astUtils/reflection.spec.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +32 -31
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/BscPlugin.js +4 -0
- package/dist/bscPlugin/BscPlugin.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.spec.js +6 -0
- package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +2 -2
- package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.d.ts +1 -0
- package/dist/bscPlugin/validation/BrsFileValidator.js +118 -6
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +21 -19
- package/dist/bscPlugin/validation/ScopeValidator.js +164 -179
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/XmlFileValidator.d.ts +8 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js +44 -0
- package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -0
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +11 -5
- package/dist/files/BrsFile.js +15 -47
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +29 -0
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/files/XmlFile.d.ts +9 -4
- package/dist/files/XmlFile.js +6 -30
- package/dist/files/XmlFile.js.map +1 -1
- package/dist/files/tests/optionalChaning.spec.js +2 -1
- package/dist/files/tests/optionalChaning.spec.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 +2 -3
- package/dist/parser/AstNode.d.ts +65 -0
- package/dist/parser/AstNode.js +93 -0
- package/dist/parser/AstNode.js.map +1 -0
- package/dist/parser/AstNode.spec.d.ts +1 -0
- package/dist/parser/AstNode.spec.js +44 -0
- package/dist/parser/AstNode.spec.js.map +1 -0
- package/dist/parser/Expression.d.ts +6 -43
- package/dist/parser/Expression.js +53 -81
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.d.ts +11 -12
- package/dist/parser/Parser.js +118 -117
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.d.ts +1 -1
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +15 -44
- package/dist/parser/Statement.js +91 -102
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/Statement.spec.js +14 -7
- package/dist/parser/Statement.spec.js.map +1 -1
- package/dist/parser/tests/expression/ArrayLiterals.spec.js +37 -0
- package/dist/parser/tests/expression/ArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js +41 -0
- package/dist/parser/tests/expression/AssociativeArrayLiterals.spec.js.map +1 -1
- package/dist/parser/tests/expression/Call.spec.js +109 -1
- package/dist/parser/tests/expression/Call.spec.js.map +1 -1
- package/dist/parser/tests/expression/Indexing.spec.js +49 -4
- package/dist/parser/tests/expression/Indexing.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +7 -4
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/util.d.ts +11 -5
- package/dist/util.js +50 -0
- package/dist/util.js.map +1 -1
- package/dist/validators/ClassValidator.js +22 -19
- package/dist/validators/ClassValidator.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { WalkVisitor, WalkOptions } from '../astUtils/visitors';
|
|
2
|
+
import type { Position, Range } from 'vscode-languageserver';
|
|
3
|
+
import { InternalWalkMode } from '../astUtils/visitors';
|
|
4
|
+
import type { SymbolTable } from '../SymbolTable';
|
|
5
|
+
import type { BrsTranspileState } from './BrsTranspileState';
|
|
6
|
+
import type { TranspileResult } from '../interfaces';
|
|
7
|
+
import type { AnnotationExpression } from './Expression';
|
|
8
|
+
/**
|
|
9
|
+
* A BrightScript AST node
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class AstNode {
|
|
12
|
+
/**
|
|
13
|
+
* The starting and ending location of the node.
|
|
14
|
+
**/
|
|
15
|
+
abstract range: Range;
|
|
16
|
+
abstract transpile(state: BrsTranspileState): TranspileResult;
|
|
17
|
+
/**
|
|
18
|
+
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
19
|
+
*/
|
|
20
|
+
visitMode: InternalWalkMode;
|
|
21
|
+
abstract walk(visitor: WalkVisitor, options: WalkOptions): any;
|
|
22
|
+
/**
|
|
23
|
+
* The parent node for this statement. This is set dynamically during `onFileValidate`, and should not be set directly.
|
|
24
|
+
*/
|
|
25
|
+
parent?: AstNode;
|
|
26
|
+
/**
|
|
27
|
+
* Certain expressions or statements can have a symbol table (such as blocks, functions, namespace bodies, etc).
|
|
28
|
+
* If you're interested in getting the closest SymbolTable, use `getSymbolTable` instead.
|
|
29
|
+
*/
|
|
30
|
+
symbolTable?: SymbolTable;
|
|
31
|
+
/**
|
|
32
|
+
* Get the closest symbol table for this node. Should be overridden in children that directly contain a symbol table
|
|
33
|
+
*/
|
|
34
|
+
getSymbolTable(): SymbolTable;
|
|
35
|
+
/**
|
|
36
|
+
* Walk upward and return the first node that results in `true` from the matcher
|
|
37
|
+
*/
|
|
38
|
+
findAncestor<TNode extends AstNode = AstNode>(matcher: (node: AstNode) => boolean | undefined): TNode;
|
|
39
|
+
/**
|
|
40
|
+
* Find the first child where the matcher evaluates to true.
|
|
41
|
+
* @param matcher a function called for each node. If you return true, this function returns the specified node. If you return a node, that node is returned. all other return values continue the loop
|
|
42
|
+
*/
|
|
43
|
+
findChild<TNodeType extends AstNode = AstNode>(matcher: (node: AstNode) => boolean | AstNode, options?: WalkOptions): TNodeType;
|
|
44
|
+
/**
|
|
45
|
+
* FInd the deepest child that includes the given position
|
|
46
|
+
*/
|
|
47
|
+
findChildAtPosition<TNodeType extends AstNode = AstNode>(position: Position, options?: WalkOptions): TNodeType;
|
|
48
|
+
}
|
|
49
|
+
export declare abstract class Statement extends AstNode {
|
|
50
|
+
/**
|
|
51
|
+
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
52
|
+
*/
|
|
53
|
+
visitMode: InternalWalkMode;
|
|
54
|
+
/**
|
|
55
|
+
* Annotations for this statement
|
|
56
|
+
*/
|
|
57
|
+
annotations: AnnotationExpression[];
|
|
58
|
+
}
|
|
59
|
+
/** A BrightScript expression */
|
|
60
|
+
export declare abstract class Expression extends AstNode {
|
|
61
|
+
/**
|
|
62
|
+
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
63
|
+
*/
|
|
64
|
+
visitMode: InternalWalkMode;
|
|
65
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Expression = exports.Statement = exports.AstNode = void 0;
|
|
4
|
+
const visitors_1 = require("../astUtils/visitors");
|
|
5
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
6
|
+
const visitors_2 = require("../astUtils/visitors");
|
|
7
|
+
const util_1 = require("../util");
|
|
8
|
+
/**
|
|
9
|
+
* A BrightScript AST node
|
|
10
|
+
*/
|
|
11
|
+
class AstNode {
|
|
12
|
+
constructor() {
|
|
13
|
+
/**
|
|
14
|
+
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
15
|
+
*/
|
|
16
|
+
this.visitMode = visitors_2.InternalWalkMode.visitStatements;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the closest symbol table for this node. Should be overridden in children that directly contain a symbol table
|
|
20
|
+
*/
|
|
21
|
+
getSymbolTable() {
|
|
22
|
+
var _a;
|
|
23
|
+
if (this.symbolTable) {
|
|
24
|
+
return this.symbolTable;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return (_a = this.parent) === null || _a === void 0 ? void 0 : _a.getSymbolTable();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Walk upward and return the first node that results in `true` from the matcher
|
|
32
|
+
*/
|
|
33
|
+
findAncestor(matcher) {
|
|
34
|
+
let node = this.parent;
|
|
35
|
+
while (node) {
|
|
36
|
+
if (matcher(node)) {
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
node = node.parent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Find the first child where the matcher evaluates to true.
|
|
44
|
+
* @param matcher a function called for each node. If you return true, this function returns the specified node. If you return a node, that node is returned. all other return values continue the loop
|
|
45
|
+
*/
|
|
46
|
+
findChild(matcher, options) {
|
|
47
|
+
const cancel = new vscode_languageserver_1.CancellationTokenSource();
|
|
48
|
+
let result;
|
|
49
|
+
this.walk((node) => {
|
|
50
|
+
const matcherValue = matcher(node);
|
|
51
|
+
if (matcherValue) {
|
|
52
|
+
cancel.cancel();
|
|
53
|
+
result = matcherValue === true ? node : matcherValue;
|
|
54
|
+
}
|
|
55
|
+
}, Object.assign(Object.assign({ walkMode: visitors_1.WalkMode.visitAllRecursive }, options !== null && options !== void 0 ? options : {}), { cancel: cancel.token }));
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* FInd the deepest child that includes the given position
|
|
60
|
+
*/
|
|
61
|
+
findChildAtPosition(position, options) {
|
|
62
|
+
return this.findChild((node) => {
|
|
63
|
+
var _a;
|
|
64
|
+
//if the current node includes this range, keep that node
|
|
65
|
+
if (util_1.default.rangeContains(node.range, position)) {
|
|
66
|
+
return (_a = node.findChildAtPosition(position, options)) !== null && _a !== void 0 ? _a : node;
|
|
67
|
+
}
|
|
68
|
+
}, options);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.AstNode = AstNode;
|
|
72
|
+
class Statement extends AstNode {
|
|
73
|
+
constructor() {
|
|
74
|
+
super(...arguments);
|
|
75
|
+
/**
|
|
76
|
+
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
77
|
+
*/
|
|
78
|
+
this.visitMode = visitors_2.InternalWalkMode.visitStatements;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.Statement = Statement;
|
|
82
|
+
/** A BrightScript expression */
|
|
83
|
+
class Expression extends AstNode {
|
|
84
|
+
constructor() {
|
|
85
|
+
super(...arguments);
|
|
86
|
+
/**
|
|
87
|
+
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
88
|
+
*/
|
|
89
|
+
this.visitMode = visitors_2.InternalWalkMode.visitExpressions;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.Expression = Expression;
|
|
93
|
+
//# sourceMappingURL=AstNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AstNode.js","sourceRoot":"","sources":["../../src/parser/AstNode.ts"],"names":[],"mappings":";;;AACA,mDAAgD;AAEhD,iEAAgE;AAChE,mDAAwD;AAKxD,kCAA2B;AAE3B;;GAEG;AACH,MAAsB,OAAO;IAA7B;QAQI;;W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IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE;gBAC1C,OAAO,MAAA,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,mCAAI,IAAI,CAAC;aAC9D;QACL,CAAC,EAAE,OAAO,CAAC,CAAC;IAChB,CAAC;CACJ;AAlFD,0BAkFC;AAED,MAAsB,SAAU,SAAQ,OAAO;IAA/C;;QACI;;WAEG;QACI,cAAS,GAAG,2BAAgB,CAAC,eAAe,CAAC;IAKxD,CAAC;CAAA;AATD,8BASC;AAGD,gCAAgC;AAChC,MAAsB,UAAW,SAAQ,OAAO;IAAhD;;QACI;;WAEG;QACI,cAAS,GAAG,2BAAgB,CAAC,gBAAgB,CAAC;IACzD,CAAC;CAAA;AALD,gCAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const util_1 = require("../util");
|
|
4
|
+
const fsExtra = require("fs-extra");
|
|
5
|
+
const Program_1 = require("../Program");
|
|
6
|
+
const chai_1 = require("chai");
|
|
7
|
+
const testHelpers_spec_1 = require("../testHelpers.spec");
|
|
8
|
+
let tempDir = (0, util_1.standardizePath) `${process.cwd()}/.tmp`;
|
|
9
|
+
let rootDir = (0, util_1.standardizePath) `${tempDir}/rootDir`;
|
|
10
|
+
let stagingDir = (0, util_1.standardizePath) `${tempDir}/staging`;
|
|
11
|
+
describe('Program', () => {
|
|
12
|
+
let program;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
fsExtra.emptyDirSync(tempDir);
|
|
15
|
+
program = new Program_1.Program({
|
|
16
|
+
rootDir: rootDir,
|
|
17
|
+
stagingFolderPath: stagingDir
|
|
18
|
+
});
|
|
19
|
+
program.createSourceScope(); //ensure source scope is created
|
|
20
|
+
});
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
fsExtra.emptyDirSync(tempDir);
|
|
23
|
+
program.dispose();
|
|
24
|
+
});
|
|
25
|
+
describe('AstNode', () => {
|
|
26
|
+
describe('findNodeAtPosition', () => {
|
|
27
|
+
it('finds deepest AstNode that matches the position', () => {
|
|
28
|
+
const file = program.setFile('source/main.brs', `
|
|
29
|
+
sub main()
|
|
30
|
+
alpha = invalid
|
|
31
|
+
print alpha.beta.charlie.delta(alpha.echo.foxtrot())
|
|
32
|
+
end sub
|
|
33
|
+
`);
|
|
34
|
+
program.validate();
|
|
35
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
36
|
+
const delta = file.ast.findChildAtPosition(util_1.util.createPosition(3, 52));
|
|
37
|
+
(0, chai_1.expect)(delta.name.text).to.eql('delta');
|
|
38
|
+
const foxtrot = file.ast.findChildAtPosition(util_1.util.createPosition(3, 71));
|
|
39
|
+
(0, chai_1.expect)(foxtrot.name.text).to.eql('foxtrot');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=AstNode.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AstNode.spec.js","sourceRoot":"","sources":["../../src/parser/AstNode.spec.ts"],"names":[],"mappings":";;AAAA,kCAAqD;AACrD,oCAAoC;AACpC,wCAAqC;AAErC,+BAA8B;AAE9B,0DAA4D;AAE5D,IAAI,OAAO,GAAG,IAAA,sBAAC,EAAA,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC;AACvC,IAAI,OAAO,GAAG,IAAA,sBAAC,EAAA,GAAG,OAAO,UAAU,CAAC;AACpC,IAAI,UAAU,GAAG,IAAA,sBAAC,EAAA,GAAG,OAAO,UAAU,CAAC;AAEvC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACrB,IAAI,OAAgB,CAAC;IAErB,UAAU,CAAC,GAAG,EAAE;QACZ,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,GA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../lexer/Token';
|
|
2
|
-
import type { Block, CommentStatement, FunctionStatement
|
|
2
|
+
import type { Block, CommentStatement, FunctionStatement } from './Statement';
|
|
3
3
|
import type { Range } from 'vscode-languageserver';
|
|
4
4
|
import type { BrsTranspileState } from './BrsTranspileState';
|
|
5
5
|
import { ParseMode } from './Parser';
|
|
6
6
|
import type { WalkOptions, WalkVisitor } from '../astUtils/visitors';
|
|
7
|
-
import { InternalWalkMode } from '../astUtils/visitors';
|
|
8
7
|
import type { TranspileResult, TypedefProvider } from '../interfaces';
|
|
9
8
|
import type { BscType } from '../types/BscType';
|
|
10
9
|
import { FunctionType } from '../types/FunctionType';
|
|
11
|
-
import {
|
|
10
|
+
import { Expression } from './AstNode';
|
|
12
11
|
export declare type ExpressionVisitor = (expression: Expression, parent: Expression) => void;
|
|
13
|
-
/** A BrightScript expression */
|
|
14
|
-
export declare abstract class Expression {
|
|
15
|
-
/**
|
|
16
|
-
* The starting and ending location of the expression.
|
|
17
|
-
*/
|
|
18
|
-
abstract range: Range;
|
|
19
|
-
abstract transpile(state: BrsTranspileState): TranspileResult;
|
|
20
|
-
/**
|
|
21
|
-
* When being considered by the walk visitor, this describes what type of element the current class is.
|
|
22
|
-
*/
|
|
23
|
-
visitMode: InternalWalkMode;
|
|
24
|
-
abstract walk(visitor: WalkVisitor, options: WalkOptions): any;
|
|
25
|
-
/**
|
|
26
|
-
* The parent node for this expression. This is set dynamically during `onFileValidate`, and should not be set directly.
|
|
27
|
-
*/
|
|
28
|
-
parent?: Statement | Expression;
|
|
29
|
-
/**
|
|
30
|
-
* Get the closest symbol table for this node. Should be overridden in children that directly contain a symbol table
|
|
31
|
-
*/
|
|
32
|
-
getSymbolTable(): SymbolTable;
|
|
33
|
-
}
|
|
34
12
|
export declare class BinaryExpression extends Expression {
|
|
35
13
|
left: Expression;
|
|
36
14
|
operator: Token;
|
|
@@ -48,20 +26,12 @@ export declare class CallExpression extends Expression {
|
|
|
48
26
|
readonly openingParen: Token;
|
|
49
27
|
readonly closingParen: Token;
|
|
50
28
|
readonly args: Expression[];
|
|
51
|
-
/**
|
|
52
|
-
* The namespace that currently wraps this call expression. This is NOT the namespace of the callee...that will be represented in the callee expression itself.
|
|
53
|
-
*/
|
|
54
|
-
readonly namespaceName: NamespacedVariableNameExpression;
|
|
55
29
|
static MaximumArguments: number;
|
|
56
30
|
constructor(callee: Expression,
|
|
57
31
|
/**
|
|
58
32
|
* Can either be `(`, or `?(` for optional chaining
|
|
59
33
|
*/
|
|
60
|
-
openingParen: Token, closingParen: Token, args: Expression[]
|
|
61
|
-
/**
|
|
62
|
-
* The namespace that currently wraps this call expression. This is NOT the namespace of the callee...that will be represented in the callee expression itself.
|
|
63
|
-
*/
|
|
64
|
-
namespaceName: NamespacedVariableNameExpression);
|
|
34
|
+
openingParen: Token, closingParen: Token, args: Expression[]);
|
|
65
35
|
readonly range: Range;
|
|
66
36
|
transpile(state: BrsTranspileState, nameOverride?: string): any[];
|
|
67
37
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|
|
@@ -79,15 +49,11 @@ export declare class FunctionExpression extends Expression implements TypedefPro
|
|
|
79
49
|
* If this function is enclosed within another function, this will reference that parent function
|
|
80
50
|
*/
|
|
81
51
|
readonly parentFunction?: FunctionExpression;
|
|
82
|
-
readonly namespaceName?: NamespacedVariableNameExpression;
|
|
83
|
-
readonly parentSymbolTable?: SymbolTable;
|
|
84
52
|
constructor(parameters: FunctionParameterExpression[], body: Block, functionType: Token | null, end: Token, leftParen: Token, rightParen: Token, asToken?: Token, returnTypeToken?: Token,
|
|
85
53
|
/**
|
|
86
54
|
* If this function is enclosed within another function, this will reference that parent function
|
|
87
55
|
*/
|
|
88
|
-
parentFunction?: FunctionExpression
|
|
89
|
-
symbolTable: SymbolTable;
|
|
90
|
-
getSymbolTable(): SymbolTable;
|
|
56
|
+
parentFunction?: FunctionExpression);
|
|
91
57
|
/**
|
|
92
58
|
* The type this function returns
|
|
93
59
|
*/
|
|
@@ -120,8 +86,7 @@ export declare class FunctionParameterExpression extends Expression {
|
|
|
120
86
|
typeToken?: Token;
|
|
121
87
|
defaultValue?: Expression;
|
|
122
88
|
asToken?: Token;
|
|
123
|
-
|
|
124
|
-
constructor(name: Identifier, typeToken?: Token, defaultValue?: Expression, asToken?: Token, namespaceName?: NamespacedVariableNameExpression);
|
|
89
|
+
constructor(name: Identifier, typeToken?: Token, defaultValue?: Expression, asToken?: Token);
|
|
125
90
|
type: BscType;
|
|
126
91
|
get range(): Range;
|
|
127
92
|
transpile(state: BrsTranspileState): any[];
|
|
@@ -268,8 +233,7 @@ export declare class UnaryExpression extends Expression {
|
|
|
268
233
|
}
|
|
269
234
|
export declare class VariableExpression extends Expression {
|
|
270
235
|
readonly name: Identifier;
|
|
271
|
-
|
|
272
|
-
constructor(name: Identifier, namespaceName: NamespacedVariableNameExpression);
|
|
236
|
+
constructor(name: Identifier);
|
|
273
237
|
readonly range: Range;
|
|
274
238
|
getName(parseMode: ParseMode): string;
|
|
275
239
|
transpile(state: BrsTranspileState): any[];
|
|
@@ -296,7 +260,6 @@ export declare class NewExpression extends Expression {
|
|
|
296
260
|
* The name of the class to initialize (with optional namespace prefixed)
|
|
297
261
|
*/
|
|
298
262
|
get className(): NamespacedVariableNameExpression;
|
|
299
|
-
get namespaceName(): NamespacedVariableNameExpression;
|
|
300
263
|
readonly range: Range;
|
|
301
264
|
transpile(state: BrsTranspileState): any[];
|
|
302
265
|
walk(visitor: WalkVisitor, options: WalkOptions): void;
|