UNPKG

@tripsnek/tmf

Version:

TypeScript Modeling Framework - A TypeScript port of the Eclipse Modeling Framework (EMF)

91 lines 4.09 kB
import { EClassifier } from './metamodel/api/eclassifier.js'; import { EObject } from './metamodel/api/eobject.js'; import { EAttribute } from './metamodel/api/eattribute.js'; import { EStructuralFeature } from './metamodel/api/estructural-feature.js'; import { EReference } from './metamodel/api/ereference.js'; import { EClass } from './metamodel/api/eclass.js'; import { EPackage } from './metamodel/api/epackage.js'; /** * Various utilities for interacting with TMF-modeled data objects, some * of which are relied upon by core TMF components (e.g. TJson) and generated * source code. */ export declare class TUtils { static PRIMITIVES: string[]; /** * Ensures all objects have IDs. * @param obj */ static generateIdsForAllContained(obj: EObject): void; /** * Sets an ID for the given object on it's ID EAttribute. If * an ID is already specified, does nothing. * * @param obj */ static genIdIfNotExists(obj: EObject): void; /** * If an ID is specified on the object, returns a new TId instance with that ID value. If not, a * new ID is assigned and that TId returned. * * @param obj */ static getOrCreateIdForObject(obj: EObject): string; /** * Gets the Typescript name for a given EClassifier, including * translation of primitive EDataType names (e.g. EBoolean -> boolean). * @param type */ static getTypescriptName(type: EClassifier): string; /** * Gets the TypeScript primitive type for a given TMF EClassifier that represents a * primitive type. * @param classifier */ static toTypeScriptPrimitive(classifier: EClassifier): string; static lookupNamedField(object: EObject, fieldName: string): EStructuralFeature | undefined; static getNamedFieldValue(object: EObject, fieldName: string): any; static setNamedFieldValue(object: EObject, fieldName: string, newValue: any): undefined; /** * Parses a value for an EAttribute from it's JSON representation. * * @param attr * @param jsonVal */ static parseAttrValFromString(attr: EAttribute, stringVal: any): any; static parseValueFromString(attrType: EClassifier, stringVal: string): string | number | boolean | Date | null; /** * Creates a deep copy of an Root and it's containment hierarchy, with optional * lists for specifying specific EReferences to traverse or prune during the copy. New * IDs will be assigned to all copied entities. Internal references will be preserved where possible. * * @param toClone - root of container containment hierarchy to copy * @param prune - EReferences not to traverse during copy. If specified, these * references will not be traversed during copy * @param traverse - EReferences to traverse during copy. If specified, no EReference * will be traversed unless it is in this list. * @param target - Allows specification of an entity into which to copy data, which does not have * to be of the same type as the copied entity (non-overlapping structure will be ignored). * @returns the copy */ static clone<T extends EObject>(toClone: T, prune?: EReference[], traverse?: EReference[], target?: T, oldToNewEntities?: Map<EObject, EObject>): T; private static cloneInto; static carbonCopy<T extends EObject>(obj: T): T; /** * Overwrites all attributes values, and replaces all containments with * carbon copies. Non-containment references are left alone. * * @param currentState * @param newState */ static shallowUpdate(currentState: EObject, newState: EObject): void; /** * Returns the package and transitive closure of all contained subpackages. * * @param pkg * @returns */ static allPackagesRecursive(pkg: EPackage, addTo?: EPackage[]): EPackage[]; static getRootEClasses(root: EPackage): EClass[]; } //# sourceMappingURL=tutils.d.ts.map