@alloy-js/csharp 0.20.0-dev.3 → 0.20.0-dev.4
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/dist/src/components/Declaration.d.ts +2 -2
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +3 -13
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +5 -1
- package/dist/src/components/SourceFile.d.ts +8 -9
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +69 -45
- package/dist/src/components/UsingDirective.d.ts +5 -1
- package/dist/src/components/UsingDirective.d.ts.map +1 -1
- package/dist/src/components/UsingDirective.js +3 -1
- package/dist/src/components/class/declaration.d.ts +2 -2
- package/dist/src/components/class/declaration.d.ts.map +1 -1
- package/dist/src/components/class/declaration.js +18 -32
- package/dist/src/components/class/declaration.test.js +171 -193
- package/dist/src/components/constructor/constructor.d.ts.map +1 -1
- package/dist/src/components/constructor/constructor.js +11 -16
- package/dist/src/components/constructor/constructor.test.js +10 -19
- package/dist/src/components/{EnumDeclaration.d.ts → enum/declaration.d.ts} +6 -11
- package/dist/src/components/enum/declaration.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.js +54 -0
- package/dist/src/components/enum/declaration.ref.test.d.ts +2 -0
- package/dist/src/components/enum/declaration.ref.test.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.ref.test.js +120 -0
- package/dist/src/components/enum/declaration.test.d.ts +2 -0
- package/dist/src/components/enum/declaration.test.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.test.js +39 -0
- package/dist/src/components/enum/member.d.ts +7 -0
- package/dist/src/components/enum/member.d.ts.map +1 -0
- package/dist/src/components/enum/member.js +29 -0
- package/dist/src/components/enum/member.test.d.ts +2 -0
- package/dist/src/components/enum/member.test.d.ts.map +1 -0
- package/dist/src/components/enum/member.test.js +28 -0
- package/dist/src/components/field/field.d.ts.map +1 -1
- package/dist/src/components/field/field.js +9 -14
- package/dist/src/components/field/field.test.js +7 -7
- package/dist/src/components/index.d.ts +5 -2
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +5 -2
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +19 -21
- package/dist/src/components/interface/declaration.test.js +26 -35
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +7 -15
- package/dist/src/components/interface/method.test.js +38 -47
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +21 -36
- package/dist/src/components/interface/property.test.js +11 -11
- package/dist/src/components/lexical-scope.d.ts +8 -0
- package/dist/src/components/lexical-scope.d.ts.map +1 -0
- package/dist/src/components/lexical-scope.js +24 -0
- package/dist/src/components/method/method.d.ts +5 -2
- package/dist/src/components/method/method.d.ts.map +1 -1
- package/dist/src/components/method/method.js +7 -13
- package/dist/src/components/method/method.test.js +11 -11
- package/dist/src/components/method-scope.d.ts +8 -0
- package/dist/src/components/method-scope.d.ts.map +1 -0
- package/dist/src/components/method-scope.js +24 -0
- package/dist/src/components/namespace-scopes.d.ts +13 -0
- package/dist/src/components/namespace-scopes.d.ts.map +1 -0
- package/dist/src/components/namespace-scopes.js +44 -0
- package/dist/src/components/namespace.d.ts +7 -0
- package/dist/src/components/namespace.d.ts.map +1 -0
- package/dist/src/components/namespace.js +46 -0
- package/dist/src/components/namespace.ref.test.d.ts +2 -0
- package/dist/src/components/namespace.ref.test.d.ts.map +1 -0
- package/dist/src/components/namespace.ref.test.js +181 -0
- package/dist/src/components/namespace.test.d.ts.map +1 -0
- package/dist/src/components/namespace.test.js +78 -0
- package/dist/src/components/parameters/parameters.d.ts +2 -2
- package/dist/src/components/parameters/parameters.d.ts.map +1 -1
- package/dist/src/components/parameters/parameters.js +12 -11
- package/dist/src/components/parameters/parameters.test.d.ts +2 -0
- package/dist/src/components/parameters/parameters.test.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.test.js +87 -0
- package/dist/src/components/property/property.d.ts.map +1 -1
- package/dist/src/components/property/property.js +21 -36
- package/dist/src/components/property/property.test.js +14 -14
- package/dist/src/components/record/declaration.d.ts.map +1 -1
- package/dist/src/components/record/declaration.js +8 -12
- package/dist/src/components/record/declaration.test.js +6 -13
- package/dist/src/components/struct/declaration.d.ts.map +1 -1
- package/dist/src/components/struct/declaration.js +4 -6
- package/dist/src/components/struct/declaration.test.js +30 -39
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -1
- package/dist/src/components/type-parameters/type-parameter.js +7 -10
- package/dist/src/components/type-parameters/type-parameters.test.js +3 -3
- package/dist/src/components/var/declaration.d.ts.map +1 -1
- package/dist/src/components/var/declaration.js +6 -8
- package/dist/src/components/var/declaration.test.js +11 -20
- package/dist/src/contexts/global-namespace.d.ts +5 -0
- package/dist/src/contexts/global-namespace.d.ts.map +1 -0
- package/dist/src/contexts/global-namespace.js +24 -0
- package/dist/src/contexts/namespace.d.ts +8 -0
- package/dist/src/contexts/namespace.d.ts.map +1 -0
- package/dist/src/contexts/namespace.js +5 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/modifiers.d.ts +11 -0
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/scopes/class.d.ts +10 -0
- package/dist/src/scopes/class.d.ts.map +1 -0
- package/dist/src/scopes/class.js +10 -0
- package/dist/src/scopes/contexts.d.ts +9 -0
- package/dist/src/scopes/contexts.d.ts.map +1 -0
- package/dist/src/scopes/contexts.js +33 -0
- package/dist/src/scopes/csharp.d.ts +8 -0
- package/dist/src/scopes/csharp.d.ts.map +1 -0
- package/dist/src/scopes/csharp.js +11 -0
- package/dist/src/scopes/factories.d.ts +9 -0
- package/dist/src/scopes/factories.d.ts.map +1 -0
- package/dist/src/scopes/factories.js +23 -0
- package/dist/src/scopes/index.d.ts +10 -0
- package/dist/src/scopes/index.d.ts.map +1 -0
- package/dist/src/scopes/index.js +9 -0
- package/dist/src/scopes/lexical.d.ts +7 -0
- package/dist/src/scopes/lexical.d.ts.map +1 -0
- package/dist/src/scopes/lexical.js +7 -0
- package/dist/src/scopes/method.d.ts +9 -0
- package/dist/src/scopes/method.d.ts.map +1 -0
- package/dist/src/scopes/method.js +13 -0
- package/dist/src/scopes/named-type.d.ts +22 -0
- package/dist/src/scopes/named-type.d.ts.map +1 -0
- package/dist/src/scopes/named-type.js +32 -0
- package/dist/src/scopes/namespace.d.ts +11 -0
- package/dist/src/scopes/namespace.d.ts.map +1 -0
- package/dist/src/scopes/namespace.js +38 -0
- package/dist/src/scopes/source-file.d.ts +16 -0
- package/dist/src/scopes/source-file.d.ts.map +1 -0
- package/dist/src/scopes/source-file.js +43 -0
- package/dist/src/symbols/csharp.d.ts +76 -0
- package/dist/src/symbols/csharp.d.ts.map +1 -0
- package/dist/src/symbols/csharp.js +222 -0
- package/dist/src/symbols/factories.d.ts +25 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +86 -0
- package/dist/src/symbols/index.d.ts +5 -2
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +6 -3
- package/dist/src/symbols/method.d.ts +13 -0
- package/dist/src/symbols/method.d.ts.map +1 -0
- package/dist/src/symbols/method.js +15 -0
- package/dist/src/symbols/named-type.d.ts +19 -0
- package/dist/src/symbols/named-type.d.ts.map +1 -0
- package/dist/src/symbols/named-type.js +30 -0
- package/dist/src/symbols/namespace.d.ts +22 -0
- package/dist/src/symbols/namespace.d.ts.map +1 -0
- package/dist/src/symbols/namespace.js +44 -0
- package/dist/src/symbols/reference.d.ts +2 -2
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +36 -43
- package/dist/test/project-directory.test.js +12 -16
- package/dist/test/sourcefile.test.js +7 -19
- package/dist/test/using.test.js +18 -16
- package/dist/test/utils.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
- package/src/components/Declaration.tsx +3 -6
- package/src/components/Reference.tsx +3 -1
- package/src/components/SourceFile.tsx +68 -55
- package/src/components/UsingDirective.tsx +12 -2
- package/src/components/class/declaration.test.tsx +120 -143
- package/src/components/class/declaration.tsx +19 -32
- package/src/components/constructor/constructor.test.tsx +10 -16
- package/src/components/constructor/constructor.tsx +13 -27
- package/src/components/enum/declaration.ref.test.tsx +93 -0
- package/src/components/enum/declaration.test.tsx +34 -0
- package/src/components/enum/declaration.tsx +65 -0
- package/src/components/enum/member.test.tsx +24 -0
- package/src/components/enum/member.tsx +36 -0
- package/src/components/field/field.test.tsx +7 -7
- package/src/components/field/field.tsx +12 -14
- package/src/components/index.ts +5 -2
- package/src/components/interface/declaration.test.tsx +26 -32
- package/src/components/interface/declaration.tsx +16 -18
- package/src/components/interface/method.test.tsx +38 -44
- package/src/components/interface/method.tsx +7 -19
- package/src/components/interface/property.test.tsx +11 -11
- package/src/components/interface/property.tsx +15 -33
- package/src/components/lexical-scope.tsx +29 -0
- package/src/components/method/method.test.tsx +11 -11
- package/src/components/method/method.tsx +12 -18
- package/src/components/method-scope.tsx +27 -0
- package/src/components/namespace-scopes.tsx +44 -0
- package/src/components/namespace.ref.test.tsx +139 -0
- package/src/components/namespace.test.tsx +52 -0
- package/src/components/namespace.tsx +45 -0
- package/src/components/parameters/parameters.test.tsx +71 -0
- package/src/components/parameters/parameters.tsx +9 -16
- package/src/components/property/property.test.tsx +14 -14
- package/src/components/property/property.tsx +17 -38
- package/src/components/record/declaration.test.tsx +5 -12
- package/src/components/record/declaration.tsx +10 -11
- package/src/components/struct/declaration.test.tsx +16 -22
- package/src/components/struct/declaration.tsx +4 -6
- package/src/components/type-parameters/type-parameter.tsx +14 -11
- package/src/components/type-parameters/type-parameters.test.tsx +4 -4
- package/src/components/var/declaration.test.tsx +8 -14
- package/src/components/var/declaration.tsx +12 -6
- package/src/contexts/global-namespace.ts +29 -0
- package/src/contexts/namespace.ts +13 -0
- package/src/index.ts +1 -0
- package/src/modifiers.ts +14 -0
- package/src/scopes/class.ts +12 -0
- package/src/scopes/contexts.ts +45 -0
- package/src/scopes/csharp.ts +18 -0
- package/src/scopes/factories.ts +45 -0
- package/src/scopes/index.ts +9 -0
- package/src/scopes/lexical.ts +10 -0
- package/src/scopes/method.ts +22 -0
- package/src/scopes/named-type.ts +44 -0
- package/src/scopes/namespace.ts +59 -0
- package/src/scopes/source-file.ts +67 -0
- package/src/symbols/csharp.ts +307 -0
- package/src/symbols/factories.ts +199 -0
- package/src/symbols/index.ts +5 -2
- package/src/symbols/method.ts +26 -0
- package/src/symbols/named-type.ts +54 -0
- package/src/symbols/namespace.ts +62 -0
- package/src/symbols/reference.ts +47 -50
- package/temp/api.json +6251 -2454
- package/test/project-directory.test.tsx +12 -16
- package/test/sourcefile.test.tsx +7 -21
- package/test/using.test.tsx +18 -16
- package/test/utils.tsx +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
- package/dist/src/components/EnumDeclaration.js +0 -82
- package/dist/src/components/Namespace.d.ts +0 -11
- package/dist/src/components/Namespace.d.ts.map +0 -1
- package/dist/src/components/Namespace.js +0 -33
- package/dist/src/symbols/csharp-output-symbol.d.ts +0 -8
- package/dist/src/symbols/csharp-output-symbol.d.ts.map +0 -1
- package/dist/src/symbols/csharp-output-symbol.js +0 -19
- package/dist/src/symbols/scopes.d.ts +0 -20
- package/dist/src/symbols/scopes.d.ts.map +0 -1
- package/dist/src/symbols/scopes.js +0 -42
- package/dist/test/enum.test.d.ts +0 -2
- package/dist/test/enum.test.d.ts.map +0 -1
- package/dist/test/enum.test.js +0 -178
- package/dist/test/namespace.test.d.ts.map +0 -1
- package/dist/test/namespace.test.js +0 -81
- package/src/components/EnumDeclaration.tsx +0 -98
- package/src/components/Namespace.tsx +0 -35
- package/src/symbols/csharp-output-symbol.ts +0 -22
- package/src/symbols/scopes.ts +0 -61
- package/test/enum.test.tsx +0 -149
- package/test/namespace.test.tsx +0 -55
- /package/dist/{test → src/components}/namespace.test.d.ts +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useScope } from "@alloy-js/core";
|
|
2
|
+
import { CSharpScope } from "./csharp.js";
|
|
3
|
+
import { CSharpLexicalScope } from "./lexical.js";
|
|
4
|
+
import { CSharpMethodScope } from "./method.js";
|
|
5
|
+
import { CSharpNamedTypeScope } from "./named-type.js";
|
|
6
|
+
export function useCSharpScope() {
|
|
7
|
+
const scope = useScope();
|
|
8
|
+
if (!(scope instanceof CSharpScope)) {
|
|
9
|
+
throw new Error("Expected a C# scope, got a different kind of scope.");
|
|
10
|
+
}
|
|
11
|
+
return scope;
|
|
12
|
+
}
|
|
13
|
+
export function useNamedTypeScope() {
|
|
14
|
+
const scope = useCSharpScope();
|
|
15
|
+
if (!(scope instanceof CSharpNamedTypeScope)) {
|
|
16
|
+
throw new Error("Expected a named type scope, got a " + scope.constructor.name);
|
|
17
|
+
}
|
|
18
|
+
return scope;
|
|
19
|
+
}
|
|
20
|
+
export function useMethodScope() {
|
|
21
|
+
const scope = useScope();
|
|
22
|
+
if (!(scope instanceof CSharpMethodScope)) {
|
|
23
|
+
throw new Error(`Expected a method scope, but got ${scope.constructor.name}.`);
|
|
24
|
+
}
|
|
25
|
+
return scope;
|
|
26
|
+
}
|
|
27
|
+
export function useLexicalScope() {
|
|
28
|
+
const scope = useScope();
|
|
29
|
+
if (!(scope instanceof CSharpLexicalScope)) {
|
|
30
|
+
throw new Error(`Expected a lexical scope, but got ${scope.constructor.name}.`);
|
|
31
|
+
}
|
|
32
|
+
return scope;
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OutputScope, OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamespaceSymbol } from "../symbols/namespace.js";
|
|
3
|
+
export declare class CSharpScope extends OutputScope {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(name: string, parent: CSharpScope | undefined, options?: OutputScopeOptions);
|
|
6
|
+
get enclosingNamespace(): NamespaceSymbol | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=csharp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csharp.d.ts","sourceRoot":"","sources":["../../../src/scopes/csharp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,qBAAa,WAAY,SAAQ,WAAW;;gBAExC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,OAAO,CAAC,EAAE,kBAAkB;IAO9B,IAAI,kBAAkB,gCAErB;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OutputScope } from "@alloy-js/core";
|
|
2
|
+
export class CSharpScope extends OutputScope {
|
|
3
|
+
constructor(name, parent, options) {
|
|
4
|
+
super(name, parent, options);
|
|
5
|
+
this.#namespaceSymbol = parent?.enclosingNamespace;
|
|
6
|
+
}
|
|
7
|
+
#namespaceSymbol;
|
|
8
|
+
get enclosingNamespace() {
|
|
9
|
+
return this.#namespaceSymbol;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamedTypeSymbol } from "../symbols/named-type.js";
|
|
3
|
+
import { CSharpClassScope } from "./class.js";
|
|
4
|
+
import { CSharpMethodScope } from "./method.js";
|
|
5
|
+
import { CSharpNamedTypeScope } from "./named-type.js";
|
|
6
|
+
export declare function createNamedTypeScope(ownerSymbol: NamedTypeSymbol, options?: OutputScopeOptions): CSharpNamedTypeScope;
|
|
7
|
+
export declare function createClassScope(ownerSymbol: NamedTypeSymbol, options?: OutputScopeOptions): CSharpClassScope;
|
|
8
|
+
export declare function createMethodScope(options?: OutputScopeOptions): CSharpMethodScope;
|
|
9
|
+
//# sourceMappingURL=factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/scopes/factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,kBAAuB,wBAcjC;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,eAAe,EAC5B,OAAO,GAAE,kBAAuB,oBAYjC;AACD,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,qBAGjE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSharpClassScope } from "./class.js";
|
|
2
|
+
import { useCSharpScope, useNamedTypeScope } from "./contexts.js";
|
|
3
|
+
import { CSharpMethodScope } from "./method.js";
|
|
4
|
+
import { CSharpNamedTypeScope } from "./named-type.js";
|
|
5
|
+
import { CSharpSourceFileScope } from "./source-file.js";
|
|
6
|
+
export function createNamedTypeScope(ownerSymbol, options = {}) {
|
|
7
|
+
const currentScope = useCSharpScope();
|
|
8
|
+
if (!(currentScope instanceof CSharpNamedTypeScope) && !(currentScope instanceof CSharpSourceFileScope)) {
|
|
9
|
+
throw new Error("Can't create C# type declaration scope inside of " + currentScope.constructor.name);
|
|
10
|
+
}
|
|
11
|
+
return new CSharpNamedTypeScope(ownerSymbol, currentScope, options);
|
|
12
|
+
}
|
|
13
|
+
export function createClassScope(ownerSymbol, options = {}) {
|
|
14
|
+
const currentScope = useCSharpScope();
|
|
15
|
+
if (!(currentScope instanceof CSharpNamedTypeScope) && !(currentScope instanceof CSharpSourceFileScope)) {
|
|
16
|
+
throw new Error("Can't create C# class scope inside of " + currentScope.constructor.name);
|
|
17
|
+
}
|
|
18
|
+
return new CSharpClassScope(ownerSymbol, currentScope, options);
|
|
19
|
+
}
|
|
20
|
+
export function createMethodScope(options = {}) {
|
|
21
|
+
const parentScope = useNamedTypeScope();
|
|
22
|
+
return new CSharpMethodScope("method scope", parentScope, options);
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./class.js";
|
|
2
|
+
export * from "./contexts.js";
|
|
3
|
+
export * from "./csharp.js";
|
|
4
|
+
export * from "./factories.js";
|
|
5
|
+
export * from "./lexical.js";
|
|
6
|
+
export * from "./method.js";
|
|
7
|
+
export * from "./named-type.js";
|
|
8
|
+
export * from "./namespace.js";
|
|
9
|
+
export * from "./source-file.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scopes/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./class.js";
|
|
2
|
+
export * from "./contexts.js";
|
|
3
|
+
export * from "./csharp.js";
|
|
4
|
+
export * from "./factories.js";
|
|
5
|
+
export * from "./lexical.js";
|
|
6
|
+
export * from "./method.js";
|
|
7
|
+
export * from "./named-type.js";
|
|
8
|
+
export * from "./namespace.js";
|
|
9
|
+
export * from "./source-file.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type OutputSpace } from "@alloy-js/core";
|
|
2
|
+
import { CSharpScope } from "./csharp.js";
|
|
3
|
+
export declare class CSharpLexicalScope extends CSharpScope {
|
|
4
|
+
static readonly declarationSpaces: string[];
|
|
5
|
+
get localVariables(): OutputSpace;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=lexical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexical.d.ts","sourceRoot":"","sources":["../../../src/scopes/lexical.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,gBAAuB,iBAAiB,WAAuB;IAE/D,IAAI,cAAc,IAAI,WAAW,CAEhC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OutputSpace } from "@alloy-js/core";
|
|
2
|
+
import { CSharpLexicalScope } from "./lexical.js";
|
|
3
|
+
export declare class CSharpMethodScope extends CSharpLexicalScope {
|
|
4
|
+
static readonly declarationSpaces: string[];
|
|
5
|
+
get localVariables(): OutputSpace;
|
|
6
|
+
get parameters(): OutputSpace;
|
|
7
|
+
get typeParameters(): OutputSpace;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../src/scopes/method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,qBAAa,iBAAkB,SAAQ,kBAAkB;IACvD,gBAAuB,iBAAiB,WAItC;IAEF,IAAI,cAAc,IAAI,WAAW,CAEhC;IAED,IAAI,UAAU,IAAI,WAAW,CAE5B;IAED,IAAI,cAAc,IAAI,WAAW,CAEhC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSharpLexicalScope } from "./lexical.js";
|
|
2
|
+
export class CSharpMethodScope extends CSharpLexicalScope {
|
|
3
|
+
static declarationSpaces = ["local-variables", "parameters", "type-parameters"];
|
|
4
|
+
get localVariables() {
|
|
5
|
+
return this.spaceFor("local-variables");
|
|
6
|
+
}
|
|
7
|
+
get parameters() {
|
|
8
|
+
return this.spaceFor("parameters");
|
|
9
|
+
}
|
|
10
|
+
get typeParameters() {
|
|
11
|
+
return this.spaceFor("type-parameters");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamedTypeSymbol } from "../symbols/named-type.js";
|
|
3
|
+
import { CSharpScope } from "./csharp.js";
|
|
4
|
+
import { CSharpSourceFileScope } from "./source-file.js";
|
|
5
|
+
/**
|
|
6
|
+
* This scope contains NamedTypeSymbols for types that are declared in
|
|
7
|
+
* containers like namespaces. This scope is a member scope which whose
|
|
8
|
+
* member symbol is a NamedTypeSymbol.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CSharpNamedTypeScope extends CSharpScope {
|
|
11
|
+
static readonly declarationSpaces: never[];
|
|
12
|
+
constructor(ownerSymbol: NamedTypeSymbol, parentScope: CSharpNamedTypeScope | CSharpSourceFileScope | undefined, options?: OutputScopeOptions);
|
|
13
|
+
get ownerSymbol(): NamedTypeSymbol;
|
|
14
|
+
get enclosingNamespace(): import("../index.js").NamespaceSymbol | undefined;
|
|
15
|
+
get members(): import("@alloy-js/core").OutputMemberSpace;
|
|
16
|
+
/**
|
|
17
|
+
* For now, we stuff type parameters into the member scope. This is to ensure
|
|
18
|
+
* name conflicts are handled correctly.
|
|
19
|
+
*/
|
|
20
|
+
get typeParameters(): import("@alloy-js/core").OutputMemberSpace;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=named-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"named-type.d.ts","sourceRoot":"","sources":["../../../src/scopes/named-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,gBAAuB,iBAAiB,UAAM;gBAG5C,WAAW,EAAE,eAAe,EAC5B,WAAW,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,SAAS,EACrE,OAAO,GAAE,kBAAuB;IAQlC,IAAI,WAAW,IAAI,eAAe,CAEjC;IAED,IAAI,kBAAkB,sDAErB;IAED,IAAI,OAAO,+CAEV;IAED;;;OAGG;IACH,IAAI,cAAc,+CAEjB;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CSharpScope } from "./csharp.js";
|
|
2
|
+
/**
|
|
3
|
+
* This scope contains NamedTypeSymbols for types that are declared in
|
|
4
|
+
* containers like namespaces. This scope is a member scope which whose
|
|
5
|
+
* member symbol is a NamedTypeSymbol.
|
|
6
|
+
*/
|
|
7
|
+
export class CSharpNamedTypeScope extends CSharpScope {
|
|
8
|
+
static declarationSpaces = [];
|
|
9
|
+
constructor(ownerSymbol, parentScope, options = {}) {
|
|
10
|
+
super(`${ownerSymbol.name} scope`, parentScope, {
|
|
11
|
+
ownerSymbol,
|
|
12
|
+
...options
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
get ownerSymbol() {
|
|
16
|
+
return super.ownerSymbol;
|
|
17
|
+
}
|
|
18
|
+
get enclosingNamespace() {
|
|
19
|
+
return this.ownerSymbol.enclosingNamespace;
|
|
20
|
+
}
|
|
21
|
+
get members() {
|
|
22
|
+
return this.ownerSymbol.members;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* For now, we stuff type parameters into the member scope. This is to ensure
|
|
27
|
+
* name conflicts are handled correctly.
|
|
28
|
+
*/
|
|
29
|
+
get typeParameters() {
|
|
30
|
+
return this.ownerSymbol.members;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NamespaceSymbol } from "../symbols/namespace.js";
|
|
2
|
+
import { CSharpNamedTypeScope } from "./named-type.js";
|
|
3
|
+
import { CSharpSourceFileScope } from "./source-file.js";
|
|
4
|
+
export declare class CSharpNamespaceScope extends CSharpNamedTypeScope {
|
|
5
|
+
constructor(namespaceSymbol: NamespaceSymbol, parentScope?: CSharpNamespaceScope | CSharpSourceFileScope);
|
|
6
|
+
get ownerSymbol(): NamespaceSymbol;
|
|
7
|
+
}
|
|
8
|
+
export declare function createCSharpNamespaceScope(namespaceSymbol: NamespaceSymbol): CSharpNamespaceScope;
|
|
9
|
+
export declare function useEnclosingNamespaceScope(): CSharpNamespaceScope | undefined;
|
|
10
|
+
export declare function useNamespace(): CSharpNamespaceScope;
|
|
11
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/scopes/namespace.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,qBAAa,oBAAqB,SAAQ,oBAAoB;gBAE1D,eAAe,EAAE,eAAe,EAChC,WAAW,CAAC,EAAE,oBAAoB,GAAG,qBAAqB;IAO5D,IAAI,WAAW,IACe,eAAe,CAC5C;CACF;AAED,wBAAgB,0BAA0B,CAAC,eAAe,EAAE,eAAe,wBAiB1E;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,GAAG,SAAS,CAO7E;AAED,wBAAgB,YAAY,yBAU3B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useScope } from "@alloy-js/core";
|
|
2
|
+
import { CSharpNamedTypeScope } from "./named-type.js";
|
|
3
|
+
import { CSharpSourceFileScope } from "./source-file.js";
|
|
4
|
+
export class CSharpNamespaceScope extends CSharpNamedTypeScope {
|
|
5
|
+
constructor(namespaceSymbol, parentScope) {
|
|
6
|
+
super(namespaceSymbol, parentScope, {
|
|
7
|
+
binder: namespaceSymbol.binder
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
get ownerSymbol() {
|
|
11
|
+
return super.ownerSymbol;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function createCSharpNamespaceScope(namespaceSymbol) {
|
|
15
|
+
const parentScope = useScope();
|
|
16
|
+
if (parentScope && !(parentScope instanceof CSharpNamespaceScope || parentScope instanceof CSharpSourceFileScope)) {
|
|
17
|
+
throw new Error("Namespaces can only be created within a namespace or source file");
|
|
18
|
+
}
|
|
19
|
+
const scope = new CSharpNamespaceScope(namespaceSymbol, parentScope);
|
|
20
|
+
return scope;
|
|
21
|
+
}
|
|
22
|
+
export function useEnclosingNamespaceScope() {
|
|
23
|
+
const currentScope = useScope();
|
|
24
|
+
if (!(currentScope instanceof CSharpNamespaceScope)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return currentScope;
|
|
28
|
+
}
|
|
29
|
+
export function useNamespace() {
|
|
30
|
+
let scope = useScope();
|
|
31
|
+
while (scope) {
|
|
32
|
+
if (scope instanceof CSharpNamespaceScope) {
|
|
33
|
+
return scope;
|
|
34
|
+
}
|
|
35
|
+
scope = scope.parent;
|
|
36
|
+
}
|
|
37
|
+
throw new Error("A namespace is not in scope");
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OutputScopeOptions } from "@alloy-js/core";
|
|
2
|
+
import { NamespaceSymbol } from "../symbols/namespace.js";
|
|
3
|
+
import { CSharpLexicalScope } from "./lexical.js";
|
|
4
|
+
import { CSharpNamespaceScope } from "./namespace.js";
|
|
5
|
+
export declare class CSharpSourceFileScope extends CSharpLexicalScope {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(name: string, parent?: CSharpNamespaceScope, options?: OutputScopeOptions);
|
|
8
|
+
get usings(): import("@vue/reactivity").ShallowReactive<Set<NamespaceSymbol>>;
|
|
9
|
+
get parent(): CSharpNamespaceScope;
|
|
10
|
+
set parent(v: CSharpNamespaceScope);
|
|
11
|
+
addUsing(using: NamespaceSymbol): void;
|
|
12
|
+
get hasBlockNamespace(): boolean;
|
|
13
|
+
set hasBlockNamespace(value: boolean);
|
|
14
|
+
}
|
|
15
|
+
export declare function useSourceFileScope(): CSharpSourceFileScope | undefined;
|
|
16
|
+
//# sourceMappingURL=source-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/scopes/source-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAOnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,qBAAa,qBAAsB,SAAQ,kBAAkB;;gBAIzD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,oBAAoB,EAC7B,OAAO,CAAC,EAAE,kBAAkB;IAI9B,IAAI,MAAM,oEAET;IAED,IAAI,MAAM,IAII,oBAAoB,CAFjC;IAED,IAAI,MAAM,CAAC,CAAC,EAAE,oBAAoB,EAEjC;IAED,QAAQ,CAAC,KAAK,EAAE,eAAe;IAK/B,IAAI,iBAAiB,IAKQ,OAAO,CAFnC;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAOnC;CACF;AAED,wBAAgB,kBAAkB,sCAUjC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { shallowReactive, track, TrackOpTypes, trigger, TriggerOpTypes, useScope } from "@alloy-js/core";
|
|
2
|
+
import { CSharpLexicalScope } from "./lexical.js";
|
|
3
|
+
export class CSharpSourceFileScope extends CSharpLexicalScope {
|
|
4
|
+
#usings = shallowReactive(new Set());
|
|
5
|
+
constructor(name, parent, options) {
|
|
6
|
+
super(name, parent, options);
|
|
7
|
+
}
|
|
8
|
+
get usings() {
|
|
9
|
+
return this.#usings;
|
|
10
|
+
}
|
|
11
|
+
get parent() {
|
|
12
|
+
return super.parent;
|
|
13
|
+
}
|
|
14
|
+
set parent(v) {
|
|
15
|
+
super.parent = v;
|
|
16
|
+
}
|
|
17
|
+
addUsing(using) {
|
|
18
|
+
this.#usings.add(using);
|
|
19
|
+
}
|
|
20
|
+
#hasBlockNamespace = false;
|
|
21
|
+
get hasBlockNamespace() {
|
|
22
|
+
track(this, TrackOpTypes.GET, "hasBlockNamespace");
|
|
23
|
+
return this.#hasBlockNamespace;
|
|
24
|
+
}
|
|
25
|
+
set hasBlockNamespace(value) {
|
|
26
|
+
const old = this.#hasBlockNamespace;
|
|
27
|
+
if (this.#hasBlockNamespace === value) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.#hasBlockNamespace = value;
|
|
31
|
+
trigger(this, TriggerOpTypes.SET, "hasBlockNamespace", value, old);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function useSourceFileScope() {
|
|
35
|
+
let scope = useScope();
|
|
36
|
+
while (scope) {
|
|
37
|
+
if (scope instanceof CSharpSourceFileScope) {
|
|
38
|
+
return scope;
|
|
39
|
+
}
|
|
40
|
+
scope = scope.parent;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Namekey, OutputSpace, OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
|
|
2
|
+
import { AccessModifiers, NonAccessModifiers } from "../modifiers.js";
|
|
3
|
+
import { NamespaceSymbol } from "./namespace.js";
|
|
4
|
+
export type DeclaredAccessibility = "private" | "protected" | "internal" | "public";
|
|
5
|
+
export interface CSharpSymbolOptions extends OutputSymbolOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The accessibility of the symbol.
|
|
8
|
+
*/
|
|
9
|
+
accessibility?: DeclaredAccessibility;
|
|
10
|
+
isOverride?: boolean;
|
|
11
|
+
isAbstract?: boolean;
|
|
12
|
+
isVirtual?: boolean;
|
|
13
|
+
isStatic?: boolean;
|
|
14
|
+
isSealed?: boolean;
|
|
15
|
+
isExtern?: boolean;
|
|
16
|
+
isReadOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type CSharpSymbolKinds = "symbol" | "named-type" | "method" | "field" | "property" | "namespace" | "event";
|
|
19
|
+
/**
|
|
20
|
+
* This is the base type for all symbols in C#.
|
|
21
|
+
*
|
|
22
|
+
* Many subtypes of this symbol exist for specific purposes. However, this symbol
|
|
23
|
+
* may be used in cases where a more specific symbol is not required.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
*
|
|
27
|
+
* This is roughly equivalent to the Roslyn ISymbol interface:
|
|
28
|
+
* https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.isymbol?view=roslyn-dotnet-4.13.0
|
|
29
|
+
*/
|
|
30
|
+
export declare class CSharpSymbol extends OutputSymbol {
|
|
31
|
+
#private;
|
|
32
|
+
readonly symbolKind: CSharpSymbolKinds;
|
|
33
|
+
constructor(name: string | Namekey, spaces: OutputSpace[] | OutputSpace | undefined, options?: CSharpSymbolOptions);
|
|
34
|
+
get enclosingNamespace(): NamespaceSymbol | undefined;
|
|
35
|
+
get accessibility(): DeclaredAccessibility | undefined;
|
|
36
|
+
set accessibility(value: DeclaredAccessibility | undefined);
|
|
37
|
+
copy(): CSharpSymbol;
|
|
38
|
+
/**
|
|
39
|
+
* Whether this symbol is static.
|
|
40
|
+
*/
|
|
41
|
+
get isStatic(): boolean;
|
|
42
|
+
set isStatic(value: boolean);
|
|
43
|
+
/**
|
|
44
|
+
* Whether this symbol is virtual.
|
|
45
|
+
*/
|
|
46
|
+
get isVirtual(): boolean;
|
|
47
|
+
set isVirtual(value: boolean);
|
|
48
|
+
/**
|
|
49
|
+
* Whether this symbol is abstract.
|
|
50
|
+
*/
|
|
51
|
+
get isAbstract(): boolean;
|
|
52
|
+
set isAbstract(value: boolean);
|
|
53
|
+
/**
|
|
54
|
+
* Whether this symbol is override.
|
|
55
|
+
*/
|
|
56
|
+
get isOverride(): boolean;
|
|
57
|
+
set isOverride(value: boolean);
|
|
58
|
+
/**
|
|
59
|
+
* Whether this symbol is sealed.
|
|
60
|
+
*/
|
|
61
|
+
get isSealed(): boolean;
|
|
62
|
+
set isSealed(value: boolean);
|
|
63
|
+
/**
|
|
64
|
+
* Whether this symbol is extern.
|
|
65
|
+
*/
|
|
66
|
+
get isExtern(): boolean;
|
|
67
|
+
set isExtern(value: boolean);
|
|
68
|
+
/**
|
|
69
|
+
* Whether this symbol is readonly.
|
|
70
|
+
*/
|
|
71
|
+
get isReadOnly(): boolean;
|
|
72
|
+
set isReadOnly(value: boolean);
|
|
73
|
+
}
|
|
74
|
+
export declare function accessibilityFromProps(props: AccessModifiers): "public" | "protected" | "private" | "internal";
|
|
75
|
+
export declare function nonAccessibilityFromProps(props: NonAccessModifiers): CSharpSymbolOptions;
|
|
76
|
+
//# sourceMappingURL=csharp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csharp.d.ts","sourceRoot":"","sources":["../../../src/symbols/csharp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAGP,WAAW,EACX,YAAY,EACZ,mBAAmB,EAMpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,MAAM,qBAAqB,GAC7B,SAAS,GACT,WAAW,GACX,UAAU,GACV,QAAQ,CAAC;AAEb,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D;;OAEG;IACH,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,UAAU,GACV,WAAW,GACX,OAAO,CAAC;AACZ;;;;;;;;;;GAUG;AACH,qBAAa,YAAa,SAAQ,YAAY;;IAC5C,SAAgB,UAAU,EAAE,iBAAiB,CAAY;gBAGvD,IAAI,EAAE,MAAM,GAAG,OAAO,EACtB,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,EAC/C,OAAO,GAAE,mBAAwB;IAcnC,IAAI,kBAAkB,IAAI,eAAe,GAAG,SAAS,CA4BpD;IAGD,IAAI,aAAa,IAKQ,qBAAqB,GAAG,SAAS,CAFzD;IAED,IAAI,aAAa,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,EASzD;IAED,IAAI;IAyBJ;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAGtB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAS1B;IAGD;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAGvB;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAS3B;IAID;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAGxB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,EAS5B;IAGD;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAGxB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,EAS5B;IAGD;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAGtB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAS1B;IAGD;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAGtB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,EAS1B;IAGD;;OAEG;IACH,IAAI,UAAU,IAAI,OAAO,CAGxB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,EAS5B;CAEF;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,eAAe,mDAQ5D;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,kBAAkB,GACxB,mBAAmB,CAUrB"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { OutputDeclarationSpace, OutputMemberSpace, OutputSymbol, track, TrackOpTypes, trigger, TriggerOpTypes, watch } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* This is the base type for all symbols in C#.
|
|
4
|
+
*
|
|
5
|
+
* Many subtypes of this symbol exist for specific purposes. However, this symbol
|
|
6
|
+
* may be used in cases where a more specific symbol is not required.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
*
|
|
10
|
+
* This is roughly equivalent to the Roslyn ISymbol interface:
|
|
11
|
+
* https://learn.microsoft.com/en-us/dotnet/api/microsoft.codeanalysis.isymbol?view=roslyn-dotnet-4.13.0
|
|
12
|
+
*/
|
|
13
|
+
export class CSharpSymbol extends OutputSymbol {
|
|
14
|
+
symbolKind = "symbol";
|
|
15
|
+
constructor(name, spaces, options = {}) {
|
|
16
|
+
super(name, spaces, options);
|
|
17
|
+
this.#accessibility = options.accessibility;
|
|
18
|
+
this.#isAbstract = options.isAbstract ?? false;
|
|
19
|
+
this.#isVirtual = options.isVirtual ?? false;
|
|
20
|
+
this.#isStatic = options.isStatic ?? false;
|
|
21
|
+
this.#isOverride = options.isOverride ?? false;
|
|
22
|
+
this.#isSealed = options.isSealed ?? false;
|
|
23
|
+
this.#isExtern = options.isExtern ?? false;
|
|
24
|
+
this.#isReadOnly = options.isReadOnly ?? false;
|
|
25
|
+
}
|
|
26
|
+
get enclosingNamespace() {
|
|
27
|
+
if (this.spaces.length === 0) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// todo: probably need to validate that a symbol can't belong to spaces in
|
|
32
|
+
// multiple namespaces.
|
|
33
|
+
const firstSpace = this.spaces[0];
|
|
34
|
+
if (firstSpace instanceof OutputMemberSpace) {
|
|
35
|
+
// this symbol is a member of something, so get the enclosing namespace from
|
|
36
|
+
// the symbol.
|
|
37
|
+
|
|
38
|
+
if (firstSpace.symbol.constructor.name === "NamespaceSymbol") {
|
|
39
|
+
// this is a namespace symbol, so return the namespace symbol itself.
|
|
40
|
+
// can't use instanceof here due to circular reference issues.
|
|
41
|
+
return firstSpace.symbol;
|
|
42
|
+
}
|
|
43
|
+
return firstSpace.symbol.enclosingNamespace;
|
|
44
|
+
} else if (firstSpace instanceof OutputDeclarationSpace) {
|
|
45
|
+
// this symbol is in a lexical scope, so get the namespace symbol from the
|
|
46
|
+
// scope.
|
|
47
|
+
return firstSpace.scope.enclosingNamespace;
|
|
48
|
+
}
|
|
49
|
+
throw new Error("No place to get namespace symbol from");
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
#accessibility;
|
|
53
|
+
get accessibility() {
|
|
54
|
+
track(this, TrackOpTypes.GET, "accessibility");
|
|
55
|
+
return this.#accessibility;
|
|
56
|
+
}
|
|
57
|
+
set accessibility(value) {
|
|
58
|
+
const old = this.#accessibility;
|
|
59
|
+
if (old === value) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.#accessibility = value;
|
|
63
|
+
trigger(this, TriggerOpTypes.SET, "accessibility", value, old);
|
|
64
|
+
}
|
|
65
|
+
copy() {
|
|
66
|
+
const options = this.getCopyOptions();
|
|
67
|
+
const copy = new CSharpSymbol(this.name, undefined, {
|
|
68
|
+
...options,
|
|
69
|
+
accessibility: this.#accessibility,
|
|
70
|
+
isStatic: this.#isStatic,
|
|
71
|
+
isVirtual: this.#isVirtual,
|
|
72
|
+
isAbstract: this.#isAbstract,
|
|
73
|
+
isOverride: this.#isOverride,
|
|
74
|
+
isSealed: this.#isSealed,
|
|
75
|
+
isExtern: this.#isExtern,
|
|
76
|
+
isReadOnly: this.#isReadOnly
|
|
77
|
+
});
|
|
78
|
+
this.initializeCopy(copy);
|
|
79
|
+
watch(() => this.accessibility, newAccessibility => {
|
|
80
|
+
copy.accessibility = newAccessibility;
|
|
81
|
+
});
|
|
82
|
+
return copy;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Whether this symbol is static.
|
|
87
|
+
*/
|
|
88
|
+
get isStatic() {
|
|
89
|
+
track(this, TrackOpTypes.GET, "isStatic");
|
|
90
|
+
return this.#isStatic;
|
|
91
|
+
}
|
|
92
|
+
set isStatic(value) {
|
|
93
|
+
const old = this.#isStatic;
|
|
94
|
+
if (old === value) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.#isStatic = value;
|
|
98
|
+
trigger(this, TriggerOpTypes.SET, "isStatic", value, old);
|
|
99
|
+
}
|
|
100
|
+
#isStatic = false;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Whether this symbol is virtual.
|
|
104
|
+
*/
|
|
105
|
+
get isVirtual() {
|
|
106
|
+
track(this, TrackOpTypes.GET, "isVirtual");
|
|
107
|
+
return this.#isVirtual;
|
|
108
|
+
}
|
|
109
|
+
set isVirtual(value) {
|
|
110
|
+
const old = this.#isVirtual;
|
|
111
|
+
if (old === value) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.#isVirtual = value;
|
|
115
|
+
trigger(this, TriggerOpTypes.SET, "isVirtual", value, old);
|
|
116
|
+
}
|
|
117
|
+
#isVirtual = false;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Whether this symbol is abstract.
|
|
121
|
+
*/
|
|
122
|
+
get isAbstract() {
|
|
123
|
+
track(this, TrackOpTypes.GET, "isAbstract");
|
|
124
|
+
return this.#isAbstract;
|
|
125
|
+
}
|
|
126
|
+
set isAbstract(value) {
|
|
127
|
+
const old = this.#isAbstract;
|
|
128
|
+
if (old === value) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.#isAbstract = value;
|
|
132
|
+
trigger(this, TriggerOpTypes.SET, "isAbstract", value, old);
|
|
133
|
+
}
|
|
134
|
+
#isAbstract = false;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Whether this symbol is override.
|
|
138
|
+
*/
|
|
139
|
+
get isOverride() {
|
|
140
|
+
track(this, TrackOpTypes.GET, "isOverride");
|
|
141
|
+
return this.#isOverride;
|
|
142
|
+
}
|
|
143
|
+
set isOverride(value) {
|
|
144
|
+
const old = this.#isOverride;
|
|
145
|
+
if (old === value) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.#isOverride = value;
|
|
149
|
+
trigger(this, TriggerOpTypes.SET, "isOverride", value, old);
|
|
150
|
+
}
|
|
151
|
+
#isOverride = false;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Whether this symbol is sealed.
|
|
155
|
+
*/
|
|
156
|
+
get isSealed() {
|
|
157
|
+
track(this, TrackOpTypes.GET, "isSealed");
|
|
158
|
+
return this.#isSealed;
|
|
159
|
+
}
|
|
160
|
+
set isSealed(value) {
|
|
161
|
+
const old = this.#isSealed;
|
|
162
|
+
if (old === value) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this.#isSealed = value;
|
|
166
|
+
trigger(this, TriggerOpTypes.SET, "isSealed", value, old);
|
|
167
|
+
}
|
|
168
|
+
#isSealed = false;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Whether this symbol is extern.
|
|
172
|
+
*/
|
|
173
|
+
get isExtern() {
|
|
174
|
+
track(this, TrackOpTypes.GET, "isExtern");
|
|
175
|
+
return this.#isExtern;
|
|
176
|
+
}
|
|
177
|
+
set isExtern(value) {
|
|
178
|
+
const old = this.#isExtern;
|
|
179
|
+
if (old === value) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.#isExtern = value;
|
|
183
|
+
trigger(this, TriggerOpTypes.SET, "isExtern", value, old);
|
|
184
|
+
}
|
|
185
|
+
#isExtern = false;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Whether this symbol is readonly.
|
|
189
|
+
*/
|
|
190
|
+
get isReadOnly() {
|
|
191
|
+
track(this, TrackOpTypes.GET, "isReadOnly");
|
|
192
|
+
return this.#isReadOnly;
|
|
193
|
+
}
|
|
194
|
+
set isReadOnly(value) {
|
|
195
|
+
const old = this.#isReadOnly;
|
|
196
|
+
if (old === value) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.#isReadOnly = value;
|
|
200
|
+
trigger(this, TriggerOpTypes.SET, "isReadOnly", value, old);
|
|
201
|
+
}
|
|
202
|
+
#isReadOnly = false;
|
|
203
|
+
}
|
|
204
|
+
export function accessibilityFromProps(props) {
|
|
205
|
+
for (const key of ["public", "internal", "protected", "private"]) {
|
|
206
|
+
if (props[key]) {
|
|
207
|
+
return key;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return "private";
|
|
211
|
+
}
|
|
212
|
+
export function nonAccessibilityFromProps(props) {
|
|
213
|
+
return {
|
|
214
|
+
isOverride: props.override ?? false,
|
|
215
|
+
isAbstract: props.abstract ?? false,
|
|
216
|
+
isVirtual: props.virtual ?? false,
|
|
217
|
+
isStatic: props.static ?? false,
|
|
218
|
+
isSealed: props.sealed ?? false,
|
|
219
|
+
isExtern: props.extern ?? false,
|
|
220
|
+
isReadOnly: props.readOnly ?? false
|
|
221
|
+
};
|
|
222
|
+
}
|