"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResolvedTrait = void 0;
const internal_1 = require("../internal");
/**
     * @internal
     */
class ResolvedTrait {
    constructor(trait, pc, values, wasSet) {
        // let bodyCode = () =>
        {
            if (pc && pc.sequence && pc.sequence.length) {
                this.parameterValues = new internal_1.ParameterValueSet(trait.ctx, pc, values, wasSet);
            }
            this.trait = trait;
        }
        // return p.measure(bodyCode);
    }
    get traitName() {
        // let bodyCode = () =>
        {
            return this.trait.declaredPath;
        }
        // return p.measure(bodyCode);
    }
    spew(resOpt, to, indent) {
        // let bodyCode = () =>
        {
            to.spewLine(`${indent}[${this.traitName}]`);
            if (this.parameterValues) {
                this.parameterValues.spew(resOpt, to, `${indent}-`);
            }
        }
        // return p.measure(bodyCode);
    }
    copy() {
        // let bodyCode = () =>
        {
            if (this.parameterValues) {
                const copyParamValues = this.parameterValues.copy();
                return new ResolvedTrait(this.trait, copyParamValues.pc, copyParamValues.values, copyParamValues.wasSet);
            }
            return new ResolvedTrait(this.trait, undefined, undefined, undefined);
        }
        // return p.measure(bodyCode);
    }
    collectTraitNames(resOpt, into) {
        // let bodyCode = () =>
        {
            // get the name of this trait and all of its base classes
            let t = this.trait;
            while (t) {
                const name = t.getName();
                if (!into.has(name)) {
                    into.add(name);
                }
                const baseRef = t.fetchExtendsTrait();
                t = (baseRef ? baseRef.fetchObjectDefinition(resOpt) : undefined);
            }
        }
        // return p.measure(bodyCode);
    }
}
exports.ResolvedTrait = ResolvedTrait;
//# sourceMappingURL=ResolvedTrait.js.map