Search in sources :

Example 6 with JavaClass

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

the class AbstractFixJavadocMojoTest method testReplaceLinkTags_twoLinks.

public void testReplaceLinkTags_twoLinks() throws Throwable {
    String comment = "/** Use {@link ConnectException} instead of {@link Exception} */";
    AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
    JavaClass clazz = mock(JavaClass.class);
    when(entity.getParentClass()).thenReturn(clazz);
    when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
    when(clazz.resolveType("Exception")).thenReturn("java.lang.Exception");
    String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
    assertEquals("/** Use {@link java.net.ConnectException} instead of {@link java.lang.Exception} */", newComment);
}
Also used : JavaClass(com.thoughtworks.qdox.model.JavaClass) JavaClass(com.thoughtworks.qdox.model.JavaClass) AbstractInheritableJavaEntity(com.thoughtworks.qdox.model.AbstractInheritableJavaEntity)

Example 7 with JavaClass

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

the class AbstractFixJavadocMojoTest method testReplaceLinkTags_containingHash.

public void testReplaceLinkTags_containingHash() throws Throwable {
    String comment = "/** {@link ConnectException#getMessage()} */";
    AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
    JavaClass clazz = mock(JavaClass.class);
    when(entity.getParentClass()).thenReturn(clazz);
    when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
    String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
    assertEquals("/** {@link java.net.ConnectException#getMessage()} */", newComment);
}
Also used : JavaClass(com.thoughtworks.qdox.model.JavaClass) JavaClass(com.thoughtworks.qdox.model.JavaClass) AbstractInheritableJavaEntity(com.thoughtworks.qdox.model.AbstractInheritableJavaEntity)

Example 8 with JavaClass

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

the class AbstractFixJavadocMojoTest method testReplaceLinkTags_oneLinkTag.

public void testReplaceLinkTags_oneLinkTag() throws Throwable {
    String comment = "/** {@link ConnectException} */";
    AbstractInheritableJavaEntity entity = spy(new PrivateAbstractInheritableJavaEntity());
    JavaClass clazz = mock(JavaClass.class);
    when(entity.getParentClass()).thenReturn(clazz);
    when(clazz.resolveType("ConnectException")).thenReturn("java.net.ConnectException");
    String newComment = (String) PrivateAccessor.invoke(AbstractFixJavadocMojo.class, "replaceLinkTags", new Class[] { String.class, AbstractInheritableJavaEntity.class }, new Object[] { comment, entity });
    assertEquals("/** {@link java.net.ConnectException} */", newComment);
}
Also used : JavaClass(com.thoughtworks.qdox.model.JavaClass) JavaClass(com.thoughtworks.qdox.model.JavaClass) AbstractInheritableJavaEntity(com.thoughtworks.qdox.model.AbstractInheritableJavaEntity)

Example 9 with JavaClass

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

the class AbstractFixJavadocMojo method getDefaultMethodJavadocComment.

/**
     * Default comment for method with taking care of getter/setter in the javaMethod name.
     *
     * @param javaMethod not null
     * @return a default comment for method.
     */
private static String getDefaultMethodJavadocComment(final JavaMethod javaMethod) {
    if (javaMethod.isConstructor()) {
        return "<p>Constructor for " + javaMethod.getName() + ".</p>";
    }
    if (javaMethod.getName().length() > 3 && (javaMethod.getName().startsWith("get") || javaMethod.getName().startsWith("set"))) {
        String field = StringUtils.lowercaseFirstLetter(javaMethod.getName().substring(3));
        JavaClass clazz = javaMethod.getParentClass();
        if (clazz.getFieldByName(field) == null) {
            return "<p>" + javaMethod.getName() + ".</p>";
        }
        StringBuilder sb = new StringBuilder();
        sb.append("<p>");
        if (javaMethod.getName().startsWith("get")) {
            sb.append("Getter ");
        } else if (javaMethod.getName().startsWith("set")) {
            sb.append("Setter ");
        }
        sb.append("for the field <code>").append(field).append("</code>.</p>");
        return sb.toString();
    }
    return "<p>" + javaMethod.getName() + ".</p>";
}
Also used : JavaClass(com.thoughtworks.qdox.model.JavaClass)

Example 10 with JavaClass

use of com.thoughtworks.qdox.model.JavaClass in project sling by apache.

the class AbstractDescriptorElement method getJavaClass.

JavaClass getJavaClass() {
    AbstractBaseJavaEntity aje = tag.getContext();
    if (aje instanceof JavaClass) {
        return (JavaClass) aje;
    }
    JavaClassParent parent = aje.getParent();
    if (parent instanceof JavaClass) {
        return (JavaClass) parent;
    }
    return null;
}
Also used : JavaClassParent(com.thoughtworks.qdox.model.JavaClassParent) JavaClass(com.thoughtworks.qdox.model.JavaClass) AbstractBaseJavaEntity(com.thoughtworks.qdox.model.AbstractBaseJavaEntity)

Aggregations

JavaClass (com.thoughtworks.qdox.model.JavaClass)48 AbstractInheritableJavaEntity (com.thoughtworks.qdox.model.AbstractInheritableJavaEntity)12 JavaMethod (com.thoughtworks.qdox.model.JavaMethod)12 DocletTag (com.thoughtworks.qdox.model.DocletTag)10 JavaDocBuilder (com.thoughtworks.qdox.JavaDocBuilder)6 File (java.io.File)6 StringReader (java.io.StringReader)6 JavaParameter (com.thoughtworks.qdox.model.JavaParameter)5 JavaSource (com.thoughtworks.qdox.model.JavaSource)5 ArrayList (java.util.ArrayList)5 JavaProjectBuilder (com.thoughtworks.qdox.JavaProjectBuilder)4 BeanProperty (com.thoughtworks.qdox.model.BeanProperty)4 JavaField (com.thoughtworks.qdox.model.JavaField)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Test (org.junit.Test)3 AbstractJavaEntity (com.thoughtworks.qdox.model.AbstractJavaEntity)2 JavaExecutable (com.thoughtworks.qdox.model.JavaExecutable)2 JavaMember (com.thoughtworks.qdox.model.JavaMember)2 JavaType (com.thoughtworks.qdox.model.JavaType)2