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

org.stjs.generator.writer.templates.fields.DefaultUnaryTemplate Maven / Gradle / Ivy

package org.stjs.generator.writer.templates.fields;

import org.stjs.generator.GenerationContext;
import org.stjs.generator.javascript.UnaryOperator;
import org.stjs.generator.writer.WriterContributor;
import org.stjs.generator.writer.WriterVisitor;

import com.sun.source.tree.UnaryTree;

/**
 * Java unary operator
 * 
 * @author acraciun
 */
public class DefaultUnaryTemplate implements WriterContributor {

	@Override
	public JS visit(WriterVisitor visitor, UnaryTree tree, GenerationContext context) {
		JS operand = visitor.scan(tree.getExpression(), context);
		UnaryOperator op = UnaryOperator.valueOf(tree.getKind());
		assert op != null : "Unknow operator:" + tree.getKind();

		return context.js().unary(op, operand);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy