Search code examples
kotlinintellij-idea

IntelliJ keeps giving cannot resolve @param in jdocs / kdocs


Not sure what I am doing wrong

/**
 * Converts a DTO to its entity representation.
 *
 * @param dto The source DTO
 * @return [EmergencyContactEntity] containing the mapped data
 */
/***********************/
/* FROM DTO TO ENTITY. */
/***********************/
internal fun toEntity(dto: EmergencyContactDTO): EmergencyContactEntity {
    return EmergencyContactDTOEntityMapMapper.toEntity(dto)
}

IntelliJ before I push the code to a repo, gives:

Warning:(24, 15) Cannot resolve symbol 'dto'

Any ideas?


Solution

  • Between the documentation comments and the function declaration, you have this block of comment

    /***********************/
    /* FROM DTO TO ENTITY. */
    /***********************/
    

    The last line starts with /**, so the last line is treated as the documentation comment associated to the function. So the actual documentation comments at the beginning isn't treated as documenting the function declaration.

    Assuming you don't want "FROM DTO TO ENTITY" to be part of the documentation, you should write it using // comments.

    /**
     * Converts a DTO to its entity representation.
     *
     * @param dto The source DTO
     * @return [EmergencyContactEntity] containing the mapped data
     */
    ///***********************/
    ///* FROM DTO TO ENTITY. */
    ///***********************/
    internal fun toEntity(dto: EmergencyContactDTO): EmergencyContactEntity
    

    Since this is a // comment, you don't need that many slashes. This looks better in my opinion:

    //***********************
    //* FROM DTO TO ENTITY. *
    //***********************
    

    Or you can start a regular block comment with /* (not /**!) just after the */ of the documentation comment:

    /**
     * Converts a DTO to its entity representation.
     *
     * @param dto The source DTO
     * @return [EmergencyContactEntity] containing the mapped data
     *//*
    ***********************
    * FROM DTO TO ENTITY. *
    ***********************/
    internal fun toEntity(dto: EmergencyContactDTO): EmergencyContactEntity
    

    Note