package jetbrains.mps.lang.quotation.generator.baseLanguage.template.util;
/*Generated by MPS */
import jetbrains.mps.generator.template.TemplateQueryContext;
import org.jetbrains.mps.openapi.model.SNode;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
public class QuotationUtil {
public QuotationUtil() {
}
public static String genQuotationNodeId(TemplateQueryContext genContext, SNode quotation) {
Integer id = (Integer) genContext.getTransientObject(quotation);
if (id == null) {
id = 1;
} else {
id = id + 1;
}
genContext.putTransientObject(quotation, id);
return id.toString();
}
public static <K, V> ConcurrentMap<K, V> getBuilderMap(TemplateQueryContext genContext, SNode builder, String prefix) {
String key = "QUtil/" + prefix + "/" + builder.getNodeId();
ConcurrentMap<K, V> map = (ConcurrentMap<K, V>) genContext.getTransientObject(key);
if (map == null) {
map = new ConcurrentHashMap<K, V>();
genContext.putTransientObject(key, map);
}
return map;
}
}