Search in sources :

Example 6 with CtJavaDoc

use of spoon.reflect.code.CtJavaDoc in project spoon by INRIA.

the class CommentTest method testJavadocShortAndLongComment.

@Test
public void testJavadocShortAndLongComment() {
    // contract: in case we cannot determine if it is a short comment, we take the whole content
    Factory f = getSpoonFactory();
    CtClass<?> type = (CtClass<?>) f.Type().get(OtherJavaDoc.class);
    CtJavaDoc classJavaDoc = (CtJavaDoc) type.getComments().get(0);
    assertEquals("A short description without a proper end", classJavaDoc.getShortDescription());
    assertEquals("A short description without a proper end", classJavaDoc.getLongDescription());
}
Also used : CtClass(spoon.reflect.declaration.CtClass) CtJavaDoc(spoon.reflect.code.CtJavaDoc) DefaultCoreFactory(spoon.support.DefaultCoreFactory) Factory(spoon.reflect.factory.Factory) OtherJavaDoc(spoon.test.comment.testclasses.OtherJavaDoc) Test(org.junit.Test)

Example 7 with CtJavaDoc

use of spoon.reflect.code.CtJavaDoc in project spoon by INRIA.

the class CtElementImpl method getDocComment.

public String getDocComment() {
    for (CtComment ctComment : comments) {
        if (ctComment.getCommentType() == CtComment.CommentType.JAVADOC) {
            StringBuffer result = new StringBuffer();
            result.append(ctComment.getContent() + System.lineSeparator());
            for (CtJavaDocTag tag : ((CtJavaDoc) ctComment).getTags()) {
                // the tag already contains a new line
                result.append(tag.toString());
            }
            return result.toString();
        }
    }
    return "";
}
Also used : CtComment(spoon.reflect.code.CtComment) CtJavaDoc(spoon.reflect.code.CtJavaDoc) CtJavaDocTag(spoon.reflect.code.CtJavaDocTag)

Aggregations

CtJavaDoc (spoon.reflect.code.CtJavaDoc)7 Test (org.junit.Test)3 CtJavaDocTag (spoon.reflect.code.CtJavaDocTag)3 CtClass (spoon.reflect.declaration.CtClass)3 Factory (spoon.reflect.factory.Factory)3 DefaultCoreFactory (spoon.support.DefaultCoreFactory)3 StringTokenizer (java.util.StringTokenizer)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Launcher (spoon.Launcher)1 CtComment (spoon.reflect.code.CtComment)1 CtJavaDocImpl (spoon.support.reflect.code.CtJavaDocImpl)1 JavaDocEmptyCommentAndTags (spoon.test.comment.testclasses.JavaDocEmptyCommentAndTags)1 OtherJavaDoc (spoon.test.comment.testclasses.OtherJavaDoc)1 WindowsEOL (spoon.test.comment.testclasses.WindowsEOL)1