
javarepl.rendering.ExpressionSourceRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javarepl Show documentation
Show all versions of javarepl Show documentation
Java REPL is a simple Read-Eval-Print-Loop for Java language.
package javarepl.rendering;
import com.googlecode.totallylazy.annotations.multimethod;
import com.googlecode.totallylazy.multi;
import javarepl.expressions.*;
public class ExpressionSourceRenderer {
@multimethod
public static String renderExpressionSource(Expression expression) {
return new multi() {
}.methodOption(expression)
.getOrThrow(new IllegalArgumentException(expression + " not mapped"));
}
@multimethod
private static String renderExpressionSource(Statement expression) {
return expression.source();
}
@multimethod
private static String renderExpressionSource(Assignment expression) {
return expression.value();
}
@multimethod
private static String renderExpressionSource(AssignmentWithType expression) {
return expression.value();
}
@multimethod
private static String renderExpressionSource(Value expression) {
return expression.source();
}
@multimethod
private static String renderExpressionSource(Method expression) {
return expression.source().replaceAll("\n", "\n ");
}
@multimethod
private static String renderExpressionSource(Import expression) {
return expression.source();
}
@multimethod
private static String renderExpressionSource(Type expression) {
return expression.source();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy