UNPKG

jsii-pacmak

Version:

A code generation framework for jsii backend languages

47 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.visitTypeReference = visitTypeReference; exports.visitType = visitType; exports.isDataType = isDataType; exports.isBehavioralInterfaceType = isBehavioralInterfaceType; const spec = require("@jsii/spec"); function visitTypeReference(typeRef, visitor) { if (spec.isNamedTypeReference(typeRef)) { return visitor.named(typeRef); } else if (spec.isPrimitiveTypeReference(typeRef)) { return visitor.primitive(typeRef); } else if (spec.isCollectionTypeReference(typeRef)) { return visitor.collection(typeRef); } else if (spec.isUnionTypeReference(typeRef)) { return visitor.union(typeRef); } else if (spec.isIntersectionTypeReference(typeRef)) { return visitor.intersection(typeRef); } throw new Error(`Unknown type reference: ${JSON.stringify(typeRef)}`); } function visitType(t, visitor) { if (spec.isClassType(t)) { return visitor.classType(t); } else if (spec.isInterfaceType(t) && t.datatype) { return visitor.dataType(t); } else if (spec.isInterfaceType(t)) { return visitor.interfaceType(t); } else if (spec.isEnumType(t)) { return visitor.enumType(t); } throw new Error(`Unknown type: ${JSON.stringify(t)}`); } function isDataType(t) { return spec.isInterfaceType(t) && !!t.datatype; } function isBehavioralInterfaceType(t) { return spec.isInterfaceType(t) && !t.datatype; } //# sourceMappingURL=type-visitor.js.map