/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const PropertyParser = require( './propertyparser' );
const ReflectionKind = require( './reflectionkind' );

module.exports = class ComputedPropertyParser extends PropertyParser {
	/**
	 * @param {BaseReflection} item
	 * @returns {Boolean}
	 */
	canParse( item ) {
		return item.kind === ReflectionKind.IndexSignature;
	}

	/**
	 * @param {ComputedPropertyReflection} item
	 * @param {String} parentName
	 * @returns {Object}
	 */
	parse( item, parentName ) {
		return {
			...super.parse( item, parentName ),
			name: this.getComputedName( item )
		};
	}
};
