brighterscript 0.66.0-alpha.7 → 0.66.0-alpha.9
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 +42 -0
- package/dist/AstValidationSegmenter.d.ts +25 -0
- package/dist/AstValidationSegmenter.js +150 -0
- package/dist/AstValidationSegmenter.js.map +1 -0
- package/dist/DiagnosticMessages.d.ts +6 -1
- package/dist/DiagnosticMessages.js +5 -0
- package/dist/DiagnosticMessages.js.map +1 -1
- package/dist/LanguageServer.js +7 -1
- package/dist/LanguageServer.js.map +1 -1
- package/dist/Program.d.ts +24 -2
- package/dist/Program.js +112 -3
- package/dist/Program.js.map +1 -1
- package/dist/Scope.d.ts +15 -27
- package/dist/Scope.js +127 -150
- package/dist/Scope.js.map +1 -1
- package/dist/SymbolTable.d.ts +4 -1
- package/dist/SymbolTable.js +19 -7
- package/dist/SymbolTable.js.map +1 -1
- package/dist/XmlScope.d.ts +1 -1
- package/dist/XmlScope.js +5 -4
- package/dist/XmlScope.js.map +1 -1
- package/dist/astUtils/visitors.d.ts +11 -0
- package/dist/astUtils/visitors.js +22 -2
- package/dist/astUtils/visitors.js.map +1 -1
- package/dist/astUtils/visitors.spec.js +51 -0
- package/dist/astUtils/visitors.spec.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +2 -2
- package/dist/bscPlugin/completions/CompletionsProcessor.js +76 -31
- package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +147 -3
- package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -1
- package/dist/bscPlugin/hover/HoverProcessor.js +9 -1
- package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js +4 -1
- package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.js +8 -3
- package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
- package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.d.ts +5 -9
- package/dist/bscPlugin/validation/ScopeValidator.js +199 -216
- package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
- package/dist/bscPlugin/validation/ScopeValidator.spec.js +343 -0
- package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -1
- package/dist/files/BrsFile.Class.spec.js +201 -0
- package/dist/files/BrsFile.Class.spec.js.map +1 -1
- package/dist/files/BrsFile.d.ts +25 -2
- package/dist/files/BrsFile.js +210 -2
- package/dist/files/BrsFile.js.map +1 -1
- package/dist/files/BrsFile.spec.js +868 -0
- package/dist/files/BrsFile.spec.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +45 -5
- package/dist/interfaces.js +10 -2
- package/dist/interfaces.js.map +1 -1
- package/dist/lexer/TokenKind.d.ts +1 -0
- package/dist/lexer/TokenKind.js +4 -0
- package/dist/lexer/TokenKind.js.map +1 -1
- package/dist/parser/Expression.d.ts +1 -1
- package/dist/parser/Expression.js +20 -10
- package/dist/parser/Expression.js.map +1 -1
- package/dist/parser/Parser.Class.spec.js +103 -0
- package/dist/parser/Parser.Class.spec.js.map +1 -1
- package/dist/parser/Parser.js +58 -13
- package/dist/parser/Parser.js.map +1 -1
- package/dist/parser/Parser.spec.js +212 -0
- package/dist/parser/Parser.spec.js.map +1 -1
- package/dist/parser/Statement.d.ts +9 -3
- package/dist/parser/Statement.js +56 -26
- package/dist/parser/Statement.js.map +1 -1
- package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +6 -6
- package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
- package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js +74 -0
- package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
- package/dist/parser/tests/statement/Enum.spec.js +9 -0
- package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
- package/dist/parser/tests/statement/InterfaceStatement.spec.js +8 -0
- package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
- package/dist/roku-types/data.json +18 -51
- package/dist/types/BooleanType.d.ts +1 -1
- package/dist/types/BscType.d.ts +2 -2
- package/dist/types/BscType.js +28 -9
- package/dist/types/BscType.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.js +6 -4
- package/dist/types/BuiltInInterfaceAdder.js.map +1 -1
- package/dist/types/BuiltInInterfaceAdder.spec.js +7 -0
- package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -1
- package/dist/types/ClassType.d.ts +4 -3
- package/dist/types/ClassType.js +6 -3
- package/dist/types/ClassType.js.map +1 -1
- package/dist/types/ClassType.spec.js +5 -3
- package/dist/types/ClassType.spec.js.map +1 -1
- package/dist/types/ComponentType.d.ts +1 -1
- package/dist/types/EnumType.d.ts +1 -1
- package/dist/types/EnumType.js +7 -2
- package/dist/types/EnumType.js.map +1 -1
- package/dist/types/InheritableType.d.ts +7 -4
- package/dist/types/InheritableType.js +67 -3
- package/dist/types/InheritableType.js.map +1 -1
- package/dist/types/InterfaceType.d.ts +4 -3
- package/dist/types/InterfaceType.js +4 -4
- package/dist/types/InterfaceType.js.map +1 -1
- package/dist/types/NamespaceType.d.ts +2 -1
- package/dist/types/NamespaceType.js +3 -0
- package/dist/types/NamespaceType.js.map +1 -1
- package/dist/types/ReferenceType.js +40 -6
- package/dist/types/ReferenceType.js.map +1 -1
- package/dist/types/TypedFunctionType.js +5 -5
- package/dist/types/TypedFunctionType.js.map +1 -1
- package/dist/types/UnionType.js +1 -0
- package/dist/types/UnionType.js.map +1 -1
- package/dist/types/helpers.js +4 -0
- package/dist/types/helpers.js.map +1 -1
- package/dist/util.d.ts +14 -4
- package/dist/util.js +86 -32
- package/dist/util.js.map +1 -1
- package/package.json +2 -3
|
@@ -23,6 +23,8 @@ const fsExtra = require("fs-extra");
|
|
|
23
23
|
const vscode_uri_1 = require("vscode-uri");
|
|
24
24
|
const undent_1 = require("undent");
|
|
25
25
|
const testHelpers_spec_2 = require("../testHelpers.spec");
|
|
26
|
+
const SymbolTable_1 = require("../SymbolTable");
|
|
27
|
+
const types_1 = require("../types");
|
|
26
28
|
let sinon = sinonImport.createSandbox();
|
|
27
29
|
describe('BrsFile', () => {
|
|
28
30
|
let program;
|
|
@@ -109,6 +111,22 @@ describe('BrsFile', () => {
|
|
|
109
111
|
program.validate();
|
|
110
112
|
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')), { range: util_1.default.createRange(3, 22, 3, 27) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')), { range: util_1.default.createRange(4, 22, 4, 32) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.itemCannotBeUsedAsVariable('namespace')), { range: util_1.default.createRange(5, 22, 5, 40) })]);
|
|
111
113
|
});
|
|
114
|
+
it('allows namespaces with the name `optional`', () => {
|
|
115
|
+
program.setFile('source/main.bs', `
|
|
116
|
+
namespace optional
|
|
117
|
+
namespace optional
|
|
118
|
+
end namespace
|
|
119
|
+
end namespace
|
|
120
|
+
namespace alpha
|
|
121
|
+
namespace optional
|
|
122
|
+
end namespace
|
|
123
|
+
end namespace
|
|
124
|
+
namespace alpha.beta.optional
|
|
125
|
+
end namespace
|
|
126
|
+
`);
|
|
127
|
+
program.validate();
|
|
128
|
+
(0, testHelpers_spec_1.expectZeroDiagnostics)(program);
|
|
129
|
+
});
|
|
112
130
|
it('flags enums used as variables', () => {
|
|
113
131
|
program.setFile('source/main.bs', `
|
|
114
132
|
enum Foo
|
|
@@ -2789,6 +2807,74 @@ describe('BrsFile', () => {
|
|
|
2789
2807
|
range: util_1.default.createRange(5, 25, 5, 31)
|
|
2790
2808
|
}]);
|
|
2791
2809
|
});
|
|
2810
|
+
it('returns interface location', () => {
|
|
2811
|
+
const file = program.setFile('source/main.bs', `
|
|
2812
|
+
sub test(selectedMovie as Movie)
|
|
2813
|
+
print selectedMovie
|
|
2814
|
+
end sub
|
|
2815
|
+
interface Movie
|
|
2816
|
+
url as string
|
|
2817
|
+
end interface
|
|
2818
|
+
`);
|
|
2819
|
+
program.validate();
|
|
2820
|
+
// sub test(selectedMovie as Mo|vie)
|
|
2821
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 44))).to.eql([{
|
|
2822
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2823
|
+
range: util_1.default.createRange(4, 26, 4, 31)
|
|
2824
|
+
}]);
|
|
2825
|
+
});
|
|
2826
|
+
it('returns namespaced interface location', () => {
|
|
2827
|
+
const file = program.setFile('source/main.bs', `
|
|
2828
|
+
sub test(selectedMovie as interfaces.Movie)
|
|
2829
|
+
print selectedMovie
|
|
2830
|
+
end sub
|
|
2831
|
+
namespace interfaces
|
|
2832
|
+
interface Movie
|
|
2833
|
+
url as string
|
|
2834
|
+
end interface
|
|
2835
|
+
end namespace
|
|
2836
|
+
`);
|
|
2837
|
+
program.validate();
|
|
2838
|
+
//sub test(selectedMovie as interfaces.Mo|vie)
|
|
2839
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 55))).to.eql([{
|
|
2840
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2841
|
+
range: util_1.default.createRange(5, 30, 5, 35)
|
|
2842
|
+
}]);
|
|
2843
|
+
});
|
|
2844
|
+
it('returns class location', () => {
|
|
2845
|
+
const file = program.setFile('source/main.bs', `
|
|
2846
|
+
sub test(selectedMovie as Movie)
|
|
2847
|
+
print selectedMovie
|
|
2848
|
+
end sub
|
|
2849
|
+
class Movie
|
|
2850
|
+
url as string
|
|
2851
|
+
end class
|
|
2852
|
+
`);
|
|
2853
|
+
program.validate();
|
|
2854
|
+
//sub test(selectedMovie as Mo|vie)
|
|
2855
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 44))).to.eql([{
|
|
2856
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2857
|
+
range: util_1.default.createRange(4, 22, 4, 27)
|
|
2858
|
+
}]);
|
|
2859
|
+
});
|
|
2860
|
+
it('returns namespaced class location', () => {
|
|
2861
|
+
const file = program.setFile('source/main.bs', `
|
|
2862
|
+
sub test(selectedMovie as classes.Movie)
|
|
2863
|
+
print selectedMovie
|
|
2864
|
+
end sub
|
|
2865
|
+
namespace classes
|
|
2866
|
+
class Movie
|
|
2867
|
+
url as string
|
|
2868
|
+
end class
|
|
2869
|
+
end namespace
|
|
2870
|
+
`);
|
|
2871
|
+
program.validate();
|
|
2872
|
+
//sub test(selectedMovie as classes.Mo|vie)
|
|
2873
|
+
(0, chai_config_spec_1.expect)(program.getDefinition(file.srcPath, vscode_languageserver_1.Position.create(1, 52))).to.eql([{
|
|
2874
|
+
uri: vscode_uri_1.URI.file(file.srcPath).toString(),
|
|
2875
|
+
range: util_1.default.createRange(5, 26, 5, 31)
|
|
2876
|
+
}]);
|
|
2877
|
+
});
|
|
2792
2878
|
it('does not crash on nulls', () => {
|
|
2793
2879
|
const file = program.setFile('source/main.bs', `
|
|
2794
2880
|
sub main()
|
|
@@ -2829,5 +2915,787 @@ describe('BrsFile', () => {
|
|
|
2829
2915
|
program.validate();
|
|
2830
2916
|
(0, testHelpers_spec_1.expectDiagnostics)(program, [Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndCallableKeyword('function', 'sub')), { range: util_1.default.createRange(2, 12, 2, 19) }), Object.assign(Object.assign({}, DiagnosticMessages_1.DiagnosticMessages.mismatchedEndCallableKeyword('sub', 'function')), { range: util_1.default.createRange(4, 12, 4, 24) })]);
|
|
2831
2917
|
});
|
|
2918
|
+
describe('requiredSymbols', () => {
|
|
2919
|
+
it('should be empty for a simple file', () => {
|
|
2920
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2921
|
+
function someFunc() as integer
|
|
2922
|
+
return 1
|
|
2923
|
+
end function
|
|
2924
|
+
`);
|
|
2925
|
+
const validateFileEvent = {
|
|
2926
|
+
program: program,
|
|
2927
|
+
file: mainFile
|
|
2928
|
+
};
|
|
2929
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2930
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
2931
|
+
});
|
|
2932
|
+
it('should be empty if the file needs no external symbols', () => {
|
|
2933
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2934
|
+
function someFunc() as integer
|
|
2935
|
+
return 1
|
|
2936
|
+
end function
|
|
2937
|
+
|
|
2938
|
+
sub useKlass()
|
|
2939
|
+
k = new Klass()
|
|
2940
|
+
k.addTwo()
|
|
2941
|
+
end sub
|
|
2942
|
+
|
|
2943
|
+
class Klass
|
|
2944
|
+
sub addTwo()
|
|
2945
|
+
print someFunc() + someFunc()
|
|
2946
|
+
end sub
|
|
2947
|
+
end class
|
|
2948
|
+
`);
|
|
2949
|
+
const validateFileEvent = {
|
|
2950
|
+
program: program,
|
|
2951
|
+
file: mainFile
|
|
2952
|
+
};
|
|
2953
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2954
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
2955
|
+
});
|
|
2956
|
+
it('should not include global callables or types', () => {
|
|
2957
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2958
|
+
function printLower(s as string) as integer
|
|
2959
|
+
print lcase(s.trim())
|
|
2960
|
+
end function
|
|
2961
|
+
|
|
2962
|
+
sub setLabelText( label as roSGNodeLabel, text as string)
|
|
2963
|
+
label.text = text
|
|
2964
|
+
end sub
|
|
2965
|
+
`);
|
|
2966
|
+
const validateFileEvent = {
|
|
2967
|
+
program: program,
|
|
2968
|
+
file: mainFile
|
|
2969
|
+
};
|
|
2970
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2971
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
2972
|
+
});
|
|
2973
|
+
it('should include unknown param and return types', () => {
|
|
2974
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2975
|
+
function someFunc(arg as OneType) as TwoType
|
|
2976
|
+
return arg.getTwo()
|
|
2977
|
+
end function
|
|
2978
|
+
`);
|
|
2979
|
+
const validateFileEvent = {
|
|
2980
|
+
program: program,
|
|
2981
|
+
file: mainFile
|
|
2982
|
+
};
|
|
2983
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
2984
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
|
|
2985
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
|
|
2986
|
+
'TwoType', 'OneType'
|
|
2987
|
+
]);
|
|
2988
|
+
});
|
|
2989
|
+
it('should include unknown param and return types on class methods', () => {
|
|
2990
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
2991
|
+
class Klass
|
|
2992
|
+
function someFunc(arg as OneType) as TwoType
|
|
2993
|
+
return arg.getTwo()
|
|
2994
|
+
end function
|
|
2995
|
+
end class
|
|
2996
|
+
`);
|
|
2997
|
+
const validateFileEvent = {
|
|
2998
|
+
program: program,
|
|
2999
|
+
file: mainFile
|
|
3000
|
+
};
|
|
3001
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3002
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
|
|
3003
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
|
|
3004
|
+
'TwoType', 'OneType'
|
|
3005
|
+
]);
|
|
3006
|
+
});
|
|
3007
|
+
it('should not include assigned symbols', () => {
|
|
3008
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3009
|
+
sub someFunc(arg as SomeOtherType)
|
|
3010
|
+
x = arg.member
|
|
3011
|
+
print x+1
|
|
3012
|
+
end sub
|
|
3013
|
+
`);
|
|
3014
|
+
const validateFileEvent = {
|
|
3015
|
+
program: program,
|
|
3016
|
+
file: mainFile
|
|
3017
|
+
};
|
|
3018
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3019
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
|
|
3020
|
+
// x and arg are assigned.. they are not included in the required symbols
|
|
3021
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].typeChain[0].name).to.equal('SomeOtherType');
|
|
3022
|
+
});
|
|
3023
|
+
it('should include functions called that are not in the file', () => {
|
|
3024
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3025
|
+
sub someFunc()
|
|
3026
|
+
x = otherFileFunc1()
|
|
3027
|
+
print x+1
|
|
3028
|
+
end sub
|
|
3029
|
+
|
|
3030
|
+
function deepFunctionCall(i as integer)
|
|
3031
|
+
x = 2*i and otherFileFunc2()
|
|
3032
|
+
y = sin(x+fix(78.2)*log(otherFileFunc3()))
|
|
3033
|
+
' this is a comment otherFileFunc5()
|
|
3034
|
+
return y-otherFileFunc4()
|
|
3035
|
+
end function
|
|
3036
|
+
`);
|
|
3037
|
+
const validateFileEvent = {
|
|
3038
|
+
program: program,
|
|
3039
|
+
file: mainFile
|
|
3040
|
+
};
|
|
3041
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3042
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(4);
|
|
3043
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.map(x => x.typeChain[0].name)).to.have.same.members([
|
|
3044
|
+
'otherFileFunc1', 'otherFileFunc2', 'otherFileFunc3', 'otherFileFunc4'
|
|
3045
|
+
]);
|
|
3046
|
+
});
|
|
3047
|
+
it('should include classes called that are not in the file', () => {
|
|
3048
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3049
|
+
function someFunc(other as OtherKlass) as NS1.Thing
|
|
3050
|
+
x = new AnotherClass()
|
|
3051
|
+
return other.getThing(x)
|
|
3052
|
+
end function
|
|
3053
|
+
`);
|
|
3054
|
+
const validateFileEvent = {
|
|
3055
|
+
program: program,
|
|
3056
|
+
file: mainFile
|
|
3057
|
+
};
|
|
3058
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3059
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(3);
|
|
3060
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3061
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3062
|
+
'OtherKlass', 'NS1.Thing', 'AnotherClass'
|
|
3063
|
+
]);
|
|
3064
|
+
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3065
|
+
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3066
|
+
SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.runtime
|
|
3067
|
+
]);
|
|
3068
|
+
});
|
|
3069
|
+
it('should include enums and consts that are not in the file', () => {
|
|
3070
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3071
|
+
sub someFunc(myEnum as SomeEnum)
|
|
3072
|
+
if myEnum = SomeEnum.value1
|
|
3073
|
+
print 1
|
|
3074
|
+
else if myEnum = SomeEnum.value2
|
|
3075
|
+
print 2
|
|
3076
|
+
else if myEnum = SomeConstValue
|
|
3077
|
+
print 3
|
|
3078
|
+
end if
|
|
3079
|
+
end sub
|
|
3080
|
+
`);
|
|
3081
|
+
const validateFileEvent = {
|
|
3082
|
+
program: program,
|
|
3083
|
+
file: mainFile
|
|
3084
|
+
};
|
|
3085
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3086
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(4);
|
|
3087
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3088
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3089
|
+
'SomeEnum', 'SomeEnum.value1', 'SomeEnum.value2', 'SomeConstValue'
|
|
3090
|
+
]);
|
|
3091
|
+
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3092
|
+
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3093
|
+
SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.runtime
|
|
3094
|
+
]);
|
|
3095
|
+
});
|
|
3096
|
+
it('should include types not defined in the file', () => {
|
|
3097
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3098
|
+
interface Data
|
|
3099
|
+
kind as DataKind
|
|
3100
|
+
getObj as DataObject
|
|
3101
|
+
subData as SubData
|
|
3102
|
+
end interface
|
|
3103
|
+
|
|
3104
|
+
class DataObject extends BaseData
|
|
3105
|
+
kind as DataKind
|
|
3106
|
+
function process(dataProcess as DataProcessor) as ProcessedData
|
|
3107
|
+
return dataProcess.work(m)
|
|
3108
|
+
end function
|
|
3109
|
+
end class
|
|
3110
|
+
`);
|
|
3111
|
+
const validateFileEvent = {
|
|
3112
|
+
program: program,
|
|
3113
|
+
file: mainFile
|
|
3114
|
+
};
|
|
3115
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3116
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(5);
|
|
3117
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3118
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3119
|
+
'DataKind', 'SubData', 'BaseData', 'DataProcessor', 'ProcessedData'
|
|
3120
|
+
]);
|
|
3121
|
+
const requiredSymbolsFlags = mainFile.requiredSymbols.map(x => x.flags);
|
|
3122
|
+
(0, chai_config_spec_1.expect)(requiredSymbolsFlags).to.have.same.members([
|
|
3123
|
+
SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime, SymbolTable_1.SymbolTypeFlag.typetime
|
|
3124
|
+
]);
|
|
3125
|
+
});
|
|
3126
|
+
it('includes namespace details', () => {
|
|
3127
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3128
|
+
namespace Alpha.Beta
|
|
3129
|
+
sub printConstVal()
|
|
3130
|
+
print CONST_VALUE
|
|
3131
|
+
end sub
|
|
3132
|
+
end namespace
|
|
3133
|
+
|
|
3134
|
+
namespace Delta
|
|
3135
|
+
namespace Gamma
|
|
3136
|
+
namespace Eta
|
|
3137
|
+
sub doStuff(x as OtherType)
|
|
3138
|
+
x.something()
|
|
3139
|
+
end sub
|
|
3140
|
+
end namespace
|
|
3141
|
+
end namespace
|
|
3142
|
+
end namespace
|
|
3143
|
+
`);
|
|
3144
|
+
const validateFileEvent = {
|
|
3145
|
+
program: program,
|
|
3146
|
+
file: mainFile
|
|
3147
|
+
};
|
|
3148
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3149
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(2);
|
|
3150
|
+
const requiredTypeChains = mainFile.requiredSymbols.map(x => x.typeChain.map(tc => tc.name).join('.'));
|
|
3151
|
+
(0, chai_config_spec_1.expect)(requiredTypeChains).to.have.same.members([
|
|
3152
|
+
'CONST_VALUE', 'OtherType'
|
|
3153
|
+
]);
|
|
3154
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].containingNamespaces).to.have.same.members(['Alpha', 'Beta']);
|
|
3155
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[1].containingNamespaces).to.have.same.members(['Delta', 'Gamma', 'Eta']);
|
|
3156
|
+
});
|
|
3157
|
+
it('does not include namespaces that are defined in the file', () => {
|
|
3158
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3159
|
+
namespace name1
|
|
3160
|
+
const PI = 3.14
|
|
3161
|
+
|
|
3162
|
+
namespace name2
|
|
3163
|
+
function getPi() as float
|
|
3164
|
+
return name1.PI
|
|
3165
|
+
end function
|
|
3166
|
+
end namespace
|
|
3167
|
+
end namespace
|
|
3168
|
+
`);
|
|
3169
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3170
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(0);
|
|
3171
|
+
});
|
|
3172
|
+
it('should put types from typecasts as typetime required', () => {
|
|
3173
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3174
|
+
function takesIface(z) as string
|
|
3175
|
+
return (z as MyInterface).name
|
|
3176
|
+
end function
|
|
3177
|
+
`);
|
|
3178
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3179
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols.length).to.eq(1);
|
|
3180
|
+
(0, chai_config_spec_1.expect)(mainFile.requiredSymbols[0].flags).to.eq(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3181
|
+
});
|
|
3182
|
+
});
|
|
3183
|
+
describe('providedSymbols', () => {
|
|
3184
|
+
it('includes functions defined in the file', () => {
|
|
3185
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3186
|
+
function someFunc() as integer
|
|
3187
|
+
return 1
|
|
3188
|
+
end function
|
|
3189
|
+
|
|
3190
|
+
function someFunc2() as float
|
|
3191
|
+
return 2.3
|
|
3192
|
+
end function
|
|
3193
|
+
`);
|
|
3194
|
+
const validateFileEvent = {
|
|
3195
|
+
program: program,
|
|
3196
|
+
file: mainFile
|
|
3197
|
+
};
|
|
3198
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3199
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3200
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3201
|
+
const someFuncType = runtimeSymbols.get('somefunc').type;
|
|
3202
|
+
(0, testHelpers_spec_1.expectTypeToBe)(someFuncType, TypedFunctionType_1.TypedFunctionType);
|
|
3203
|
+
const someFunc2Type = runtimeSymbols.get('somefunc2').type;
|
|
3204
|
+
(0, testHelpers_spec_1.expectTypeToBe)(someFunc2Type, TypedFunctionType_1.TypedFunctionType);
|
|
3205
|
+
});
|
|
3206
|
+
it('includes functions with unresolved params/return types', () => {
|
|
3207
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3208
|
+
function someFunc() as OtherFileType
|
|
3209
|
+
return new OtherFileType()
|
|
3210
|
+
end function
|
|
3211
|
+
`);
|
|
3212
|
+
const validateFileEvent = {
|
|
3213
|
+
program: program,
|
|
3214
|
+
file: mainFile
|
|
3215
|
+
};
|
|
3216
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3217
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3218
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3219
|
+
const someFuncType = runtimeSymbols.get('somefunc').type;
|
|
3220
|
+
(0, testHelpers_spec_1.expectTypeToBe)(someFuncType, TypedFunctionType_1.TypedFunctionType);
|
|
3221
|
+
const requiredSymbols = mainFile.requiredSymbols.map(x => x.typeChain[0].name);
|
|
3222
|
+
(0, chai_config_spec_1.expect)(requiredSymbols).to.have.same.members(['OtherFileType', 'OtherFileType']);
|
|
3223
|
+
const requiredSymbolTypes = mainFile.requiredSymbols.map(x => x.flags);
|
|
3224
|
+
(0, chai_config_spec_1.expect)(requiredSymbolTypes).to.have.same.members([SymbolTable_1.SymbolTypeFlag.runtime, SymbolTable_1.SymbolTypeFlag.typetime]);
|
|
3225
|
+
});
|
|
3226
|
+
it('includes classes defined in the file', () => {
|
|
3227
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3228
|
+
class Klass
|
|
3229
|
+
name as string
|
|
3230
|
+
end class
|
|
3231
|
+
|
|
3232
|
+
class Klass2 extends Klass
|
|
3233
|
+
age as integer
|
|
3234
|
+
|
|
3235
|
+
function getId() as string
|
|
3236
|
+
return m.name + " " + m.age.toStr()
|
|
3237
|
+
end function
|
|
3238
|
+
end class
|
|
3239
|
+
|
|
3240
|
+
class Klass3
|
|
3241
|
+
propClass = new Klass2()
|
|
3242
|
+
end class
|
|
3243
|
+
`);
|
|
3244
|
+
const validateFileEvent = {
|
|
3245
|
+
program: program,
|
|
3246
|
+
file: mainFile
|
|
3247
|
+
};
|
|
3248
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3249
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3250
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3251
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
|
|
3252
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass2').type, types_1.ClassType);
|
|
3253
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass3').type, types_1.ClassType);
|
|
3254
|
+
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3255
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(3);
|
|
3256
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass').type, types_1.ClassType);
|
|
3257
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass2').type, types_1.ClassType);
|
|
3258
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('klass3').type, types_1.ClassType);
|
|
3259
|
+
});
|
|
3260
|
+
it('includes other types defined in the file', () => {
|
|
3261
|
+
const mainFile = program.setFile('source/main.bs', `
|
|
3262
|
+
interface MyInterface
|
|
3263
|
+
name as string
|
|
3264
|
+
end interface
|
|
3265
|
+
|
|
3266
|
+
enum MyEnum
|
|
3267
|
+
val1
|
|
3268
|
+
val2
|
|
3269
|
+
end enum
|
|
3270
|
+
|
|
3271
|
+
namespace MyNamespace
|
|
3272
|
+
const MyConst = 3.14
|
|
3273
|
+
end namespace
|
|
3274
|
+
`);
|
|
3275
|
+
const validateFileEvent = {
|
|
3276
|
+
program: program,
|
|
3277
|
+
file: mainFile
|
|
3278
|
+
};
|
|
3279
|
+
program.plugins.emit('onFileValidate', validateFileEvent);
|
|
3280
|
+
const runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3281
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3282
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
|
|
3283
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('mynamespace.myconst').type, types_1.FloatType);
|
|
3284
|
+
const typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3285
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(2);
|
|
3286
|
+
(0, testHelpers_spec_1.expectTypeToBe)(typetimeSymbols.get('myinterface').type, types_1.InterfaceType);
|
|
3287
|
+
(0, testHelpers_spec_1.expectTypeToBe)(runtimeSymbols.get('myenum').type, types_1.EnumType);
|
|
3288
|
+
});
|
|
3289
|
+
describe('changes', () => {
|
|
3290
|
+
it('new symbols are added to the changes set', () => {
|
|
3291
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3292
|
+
sub someFunc()
|
|
3293
|
+
print 1
|
|
3294
|
+
end sub
|
|
3295
|
+
`);
|
|
3296
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3297
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3298
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3299
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3300
|
+
sub someFunc()
|
|
3301
|
+
print 1
|
|
3302
|
+
end sub
|
|
3303
|
+
|
|
3304
|
+
sub someFunc2()
|
|
3305
|
+
print 2
|
|
3306
|
+
end sub
|
|
3307
|
+
`);
|
|
3308
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3309
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3310
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3311
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3312
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3313
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc2')).to.be.true;
|
|
3314
|
+
});
|
|
3315
|
+
it('removed symbols are added to the changes set', () => {
|
|
3316
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3317
|
+
sub someFunc()
|
|
3318
|
+
print 1
|
|
3319
|
+
end sub
|
|
3320
|
+
|
|
3321
|
+
sub someFunc2()
|
|
3322
|
+
print 2
|
|
3323
|
+
end sub
|
|
3324
|
+
`);
|
|
3325
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3326
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3327
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3328
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3329
|
+
sub someFunc()
|
|
3330
|
+
print 1
|
|
3331
|
+
end sub
|
|
3332
|
+
`);
|
|
3333
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3334
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3335
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3336
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3337
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3338
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc2')).to.be.true;
|
|
3339
|
+
});
|
|
3340
|
+
it('new symbols in a namespace are added to the changes set', () => {
|
|
3341
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3342
|
+
namespace Alpha
|
|
3343
|
+
end namespace
|
|
3344
|
+
`);
|
|
3345
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3346
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3347
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
|
|
3348
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3349
|
+
namespace Alpha
|
|
3350
|
+
const ABC = "abc"
|
|
3351
|
+
end namespace
|
|
3352
|
+
`);
|
|
3353
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3354
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3355
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3356
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3357
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3358
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('alpha.abc')).to.be.true;
|
|
3359
|
+
});
|
|
3360
|
+
it('should be empty if no changes in actual provided symbols', () => {
|
|
3361
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3362
|
+
sub printSomething()
|
|
3363
|
+
print "Something"
|
|
3364
|
+
end sub
|
|
3365
|
+
|
|
3366
|
+
namespace alpha.beta
|
|
3367
|
+
const PI = 3.14
|
|
3368
|
+
end namespace
|
|
3369
|
+
`);
|
|
3370
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3371
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3372
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3373
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3374
|
+
sub printSomething()
|
|
3375
|
+
print "Something Else"
|
|
3376
|
+
end sub
|
|
3377
|
+
|
|
3378
|
+
namespace alpha.beta
|
|
3379
|
+
const PI = 3.14159
|
|
3380
|
+
end namespace
|
|
3381
|
+
`);
|
|
3382
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3383
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3384
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3385
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3386
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3387
|
+
});
|
|
3388
|
+
it('should include changes in function signatures', () => {
|
|
3389
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3390
|
+
function someFunc(x)
|
|
3391
|
+
return x
|
|
3392
|
+
end function
|
|
3393
|
+
`);
|
|
3394
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3395
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3396
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3397
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3398
|
+
function someFunc(x, y)
|
|
3399
|
+
return x+y
|
|
3400
|
+
end function
|
|
3401
|
+
`);
|
|
3402
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3403
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3404
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3405
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3406
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3407
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('somefunc'));
|
|
3408
|
+
});
|
|
3409
|
+
it('should include changes in classes', () => {
|
|
3410
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3411
|
+
class MyKlass
|
|
3412
|
+
name as string
|
|
3413
|
+
function getValue() as float
|
|
3414
|
+
return 3.14
|
|
3415
|
+
end function
|
|
3416
|
+
end class
|
|
3417
|
+
`);
|
|
3418
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3419
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3420
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3421
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3422
|
+
class MyKlass
|
|
3423
|
+
name as string
|
|
3424
|
+
function getValue() as string
|
|
3425
|
+
return "hello"
|
|
3426
|
+
end function
|
|
3427
|
+
end class
|
|
3428
|
+
`);
|
|
3429
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3430
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3431
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3432
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3433
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3434
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('myklass'));
|
|
3435
|
+
let typeTimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3436
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.size).to.eq(1);
|
|
3437
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.has('myklass'));
|
|
3438
|
+
});
|
|
3439
|
+
it('should include changes in interfaces', () => {
|
|
3440
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3441
|
+
interface Iface1
|
|
3442
|
+
name as string
|
|
3443
|
+
function doStuff() as float
|
|
3444
|
+
end interface
|
|
3445
|
+
`);
|
|
3446
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3447
|
+
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3448
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3449
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3450
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(0);
|
|
3451
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3452
|
+
interface Iface1
|
|
3453
|
+
name as string
|
|
3454
|
+
age as integer
|
|
3455
|
+
function doStuff() as float
|
|
3456
|
+
end interface
|
|
3457
|
+
`);
|
|
3458
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3459
|
+
typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3460
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3461
|
+
let typeTimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3462
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.size).to.eq(1);
|
|
3463
|
+
(0, chai_config_spec_1.expect)(typeTimeChanges.has('iface1'));
|
|
3464
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3465
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3466
|
+
});
|
|
3467
|
+
it('should not include changes in enum values, if inner type is the same', () => {
|
|
3468
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3469
|
+
enum MyEnum
|
|
3470
|
+
north = 4
|
|
3471
|
+
east = 3
|
|
3472
|
+
south = 2
|
|
3473
|
+
west = 1
|
|
3474
|
+
end enum
|
|
3475
|
+
`);
|
|
3476
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3477
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3478
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3479
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3480
|
+
enum MyEnum
|
|
3481
|
+
north = 1
|
|
3482
|
+
east = 2
|
|
3483
|
+
south = 3
|
|
3484
|
+
west = 4
|
|
3485
|
+
end enum
|
|
3486
|
+
`);
|
|
3487
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3488
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3489
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3490
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3491
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3492
|
+
let typetimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3493
|
+
(0, chai_config_spec_1.expect)(typetimeSymbols.size).to.eq(1);
|
|
3494
|
+
let typetimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.typetime);
|
|
3495
|
+
(0, chai_config_spec_1.expect)(typetimeChanges.size).to.eq(0);
|
|
3496
|
+
});
|
|
3497
|
+
it('should include changes in enum, if different number of members', () => {
|
|
3498
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3499
|
+
enum Direction
|
|
3500
|
+
north = 1
|
|
3501
|
+
east = 2
|
|
3502
|
+
south = 3
|
|
3503
|
+
west = 4
|
|
3504
|
+
end enum
|
|
3505
|
+
|
|
3506
|
+
enum Weather
|
|
3507
|
+
rainy
|
|
3508
|
+
sunny
|
|
3509
|
+
end enum
|
|
3510
|
+
|
|
3511
|
+
enum Colors
|
|
3512
|
+
blue
|
|
3513
|
+
red
|
|
3514
|
+
green
|
|
3515
|
+
purple
|
|
3516
|
+
end enum
|
|
3517
|
+
`);
|
|
3518
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3519
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3520
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3521
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3522
|
+
enum Direction ' same
|
|
3523
|
+
north = 1
|
|
3524
|
+
east = 2
|
|
3525
|
+
south = 3
|
|
3526
|
+
west = 4
|
|
3527
|
+
end enum
|
|
3528
|
+
|
|
3529
|
+
enum Weather 'added member
|
|
3530
|
+
rainy
|
|
3531
|
+
sunny
|
|
3532
|
+
snowy
|
|
3533
|
+
end enum
|
|
3534
|
+
|
|
3535
|
+
enum Colors 'removed member
|
|
3536
|
+
blue
|
|
3537
|
+
red
|
|
3538
|
+
green
|
|
3539
|
+
end enum
|
|
3540
|
+
`);
|
|
3541
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3542
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3543
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(3);
|
|
3544
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3545
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(2);
|
|
3546
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('weather'));
|
|
3547
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('colors'));
|
|
3548
|
+
});
|
|
3549
|
+
it('should include changes in enum, if different underlying type', () => {
|
|
3550
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3551
|
+
enum Direction
|
|
3552
|
+
north = 1
|
|
3553
|
+
east = 2
|
|
3554
|
+
south = 3
|
|
3555
|
+
west = 4
|
|
3556
|
+
end enum
|
|
3557
|
+
`);
|
|
3558
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3559
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3560
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3561
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3562
|
+
enum Direction ' now is a string
|
|
3563
|
+
north = "N"
|
|
3564
|
+
east = "E"
|
|
3565
|
+
south = "S"
|
|
3566
|
+
west = "W"
|
|
3567
|
+
end enum
|
|
3568
|
+
`);
|
|
3569
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3570
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3571
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3572
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3573
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3574
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('direction'));
|
|
3575
|
+
});
|
|
3576
|
+
it('should include changes in const, if different underlying type', () => {
|
|
3577
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3578
|
+
namespace alpha.beta
|
|
3579
|
+
const PI = 3.14
|
|
3580
|
+
end namespace
|
|
3581
|
+
`);
|
|
3582
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3583
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3584
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3585
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3586
|
+
namespace alpha.beta
|
|
3587
|
+
const PI = "lemon chiffon"
|
|
3588
|
+
end namespace
|
|
3589
|
+
`);
|
|
3590
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3591
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3592
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(1);
|
|
3593
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3594
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(1);
|
|
3595
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.has('alpha.beta.pi'));
|
|
3596
|
+
});
|
|
3597
|
+
it('should not include changes inside a function if the param types are known', () => {
|
|
3598
|
+
let mainFile = program.setFile('source/main.bs', `
|
|
3599
|
+
function func1(p as string) as integer
|
|
3600
|
+
return len(p)
|
|
3601
|
+
end function
|
|
3602
|
+
|
|
3603
|
+
sub displayModelTypeInLabel(myLabel as roSgNodeLabel)
|
|
3604
|
+
print myLabel.text
|
|
3605
|
+
di = createObject("roDeviceInfo")' as roDeviceInfo
|
|
3606
|
+
myLabel.text = di.GetFriendlyName()
|
|
3607
|
+
print myLabel.getChildren(0, -1)
|
|
3608
|
+
end sub
|
|
3609
|
+
`);
|
|
3610
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3611
|
+
let runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3612
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3613
|
+
mainFile = program.setFile('source/main.bs', `
|
|
3614
|
+
function func1(p as string) as integer
|
|
3615
|
+
return len(p)+1
|
|
3616
|
+
end function
|
|
3617
|
+
|
|
3618
|
+
sub displayModelTypeInLabel(myLabel as roSgNodeLabel)
|
|
3619
|
+
print myLabel.text
|
|
3620
|
+
di = createObject("roDeviceInfo") as roDeviceInfo
|
|
3621
|
+
myLabel.text = di.GetFriendlyName()
|
|
3622
|
+
print myLabel.getChildren(0, -1)
|
|
3623
|
+
end sub
|
|
3624
|
+
`);
|
|
3625
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3626
|
+
runtimeSymbols = mainFile.providedSymbols.symbolMap.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3627
|
+
(0, chai_config_spec_1.expect)(runtimeSymbols.size).to.eq(2);
|
|
3628
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3629
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3630
|
+
});
|
|
3631
|
+
it('classes that override AA built-in methods show change properly', () => {
|
|
3632
|
+
const classFileContent = `
|
|
3633
|
+
class AAOverRide
|
|
3634
|
+
sub count(num as integer) as void
|
|
3635
|
+
print num
|
|
3636
|
+
end sub
|
|
3637
|
+
end class
|
|
3638
|
+
`;
|
|
3639
|
+
let mainFile = program.setFile('source/class.bs', classFileContent);
|
|
3640
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3641
|
+
// No changes!
|
|
3642
|
+
mainFile = program.setFile('source/class.bs', classFileContent);
|
|
3643
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3644
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3645
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3646
|
+
});
|
|
3647
|
+
it('functions in a namespace that return classes show change properly', () => {
|
|
3648
|
+
const fileContent = `
|
|
3649
|
+
namespace Alpha.Beta
|
|
3650
|
+
|
|
3651
|
+
class SomeKlass
|
|
3652
|
+
name as string
|
|
3653
|
+
function combineName(klass as SomeKlass)
|
|
3654
|
+
m.name = m.name+klass.name
|
|
3655
|
+
end function
|
|
3656
|
+
end class
|
|
3657
|
+
|
|
3658
|
+
function getSomeKlass(name as string) as SomeKlass
|
|
3659
|
+
k = new SomeKlass()
|
|
3660
|
+
k.name = name
|
|
3661
|
+
return k
|
|
3662
|
+
end function
|
|
3663
|
+
end namespace
|
|
3664
|
+
`;
|
|
3665
|
+
let mainFile = program.setFile('source/class.bs', fileContent);
|
|
3666
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3667
|
+
// No changes!
|
|
3668
|
+
mainFile = program.setFile('source/class.bs', fileContent);
|
|
3669
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3670
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3671
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3672
|
+
});
|
|
3673
|
+
it('functions in a namespace that have class params show change properly', () => {
|
|
3674
|
+
const fileContent = `
|
|
3675
|
+
namespace Alpha.Beta
|
|
3676
|
+
|
|
3677
|
+
class SomeKlass
|
|
3678
|
+
name as string
|
|
3679
|
+
function combineName(klass as SomeKlass)
|
|
3680
|
+
m.name = m.name+klass.name
|
|
3681
|
+
end function
|
|
3682
|
+
end class
|
|
3683
|
+
|
|
3684
|
+
function combineKlass(klass1 as SomeKlass, klass2 as SomeKlass) as SomeKlass
|
|
3685
|
+
klass1.combineName(klass2)
|
|
3686
|
+
return klass1
|
|
3687
|
+
end function
|
|
3688
|
+
end namespace
|
|
3689
|
+
`;
|
|
3690
|
+
let mainFile = program.setFile('source/class.bs', fileContent);
|
|
3691
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3692
|
+
// No changes!
|
|
3693
|
+
mainFile = program.setFile('source/class.bs', fileContent);
|
|
3694
|
+
program.plugins.emit('onFileValidate', { program: program, file: mainFile });
|
|
3695
|
+
let runtimeChanges = mainFile.providedSymbols.changes.get(SymbolTable_1.SymbolTypeFlag.runtime);
|
|
3696
|
+
(0, chai_config_spec_1.expect)(runtimeChanges.size).to.eq(0);
|
|
3697
|
+
});
|
|
3698
|
+
});
|
|
3699
|
+
});
|
|
2832
3700
|
});
|
|
2833
3701
|
//# sourceMappingURL=BrsFile.spec.js.map
|