Search in sources :

Example 6 with CtJavaDocTag

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

the class CodeFactory method createJavaDocTag.

/**
 * Creates a javadoc tag
 *
 * @param content The content of the javadoc tag with a possible paramater
 * @param type The tag type
 * @return a new CtJavaDocTag
 */
public CtJavaDocTag createJavaDocTag(String content, CtJavaDocTag.TagType type) {
    if (content == null) {
        content = "";
    }
    CtJavaDocTag docTag = factory.Core().createJavaDocTag();
    if (type != null && type.hasParam()) {
        int firstWord = content.indexOf(" ");
        int firstLine = content.indexOf("\n");
        if (firstLine < firstWord && firstLine >= 0) {
            firstWord = firstLine;
        }
        if (firstWord == -1) {
            firstWord = content.length();
        }
        String param = content.substring(0, firstWord);
        content = content.substring(firstWord);
        docTag.setParam(param);
    }
    return docTag.setContent(content.trim()).setType(type);
}
Also used : CtJavaDocTag(spoon.reflect.code.CtJavaDocTag)

Aggregations

CtJavaDocTag (spoon.reflect.code.CtJavaDocTag)6 CtJavaDoc (spoon.reflect.code.CtJavaDoc)3 StringTokenizer (java.util.StringTokenizer)1 CtComment (spoon.reflect.code.CtComment)1 CtJavaDocTagImpl (spoon.support.reflect.code.CtJavaDocTagImpl)1