示例#1
0
 public static ArrayList<Message> findMessage(Thing thing, String name, boolean fuzzy) {
   ArrayList<Message> result = new ArrayList<Message>();
   for (Message msg : allMessages(thing)) {
     if (msg.getName().startsWith(name)) {
       if (fuzzy) result.add(msg);
       else if (msg.getName().equals(name)) result.add(msg);
     }
   }
   return result;
 }
示例#2
0
 public static ArrayList<Message> findOutgoingMessage(Port port, String name, boolean fuzzy) {
   ArrayList<Message> result = new ArrayList<Message>();
   for (Message t : port.getSends()) {
     if (t.getName().startsWith(name)) {
       if (fuzzy) result.add(t);
       else if (t.getName().equals(name)) result.add(t);
     }
   }
   return result;
 }
示例#3
0
 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);
  }