1 package org.simantics.scl.compiler.elaboration.expressions.annotations;
3 import org.simantics.scl.compiler.constants.StringConstant;
4 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
5 import org.simantics.scl.compiler.elaboration.expressions.EStringLiteral;
6 import org.simantics.scl.compiler.elaboration.expressions.EVar;
7 import org.simantics.scl.compiler.elaboration.expressions.Expression;
9 public class AnnotationUtils {
10 public static String extractString(Expression expression) {
11 if(expression instanceof EVar)
12 return ((EVar)expression).name;
13 else if(expression instanceof EStringLiteral) {
14 EStringLiteral literal = (EStringLiteral)expression;
15 if(literal.strings.length == 1)
16 return literal.strings[0];
18 else if(expression instanceof ELiteral) {
19 ELiteral literal = (ELiteral)expression;
20 if(literal.getValue() instanceof StringConstant) {
21 StringConstant constant = (StringConstant)literal.getValue();
22 return constant.getValue();