MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / getDeclarationRef

Function getDeclarationRef

packages/cli/src/actions/pull/utils.ts:170–180  ·  view source on GitHub ↗
(
    type: T['$type'],
    name: string,
    services: ZModelServices,
)

Source from the content-addressed store, hash-verified

168}
169
170export function getDeclarationRef<T extends AbstractDeclaration>(
171 type: T['$type'],
172 name: string,
173 services: ZModelServices,
174) {
175 const node = services.shared.workspace.IndexManager.allElements(type).find(
176 (m) => m.node && getDbName(m.node as T) === name,
177 )?.node;
178 if (!node) throw new CliError(`Declaration not found: ${name}`);
179 return node as T;
180}
181
182export function getEnumRef(name: string, services: ZModelServices) {
183 return getDeclarationRef<Enum>('Enum', name, services);

Callers 4

getEnumRefFunction · 0.85
getModelRefFunction · 0.85
getAttributeRefFunction · 0.85
getFunctionRefFunction · 0.85

Calls 2

getDbNameFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected