TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
101 stars 32 forks source link

Not retrieving all types in some helpers? #177

Closed jakhog closed 7 years ago

jakhog commented 7 years ago

While going through some helper functions, it seems that we might not be retrieving all types in some of them. E.g. in allUsedTypes here:

for(Property p : ThingHelper.allPropertiesInDepth(thing)) {
    if (EcoreUtil.equals(p.getTypeRef().getType(), t))
        result.add(t);
    }
    for(Message m : ThingMLHelpers.allMessages(thing)) {
        for(Parameter p : m.getParameters()) {
            if (EcoreUtil.equals(p.getTypeRef().getType(), t)) {
                result.add(t);
            }
        }
    }
}

But then we are missing the types for the variables in actions and functions right?

Also might be a problem in allUsedSimpleTypes, allObjectTypes.

brice-morin commented 7 years ago

Yes, I guess allPropertiesInDepth is limited to property/var declared in things and states, but does not go deeper. We should also look at functions params, like we do for messages, but also in the detailed code for local vars, etc, as you mention. We have some utilities to find all expressions or all actions of a given type, which can help e.g. ThingMLHelpers.getAllExpressions(t, PropertyReference.class) to get all PropertyReference anywhere in thing t (it will go recursively down to eveything that is contained directly or indirectly by t)

brice-morin commented 7 years ago

e.g. you should look for all actions of type LocalVariable in addition to the rest something like: ActionHelper.getAllActions(t, LocalVariable.class)