public void resolve(
      String identifier,
      org.sintef.thingml.InstanceRef container,
      org.eclipse.emf.ecore.EReference reference,
      int position,
      boolean resolveFuzzy,
      final org.sintef.thingml.resource.thingml.IThingmlReferenceResolveResult<
              org.sintef.thingml.Instance>
          result) {

    // In which configuration should we look:
    Configuration cfg = ThingMLHelpers.findContainingConfiguration(container);
    if (cfg != null) {

      for (Instance ci : cfg.getInstances()) {
        if (ci.getName().startsWith(identifier)) {
          if (resolveFuzzy) result.addMapping(ci.getName(), ci);
          else if (ci.getName().equals(identifier)) result.addMapping(ci.getName(), ci);
        }
      }
      if (!result.wasResolved())
        result.setErrorMessage(
            "Cannot resolve instance " + identifier + " in configuration " + cfg.getName());
    }
    if (!result.wasResolved()) result.setErrorMessage("Cannot resolve instance " + identifier);
  }
 public Set<Message> allMessages(ThingMLModel self) {
   Set<Message> msg = new HashSet<Message>();
   for (Thing t : allThings(self)) {
     msg.addAll(ThingMLHelpers.allMessages(t));
   }
   return msg;
 }
 public void resolve(
     String identifier,
     org.sintef.thingml.EnumLiteralRef container,
     org.eclipse.emf.ecore.EReference reference,
     int position,
     boolean resolveFuzzy,
     final org.sintef.thingml.resource.thingml.IThingmlReferenceResolveResult<
             org.sintef.thingml.EnumerationLiteral>
         result) {
   ArrayList<EnumerationLiteral> ts =
       ThingMLHelpers.findEnumerationLiteral(container.getEnum(), identifier, resolveFuzzy);
   for (EnumerationLiteral t : ts) result.addMapping(t.getName(), t);
   if (!result.wasResolved())
     result.setErrorMessage("Cannot resolve enumeration literal " + identifier);
 }
 public static Set<Type> allUsedSimpleTypes(ThingMLModel model) {
   Set<Type> result = new HashSet<Type>();
   for (Type t : allSimpleTypes(model)) {
     for (Thing thing : allThings(model)) {
       for (Property p : ThingHelper.allPropertiesInDepth(thing)) {
         if (EcoreUtil.equals(p.getType(), t)) result.add(t);
       }
       for (Message m : ThingMLHelpers.allMessages(thing)) {
         for (Parameter p : m.getParameters()) {
           if (EcoreUtil.equals(p.getType(), t)) {
             result.add(t);
           }
         }
       }
     }
   }
   return result;
 }
  public void resolve(
      String identifier,
      org.sintef.thingml.MessageParameter container,
      org.eclipse.emf.ecore.EReference reference,
      int position,
      boolean resolveFuzzy,
      final org.sintef.thingml.resource.thingml.IThingmlReferenceResolveResult<
              org.sintef.thingml.Message>
          result) {
    Thing thing = ThingMLHelpers.findContainingThing(container);

    for (Message m : thing.allMessages()) {
      if (resolveFuzzy && m.getName().startsWith(identifier)) {
        result.addMapping(m.getName(), m);
      } else if (!resolveFuzzy && m.getName().equals(identifier)) {
        result.addMapping(m.getName(), m);
      }
    }

    if (!result.wasResolved()) result.setErrorMessage("Cannot resolve message name: " + identifier);
  }
  @Override
  public void do_call_compiler(Configuration cfg, String... options) {
    this.checker.do_check(cfg);
    this.checker.printErrors();
    this.checker.printWarnings();
    this.checker.printNotices();

    Context ctx =
        new Context(
            this,
            "match",
            "requires",
            "type",
            "abstract",
            "do",
            "finally",
            "import",
            "object",
            "throw",
            "case",
            "else",
            "for",
            "lazy",
            "override",
            "return",
            "trait",
            "catch",
            "extends",
            "forSome",
            "match",
            "package",
            "sealed",
            "try",
            "while",
            "class",
            "false",
            "if",
            "new",
            "private",
            "super",
            "true",
            "final",
            "null",
            "protected",
            "this",
            "_",
            ":",
            "=",
            "=>",
            "<-",
            "<:",
            "<%",
            ">:",
            "#",
            "@");
    ctx.addContextAnnotation("thisRef", "");
    String pack = "org.thingml.generated";
    boolean doingTests = false;
    if (options != null && options.length > 0) pack = options[0];
    if (options != null && options.length > 1) {
      if (options[1].equals("doingTest")) {
        doingTests = true;
      }
    }

    String tmpFolder = System.getProperty("java.io.tmpdir") + "/ThingML_temp/";
    if (doingTests) {
      tmpFolder = "tmp/ThingML_Java/";
    }
    if (ctx.getOutputDirectory() != null)
      tmpFolder = ctx.getOutputDirectory().getAbsolutePath() + File.separator;
    else new File(tmpFolder).deleteOnExit();
    ctx.addContextAnnotation("package", pack);
    ctx.setCurrentConfiguration(cfg);
    processDebug(cfg);
    for (Thing th : ConfigurationHelper.allThings(cfg)) {
      ctx.getCompiler().getThingApiCompiler().generatePublicAPI(th, ctx);
      ctx.getCompiler().getThingImplCompiler().generateImplementation(th, ctx);
    }
    ctx.getCompiler()
        .getMainCompiler()
        .generateMainAndInit(cfg, ThingMLHelpers.findContainingModel(cfg), ctx);

    // GENERATE A DOCKERFILE IF ASKED
    ctx.getCompiler().getCfgBuildCompiler().generateDockerFile(cfg, ctx);

    ctx.getCompiler().getCfgBuildCompiler().generateBuildScript(cfg, ctx);
    ctx.writeGeneratedCodeToFiles();
    ctx.generateNetworkLibs(cfg);
  }