/**
 * @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 ReferenceParser extends AbstractParser {
	/**
	 * @param {BaseReflection} item
	 * @returns {Boolean}
	 */
	canParse( item ) {
		return item.kind === ReflectionKind.Reference;
	}

	/**
	 * @param {ReferenceReflection} item
	 * @param {String} parentName
	 * @returns {Object}
	 */
	parse( item, parentName ) {
		return {
			// Needed for post-processing once all project reflections are converted.
			_signature: item,

			id: item.id,
			name: item.name,
			memberof: parentName,
			longname: this.getLongName( item, parentName ),
			file: this.getFile( item ),

			_isReference: true,

			targetDoclet: null
		};
	}
};
