Search in sources :

Example 1 with JavaTypeVariable

use of com.thoughtworks.qdox.model.JavaTypeVariable in project maven-plugins by apache.

the class AbstractFixJavadocMojo method writeParamTag.

private void writeParamTag(final StringBuilder sb, final JavaExecutable javaExecutable, final JavaEntityTags javaEntityTags, List<String> params) {
    String paramName = params.get(0);
    if (!fixTag(PARAM_TAG)) {
        // write original param tag if found
        String originalJavadocTag = javaEntityTags.getJavadocParamTag(paramName);
        if (originalJavadocTag != null) {
            sb.append(originalJavadocTag);
        }
        return;
    }
    boolean found = false;
    JavaParameter javaParam = javaExecutable.getParameterByName(paramName);
    if (javaParam == null) {
        // is generic?
        List<JavaTypeVariable<JavaGenericDeclaration>> typeParams = javaExecutable.getTypeParameters();
        for (JavaTypeVariable<JavaGenericDeclaration> typeParam : typeParams) {
            if (typeParam.getGenericValue().equals(paramName)) {
                found = true;
            }
        }
    } else {
        found = true;
    }
    if (!found) {
        if (getLog().isWarnEnabled()) {
            getLog().warn("Fixed unknown param '" + paramName + "' defined in " + getJavaMethodAsString(javaExecutable));
        }
        if (sb.toString().endsWith(EOL)) {
            sb.delete(sb.toString().lastIndexOf(EOL), sb.toString().length());
        }
    } else {
        String originalJavadocTag = javaEntityTags.getJavadocParamTag(paramName);
        if (originalJavadocTag != null) {
            sb.append(originalJavadocTag);
            String s = "@" + PARAM_TAG + " " + paramName;
            if (StringUtils.removeDuplicateWhitespace(originalJavadocTag).trim().endsWith(s)) {
                sb.append(" ");
                sb.append(getDefaultJavadocForType(javaParam.getJavaClass()));
            }
        }
    }
}
Also used : JavaGenericDeclaration(com.thoughtworks.qdox.model.JavaGenericDeclaration) JavaParameter(com.thoughtworks.qdox.model.JavaParameter) JavaTypeVariable(com.thoughtworks.qdox.model.JavaTypeVariable)

Aggregations

JavaGenericDeclaration (com.thoughtworks.qdox.model.JavaGenericDeclaration)1 JavaParameter (com.thoughtworks.qdox.model.JavaParameter)1 JavaTypeVariable (com.thoughtworks.qdox.model.JavaTypeVariable)1