JavaToRascalConverter(
      final TypeStore typeStore, Map<String, ISourceLocation> cache, boolean collectBindings) {
    super(true);
    this.typeStore = typeStore;
    this.bindingsResolver = new BindingsResolver(typeStore, cache, collectBindings);
    this.collectBindings = collectBindings;
    DATATYPE_RASCAL_AST_TYPE_NODE_TYPE =
        this.typeStore.lookupAbstractDataType(DATATYPE_RASCAL_AST_TYPE_NODE);
    DATATYPE_RASCAL_AST_MODIFIER_NODE_TYPE =
        this.typeStore.lookupAbstractDataType(DATATYPE_RASCAL_AST_MODIFIER_NODE);
    this.DATATYPE_RASCAL_AST_DECLARATION_NODE_TYPE =
        typeStore.lookupAbstractDataType(DATATYPE_RASCAL_AST_DECLARATION_NODE);
    this.DATATYPE_RASCAL_AST_EXPRESSION_NODE_TYPE =
        typeStore.lookupAbstractDataType(DATATYPE_RASCAL_AST_EXPRESSION_NODE);
    this.DATATYPE_RASCAL_AST_STATEMENT_NODE_TYPE =
        typeStore.lookupAbstractDataType(DATATYPE_RASCAL_AST_STATEMENT_NODE);
    JavaToRascalConverter.DATATYPE_RASCAL_MESSAGE_DATA_TYPE =
        typeStore.lookupAbstractDataType(DATATYPE_RASCAL_MESSAGE);
    JavaToRascalConverter.DATATYPE_RASCAL_MESSAGE_ERROR_NODE_TYPE =
        typeStore
            .lookupConstructor(DATATYPE_RASCAL_MESSAGE_DATA_TYPE, DATATYPE_RASCAL_MESSAGE_ERROR)
            .iterator()
            .next();
    this.locationCache = cache;

    messages = values.listWriter();
  }
  protected void insertCompilationUnitMessages(boolean insertErrors, IList otherMessages) {
    org.rascalmpl.value.type.Type args = TF.tupleType(TF.stringType(), TF.sourceLocationType());

    IValueList result = new IValueList(values);

    if (otherMessages != null) {
      for (IValue message : otherMessages) {
        result.add(message);
      }
    }

    if (insertErrors) {
      int i;

      IProblem[] problems = compilUnit.getProblems();
      for (i = 0; i < problems.length; i++) {
        int offset = problems[i].getSourceStart();
        int length = problems[i].getSourceEnd() - offset + 1;
        int sl = problems[i].getSourceLineNumber();
        ISourceLocation pos = values.sourceLocation(loc, offset, length, sl, sl, 0, 0);
        org.rascalmpl.value.type.Type constr;
        if (problems[i].isError()) {
          constr =
              typeStore.lookupConstructor(
                  this.typeStore.lookupAbstractDataType("Message"), "error", args);
        } else {
          constr =
              typeStore.lookupConstructor(
                  this.typeStore.lookupAbstractDataType("Message"), "warning", args);
        }
        result.add(values.constructor(constr, values.string(problems[i].getMessage()), pos));
      }
    }
    setAnnotation("messages", result.asList());
  }
  protected IValueList parseModifiers(int modifiers) {
    IValueList extendedModifierList = new IValueList(values);

    for (String constructor : java.lang.reflect.Modifier.toString(modifiers).split(" ")) {
      Set<org.rascalmpl.value.type.Type> exConstr =
          typeStore.lookupConstructor(DATATYPE_RASCAL_AST_MODIFIER_NODE_TYPE, constructor);
      for (org.rascalmpl.value.type.Type con : exConstr) {
        extendedModifierList.add(values.constructor(con));
      }
    }

    return extendedModifierList;
  }
 protected IValue constructTypeNode(String constructor, IValue... children) {
   org.rascalmpl.value.type.Type args = TF.tupleType(removeNulls(children));
   org.rascalmpl.value.type.Type constr =
       typeStore.lookupConstructor(DATATYPE_RASCAL_AST_TYPE_NODE_TYPE, constructor, args);
   return values.constructor(constr, removeNulls(children));
 }