All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.stjs.generator.writer.CommentWriter Maven / Gradle / Ivy

There is a newer version: 3.3.2.2
Show newest version
package org.stjs.generator.writer;

import javax.lang.model.element.Element;

import org.stjs.generator.GenerationContext;
import org.stjs.generator.javac.InternalUtils;
import org.stjs.generator.visitor.VisitorContributor;

import com.sun.source.tree.Tree;

/**
 * add the javadoc comment for the processed nodes.
 * 
 * @author acraciun
 * 
 * @param 
 */
public class CommentWriter implements WriterFilter {

	@Override
	public JS visit(WriterVisitor visitor, Tree tree, GenerationContext context,
			VisitorContributor, WriterVisitor> chain) {
		JS jsNode = chain.visit(visitor, tree, context);
		if (jsNode == null) {
			return null;
		}

		Element element = InternalUtils.symbol(tree);
		if (element != null) {
			String comment = context.getElements().getDocComment(element);
			if (comment != null) {
				return context.js().comment(jsNode, comment);
			}
		}
		return jsNode;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy