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

'use strict';

const AbstractParser = require( './abstractparser' );
const ReflectionKind = require( './reflectionkind' );

module.exports = class ModuleParser extends AbstractParser {
	/**
	 * @param {BaseReflection} item
	 * @returns {Boolean}
	 */
	canParse( item ) {
		return item.kind === ReflectionKind.Module;
	}

	/**
	 * @param {ModuleReflection} item
	 * @returns {Object}
	 */
	parse( item ) {
		if ( !item.name.includes( '/' ) ) {
			item.name += '/index';
		}

		return {
			id: item.id,
			name: item.name,
			longname: this.getLongName( item ),
			kind: this.getKind( item ),
			extraId: this.getExtraId( item ),
			file: this.getFile( item )
		};
	}
};
