@alloy-js/core 0.20.0-dev.4 → 0.20.0-dev.6

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 (129) hide show
  1. package/dist/src/binder.d.ts +62 -38
  2. package/dist/src/binder.d.ts.map +1 -1
  3. package/dist/src/binder.js +214 -173
  4. package/dist/src/components/Declaration.d.ts +2 -2
  5. package/dist/src/components/Declaration.d.ts.map +1 -1
  6. package/dist/src/components/Declaration.js +8 -2
  7. package/dist/src/components/MemberDeclaration.d.ts +2 -2
  8. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  9. package/dist/src/components/MemberDeclaration.js +9 -5
  10. package/dist/src/components/MemberScope.d.ts +30 -13
  11. package/dist/src/components/MemberScope.d.ts.map +1 -1
  12. package/dist/src/components/MemberScope.js +37 -15
  13. package/dist/src/components/Output.d.ts.map +1 -1
  14. package/dist/src/components/Output.js +2 -5
  15. package/dist/src/components/ReferenceOrContent.d.ts +1 -1
  16. package/dist/src/components/ReferenceOrContent.d.ts.map +1 -1
  17. package/dist/src/components/Scope.d.ts +5 -5
  18. package/dist/src/components/Scope.d.ts.map +1 -1
  19. package/dist/src/components/Scope.js +9 -5
  20. package/dist/src/context/member-scope.d.ts +7 -8
  21. package/dist/src/context/member-scope.d.ts.map +1 -1
  22. package/dist/src/context/member-scope.js +5 -5
  23. package/dist/src/context/name-policy.d.ts.map +1 -1
  24. package/dist/src/context/name-policy.js +3 -0
  25. package/dist/src/context/scope.d.ts +1 -0
  26. package/dist/src/context/scope.d.ts.map +1 -1
  27. package/dist/src/context/scope.js +7 -0
  28. package/dist/src/inspect.browser.d.ts +5 -0
  29. package/dist/src/inspect.browser.d.ts.map +1 -0
  30. package/dist/src/inspect.browser.js +5 -0
  31. package/dist/src/inspect.d.ts +2 -0
  32. package/dist/src/inspect.d.ts.map +1 -0
  33. package/dist/src/inspect.js +1 -0
  34. package/dist/src/name-policy.d.ts +11 -0
  35. package/dist/src/name-policy.d.ts.map +1 -1
  36. package/dist/src/name-policy.js +3 -0
  37. package/dist/src/reactive-union-set.d.ts.map +1 -1
  38. package/dist/src/reactive-union-set.js +12 -8
  39. package/dist/src/refkey.d.ts +39 -3
  40. package/dist/src/refkey.d.ts.map +1 -1
  41. package/dist/src/refkey.js +52 -8
  42. package/dist/src/symbols/basic-scope.d.ts +14 -0
  43. package/dist/src/symbols/basic-scope.d.ts.map +1 -0
  44. package/dist/src/symbols/basic-scope.js +20 -0
  45. package/dist/src/symbols/basic-symbol.d.ts +19 -0
  46. package/dist/src/symbols/basic-symbol.d.ts.map +1 -0
  47. package/dist/src/symbols/basic-symbol.js +28 -0
  48. package/dist/src/symbols/index.d.ts +3 -1
  49. package/dist/src/symbols/index.d.ts.map +1 -1
  50. package/dist/src/symbols/index.js +3 -1
  51. package/dist/src/symbols/output-scope.d.ts +70 -41
  52. package/dist/src/symbols/output-scope.d.ts.map +1 -1
  53. package/dist/src/symbols/output-scope.js +98 -130
  54. package/dist/src/symbols/output-space.d.ts +25 -0
  55. package/dist/src/symbols/output-space.d.ts.map +1 -0
  56. package/dist/src/symbols/output-space.js +35 -0
  57. package/dist/src/symbols/output-symbol.d.ts +213 -37
  58. package/dist/src/symbols/output-symbol.d.ts.map +1 -1
  59. package/dist/src/symbols/output-symbol.js +323 -203
  60. package/dist/src/symbols/symbol-flow.d.ts +1 -1
  61. package/dist/src/symbols/symbol-flow.d.ts.map +1 -1
  62. package/dist/src/symbols/symbol-flow.js +22 -7
  63. package/dist/src/symbols/symbol-slot.d.ts +27 -9
  64. package/dist/src/symbols/symbol-slot.d.ts.map +1 -1
  65. package/dist/src/symbols/symbol-slot.js +20 -4
  66. package/dist/src/symbols/symbol-table.d.ts +19 -8
  67. package/dist/src/symbols/symbol-table.d.ts.map +1 -1
  68. package/dist/src/symbols/symbol-table.js +65 -16
  69. package/dist/src/tracer.d.ts +15 -3
  70. package/dist/src/tracer.d.ts.map +1 -1
  71. package/dist/src/tracer.js +39 -63
  72. package/dist/test/components/declaration.test.js +9 -14
  73. package/dist/test/components/reference-or-content.test.js +2 -2
  74. package/dist/test/symbols/output-scope.test.js +33 -198
  75. package/dist/test/symbols/output-symbol.test.js +139 -385
  76. package/dist/test/symbols/resolution.test.js +431 -114
  77. package/dist/test/symbols/symbol-table.test.d.ts +2 -0
  78. package/dist/test/symbols/symbol-table.test.d.ts.map +1 -0
  79. package/dist/test/symbols/symbol-table.test.js +14 -0
  80. package/dist/test/symbols/utils.d.ts +10 -24
  81. package/dist/test/symbols/utils.d.ts.map +1 -1
  82. package/dist/test/symbols/utils.js +23 -45
  83. package/dist/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +4 -2
  85. package/src/binder.ts +348 -273
  86. package/src/components/Declaration.tsx +13 -3
  87. package/src/components/MemberDeclaration.tsx +15 -8
  88. package/src/components/MemberScope.tsx +61 -20
  89. package/src/components/Output.tsx +0 -4
  90. package/src/components/Scope.tsx +16 -9
  91. package/src/context/member-scope.ts +10 -10
  92. package/src/context/name-policy.ts +3 -0
  93. package/src/context/scope.ts +9 -0
  94. package/src/inspect.browser.ts +6 -0
  95. package/src/inspect.ts +1 -0
  96. package/src/name-policy.ts +14 -0
  97. package/src/reactive-union-set.ts +14 -8
  98. package/src/refkey.ts +88 -14
  99. package/src/symbols/basic-scope.ts +23 -0
  100. package/src/symbols/basic-symbol.ts +32 -0
  101. package/src/symbols/index.ts +3 -1
  102. package/src/symbols/output-scope.ts +131 -170
  103. package/src/symbols/output-space.ts +49 -0
  104. package/src/symbols/output-symbol.ts +434 -258
  105. package/src/symbols/symbol-flow.ts +38 -9
  106. package/src/symbols/symbol-slot.tsx +46 -8
  107. package/src/symbols/symbol-table.ts +95 -21
  108. package/src/tracer.ts +53 -83
  109. package/temp/api.json +5559 -3079
  110. package/test/components/declaration.test.tsx +6 -19
  111. package/test/components/reference-or-content.test.tsx +2 -2
  112. package/test/symbols/output-scope.test.ts +33 -125
  113. package/test/symbols/output-symbol.test.ts +128 -348
  114. package/test/symbols/resolution.test.ts +530 -117
  115. package/test/symbols/symbol-table.test.ts +15 -0
  116. package/test/symbols/utils.ts +38 -74
  117. package/tsdoc.json +4 -0
  118. package/dist/src/slot.d.ts +0 -15
  119. package/dist/src/slot.d.ts.map +0 -1
  120. package/dist/src/slot.js +0 -50
  121. package/dist/src/symbols/flags.d.ts +0 -70
  122. package/dist/src/symbols/flags.d.ts.map +0 -1
  123. package/dist/src/symbols/flags.js +0 -72
  124. package/dist/test/components/slot.test.d.ts +0 -2
  125. package/dist/test/components/slot.test.d.ts.map +0 -1
  126. package/dist/test/components/slot.test.js +0 -134
  127. package/src/slot.ts +0 -89
  128. package/src/symbols/flags.ts +0 -82
  129. package/test/components/slot.test.tsx +0 -174
@@ -1,6 +1,5 @@
1
1
  import { Ref } from "@vue/reactivity";
2
2
  import { Refkey } from "./refkey.js";
3
- import { OutputSymbolFlags } from "./symbols/flags.js";
4
3
  import { OutputScope } from "./symbols/output-scope.js";
5
4
  import { type OutputSymbol } from "./symbols/output-symbol.js";
6
5
  export type Metadata = object;
@@ -25,28 +24,12 @@ export interface Binder {
25
24
  * @see {@link resolve} a convenience function that uses the current scope and
26
25
  * binder.
27
26
  */
28
- resolveDeclarationByKey<TScope extends OutputScope = OutputScope, TSymbol extends OutputSymbol = OutputSymbol>(currentScope: TScope | undefined, currentMemberScope: TScope | undefined, key: Refkey): Ref<ResolutionResult<TScope, TSymbol> | undefined>;
29
- getSymbolForRefkey<TSymbol extends OutputSymbol>(refkey: Refkey): Ref<TSymbol | undefined>;
30
- /**
31
- * Find a symbol with a given name in the given scope. Returns a ref
32
- * for the symbol, such that when the symbol is available, the ref value
33
- * will update.
34
- */
35
- findSymbolName<TScope extends OutputScope = OutputScope, TSymbol extends OutputSymbol = OutputSymbol>(currentScope: TScope | undefined, name: string): Ref<TSymbol | undefined>;
36
- findScopeName<TScope extends OutputScope = OutputScope>(currentScope: TScope | undefined, name: string): Ref<TScope | undefined>;
37
- /**
38
- * Resolve a fully qualified name to a symbol. Access a nested scope by name
39
- * with `::`, a nested static member with `.` and a nested instance member
40
- * with `#`.
41
- *
42
- * Per-language packages may provide their own resolveFQN function that uses
43
- * syntax more natural to that language.
44
- */
45
- resolveFQN<TScope extends OutputScope = OutputScope, TSymbol extends OutputSymbol = OutputSymbol>(fqn: string): Ref<TSymbol | TScope | undefined>;
27
+ resolveDeclarationByKey<TScope extends OutputScope = OutputScope, TSymbol extends OutputSymbol = OutputSymbol>(currentScope: TScope | undefined, key: Refkey, options?: ResolveDeclarationByKeyOptions<TScope, TSymbol>): Ref<ResolutionResult<TScope, TSymbol> | undefined>;
46
28
  /**
47
- * The global scope. This is the root scope for all symbols.
29
+ * Get a ref to the symbol associated with the given refkey. The value of the
30
+ * ref is undefined if the symbol has not been created yet.
48
31
  */
49
- globalScope: OutputScope;
32
+ getSymbolForRefkey<TSymbol extends OutputSymbol>(refkey: Refkey): Ref<TSymbol | undefined>;
50
33
  /**
51
34
  * The name conflict resolver to use for this binder.
52
35
  */
@@ -75,7 +58,7 @@ export interface Binder {
75
58
  * scope: global scope
76
59
  * ├── scope: namespace scope 1
77
60
  * │ └── symbol: foo
78
- * │ └── static member scope
61
+ * │ └── static members
79
62
  * │ └── symbol: bar
80
63
  * └── scope: namespace scope 2
81
64
  * └── (resolve bar from here)
@@ -92,11 +75,19 @@ export interface Binder {
92
75
  */
93
76
  export interface ResolutionResult<TScope extends OutputScope, TSymbol extends OutputSymbol> {
94
77
  /**
95
- * The symbol for the resolved declaration.
78
+ * The resolved symbol. May be declared in a lexical scope or be a member symbol.
79
+ */
80
+ symbol: TSymbol;
81
+ /**
82
+ * When the symbol is a member symbol, this is the symbol of the lexical
83
+ * declaration which contains this member symbol, either as one of its own
84
+ * member symbols, or as a member of one of its members.
85
+ *
86
+ * When the symbol is a non-member symbol, this is the same as `symbol`.
96
87
  */
97
- targetDeclaration: TSymbol;
88
+ lexicalDeclaration: TSymbol;
98
89
  /**
99
- * The scopes between the common scope and the reference
90
+ * The scopes between the common scope and the reference.
100
91
  */
101
92
  pathUp: TScope[];
102
93
  /**
@@ -104,18 +95,60 @@ export interface ResolutionResult<TScope extends OutputScope, TSymbol extends Ou
104
95
  */
105
96
  pathDown: TScope[];
106
97
  /**
107
- * The scope which contains both the reference and the declaration.
98
+ * The scopes from the root to scope of the lexical declaration.
99
+ */
100
+ fullSymbolPath: TScope[];
101
+ /**
102
+ * The scopes from the root to the scope of the reference.
103
+ */
104
+ fullReferencePath: TScope[];
105
+ /**
106
+ * The lexical scope which contains both the reference and the lexical
107
+ * declaration. Undefined when they do not share a common scope.
108
108
  */
109
109
  commonScope: TScope | undefined;
110
110
  /**
111
111
  * When resolving a member symbol, this is the path of symbols that lead from
112
- * the base declaration to the member symbol.
112
+ * the lexical declaration to the member symbol.
113
113
  */
114
- memberPath?: TSymbol[];
114
+ memberPath: TSymbol[];
115
+ }
116
+ /**
117
+ * Describes a member in a member access chain, tracking both the symbol
118
+ * and whether this specific member was accessed via a memberRefkey.
119
+ */
120
+ export interface MemberDescriptor {
121
+ symbol: OutputSymbol;
122
+ isMemberAccess: boolean;
115
123
  }
116
124
  export interface NameConflictResolver {
117
125
  (name: string, symbols: OutputSymbol[]): void;
118
126
  }
127
+ /**
128
+ * The context for a member resolution. This is used to properly resolve a
129
+ * member in the MemberResolver.
130
+ */
131
+ export interface MemberResolutionContext<TScope extends OutputScope> {
132
+ /**
133
+ * The scopes that the member reference occurred in.
134
+ */
135
+ referencePath: TScope[];
136
+ /**
137
+ * Whether we are using member access e.g. via `memberRefkey`.
138
+ * This is true when the member was resolved using a memberRefkey,
139
+ * which may carry additional metadata about the member access in the future.
140
+ */
141
+ isMemberAccess: boolean;
142
+ }
143
+ /**
144
+ *
145
+ */
146
+ export interface MemberResolver<TScope extends OutputScope, TSymbol extends OutputSymbol> {
147
+ (owner: TSymbol, member: TSymbol, context: MemberResolutionContext<TScope>): void;
148
+ }
149
+ export interface ResolveDeclarationByKeyOptions<TScope extends OutputScope, TSymbol extends OutputSymbol> {
150
+ memberResolver?: MemberResolver<TScope, TSymbol>;
151
+ }
119
152
  export interface BinderOptions {
120
153
  nameConflictResolver?: NameConflictResolver;
121
154
  }
@@ -130,21 +163,12 @@ export declare function createOutputBinder(options?: BinderOptions): Binder;
130
163
  * not found. The symbol you're looking for may not have been declared yet. When the symbol
131
164
  * is declared, the ref will be updated with the resolution result.
132
165
  */
133
- export declare function resolve<TScope extends OutputScope, TSymbol extends OutputSymbol>(refkey: Refkey): Ref<ResolutionResult<TScope, TSymbol>>;
166
+ export declare function resolve<TScope extends OutputScope, TSymbol extends OutputSymbol>(refkey: Refkey, options?: ResolveDeclarationByKeyOptions<TScope, TSymbol>): Ref<ResolutionResult<TScope, TSymbol>>;
134
167
  declare const createSymbolsSymbol: unique symbol;
135
168
  export declare function getSymbolCreator(creator: SymbolCreator): SymbolCreator[typeof createSymbolsSymbol];
136
169
  export declare function getSymbolCreatorSymbol(): typeof createSymbolsSymbol;
137
170
  export interface SymbolCreator {
138
171
  [createSymbolsSymbol](binder: Binder): void;
139
172
  }
140
- /**
141
- * Use symbol flags to determine the scope in which a symbol with those flags
142
- * should be declared given the current context.
143
- *
144
- * @param flags - The symbol flags to use to determine the default scope.
145
- * @returns an {@link OutputScope} that is the default scope for the given
146
- * flags.
147
- */
148
- export declare function useDefaultScope(flags?: OutputSymbolFlags): OutputScope | undefined;
149
173
  export {};
150
174
  //# sourceMappingURL=binder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"binder.d.ts","sourceRoot":"","sources":["../../src/binder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAA0B,MAAM,iBAAiB,CAAC;AAI7E,OAAO,EAAU,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQ/D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C;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM,CA2btE;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACrB,MAAM,SAAS,WAAW,EAC1B,OAAO,SAAS,YAAY,EAE5B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,8BAA8B,CAAC,MAAM,EAAE,OAAO,CAAM,GAC5D,GAAG,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAcxC;AAED,QAAA,MAAM,mBAAmB,EAAE,OAAO,MAAiB,CAAC;AACpD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,GACrB,aAAa,CAAC,OAAO,mBAAmB,CAAC,CAE3C;AAED,wBAAgB,sBAAsB,IAAI,OAAO,mBAAmB,CAEnE;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C"}
@@ -1,11 +1,9 @@
1
- import { computed, ref, shallowRef } from "@vue/reactivity";
2
- import { useMemberScope } from "./context/member-scope.js";
1
+ import { computed, shallowRef } from "@vue/reactivity";
2
+ import { useMemberContext } from "./context/member-scope.js";
3
3
  import { useScope } from "./context/scope.js";
4
- import { effect, untrack } from "./reactivity.js";
5
- import { refkey } from "./refkey.js";
6
- import { OutputSymbolFlags } from "./symbols/flags.js";
7
- import { OutputScope } from "./symbols/output-scope.js";
8
- import { formatRefkeys, formatSymbol, formatSymbolName, trace, TracePhase } from "./tracer.js";
4
+ import { effect } from "./reactivity.js";
5
+ import { isMemberRefkey, refkey } from "./refkey.js";
6
+ import { formatRefkeys, formatSymbolName, trace, TracePhase } from "./tracer.js";
9
7
 
10
8
  /**
11
9
  * The binder tracks all output scopes and symbols. Scopes are nested containers
@@ -32,7 +30,7 @@ import { formatRefkeys, formatSymbol, formatSymbolName, trace, TracePhase } from
32
30
  * scope: global scope
33
31
  * ├── scope: namespace scope 1
34
32
  * │ └── symbol: foo
35
- * │ └── static member scope
33
+ * │ └── static members
36
34
  * │ └── symbol: bar
37
35
  * └── scope: namespace scope 2
38
36
  * └── (resolve bar from here)
@@ -48,23 +46,29 @@ import { formatRefkeys, formatSymbol, formatSymbolName, trace, TracePhase } from
48
46
  * * **memberPath**: [foo, bar], because we resolved a member symbol and these are the symbols that lead from the base declaration to the member symbol.
49
47
  */
50
48
 
49
+ /**
50
+ * Describes a member in a member access chain, tracking both the symbol
51
+ * and whether this specific member was accessed via a memberRefkey.
52
+ */
53
+
54
+ /**
55
+ * The context for a member resolution. This is used to properly resolve a
56
+ * member in the MemberResolver.
57
+ */
58
+
59
+ /**
60
+ *
61
+ */
62
+
51
63
  export function createOutputBinder(options = {}) {
52
64
  const binder = {
53
65
  resolveDeclarationByKey,
54
66
  getSymbolForRefkey,
55
- findSymbolName,
56
- findScopeName,
57
- resolveFQN: resolveFQN,
58
- globalScope: undefined,
59
67
  notifyScopeCreated,
60
68
  notifySymbolCreated,
61
69
  notifySymbolDeleted,
62
70
  nameConflictResolver: options.nameConflictResolver
63
71
  };
64
- binder.globalScope = new OutputScope("<global>", {
65
- binder,
66
- kind: "global"
67
- });
68
72
  const knownDeclarations = new Map();
69
73
  const waitingDeclarations = new Map();
70
74
  const waitingSymbolNames = new Map();
@@ -90,67 +94,95 @@ export function createOutputBinder(options = {}) {
90
94
  resolution.value = undefined;
91
95
  }
92
96
  }
93
- function hasTransientScope(symbol) {
94
- let sym = symbol;
95
- let transient = false;
96
- while (sym) {
97
- if (sym.flags & OutputSymbolFlags.Transient) {
98
- transient = true;
99
- break;
97
+ function buildResult(currentScope, targetDeclarationBase) {
98
+ const {
99
+ memberPath: targetMemberPath,
100
+ scopeChain: targetChain
101
+ } = scopeAndMemberChain(targetDeclarationBase);
102
+ let targetLexicalDeclaration = targetMemberPath && targetMemberPath.length > 0 ? targetMemberPath[0].ownerSymbol : targetDeclarationBase;
103
+ // when we are resolving from a scope which is a member scope and might have
104
+ // member scope parents, and any symbols in the member path are members of
105
+ // the member scope's owner symbol (i.e., those symbols are in scope where
106
+ // the reference is made), we replace the target member path with an entry
107
+ // on the scope chain.
108
+
109
+ // So, first we find all the owner symbols for any member scopes in scope
110
+ // for the reference.
111
+ const referenceChain = scopeChain(currentScope);
112
+ const inScopeSymbols = new Map();
113
+ for (const scope of referenceChain) {
114
+ if (scope.isMemberScope) {
115
+ inScopeSymbols.set(scope.ownerSymbol, scope);
100
116
  }
101
- if (sym.flags & ~OutputSymbolFlags.Member) {
102
- break;
117
+ }
118
+
119
+ // then if the lexical declaration symbol's members are in scope, remove the
120
+ // symbol from the member path and add its corresponding member scope to the
121
+ // target chain.
122
+ while (targetMemberPath.length > 0 && inScopeSymbols.has(targetLexicalDeclaration)) {
123
+ targetChain.push(inScopeSymbols.get(targetLexicalDeclaration));
124
+ targetLexicalDeclaration = targetMemberPath.shift();
125
+ }
126
+
127
+ // Now we replace any scopes in the target chain with corresponding scopes
128
+ // from the reference chain.
129
+ for (const [index, scope] of targetChain.entries()) {
130
+ if (inScopeSymbols.has(scope.ownerSymbol)) {
131
+ targetChain[index] = inScopeSymbols.get(scope.ownerSymbol);
103
132
  }
104
- sym = sym.scope.owner;
105
133
  }
106
- return transient;
107
- }
108
- function buildResult(currentScope, currentMemberScope, targetDeclarationBase) {
109
- trace(TracePhase.resolve.success, () => {
110
- return `Resolved ${formatRefkeys(targetDeclarationBase.refkeys)} to ${formatSymbol(targetDeclarationBase)}`;
111
- });
112
- if (targetDeclarationBase.flags & OutputSymbolFlags.InstanceMember) {
113
- // todo: handle referencing nested objects by refkey
114
- return {
115
- pathUp: [],
116
- pathDown: [],
117
- memberPath: [targetDeclarationBase],
118
- commonScope: currentMemberScope,
119
- targetDeclaration: targetDeclarationBase
120
- };
134
+
135
+ // Next we look for member scopes in the target chain that correspond to
136
+ // member scopes in the reference chain. We splice the reference chain into
137
+ // the target chain at that point. This ensures that we establish the proper
138
+ // common scope and path up/down even if the reference chain has additional
139
+ // scopes above it (e.g. a scope for the current source file).
140
+ const commonMemberContainer = targetChain.findIndex(scope => scope.isMemberScope && inScopeSymbols.has(scope.ownerSymbol));
141
+ if (commonMemberContainer > -1) {
142
+ const sourceLocation = referenceChain.findIndex(scope => scope.isMemberScope && scope.ownerSymbol === targetChain[commonMemberContainer].ownerSymbol);
143
+
144
+ // source location is guaranteed to exist at this point.
145
+ targetChain.splice(0, commonMemberContainer + 1, ...referenceChain.slice(0, sourceLocation + 1));
121
146
  }
122
- const {
123
- memberPath,
124
- scopeChain: targetChain
125
- } = scopeAndMemberChain(targetDeclarationBase);
126
- const currentChain = scopeChain(currentScope);
147
+
148
+ // Now that we have the target chain and scopes, we can determine the common
149
+ // scopes and paths.
127
150
  let diffStart = 0;
128
- while (targetChain[diffStart] && currentChain[diffStart] && targetChain[diffStart] === currentChain[diffStart]) {
151
+ while (targetChain[diffStart] && referenceChain[diffStart] && targetChain[diffStart] === referenceChain[diffStart]) {
129
152
  diffStart++;
130
153
  }
131
- const pathUp = currentChain.slice(diffStart);
154
+ const pathUp = referenceChain.slice(diffStart);
132
155
  const pathDown = targetChain.slice(diffStart);
133
- const commonScope = targetChain[diffStart - 1] ?? null;
156
+ const commonScope = targetChain[diffStart - 1] ?? undefined;
134
157
  return {
135
158
  pathUp,
136
159
  pathDown,
137
- memberPath,
160
+ memberPath: targetMemberPath,
138
161
  commonScope,
139
- targetDeclaration: memberPath && memberPath.length > 0 ? memberPath.at(0) : targetDeclarationBase
162
+ symbol: targetDeclarationBase,
163
+ lexicalDeclaration: targetLexicalDeclaration,
164
+ fullSymbolPath: targetChain,
165
+ fullReferencePath: referenceChain
140
166
  };
141
167
  }
168
+
169
+ /**
170
+ * Walk from the provided symbol up to the non-member symbol. This constitutes
171
+ * the member path. Then, walk from the first non-member symbol's scope up to
172
+ * the global scope. This constitutes the scope chain.
173
+ */
142
174
  function scopeAndMemberChain(symbol) {
143
175
  const result = {
144
176
  memberPath: [],
145
177
  scopeChain: []
146
178
  };
147
179
  let currentSymbol = symbol;
148
- while (currentSymbol.flags & OutputSymbolFlags.StaticMember) {
149
- result.memberPath.unshift(currentSymbol);
150
- currentSymbol = currentSymbol.scope.owner;
151
- }
152
- if (symbol.flags & OutputSymbolFlags.StaticMember) {
153
- result.memberPath.unshift(currentSymbol);
180
+ if (currentSymbol.isMemberSymbol) {
181
+ result.memberPath = [];
182
+ while (currentSymbol.isMemberSymbol) {
183
+ result.memberPath.unshift(currentSymbol);
184
+ currentSymbol = currentSymbol.ownerSymbol;
185
+ }
154
186
  }
155
187
  const startScope = currentSymbol.scope;
156
188
  result.scopeChain = scopeChain(startScope);
@@ -168,14 +200,39 @@ export function createOutputBinder(options = {}) {
168
200
  if (waitingDeclarations.has(refkey)) {
169
201
  return waitingDeclarations.get(refkey);
170
202
  }
171
- const symbolRef = shallowRef();
203
+ let symbolRef;
204
+ if (isMemberRefkey(refkey)) {
205
+ const baseSymbolRef = getSymbolForRefkey(refkey.base);
206
+ const memberSymbolRef = getSymbolForRefkey(refkey.member);
207
+ symbolRef = computed(() => {
208
+ // even though we don't necessarily need the base symbol to be available
209
+ // yet (the member symbol might already be declared on a type), we wait
210
+ // to resolve the member refkey until the base symbol is available.
211
+ const baseSymbol = baseSymbolRef.value;
212
+ const memberSymbol = memberSymbolRef.value;
213
+ if (!baseSymbol || !memberSymbol) {
214
+ return undefined;
215
+ }
216
+ return memberSymbol;
217
+ });
218
+ } else {
219
+ symbolRef = shallowRef();
220
+ }
172
221
  waitingDeclarations.set(refkey, symbolRef);
173
222
  if (knownDeclarations.has(refkey)) {
174
223
  symbolRef.value = knownDeclarations.get(refkey);
175
224
  }
176
225
  return symbolRef;
177
226
  }
178
- function resolveDeclarationByKey(currentScope, currentMemberScope, refkey) {
227
+
228
+ /**
229
+ * There are two ways to reference a member symbol - directly via its refkey,
230
+ * and via a member refkey. In the former case, we just find the member
231
+ * symbol, and then compute its path directly from there. In hte latter case,
232
+ * we need to find the base of the member expression, and then add the members
233
+ * from the (possibly nested) member refkey to result.
234
+ */
235
+ function resolveDeclarationByKey(currentScope, refkey, options = {}) {
179
236
  const resolvedSymbol = getSymbolForRefkey(refkey);
180
237
  return computed(() => {
181
238
  trace(TracePhase.resolve.pending, () => `Resolving ${formatRefkeys(refkey)}.`);
@@ -185,21 +242,101 @@ export function createOutputBinder(options = {}) {
185
242
  return undefined;
186
243
  }
187
244
  trace(TracePhase.resolve.pending, () => `${formatRefkeys(refkey)} resolved to ${formatSymbolName(symbol)}.`);
188
- if (hasTransientScope(symbol)) {
189
- trace(TracePhase.resolve.failure, () => `Symbol ${formatSymbolName(symbol)} in transient scope.`);
245
+ if (symbol.isTransient) {
246
+ trace(TracePhase.resolve.failure, () => `Symbol ${formatSymbolName(symbol)} is transient.`);
190
247
  return undefined;
191
248
  }
192
- trace(TracePhase.resolve.success, () => `${formatRefkeys(refkey)} successfully resolved to ${formatSymbolName(symbol)}.`);
193
- return buildResult(currentScope, currentMemberScope, symbol);
249
+ const chain = scopeChain(symbol.scope);
250
+ if (chain.some(scope => scope.isTransient)) {
251
+ trace(TracePhase.resolve.failure, () => `Symbol ${formatSymbolName(symbol)} is in a transient scope.`);
252
+ return undefined;
253
+ }
254
+ let result;
255
+ let memberDescriptorsFromRefkey;
256
+ if (isMemberRefkey(refkey)) {
257
+ memberDescriptorsFromRefkey = getMemberPathFromRefkey(refkey);
258
+ result = buildResult(currentScope, memberDescriptorsFromRefkey[0].symbol);
259
+ } else {
260
+ memberDescriptorsFromRefkey = [];
261
+ result = buildResult(currentScope, symbol);
262
+ }
263
+
264
+ // When we have member descriptors, this first entry is already part of the result due to passing it
265
+ // to buildResult above, so we don't need it here.
266
+ const newMemberPathDescriptors = memberDescriptorsFromRefkey.slice(1);
267
+ const allDescriptors = [...result.memberPath.map(s => ({
268
+ symbol: s,
269
+ isMemberAccess: false
270
+ })), ...newMemberPathDescriptors];
271
+
272
+ // update the member path and resolved symbol from our member descriptors
273
+ // (if we have them)
274
+ if (memberDescriptorsFromRefkey.length > 0) {
275
+ for (const descriptor of newMemberPathDescriptors) {
276
+ result.memberPath.push(descriptor.symbol);
277
+ }
278
+ result.symbol = memberDescriptorsFromRefkey.at(-1).symbol;
279
+ }
280
+
281
+ // a subcomputed here ensures we don't lose the progress above When
282
+ // we fail to resolve because a type isn't available yet.
283
+ return computed(() => {
284
+ // resolve each member in the member path
285
+ let currentBase = result.lexicalDeclaration;
286
+ for (const descriptor of allDescriptors) {
287
+ const member = descriptor.symbol;
288
+ if (currentBase.isTyped && !currentBase.hasTypeSymbol) {
289
+ trace(TracePhase.resolve.pending, () => `${formatRefkeys(refkey)} needs type information from a parent type.`);
290
+ // waiting for type
291
+ return undefined;
292
+ }
293
+ resolveMember(currentBase, member, options.memberResolver, {
294
+ referencePath: result.fullReferencePath,
295
+ isMemberAccess: descriptor.isMemberAccess
296
+ });
297
+ currentBase = member;
298
+ }
299
+ trace(TracePhase.resolve.success, () => `${formatRefkeys(refkey)} successfully resolved to ${formatSymbolName(symbol)}.`);
300
+ return result;
301
+ }).value;
194
302
  });
195
303
  }
196
- function notifySymbolCreated(symbol) {
197
- if (symbol.flags & OutputSymbolFlags.Transient) {
198
- // just ignore transient symbols.
199
- return;
304
+
305
+ /**
306
+ * Extracts member descriptors from a refkey, tracking which members
307
+ * were accessed via memberRefkey for proper member resolution context.
308
+ */
309
+ function getMemberPathFromRefkey(refkey) {
310
+ if (isMemberRefkey(refkey)) {
311
+ return [...getMemberPathFromRefkey(refkey.base), {
312
+ symbol: getSymbolForRefkey(refkey.member).value,
313
+ isMemberAccess: true
314
+ }];
315
+ }
316
+ return [{
317
+ symbol: getSymbolForRefkey(refkey).value,
318
+ isMemberAccess: false
319
+ }];
320
+ }
321
+ function resolveMember(base, member, memberResolver, context) {
322
+ if (memberResolver) {
323
+ memberResolver(base, member, context);
324
+ } else {
325
+ // default member resolution
326
+ if (!member.isMemberSymbol) {
327
+ throw new Error(`${formatSymbolName(member)} is not a member symbol.`);
328
+ }
329
+ const memberOwner = base.hasTypeSymbol ? base.type : base.dealias();
330
+ if (member.ownerSymbol !== memberOwner) {
331
+ throw new Error(`${formatSymbolName(member)} is not a member of ${formatSymbolName(base)}.`);
332
+ }
200
333
  }
334
+ }
335
+ function notifySymbolCreated(symbol) {
201
336
  effect(oldRefkeys => {
202
- trace(TracePhase.resolve.pending, () => `Notifying resolutions for ${formatRefkeys(symbol.refkeys)}.`);
337
+ if (symbol.refkeys) {
338
+ trace(TracePhase.resolve.pending, () => `Notifying resolutions for ${formatRefkeys(symbol.refkeys)}.`);
339
+ }
203
340
  if (oldRefkeys) {
204
341
  for (const refkey of oldRefkeys) {
205
342
  if (!symbol.refkeys.includes(refkey)) {
@@ -221,9 +358,13 @@ export function createOutputBinder(options = {}) {
221
358
  const signal = waitingDeclarations.get(refkey);
222
359
  signal.value = symbol;
223
360
  }
361
+ const scope = symbol.scope;
362
+ if (!scope) {
363
+ continue;
364
+ }
224
365
 
225
366
  // notify those waiting for this symbol name
226
- const waitingScope = waitingSymbolNames.get(symbol.scope);
367
+ const waitingScope = waitingSymbolNames.get(scope);
227
368
  if (waitingScope) {
228
369
  const waitingName = waitingScope.get(symbol.name);
229
370
  if (waitingName) {
@@ -234,83 +375,6 @@ export function createOutputBinder(options = {}) {
234
375
  return [...symbol.refkeys];
235
376
  });
236
377
  }
237
- function findSymbolName(scope, name) {
238
- return untrack(() => {
239
- scope ??= binder.globalScope;
240
- for (const sym of scope.symbols) {
241
- if (sym.name === name) {
242
- return shallowRef(sym);
243
- }
244
- }
245
- const symRef = shallowRef(undefined);
246
- if (!waitingSymbolNames.has(scope)) {
247
- waitingSymbolNames.set(scope, new Map());
248
- }
249
- const waiting = waitingSymbolNames.get(scope);
250
- waiting.set(name, symRef);
251
- return symRef;
252
- });
253
- }
254
- function findScopeName(scope, name) {
255
- return untrack(() => {
256
- scope ??= binder.globalScope;
257
- for (const child of scope.children) {
258
- if (child.name === name) {
259
- return shallowRef(child);
260
- }
261
- }
262
- const scopeRef = shallowRef(undefined);
263
- if (!waitingScopeNames.has(scope)) {
264
- waitingScopeNames.set(scope, new Map());
265
- }
266
- const waiting = waitingScopeNames.get(scope);
267
- waiting.set(name, scopeRef);
268
- return scopeRef;
269
- });
270
- }
271
- function findScopeOrSymbolName(scope, name) {
272
- return untrack(() => {
273
- return computed(() => {
274
- return findSymbolName(scope, name).value ?? findScopeName(scope, name).value;
275
- });
276
- });
277
- }
278
- function resolveFQN(fqn) {
279
- const parts = fqn.match(/[^.#]+|[.#]/g);
280
- if (!parts) return ref(undefined);
281
- if (parts.length === 0) return ref(undefined);
282
- parts.unshift(".");
283
- return computed(() => {
284
- let base = binder.globalScope;
285
- for (let i = 0; i < parts.length; i += 2) {
286
- if (base === undefined) {
287
- return;
288
- }
289
- const op = parts[i];
290
- const name = parts[i + 1];
291
- if (op === ".") {
292
- if ("originalName" in base) {
293
- if (!base.staticMemberScope) {
294
- return undefined;
295
- }
296
- base = findSymbolName(base.staticMemberScope, name).value;
297
- } else {
298
- base = findScopeOrSymbolName(base, name).value;
299
- }
300
- } else if (op === "#") {
301
- if ("originalName" in base) {
302
- if (!base.instanceMemberScope) {
303
- return undefined;
304
- }
305
- base = findSymbolName(base.instanceMemberScope, name).value;
306
- } else {
307
- return undefined;
308
- }
309
- }
310
- }
311
- return base;
312
- });
313
- }
314
378
  }
315
379
 
316
380
  /**
@@ -323,14 +387,14 @@ export function createOutputBinder(options = {}) {
323
387
  * not found. The symbol you're looking for may not have been declared yet. When the symbol
324
388
  * is declared, the ref will be updated with the resolution result.
325
389
  */
326
- export function resolve(refkey) {
390
+ export function resolve(refkey, options = {}) {
327
391
  const scope = useScope();
328
- const memberScope = useMemberScope();
329
- const binder = scope?.binder ?? memberScope?.instanceMembers?.binder ?? memberScope?.staticMembers?.binder;
392
+ const memberScope = useMemberContext();
393
+ const binder = scope?.binder ?? memberScope?.ownerSymbol.binder;
330
394
  if (!binder) {
331
395
  throw new Error("Can't resolve refkey without a binder");
332
396
  }
333
- return binder.resolveDeclarationByKey(scope, memberScope?.instanceMembers, refkey);
397
+ return binder.resolveDeclarationByKey(scope, refkey, options);
334
398
  }
335
399
  const createSymbolsSymbol = Symbol();
336
400
  export function getSymbolCreator(creator) {
@@ -338,27 +402,4 @@ export function getSymbolCreator(creator) {
338
402
  }
339
403
  export function getSymbolCreatorSymbol() {
340
404
  return createSymbolsSymbol;
341
- }
342
- /**
343
- * Use symbol flags to determine the scope in which a symbol with those flags
344
- * should be declared given the current context.
345
- *
346
- * @param flags - The symbol flags to use to determine the default scope.
347
- * @returns an {@link OutputScope} that is the default scope for the given
348
- * flags.
349
- */
350
- export function useDefaultScope(flags = OutputSymbolFlags.None) {
351
- if ((flags & OutputSymbolFlags.Member) === 0) {
352
- return useScope();
353
- } else {
354
- const memberScope = useMemberScope();
355
- if (!memberScope) {
356
- throw new Error("Cannot declare member symbols without a member scope");
357
- }
358
- if (flags & OutputSymbolFlags.InstanceMember) {
359
- return memberScope.instanceMembers;
360
- } else {
361
- return memberScope.staticMembers;
362
- }
363
- }
364
405
  }