@alloy-js/csharp 0.20.0-dev.3 → 0.20.0-dev.5
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 +5 -14
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/Name.js +2 -1
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/ProjectDirectory.js +2 -1
- package/dist/src/components/ProjectDirectory.js.map +1 -0
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +7 -2
- package/dist/src/components/Reference.js.map +1 -0
- 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 +71 -46
- package/dist/src/components/SourceFile.js.map +1 -0
- 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 +5 -2
- package/dist/src/components/UsingDirective.js.map +1 -0
- package/dist/src/components/attributes/attributes.js +2 -1
- package/dist/src/components/attributes/attributes.js.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +2 -1
- package/dist/src/components/attributes/attributes.test.js.map +1 -0
- 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 +20 -33
- package/dist/src/components/class/declaration.js.map +1 -0
- package/dist/src/components/class/declaration.test.js +173 -194
- package/dist/src/components/class/declaration.test.js.map +1 -0
- package/dist/src/components/constructor/constructor.d.ts.map +1 -1
- package/dist/src/components/constructor/constructor.js +13 -17
- package/dist/src/components/constructor/constructor.js.map +1 -0
- package/dist/src/components/constructor/constructor.test.js +12 -20
- package/dist/src/components/constructor/constructor.test.js.map +1 -0
- package/dist/src/components/doc/comment.js +2 -1
- package/dist/src/components/doc/comment.js.map +1 -0
- package/dist/src/components/doc/comment.test.js +2 -1
- package/dist/src/components/doc/comment.test.js.map +1 -0
- package/dist/src/components/doc/from-markdown.js +2 -1
- package/dist/src/components/doc/from-markdown.js.map +1 -0
- package/dist/src/components/doc/from-markdown.test.js +2 -1
- package/dist/src/components/doc/from-markdown.test.js.map +1 -0
- 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 +55 -0
- package/dist/src/components/enum/declaration.js.map +1 -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 +121 -0
- package/dist/src/components/enum/declaration.ref.test.js.map +1 -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 +40 -0
- package/dist/src/components/enum/declaration.test.js.map +1 -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 +30 -0
- package/dist/src/components/enum/member.js.map +1 -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 +29 -0
- package/dist/src/components/enum/member.test.js.map +1 -0
- package/dist/src/components/field/field.d.ts.map +1 -1
- package/dist/src/components/field/field.js +11 -15
- package/dist/src/components/field/field.js.map +1 -0
- package/dist/src/components/field/field.test.js +9 -8
- package/dist/src/components/field/field.test.js.map +1 -0
- 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 +7 -3
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +21 -22
- package/dist/src/components/interface/declaration.js.map +1 -0
- package/dist/src/components/interface/declaration.test.js +28 -36
- package/dist/src/components/interface/declaration.test.js.map +1 -0
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +9 -16
- package/dist/src/components/interface/method.js.map +1 -0
- package/dist/src/components/interface/method.test.js +40 -48
- package/dist/src/components/interface/method.test.js.map +1 -0
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +23 -37
- package/dist/src/components/interface/property.js.map +1 -0
- package/dist/src/components/interface/property.test.js +13 -12
- package/dist/src/components/interface/property.test.js.map +1 -0
- 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 +25 -0
- package/dist/src/components/lexical-scope.js.map +1 -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 +9 -14
- package/dist/src/components/method/method.js.map +1 -0
- package/dist/src/components/method/method.test.js +13 -12
- package/dist/src/components/method/method.test.js.map +1 -0
- 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 +25 -0
- package/dist/src/components/method-scope.js.map +1 -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 +45 -0
- package/dist/src/components/namespace-scopes.js.map +1 -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 +47 -0
- package/dist/src/components/namespace.js.map +1 -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 +182 -0
- package/dist/src/components/namespace.ref.test.js.map +1 -0
- package/dist/src/components/namespace.test.d.ts.map +1 -0
- package/dist/src/components/namespace.test.js +79 -0
- package/dist/src/components/namespace.test.js.map +1 -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 +14 -12
- package/dist/src/components/parameters/parameters.js.map +1 -0
- 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 +88 -0
- package/dist/src/components/parameters/parameters.test.js.map +1 -0
- package/dist/src/components/property/property.d.ts.map +1 -1
- package/dist/src/components/property/property.js +23 -37
- package/dist/src/components/property/property.js.map +1 -0
- package/dist/src/components/property/property.test.js +16 -15
- package/dist/src/components/property/property.test.js.map +1 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -1
- package/dist/src/components/record/declaration.js +10 -13
- package/dist/src/components/record/declaration.js.map +1 -0
- package/dist/src/components/record/declaration.test.js +8 -14
- package/dist/src/components/record/declaration.test.js.map +1 -0
- package/dist/src/components/stc/index.js +2 -1
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/components/struct/declaration.d.ts.map +1 -1
- package/dist/src/components/struct/declaration.js +6 -7
- package/dist/src/components/struct/declaration.js.map +1 -0
- package/dist/src/components/struct/declaration.test.js +32 -40
- package/dist/src/components/struct/declaration.test.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.js +2 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +2 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -1
- package/dist/src/components/type-parameters/type-parameter.js +9 -11
- package/dist/src/components/type-parameters/type-parameter.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.js +2 -1
- package/dist/src/components/type-parameters/type-parameters.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.test.js +5 -4
- package/dist/src/components/type-parameters/type-parameters.test.js.map +1 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -1
- package/dist/src/components/var/declaration.js +8 -9
- package/dist/src/components/var/declaration.js.map +1 -0
- package/dist/src/components/var/declaration.test.js +13 -21
- package/dist/src/components/var/declaration.test.js.map +1 -0
- 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 +25 -0
- package/dist/src/contexts/global-namespace.js.map +1 -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 +6 -0
- package/dist/src/contexts/namespace.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/modifiers.d.ts +11 -0
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +2 -1
- package/dist/src/modifiers.js.map +1 -0
- package/dist/src/name-policy.js +2 -1
- package/dist/src/name-policy.js.map +1 -0
- 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 +11 -0
- package/dist/src/scopes/class.js.map +1 -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 +34 -0
- package/dist/src/scopes/contexts.js.map +1 -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 +12 -0
- package/dist/src/scopes/csharp.js.map +1 -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 +24 -0
- package/dist/src/scopes/factories.js.map +1 -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 +10 -0
- package/dist/src/scopes/index.js.map +1 -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 +8 -0
- package/dist/src/scopes/lexical.js.map +1 -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 +14 -0
- package/dist/src/scopes/method.js.map +1 -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 +33 -0
- package/dist/src/scopes/named-type.js.map +1 -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 +39 -0
- package/dist/src/scopes/namespace.js.map +1 -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 +44 -0
- package/dist/src/scopes/source-file.js.map +1 -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 +223 -0
- package/dist/src/symbols/csharp.js.map +1 -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 +87 -0
- package/dist/src/symbols/factories.js.map +1 -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 -2
- package/dist/src/symbols/index.js.map +1 -0
- 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 +16 -0
- package/dist/src/symbols/method.js.map +1 -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 +31 -0
- package/dist/src/symbols/named-type.js.map +1 -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 +45 -0
- package/dist/src/symbols/namespace.js.map +1 -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 +38 -44
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/test/project-directory.test.js +14 -17
- package/dist/test/project-directory.test.js.map +1 -0
- package/dist/test/sourcefile.test.js +8 -19
- package/dist/test/sourcefile.test.js.map +1 -0
- package/dist/test/using.test.js +20 -17
- package/dist/test/using.test.js.map +1 -0
- package/dist/test/utils.js +4 -3
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -3
- 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/tsconfig.json +4 -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
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
|
-
import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
|
|
3
2
|
|
|
4
3
|
// properties for creating a declaration
|
|
5
4
|
export interface DeclarationProps {
|
|
6
5
|
name: string;
|
|
7
|
-
refkey?: core.Refkey;
|
|
6
|
+
refkey?: core.Refkey | core.Refkey[];
|
|
8
7
|
children?: core.Children;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
// declares a symbol in the program (class, enum, interface etc)
|
|
12
11
|
export function Declaration(props: DeclarationProps) {
|
|
13
|
-
|
|
14
|
-
refkeys: props.refkey,
|
|
15
|
-
});
|
|
12
|
+
throw new Error("Not supported");
|
|
16
13
|
|
|
17
|
-
return <core.Declaration symbol={sym}>{props.children}</core.Declaration>;
|
|
14
|
+
//return <core.Declaration symbol={sym}>{props.children}</core.Declaration>;
|
|
18
15
|
}
|
|
@@ -8,6 +8,8 @@ export interface ReferenceProps {
|
|
|
8
8
|
// used to resolve refkey references within source files
|
|
9
9
|
export function Reference({ refkey }: ReferenceProps) {
|
|
10
10
|
const reference = ref(refkey);
|
|
11
|
+
const symbolRef = core.computed(() => reference()[1]);
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
core.emitSymbol(symbolRef);
|
|
14
|
+
return <>{reference()[0]}</>;
|
|
13
15
|
}
|
|
@@ -1,78 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
computed,
|
|
4
|
+
SourceFile as CoreSourceFile,
|
|
5
|
+
Scope,
|
|
6
|
+
Show,
|
|
7
|
+
useBinder,
|
|
8
|
+
} from "@alloy-js/core";
|
|
9
|
+
import { getGlobalNamespace } from "../contexts/global-namespace.js";
|
|
10
|
+
import { useNamespaceContext } from "../contexts/namespace.js";
|
|
11
|
+
import { CSharpSourceFileScope } from "../scopes/source-file.js";
|
|
12
|
+
import { NamespaceSymbol } from "../symbols/namespace.js";
|
|
13
|
+
import { NamespaceScope, NamespaceScopes } from "./namespace-scopes.jsx";
|
|
3
14
|
import { Reference } from "./Reference.jsx";
|
|
4
15
|
import { UsingDirective } from "./UsingDirective.jsx";
|
|
5
16
|
|
|
6
|
-
// contains the info for the current source file
|
|
7
|
-
export interface SourceFileContext {
|
|
8
|
-
// adds a namespace to the array of using statements
|
|
9
|
-
addUsing(namespace: string): void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const SourceFileContext = core.createContext<SourceFileContext>();
|
|
13
|
-
|
|
14
|
-
// returns the current source file
|
|
15
|
-
export function useSourceFile(): SourceFileContext | undefined {
|
|
16
|
-
return core.useContext(SourceFileContext) as SourceFileContext;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
17
|
export interface SourceFileProps {
|
|
20
18
|
/** Path of the source file */
|
|
21
19
|
path: string;
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
using?: Array<string>;
|
|
21
|
+
children?: Children;
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
/**
|
|
24
|
+
* A list of using directives to explicitly include. Note that providing
|
|
25
|
+
* explicit usings is not necessary when referencing symbols via refkeys.
|
|
26
|
+
*/
|
|
27
|
+
using?: string[];
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// a C# source file. exists within the context of a namespace
|
|
30
31
|
// contains using statements and declarations
|
|
31
32
|
export function SourceFile(props: SourceFileProps) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
if (!namespaceCtx) {
|
|
35
|
-
throw new Error("SourceFile must be declared inside a namespace");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const using: Array<string> = core.reactive(new Array<string>());
|
|
39
|
-
if (props.using) {
|
|
40
|
-
using.push(...props.using);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// adds the specified namespace to the array of using statements.
|
|
44
|
-
// called via SourceFileContext.addUsing when resolving refkeys.
|
|
45
|
-
function addUsing(namespace: string): void {
|
|
46
|
-
if (!using.includes(namespace)) {
|
|
47
|
-
using.push(namespace);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const sourceFileCtx: SourceFileContext = {
|
|
52
|
-
addUsing,
|
|
53
|
-
};
|
|
33
|
+
const sourceFileScope = new CSharpSourceFileScope(props.path);
|
|
54
34
|
|
|
35
|
+
const nsContext = useNamespaceContext();
|
|
36
|
+
const globalNs = getGlobalNamespace(useBinder());
|
|
37
|
+
const nsSymbol = nsContext ? nsContext.symbol : globalNs;
|
|
38
|
+
const nsRef = nsContext ? nsContext.symbol.name : undefined;
|
|
39
|
+
const usings = computed(() => {
|
|
40
|
+
return (
|
|
41
|
+
Array.from(sourceFileScope.usings) as (NamespaceSymbol | string)[]
|
|
42
|
+
).concat(props.using ?? []);
|
|
43
|
+
});
|
|
55
44
|
return (
|
|
56
|
-
<
|
|
45
|
+
<CoreSourceFile
|
|
57
46
|
path={props.path}
|
|
58
47
|
filetype="cs"
|
|
59
48
|
reference={Reference}
|
|
60
49
|
tabWidth={4}
|
|
61
50
|
printWidth={120}
|
|
62
51
|
>
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
<Scope value={sourceFileScope}>
|
|
53
|
+
{(sourceFileScope.usings.size > 0 ||
|
|
54
|
+
(props.using && props.using.length > 0)) && (
|
|
55
|
+
<>
|
|
56
|
+
<UsingDirective namespaces={usings.value} />
|
|
57
|
+
<hbr />
|
|
58
|
+
<hbr />
|
|
59
|
+
</>
|
|
60
|
+
)}
|
|
61
|
+
<Show when={!!nsContext && nsSymbol !== globalNs}>
|
|
62
|
+
<Show when={sourceFileScope.hasBlockNamespace}>
|
|
63
|
+
namespace {nsRef}
|
|
64
|
+
{" {"}
|
|
65
|
+
<hbr />
|
|
66
|
+
{" "}
|
|
67
|
+
</Show>
|
|
68
|
+
|
|
69
|
+
<Show when={!sourceFileScope.hasBlockNamespace}>
|
|
70
|
+
namespace {nsRef};<hbr />
|
|
71
|
+
<hbr />
|
|
72
|
+
</Show>
|
|
73
|
+
<align width={sourceFileScope.hasBlockNamespace ? 4 : 0}>
|
|
74
|
+
<NamespaceScopes symbol={nsContext!.symbol}>
|
|
75
|
+
{props.children}
|
|
76
|
+
</NamespaceScopes>
|
|
77
|
+
</align>
|
|
78
|
+
<Show when={sourceFileScope.hasBlockNamespace}>
|
|
79
|
+
<hbr />
|
|
80
|
+
{"}"}
|
|
81
|
+
</Show>
|
|
82
|
+
</Show>
|
|
83
|
+
<Show when={!nsContext || nsSymbol === globalNs}>
|
|
84
|
+
<NamespaceScope symbol={getGlobalNamespace(useBinder())}>
|
|
85
|
+
{props.children}
|
|
86
|
+
</NamespaceScope>
|
|
87
|
+
</Show>
|
|
88
|
+
</Scope>
|
|
89
|
+
</CoreSourceFile>
|
|
77
90
|
);
|
|
78
91
|
}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
|
+
import { NamespaceSymbol } from "../symbols/namespace.js";
|
|
2
3
|
|
|
3
4
|
export interface UsingDirectiveProps {
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Namespace symbols or namespace names to use to generate using statements.
|
|
7
|
+
*/
|
|
8
|
+
namespaces?: (NamespaceSymbol | string)[];
|
|
5
9
|
}
|
|
6
10
|
|
|
7
11
|
// one ore more C# using directives
|
|
8
12
|
export function UsingDirective(props: UsingDirectiveProps) {
|
|
9
13
|
const sortedNamespaces = core.computed(() => {
|
|
10
|
-
return props
|
|
14
|
+
return props
|
|
15
|
+
.namespaces!.map((ns) =>
|
|
16
|
+
typeof ns === "string" ? ns : (
|
|
17
|
+
ns.getFullyQualifiedName({ omitGlobal: true })
|
|
18
|
+
),
|
|
19
|
+
)
|
|
20
|
+
.sort((n1, n2) => n1.localeCompare(n2));
|
|
11
21
|
});
|
|
12
22
|
|
|
13
23
|
return (
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Constructor } from "#components/constructor/constructor.jsx";
|
|
2
|
+
import { EnumDeclaration } from "#components/enum/declaration.jsx";
|
|
3
|
+
import { EnumMember } from "#components/enum/member.jsx";
|
|
1
4
|
import {
|
|
2
5
|
Children,
|
|
3
6
|
code,
|
|
@@ -15,19 +18,13 @@ import { createCSharpNamePolicy } from "../../name-policy.js";
|
|
|
15
18
|
import { Attribute } from "../attributes/attributes.jsx";
|
|
16
19
|
import { Field } from "../field/field.jsx";
|
|
17
20
|
import { Method } from "../method/method.jsx";
|
|
18
|
-
import { Namespace } from "../Namespace.jsx";
|
|
19
21
|
import { Property } from "../property/property.jsx";
|
|
20
22
|
import { SourceFile } from "../SourceFile.jsx";
|
|
21
|
-
import { Constructor, EnumDeclaration, EnumMember } from "../stc/index.js";
|
|
22
23
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
23
24
|
import { ClassDeclaration } from "./declaration.jsx";
|
|
24
25
|
|
|
25
26
|
function Wrapper({ children }: { children: Children }) {
|
|
26
|
-
return
|
|
27
|
-
<TestNamespace>
|
|
28
|
-
<SourceFile path="Test.cs">{children}</SourceFile>
|
|
29
|
-
</TestNamespace>
|
|
30
|
-
);
|
|
27
|
+
return <TestNamespace>{children}</TestNamespace>;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
30
|
it("declares class with no members", () => {
|
|
@@ -127,45 +124,43 @@ describe("base", () => {
|
|
|
127
124
|
});
|
|
128
125
|
|
|
129
126
|
it("declares class with some members", () => {
|
|
130
|
-
const
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
const tree = (
|
|
128
|
+
<TestNamespace>
|
|
129
|
+
<ClassDeclaration public name="TestClass">
|
|
130
|
+
<List>
|
|
131
|
+
<Field public name="MemberOne" type="string" />
|
|
132
|
+
<Field public name="MemberTwo" type="int" />
|
|
133
|
+
</List>
|
|
134
|
+
</ClassDeclaration>
|
|
135
|
+
</TestNamespace>
|
|
137
136
|
);
|
|
138
137
|
|
|
139
|
-
expect(
|
|
140
|
-
|
|
138
|
+
expect(tree).toRenderTo(coretest.d`
|
|
139
|
+
public class TestClass
|
|
141
140
|
{
|
|
142
|
-
public
|
|
143
|
-
|
|
144
|
-
public string MemberOne;
|
|
145
|
-
public int MemberTwo;
|
|
146
|
-
}
|
|
141
|
+
public string MemberOne;
|
|
142
|
+
public int MemberTwo;
|
|
147
143
|
}
|
|
148
144
|
`);
|
|
149
145
|
});
|
|
150
146
|
|
|
151
147
|
it("declares class with some methods", () => {
|
|
152
|
-
const
|
|
153
|
-
<
|
|
154
|
-
<
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
const tree = (
|
|
149
|
+
<TestNamespace>
|
|
150
|
+
<ClassDeclaration public name="TestClass">
|
|
151
|
+
<List>
|
|
152
|
+
<Method public name="MethodOne" />
|
|
153
|
+
<Method private virtual name="MethodTwo" />
|
|
154
|
+
</List>
|
|
155
|
+
</ClassDeclaration>
|
|
156
|
+
</TestNamespace>
|
|
159
157
|
);
|
|
160
158
|
|
|
161
|
-
expect(
|
|
162
|
-
|
|
159
|
+
expect(tree).toRenderTo(coretest.d`
|
|
160
|
+
public class TestClass
|
|
163
161
|
{
|
|
164
|
-
public
|
|
165
|
-
{
|
|
166
|
-
public void MethodOne() {}
|
|
167
|
-
private virtual void MethodTwo() {}
|
|
168
|
-
}
|
|
162
|
+
public void MethodOne() {}
|
|
163
|
+
private virtual void MethodTwo() {}
|
|
169
164
|
}
|
|
170
165
|
`);
|
|
171
166
|
});
|
|
@@ -188,57 +183,52 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
188
183
|
|
|
189
184
|
const res = render(
|
|
190
185
|
<Output namePolicy={createCSharpNamePolicy()}>
|
|
191
|
-
<
|
|
192
|
-
<
|
|
193
|
-
<
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
<SourceFile path="Test.cs">
|
|
187
|
+
<EnumDeclaration public name="TestEnum" refkey={enumTypeRefkey}>
|
|
188
|
+
<List comma hardline>
|
|
189
|
+
<EnumMember name="One" />
|
|
190
|
+
<EnumMember name="Two" />
|
|
191
|
+
</List>
|
|
192
|
+
</EnumDeclaration>
|
|
193
|
+
<hbr />
|
|
194
|
+
<ClassDeclaration public name="TestInput" refkey={inputTypeRefkey} />
|
|
195
|
+
<hbr />
|
|
196
|
+
<ClassDeclaration
|
|
197
|
+
public
|
|
198
|
+
name="TestResult"
|
|
199
|
+
refkey={testResultTypeRefkey}
|
|
200
|
+
/>
|
|
201
|
+
<hbr />
|
|
202
|
+
<ClassDeclaration public name="TestClass">
|
|
203
|
+
<Field private name="MemberOne" type={enumTypeRefkey} />
|
|
201
204
|
<hbr />
|
|
202
|
-
<
|
|
205
|
+
<Method
|
|
203
206
|
public
|
|
204
|
-
name="
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
public
|
|
213
|
-
name="MethodOne"
|
|
214
|
-
parameters={params}
|
|
215
|
-
returns={testResultTypeRefkey}
|
|
216
|
-
>
|
|
217
|
-
return new {testResultTypeRefkey}();
|
|
218
|
-
</Method>
|
|
219
|
-
</ClassDeclaration>
|
|
220
|
-
</SourceFile>
|
|
221
|
-
</Namespace>
|
|
207
|
+
name="MethodOne"
|
|
208
|
+
parameters={params}
|
|
209
|
+
returns={testResultTypeRefkey}
|
|
210
|
+
>
|
|
211
|
+
return new {testResultTypeRefkey}();
|
|
212
|
+
</Method>
|
|
213
|
+
</ClassDeclaration>
|
|
214
|
+
</SourceFile>
|
|
222
215
|
</Output>,
|
|
223
216
|
);
|
|
224
217
|
|
|
225
218
|
expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
|
|
226
|
-
|
|
219
|
+
public enum TestEnum
|
|
227
220
|
{
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
221
|
+
One,
|
|
222
|
+
Two
|
|
223
|
+
}
|
|
224
|
+
public class TestInput;
|
|
225
|
+
public class TestResult;
|
|
226
|
+
public class TestClass
|
|
227
|
+
{
|
|
228
|
+
private TestEnum _memberOne;
|
|
229
|
+
public TestResult MethodOne(int intParam, TestInput bodyParam)
|
|
236
230
|
{
|
|
237
|
-
|
|
238
|
-
public TestResult MethodOne(int intParam, TestInput bodyParam)
|
|
239
|
-
{
|
|
240
|
-
return new TestResult();
|
|
241
|
-
}
|
|
231
|
+
return new TestResult();
|
|
242
232
|
}
|
|
243
233
|
}
|
|
244
234
|
`);
|
|
@@ -259,27 +249,22 @@ describe("with type parameters", () => {
|
|
|
259
249
|
|
|
260
250
|
expect(
|
|
261
251
|
<TestNamespace>
|
|
262
|
-
<
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
>
|
|
268
|
-
<
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
</ClassDeclaration>
|
|
273
|
-
</SourceFile>
|
|
252
|
+
<ClassDeclaration
|
|
253
|
+
public
|
|
254
|
+
name="TestClass"
|
|
255
|
+
typeParameters={typeParameters}
|
|
256
|
+
>
|
|
257
|
+
<List>
|
|
258
|
+
<Property name="PropA" type={typeParameters[0].refkey} get set />
|
|
259
|
+
<Property name="PropB" type={typeParameters[1].refkey} get set />
|
|
260
|
+
</List>
|
|
261
|
+
</ClassDeclaration>
|
|
274
262
|
</TestNamespace>,
|
|
275
263
|
).toRenderTo(`
|
|
276
|
-
|
|
264
|
+
public class TestClass<T, U>
|
|
277
265
|
{
|
|
278
|
-
|
|
279
|
-
{
|
|
280
|
-
T PropA { get; set; }
|
|
281
|
-
U PropB { get; set; }
|
|
282
|
-
}
|
|
266
|
+
T PropA { get; set; }
|
|
267
|
+
U PropB { get; set; }
|
|
283
268
|
}
|
|
284
269
|
`);
|
|
285
270
|
});
|
|
@@ -308,10 +293,10 @@ describe("with type parameters", () => {
|
|
|
308
293
|
</TestNamespace>,
|
|
309
294
|
).toRenderTo(`
|
|
310
295
|
public class TestClass<T, U>
|
|
311
|
-
|
|
312
|
-
|
|
296
|
+
where T : IFoo
|
|
297
|
+
where U : IBar
|
|
313
298
|
{
|
|
314
|
-
|
|
299
|
+
// Body
|
|
315
300
|
}
|
|
316
301
|
`);
|
|
317
302
|
});
|
|
@@ -326,25 +311,24 @@ it("declares class with invalid members", () => {
|
|
|
326
311
|
);
|
|
327
312
|
|
|
328
313
|
expect(() => toSourceText(decl)).toThrow(
|
|
329
|
-
"
|
|
314
|
+
"EnumMember must be used within an EnumDeclaration.",
|
|
330
315
|
);
|
|
331
316
|
});
|
|
332
317
|
|
|
333
318
|
describe("constructor", () => {
|
|
334
319
|
it("declares with constructor", () => {
|
|
335
|
-
const
|
|
336
|
-
<
|
|
337
|
-
<
|
|
338
|
-
|
|
320
|
+
const tree = (
|
|
321
|
+
<TestNamespace>
|
|
322
|
+
<ClassDeclaration public name="TestClass">
|
|
323
|
+
<Constructor public />
|
|
324
|
+
</ClassDeclaration>
|
|
325
|
+
</TestNamespace>
|
|
339
326
|
);
|
|
340
327
|
|
|
341
|
-
expect(
|
|
342
|
-
|
|
328
|
+
expect(tree).toRenderTo(coretest.d`
|
|
329
|
+
public class TestClass
|
|
343
330
|
{
|
|
344
|
-
public
|
|
345
|
-
{
|
|
346
|
-
public TestClass() {}
|
|
347
|
-
}
|
|
331
|
+
public TestClass() {}
|
|
348
332
|
}
|
|
349
333
|
`);
|
|
350
334
|
});
|
|
@@ -368,33 +352,32 @@ describe("constructor", () => {
|
|
|
368
352
|
},
|
|
369
353
|
];
|
|
370
354
|
|
|
371
|
-
const
|
|
372
|
-
<
|
|
373
|
-
<
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
355
|
+
const tree = (
|
|
356
|
+
<TestNamespace>
|
|
357
|
+
<ClassDeclaration public name="TestClass">
|
|
358
|
+
<Field private name="name" type="string" refkey={thisNameRefkey} />
|
|
359
|
+
<hbr />
|
|
360
|
+
<Field private name="size" type="int" refkey={thisSizeRefkey} />
|
|
361
|
+
<hbr />
|
|
362
|
+
<Constructor public parameters={ctorParams}>
|
|
363
|
+
{thisNameRefkey} = {paramNameRefkey};<hbr />
|
|
364
|
+
{thisSizeRefkey} = {paramSizeRefkey};
|
|
365
|
+
</Constructor>
|
|
366
|
+
</ClassDeclaration>
|
|
367
|
+
</TestNamespace>
|
|
382
368
|
);
|
|
383
369
|
|
|
384
370
|
// TODO: assignments to members should have this. prefix
|
|
385
371
|
// e.g. this.name = name;
|
|
386
|
-
expect(
|
|
387
|
-
|
|
372
|
+
expect(tree).toRenderTo(coretest.d`
|
|
373
|
+
public class TestClass
|
|
388
374
|
{
|
|
389
|
-
|
|
375
|
+
private string _name;
|
|
376
|
+
private int _size;
|
|
377
|
+
public TestClass(string name, int size)
|
|
390
378
|
{
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
public TestClass(string name, int size)
|
|
394
|
-
{
|
|
395
|
-
_name = name;
|
|
396
|
-
_size = size;
|
|
397
|
-
}
|
|
379
|
+
_name = name;
|
|
380
|
+
_size = size;
|
|
398
381
|
}
|
|
399
382
|
}
|
|
400
383
|
`);
|
|
@@ -433,12 +416,9 @@ describe("constructor", () => {
|
|
|
433
416
|
</ClassDeclaration>
|
|
434
417
|
</Wrapper>,
|
|
435
418
|
).toRenderTo(`
|
|
436
|
-
|
|
419
|
+
public class TestClass(string name, int size)
|
|
437
420
|
{
|
|
438
|
-
|
|
439
|
-
{
|
|
440
|
-
string PrettyName { get; } = $"{name} {size}";
|
|
441
|
-
}
|
|
421
|
+
string PrettyName { get; } = $"{name} {size}";
|
|
442
422
|
}
|
|
443
423
|
`);
|
|
444
424
|
});
|
|
@@ -459,12 +439,9 @@ describe("constructor", () => {
|
|
|
459
439
|
</NamePolicyContext.Provider>
|
|
460
440
|
</Wrapper>,
|
|
461
441
|
).toRenderTo(`
|
|
462
|
-
|
|
442
|
+
public class TestClass(string name)
|
|
463
443
|
{
|
|
464
|
-
|
|
465
|
-
{
|
|
466
|
-
string name_2;
|
|
467
|
-
}
|
|
444
|
+
string name_2;
|
|
468
445
|
}
|
|
469
446
|
`);
|
|
470
447
|
});
|
|
@@ -492,8 +469,8 @@ it("supports class member doc comments", () => {
|
|
|
492
469
|
/// This is a test
|
|
493
470
|
class Test
|
|
494
471
|
{
|
|
495
|
-
|
|
496
|
-
|
|
472
|
+
/// This is a member
|
|
473
|
+
public int Member;
|
|
497
474
|
}
|
|
498
475
|
`);
|
|
499
476
|
});
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
DeclarationProps,
|
|
6
6
|
join,
|
|
7
7
|
Name,
|
|
8
|
+
Namekey,
|
|
8
9
|
Refkey,
|
|
9
10
|
Scope,
|
|
10
11
|
} from "@alloy-js/core";
|
|
@@ -14,9 +15,8 @@ import {
|
|
|
14
15
|
getAccessModifier,
|
|
15
16
|
makeModifiers,
|
|
16
17
|
} from "../../modifiers.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { CSharpMemberScope } from "../../symbols/scopes.js";
|
|
18
|
+
import { createClassScope } from "../../scopes/factories.js";
|
|
19
|
+
import { createNamedTypeSymbol } from "../../symbols/factories.js";
|
|
20
20
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
21
21
|
import { DocWhen } from "../doc/comment.jsx";
|
|
22
22
|
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
@@ -43,7 +43,7 @@ export interface ClassDeclarationProps
|
|
|
43
43
|
extends Omit<DeclarationProps, "nameKind">,
|
|
44
44
|
AccessModifiers,
|
|
45
45
|
ClassModifiers {
|
|
46
|
-
name: string;
|
|
46
|
+
name: string | Namekey;
|
|
47
47
|
/** Doc comment */
|
|
48
48
|
doc?: Children;
|
|
49
49
|
refkey?: Refkey;
|
|
@@ -130,19 +130,10 @@ export interface ClassDeclarationProps
|
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
132
|
export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
const thisClassSymbol = new CSharpOutputSymbol(name, {
|
|
133
|
+
const thisClassSymbol = createNamedTypeSymbol(props.name, "class", {
|
|
136
134
|
refkeys: props.refkey,
|
|
137
135
|
});
|
|
138
|
-
|
|
139
|
-
// this creates a new scope for the class definition.
|
|
140
|
-
// members will automatically "inherit" this scope so
|
|
141
|
-
// that refkeys to them will produce the fully-qualified
|
|
142
|
-
// name e.g. Foo.Bar.
|
|
143
|
-
const thisClassScope = new CSharpMemberScope("class-decl", {
|
|
144
|
-
owner: thisClassSymbol,
|
|
145
|
-
});
|
|
136
|
+
const thisClassScope = createClassScope(thisClassSymbol);
|
|
146
137
|
|
|
147
138
|
const bases = [
|
|
148
139
|
...(props.baseType ? [props.baseType] : []),
|
|
@@ -159,24 +150,20 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
|
|
|
159
150
|
<DocWhen doc={props.doc} />
|
|
160
151
|
<AttributeList attributes={props.attributes} endline />
|
|
161
152
|
{modifiers}class <Name />
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
<Scope value={thisClassScope}>
|
|
154
|
+
{props.typeParameters && (
|
|
155
|
+
<TypeParameters parameters={props.typeParameters} />
|
|
156
|
+
)}
|
|
157
|
+
{props.primaryConstructor && (
|
|
167
158
|
<Parameters parameters={props.primaryConstructor} />
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
<Block newline>
|
|
177
|
-
<Scope value={thisClassScope}>{props.children}</Scope>
|
|
178
|
-
</Block>
|
|
179
|
-
)}
|
|
159
|
+
)}
|
|
160
|
+
{base}
|
|
161
|
+
{props.typeParameters && (
|
|
162
|
+
<TypeParameterConstraints parameters={props.typeParameters} />
|
|
163
|
+
)}
|
|
164
|
+
{!props.children && ";"}
|
|
165
|
+
{props.children && <Block newline>{props.children}</Block>}
|
|
166
|
+
</Scope>
|
|
180
167
|
</Declaration>
|
|
181
168
|
);
|
|
182
169
|
}
|