Skip to content

Binder context

The binder context provides the binder instance to all components. This context is provided by the output component.

const BinderContext: ComponentContext<Binder>
import { useBinder } from "@alloy-js/core";
const myContext = useBinder();
findScopeName(TScope | undefined, string) => Ref<TScope | undefined>
findSymbolName(TScope | undefined, string) => Ref<TSymbol | undefined>

Find a symbol with a given name in the given scope. Returns a ref for the symbol, such that when the symbol is available, the ref value will update.

getSymbolForRefkey(Refkey) => Ref<TSymbol | undefined>
globalScopeScope context interface

The global scope. This is the root scope for all symbols.

nameConflictResolveroptionalNameConflictResolver

The name conflict resolver to use for this binder.

notifyScopeCreated(OutputScope) => void

Notifies the binder that a scope has been created.

notifySymbolCreated(OutputSymbol) => void

Notifies the binder that a symbol has been created.

notifySymbolDeleted(OutputSymbol) => void

Notifies the binder that a symbol has been deleted.

resolveDeclarationByKey(TScope | undefined, TScope | undefined, Refkey) => Ref<ResolutionResult<TScope, TSymbol> | undefined>

Resolve the given refkey in the current scope.

resolveFQN(string) => Ref<TSymbol | TScope | undefined>

Resolve a fully qualified name to a symbol. Access a nested scope by name with ::, a nested static member with . and a nested instance member with #.

Per-language packages may provide their own resolveFQN function that uses syntax more natural to that language.