@bikky/compiler 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/Libraries/MixinCode.d.ts +4 -4
  2. package/Libraries/MixinCode.d.ts.map +1 -1
  3. package/Source/ASTHelper.d.ts +74 -0
  4. package/Source/ASTHelper.d.ts.map +1 -0
  5. package/Source/ASTHelper.js +16 -30
  6. package/Transformers/CompilerInsertions.d.ts +8 -0
  7. package/Transformers/CompilerInsertions.d.ts.map +1 -0
  8. package/Transformers/CompilerInsertions.js +12 -0
  9. package/Transformers/MacroTransformer.d.ts +3 -0
  10. package/Transformers/MacroTransformer.d.ts.map +1 -0
  11. package/Transformers/MacroTransformer.js +3 -6
  12. package/Transformers/MixinTransformer.d.ts +4 -0
  13. package/Transformers/MixinTransformer.d.ts.map +1 -0
  14. package/Transformers/MixinTransformer.js +18 -22
  15. package/Transformers/SuperTransform.js +2 -5
  16. package/obj/Debug/BiscuitCompiler.njsproj.AssemblyReference.cache +0 -0
  17. package/package.json +4 -4
  18. package/tsconfig.build.json +3 -2
  19. package/tsconfig.build.tsbuildinfo +1 -1
  20. package/tsconfig.json +1 -4
  21. package/BiscuitCompiler.njsproj +0 -89
  22. package/BiscuitCompiler.njsproj.user +0 -7
  23. package/Libraries/BiscuitLibraries.js.map +0 -1
  24. package/Libraries/BiscuitLibraries.ts +0 -2
  25. package/Libraries/MixinCode.js.map +0 -1
  26. package/Libraries/MixinCode.ts +0 -125
  27. package/Source/ASTHelper.js.map +0 -1
  28. package/Source/ASTHelper.ts +0 -373
  29. package/Transformers/CompilerInsertions.ts +0 -21
  30. package/Transformers/MacroTransformer.js.map +0 -1
  31. package/Transformers/MacroTransformer.ts +0 -304
  32. package/Transformers/MixinTransformer.js.map +0 -1
  33. package/Transformers/MixinTransformer.ts +0 -151
  34. package/Transformers/SuperTransform.js.map +0 -1
  35. package/Transformers/SuperTransform.ts +0 -129
@@ -1,89 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <PropertyGroup>
4
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
- <SchemaVersion>2.0</SchemaVersion>
6
- <ProjectGuid>{3e2ffef5-c505-494a-be1e-0949a90874f1}</ProjectGuid>
7
- <ProjectHome>.</ProjectHome>
8
- <ProjectView>ProjectFiles</ProjectView>
9
- <StartupFile>tsc.ts</StartupFile>
10
- <WorkingDirectory>.</WorkingDirectory>
11
- <OutputPath>.</OutputPath>
12
- <ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
13
- <EnableTypeScript>true</EnableTypeScript>
14
- <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">17.0</VisualStudioVersion>
15
- <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16
- </PropertyGroup>
17
- <PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
18
- <PropertyGroup Condition="'$(Configuration)' == 'Release'" />
19
- <ItemGroup>
20
- <Content Include="package.json" />
21
- <Content Include="Source\TSPatchTypes.d.ts" />
22
- <Content Include="tsconfig.json" />
23
- <Content Include="tsconfig.build.json" />
24
- </ItemGroup>
25
- <ItemGroup>
26
- <TypeScriptCompile Include="Libraries\BiscuitLibraries.ts" />
27
- <TypeScriptCompile Include="Source\ASTHelper.ts" />
28
- <TypeScriptCompile Include="Transformers\MacroTransformer.ts">
29
- <SubType>Code</SubType>
30
- </TypeScriptCompile>
31
- <TypeScriptCompile Include="Libraries\GlobalTypes.d.ts">
32
- <SubType>Code</SubType>
33
- </TypeScriptCompile>
34
- <TypeScriptCompile Include="Libraries\MixinCode.ts" />
35
- <TypeScriptCompile Include="Transformers\MixinTransformer.ts">
36
- <SubType>Code</SubType>
37
- </TypeScriptCompile>
38
- <TypeScriptCompile Include="Transformers\SuperTransform.ts">
39
- <SubType>Code</SubType>
40
- </TypeScriptCompile>
41
- </ItemGroup>
42
- <ItemGroup>
43
- <Folder Include="Libraries\" />
44
- <Folder Include="Transformers\" />
45
- </ItemGroup>
46
- <ItemGroup>
47
- <Script Include="Transformers\CompilerInsertions.ts" />
48
- </ItemGroup>
49
- <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
50
- <Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsToolsV2.targets" />
51
- <ProjectExtensions>
52
- <VisualStudio>
53
- <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
54
- <WebProjectProperties>
55
- <UseIIS>False</UseIIS>
56
- <AutoAssignPort>True</AutoAssignPort>
57
- <DevelopmentServerPort>0</DevelopmentServerPort>
58
- <DevelopmentServerVPath>/</DevelopmentServerVPath>
59
- <IISUrl>http://localhost:48022/</IISUrl>
60
- <NTLMAuthentication>False</NTLMAuthentication>
61
- <UseCustomServer>True</UseCustomServer>
62
- <CustomServerUrl>http://localhost:1337</CustomServerUrl>
63
- <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
64
- </WebProjectProperties>
65
- </FlavorProperties>
66
- <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
67
- <WebProjectProperties>
68
- <StartPageUrl>
69
- </StartPageUrl>
70
- <StartAction>CurrentPage</StartAction>
71
- <AspNetDebugging>True</AspNetDebugging>
72
- <SilverlightDebugging>False</SilverlightDebugging>
73
- <NativeDebugging>False</NativeDebugging>
74
- <SQLDebugging>False</SQLDebugging>
75
- <ExternalProgram>
76
- </ExternalProgram>
77
- <StartExternalURL>
78
- </StartExternalURL>
79
- <StartCmdLineArguments>
80
- </StartCmdLineArguments>
81
- <StartWorkingDirectory>
82
- </StartWorkingDirectory>
83
- <EnableENC>False</EnableENC>
84
- <AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
85
- </WebProjectProperties>
86
- </FlavorProperties>
87
- </VisualStudio>
88
- </ProjectExtensions>
89
- </Project>
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
- <PropertyGroup>
4
- <ToolsVersionPromptShown>4.2</ToolsVersionPromptShown>
5
- <LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
6
- </PropertyGroup>
7
- </Project>
@@ -1 +0,0 @@
1
- {"version":3,"file":"BiscuitLibraries.js","sourceRoot":"","sources":["BiscuitLibraries.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,gBAAgB,CAAC"}
@@ -1,2 +0,0 @@
1
- /// <reference path="./GlobalTypes.d.ts" />
2
- import "./MixinCode.js";
@@ -1 +0,0 @@
1
- {"version":3,"file":"MixinCode.js","sourceRoot":"","sources":["MixinCode.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,6GAA6G;AAC7G,SAAS,kBAAkB,CAAC,SAAc,EAAE,MAAW;IACtD,IAAI,KAAK,GAAyB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAE,CAAC;IACrF,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC;IACvD,IAAI,MAAM,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACnC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3C,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,UAAU,GAAG,MAAM,CAAC,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C,CAAC,CAAC;YAC7B,OAAO,MAAM,CAAC;QACf,CAAC;KACD;IAAA,CAAC;IACF,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,OAAkB,OAAO,CAAC;AAC3B,CAAC;AAMD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IAC5B,MAAO,CAAC,OAAO,GAAG,YAAY,CAAC;IAC/B,MAAO,CAAC,SAAS,GAAG,YAAY,CAAC;CACvC;KACI;IACJ,OAAO,GAAG,YAAY,CAAC;IACvB,SAAS,GAAG,YAAY,CAAC;IACnB,MAAO,CAAC,OAAO,GAAG,YAAY,CAAC;IAC/B,MAAO,CAAC,SAAS,GAAG,YAAY,CAAC;CACvC"}
@@ -1,125 +0,0 @@
1
- 
2
-
3
- //Propertydescriptor is needed to preserve getters and setters, otherwise we trigger them.
4
- // We assign functions directly though to preserve the prototype chain when using super() [it's not working].
5
- function duplicatePrototype(prototype: any, parent: any) {
6
- var names = (<(string | symbol)[]>Array.from(Object.getOwnPropertyNames(prototype)));
7
- names.push(...Object.getOwnPropertySymbols(prototype));
8
- var result = { __proto__: parent };
9
- for (let i = names.length - 1; i >= 0; i--) {
10
- let name = names[i];
11
- var descriptor = Object.getOwnPropertyDescriptor(prototype, name)!;
12
- Object.defineProperty(result, name, descriptor);
13
- }
14
- return result;
15
- }
16
-
17
- var mixingObject: any[] = [];
18
- type GetConstraints<Extras> = Extras extends (Function & { prototype: infer Constraints })[] ? Constraints : never;
19
- type UnionToIntersection<U> =
20
- (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
21
- type AllConstraints<Super, Constraints> = UnionToIntersection<Constraints> extends never ? Super : Super & UnionToIntersection<Constraints>;
22
-
23
- type Class<T> = (Function & { prototype: T });
24
-
25
- var mixingBases = <Class<Object>[]>[];
26
- var mixingBaseProtos = <any[]>[];
27
-
28
- //The following parameter type allows abstract classes, where as new () => Core doesn't.
29
- export function makeMixerFoo<Mixin extends Object, Super extends Object, Extras extends Class<any>[]>
30
- (mixin: Class<Mixin>, common: Class<Super>, ...constraints: Extras) {
31
- if (typeof mixin !== "function" || !(mixin as any).prototype) throw new Error("Can only mix classes into other classes.");
32
- return function mix<Core extends AllConstraints<Super, GetConstraints<Extras>>>(core: Function & { prototype: Core }) {
33
- var newClass: Function = eval(`
34
- function Mixin_${(mixin as any).name}(...args) {
35
- //This allows us to change the prototype which the constructor uses for creating
36
- // the object, forcing it to use the prototype of the child class rather than
37
- // the prototype of the core.
38
- var object = Reflect.construct(core, args, this.__proto__.constructor);
39
- mixingObject.push(object);
40
-
41
- //Mixins extend from Mixbase, which assigns the this object to the object created
42
- // by core (above).
43
- new (mixin)(...args);
44
- mixingObject.shift();
45
-
46
- return object;
47
- };
48
- Mixin_${(mixin as any).name}
49
- `);
50
- var originalPrototypes: any[] = [];
51
- var current: any = mixin;
52
- originalPrototypes.push(current.prototype);
53
- current = current.prototype;
54
- while (mixingBaseProtos.indexOf(current.__proto__) < 0 && current.__proto__ != Object.prototype) {
55
- originalPrototypes.push(current.__proto__);
56
- current = current.__proto__;
57
- }
58
- var newPrototypes: any[] = [];
59
- while (originalPrototypes.length > 0) {
60
- current = originalPrototypes.pop();
61
- let originalClass = current;
62
- var prototype = newPrototypes.length == 0 ? core.prototype : newPrototypes[0];
63
- let newmix = duplicatePrototype(current, prototype);
64
- var edits: any = {
65
- //We override the original isA so that this class appears to be a movable as well as other types.
66
- isA<T extends Object>(other: new (...args: any[]) => T) {
67
- if ((<any>other).prototype == originalClass) {
68
- return true;
69
- }
70
- else {
71
- return super.isA(other);
72
- }
73
- },
74
- }
75
- Object.assign(newmix, edits);
76
- newmix.__proto__ = prototype;
77
- //This ensures any super calls in the edits to the prototype resolve correctly, because
78
- // they're based on the original object the function is defined in, not the prototype the
79
- // function ends up on.
80
- edits.__proto__ = prototype;
81
- newPrototypes.unshift(newmix);
82
- }
83
- newClass.prototype = newPrototypes[0];
84
- newClass.prototype.constructor = newClass;
85
- //I wanted to do this on object creation rather than having it be inherited, but that caused a problem with the value
86
- // not being accessible in the constructor, which is necessary because the constructor can call other functons.
87
- if ((<any>mixin).Super) {
88
- //console.log("Configuring", mixin.name, "to have a parent that is", newClass.prototype.__proto__.constructor.name);
89
- newClass.prototype[(<any>mixin).Super] = core.prototype;
90
- }
91
- //newClass.__proto__ = newPrototypes[0];
92
-
93
- return <new (id: string, name: string, data: any, instance?: any) => Core & Mixin><any>newClass;
94
- }
95
- }
96
-
97
- export function MixableClass<Base extends Class<Object>>(param: Base) {
98
- //This is done to preserve super calls in mixins.
99
- class Mixbase extends (<any>param) {
100
- //@ts-ignore we don't need to call super in this child class.
101
- constructor(...args: any[]) {
102
- //We can't override the class' object using .call or .apply, but we can override it in the base class.
103
- var object = mixingObject[0];
104
- return object;
105
- }
106
- };
107
- mixingBases.push(Mixbase);
108
- mixingBaseProtos.push(Mixbase.prototype);
109
- return <Base><any>Mixbase;
110
- }
111
-
112
- declare var window: any;
113
- declare var Mixable: typeof MixableClass;
114
- declare var makeMixer: typeof makeMixerFoo;
115
-
116
- if (typeof global !== "undefined") {
117
- (<any>global).Mixable = MixableClass;
118
- (<any>global).makeMixer = makeMixerFoo;
119
- }
120
- else {
121
- Mixable = MixableClass;
122
- makeMixer = makeMixerFoo;
123
- (<any>window).Mixable = MixableClass;
124
- (<any>window).makeMixer = makeMixerFoo;
125
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ASTHelper.js","sourceRoot":"","sources":["ASTHelper.ts"],"names":[],"mappings":";;;AACA,iCAAiC;AAEjC,SAAgB,UAAU,CAAC,OAAiC,EAAE,IAAY;IACzE,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAFD,gCAEC;AAED,SAAgB,aAAa,CAAC,OAAiC,EAAE,IAAY;IAC5E,OAAO,OAAO,CAAC,OAAO,CAAC,mBAAmB,CA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ts.TransformationContext, name: string) {
5
- return context.factory.createIdentifier(name);
6
- }
7
-
8
- export function StringLiteral(context: ts.TransformationContext, name: string) {
9
- return context.factory.createStringLiteral(name);
10
- }
11
-
12
- export function StaticModifier(context: ts.TransformationContext) {
13
- return context.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Static)[0];
14
- }
15
-
16
- export interface fromable {
17
- from: (param: any)=> any;
18
- }
19
-
20
- export class NamedExpression {
21
- name: ts.Identifier;
22
-
23
- constructor(name: ts.Identifier) {
24
- this.name = name;
25
- }
26
-
27
- getName() {
28
- return this.name;
29
- }
30
-
31
- rename(name: ts.Identifier) {
32
- this.name = name;
33
- return this;
34
- }
35
- }
36
-
37
- export class VariableDeclaration extends NamedExpression {
38
- modifiers?: ts.Modifier[] = [];
39
- value?: ts.Expression;
40
-
41
-
42
- setValue(value: ts.Expression) {
43
- this.value = value;
44
- return this;
45
- }
46
-
47
- addModifier(modifier: ts.Modifier) {
48
- if (!this.modifiers) {
49
- this.modifiers = [];
50
- }
51
- this.modifiers.push(modifier);
52
- return this;
53
- }
54
-
55
- make(context: ts.TransformationContext): ts.Node {
56
- return context.factory.createVariableStatement(this.modifiers,
57
- context.factory.createVariableDeclarationList(
58
- [context.factory.createVariableDeclaration(this.name, undefined, undefined, this.value)]));
59
- }
60
- }
61
-
62
- export module VariableDeclaration {
63
- export function from(variable: ts.VariableDeclaration): VariableDeclaration {
64
- var result = new VariableDeclaration(<ts.Identifier>variable.name);
65
- result.value = variable.initializer;
66
- result.modifiers = variable.modifiers ? Array.from(variable.modifiers) : undefined;
67
- return result;
68
- }
69
- }
70
-
71
- export class PropertyDeclaration extends VariableDeclaration {
72
-
73
- //Property declarations can support a few more name types than normal variables.
74
- constructor(name: ts.Identifier | ts.ComputedPropertyName) {
75
- super(<ts.Identifier>name);
76
- }
77
-
78
- make(context: ts.TransformationContext) {
79
- return context.factory.createPropertyDeclaration([], this.modifiers, this.name, undefined, undefined, this.value);
80
- }
81
- }
82
-
83
- export module PropertyDeclaration {
84
- export function from(variable: ts.PropertyDeclaration | ts.VariableDeclaration): PropertyDeclaration {
85
- var result = new PropertyDeclaration(<ts.Identifier>variable.name);
86
- result.value = variable.initializer;
87
- result.modifiers = variable.modifiers ? Array.from(variable.modifiers) : undefined;
88
- return result;
89
- }
90
- }
91
-
92
- export class CallExpression extends NamedExpression {
93
- arguments: ts.Expression[] = [];
94
- addArgument(...arg: ts.Expression[]) {
95
- this.arguments.push(...arg);
96
- return this;
97
- }
98
- make(context: ts.TransformationContext) {
99
- return context.factory.createCallExpression(this.name, undefined, this.arguments);
100
- }
101
- }
102
-
103
- //this[super].function.call(this, arguments);
104
- export class AccessExpression {
105
- start!: ts.Expression | ts.Identifier;
106
- chain!: ts.AccessExpression;
107
- context: ts.TransformationContext;
108
- constructor(context: ts.TransformationContext) {
109
- this.context = context;
110
- }
111
- this() {
112
- if (!this.start) {
113
- this.start = this.context.factory.createThis();
114
- }
115
- else {
116
- throw new Error("This can only be the first expression in an access chain");
117
- }
118
- return this;
119
- }
120
- access(node: ts.Expression | ts.Identifier | ts.ComputedPropertyName) {
121
- if (!this.start) {
122
- this.start = <ts.Identifier>node;
123
- }
124
- else {
125
- if (!this.chain) {
126
- if (this.start.kind === ts.SyntaxKind.ThisKeyword) {
127
- this.chain = this.context.factory.createElementAccessExpression(this.start, <ts.Identifier>node);
128
- }
129
- else {
130
- this.chain = this.context.factory.createPropertyAccessExpression(this.start, <ts.Identifier>node);
131
- }
132
- }
133
- else {
134
- this.chain = this.context.factory.createPropertyAccessExpression(this.chain, <ts.Identifier>node);
135
- }
136
- }
137
- return this;
138
- }
139
- make() {
140
- return this.chain;
141
- }
142
- }
143
-
144
- export class ClassDeclaration extends NamedExpression {
145
- original?: ts.ClassDeclaration;
146
- decorators: ts.Decorator[] = [];
147
- extends: ts.Expression | undefined;
148
- members: (ts.ClassElement)[] = [];
149
-
150
- static from(oldClass: ts.ClassDeclaration) {
151
- var Class = new ClassDeclaration(oldClass.name!);
152
- Class.original = oldClass;
153
- if (oldClass.heritageClauses) {
154
- for (var clause of oldClass.heritageClauses) {
155
- if ((<ts.HeritageClause>clause).token == ts.SyntaxKind.ExtendsKeyword) {
156
- Class.extends = clause.types[0].expression;
157
- }
158
- }
159
- }
160
- Class.members = Array.from(oldClass.members);
161
- if (oldClass.decorators) {
162
- Class.decorators = Array.from(oldClass.decorators);
163
- }
164
- return Class;
165
- }
166
-
167
- addMemberAtStart(member: ts.ClassElement) {
168
- this.members.unshift(member);
169
- return this;
170
- }
171
-
172
- addMember(member: ts.ClassElement) {
173
- this.members.push(member);
174
- return this;
175
- }
176
-
177
- hasDecorator(identifier: string | ts.Identifier) {
178
- var name = (typeof identifier === "string") ? identifier : identifier.text;
179
- for (var i = 0; i < this.decorators.length; i++) {
180
- var decorator = this.decorators[i];
181
- if (ts.isIdentifier(decorator.expression) && decorator.expression.text == name) {
182
- return true;
183
- }
184
- else if (ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() == name) {
185
- return true;
186
- }
187
- }
188
- return false;
189
- }
190
-
191
- removeDecorator(identifier: string | ts.Identifier) {
192
- var name = (typeof identifier === "string") ? identifier : identifier.text;
193
- for (var i = 0; i < this.decorators.length; i++) {
194
- var decorator = this.decorators[i];
195
- if (ts.isIdentifier(decorator.expression) && decorator.expression.text == name) {
196
- this.decorators.splice(i, 1);
197
- return this;
198
- }
199
- else if (ts.isCallExpression(decorator.expression) && decorator.expression.expression.getText() == name) {
200
- this.decorators.splice(i, 1);
201
- return this;
202
- }
203
- }
204
- return this;
205
- }
206
-
207
- hasExtends() {
208
- return !!this.extends;
209
- }
210
-
211
- getExtends() {
212
- return this.extends;
213
- }
214
-
215
- setExtends(Extends: ts.Expression | undefined) {
216
- this.extends = Extends;
217
- return this;
218
- }
219
-
220
- static eachContextualNode(Class: ts.ClassDeclaration, foo: ts.Visitor, context: ts.TransformationContext) {
221
- var statement = (node: ts.Node): ts.VisitResult<ts.Node> => {
222
- if (ts.isBlock(node)) {
223
- return blocks(node);
224
- }
225
- else if (ts.isArrowFunction(node)) {
226
- return members(node);
227
- }
228
- else {
229
- var result = foo(node);
230
- if (!result) {
231
- return result;
232
- }
233
- if (Array.isArray(result)) {
234
- //TODO: Should probably do something smart here?
235
- return result;
236
- }
237
- return ts.visitEachChild(result, statement, context);
238
- }
239
- };
240
-
241
- var blocks = (node: ts.Node): ts.VisitResult<ts.Node> => {
242
- if (ts.isBlock(node)) {
243
- return ts.visitEachChild(node, statement, context);
244
- }
245
- return node;
246
- };
247
- var members = (node: ts.Node): ts.VisitResult<ts.Node> => {
248
- if (ts.isMethodDeclaration(node)) {
249
- return ts.visitEachChild(node, blocks, context);
250
- }
251
- else {
252
- return node;
253
- }
254
- };
255
- return ts.visitEachChild(Class, members, context);
256
- }
257
-
258
- update(context: ts.TransformationContext) {
259
- if (!this.original) {
260
- throw new Error("Cannot update class that doesn't exist!");
261
- }
262
-
263
- var replaceNodeArrays = (nodes: ts.NodeArray<any> | undefined, visitor: ts.Visitor | undefined, test?: (node: ts.Node) => boolean, start?: number, count?: number): ts.NodeArray<ts.Node> => {
264
- if (nodes == this.original!.decorators) {
265
- return context.factory.createNodeArray(this.decorators);
266
- }
267
- if (nodes == this.original!.members) {
268
- return context.factory.createNodeArray(this.members);
269
- }
270
- if (nodes) {
271
- var changedArray = false;
272
- var newArray = [];
273
- for (var node of nodes) {
274
- var newNode = ts.visitNode(node, visitor, test);
275
- newArray.push(newNode);
276
- if (node != newNode) {
277
- changedArray = true;
278
- }
279
- }
280
- if (changedArray) {
281
- return context.factory.createNodeArray(newArray);
282
- }
283
- }
284
- return nodes!;
285
- };
286
-
287
- var replaceExports: ts.Visitor = (node: ts.Node) => {
288
- if (node.kind == ts.SyntaxKind.HeritageClause && (<ts.HeritageClause>node).token == ts.SyntaxKind.ExtendsKeyword) {
289
- //I hope this works...
290
- var result = context.factory.createHeritageClause(ts.SyntaxKind.ExtendsKeyword, [ts.createExpressionWithTypeArguments(undefined, this.extends!)]);
291
- return result;
292
- }
293
- return node;
294
- }
295
-
296
- //first parameter is the class, second is the thing to edit individual nodes, third is the context
297
- // last parameter is the thing to edit entire node arrays.
298
- return ts.visitEachChild(this.original, replaceExports, context, replaceNodeArrays);
299
- }
300
- }
301
-
302
- export class SourceFile {
303
- original?: ts.SourceFile;
304
- statements: ts.Statement[] = [];
305
-
306
- static from(oldfile: ts.SourceFile) {
307
- var file = new SourceFile;
308
- file.statements = Array.from(oldfile.statements);
309
- file.original = oldfile;
310
- return file;
311
- }
312
-
313
- replaceNode(oldNode: ts.Statement, newNode: ts.Statement) {
314
- var index = this.statements.indexOf(oldNode);
315
- if (index < 0) {
316
- throw new Error("Tried to replace a node that doesn't exist in file");
317
- }
318
- this.statements[index] = newNode;
319
- return this;
320
- }
321
-
322
- insertUnderImports(node: ts.Statement) {
323
- for (var i = 0; i < this.statements.length; i++) {
324
- if (this.statements[i].kind !== ts.SyntaxKind.ImportDeclaration) {
325
- this.statements.splice(i, 0, node);
326
- break;
327
- }
328
- }
329
- return this;
330
- }
331
-
332
- update(context: ts.TransformationContext) {
333
- if (!this.original) {
334
- throw new Error("Cannot update file that doesn't exist!");
335
- }
336
- var newSource = ts.getMutableClone(this.original);
337
- //Cast to any because mutable clones use the same immutable typing as their original node.
338
- (<any>newSource).statements = context.factory.createNodeArray(this.statements);
339
- return newSource;
340
- }
341
- }
342
-
343
-
344
- export function logError(node: ts.Node, error: string): undefined {
345
- if (!node || !node.getSourceFile()) {
346
- console.error("Why are we here?");
347
- return;
348
- }
349
- var source = ts.isSourceFile(node) ? node : node.getSourceFile();
350
- var pos = source.getLineAndCharacterOfPosition(node.pos);
351
- console.error(`${source.fileName}(${pos.line},${pos.character}):`, error);
352
- // This can cause the compiler to stop, but we're not using it because the above will allow
353
- // us to go to the right location in the file. And we probably want to return what we can if
354
- // there's an error since that's how the rest of typescript works.
355
- //ts.createThrow(ts.createStringLiteral("Compiler Error."));
356
- return;
357
- }
358
-
359
- export module Printer {
360
- var printer = ts.createPrinter();
361
-
362
- export function printNode(node: ts.Node, sourceFile: ts.SourceFile) {
363
- return printer.printNode(ts.EmitHint.Unspecified, node, sourceFile);
364
- }
365
-
366
- export function printNodeFirstLine(node: ts.Node, sourceFile: ts.SourceFile) {
367
- var code = printNode(node, node.getSourceFile());
368
- //space matches tab.
369
- code = code.replace(/^ *{? *\r\n?/, "");
370
- return code.replace(/\r\n.*/gi, "");
371
-
372
- }
373
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Adds BikkyCompiler type files and supporting code into the program at compile-time.
3
- */
4
-
5
- import * as ts from 'typescript';
6
- import * as path from 'path';
7
- import { ProgramTransformerExtras, PluginConfig } from 'ts-patch';
8
- import {ProgramPatchableTS} from "../Source/TSPatchTypes.js";
9
-
10
- export const newFile = path.resolve(__dirname, '../Libraries/GlobalTypes.d.ts');
11
-
12
-
13
- export default function (program: ts.Program, host: ts.CompilerHost | undefined, options: PluginConfig, pte: ProgramTransformerExtras) {
14
- const tsInstance : ProgramPatchableTS = pte.ts;
15
- return tsInstance.createProgram(
16
- /* rootNames */ [newFile, ...program.getRootFileNames()],
17
- program.getCompilerOptions(),
18
- host,
19
- /* oldProgram */ program
20
- );
21
- }