use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.
the class GroupPrototypeHolderItemProvider method getImage.
/**
* This returns GroupPrototypeHolder.gif.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
@Override
public Object getImage(Object object) {
String imgFile = BehaviorElementItemProvider.OSATE_IMG_PATH;
PrototypeHolder holder = (PrototypeHolder) object;
PrototypeBinding pb = holder.getPrototypeBinding();
if (pb != null) {
FeatureType type = FeatureType.ABSTRACT_FEATURE;
if (pb instanceof ComponentPrototypeBinding) {
type = AadlBaUtils.getCompPrototypeType((ComponentPrototypeBinding) pb);
} else if (pb instanceof FeatureGroupPrototypeBinding) {
type = FeatureType.FEATURE_GROUP_PROTOTYPE;
} else if (pb instanceof FeaturePrototypeBinding) {
type = AadlBaUtils.getFeatPrototypeType((FeaturePrototypeBinding) pb);
}
switch(type) {
case FEATURE_GROUP_PROTOTYPE:
{
imgFile += "FeatureGroup";
break;
}
case THREAD_GROUP_PROTOTYPE:
{
imgFile += "ThreadGroup";
break;
}
case REQUIRES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
case PROVIDES_SUBPROGRAM_GROUP_ACCESS_PROTOTYPE:
case SUBPROGRAM_GROUP_PROTOTYPE:
{
imgFile += "Subprogram";
break;
}
default:
imgFile = "full/obj16/IfStatement";
}
}
return overlayImage(object, getResourceLocator().getImage(imgFile));
}
use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.
the class AadlBaTypeChecker method subprogramTypeCheck.
// Gets subprogram type binded to the given subprogram call action.
// On error, reports error and returns null.
private Classifier subprogramTypeCheck(CommAction comAct) {
Element el = null;
if (comAct.getReference() != null) {
el = comAct.getReference().getOsateRef();
} else {
el = comAct.getQualifiedName().getOsateRef();
}
Classifier result = null;
String errorMsg = null;
if (el instanceof ComponentPrototype) {
ComponentPrototype cp = (ComponentPrototype) el;
if (cp instanceof SubprogramPrototype) {
ComponentClassifier cc = cp.getConstrainingClassifier();
if (cc != null && cc instanceof SubprogramType) {
result = cc;
} else {
errorMsg = " is not a defined subprogram prototype";
result = null;
}
} else {
errorMsg = " is not an subprogram prototype";
result = null;
}
} else if (// Always after ComponentPrototype
el instanceof CalledSubprogram) {
// case.
result = getSubprogramType((CalledSubprogram) el);
} else if (el instanceof ComponentPrototypeBinding) {
ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) el;
// Takes the last binding.
ComponentPrototypeActual cpa = cpb.getActuals().get(cpb.getActuals().size() - 1);
if (cpa.getSubcomponentType() instanceof SubprogramType) {
result = (SubprogramType) cpa.getSubcomponentType();
} else {
errorMsg = " is not an subprogram prototype";
result = null;
}
} else // Error case : the binded object is not an subprogram.
{
errorMsg = "is not subprogram";
result = null;
}
// Error reporting.
if (result == null && errorMsg != null) {
String subprogramName = unparseReference(comAct.getReference());
reportError(comAct, '\'' + subprogramName + '\'' + errorMsg);
}
return result;
}
use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.
the class AadlBaUtils method getDataClassifier.
/**
* Returns the DataClassifier object associated to the given List of PrototypeBinging objects.
*
* @param prototypeBindings the list of PrototypeBinging object
* @param dp the DataPrototype searched for in prototypeBindings
* @return the DataClassifier object (null if not found)
*/
private static DataClassifier getDataClassifier(List<PrototypeBinding> prototypeBindings, DataPrototype dp) {
for (PrototypeBinding pb : prototypeBindings) {
if (pb instanceof ComponentPrototypeBinding && pb.getFormal().equals(dp)) {
ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) pb;
ComponentPrototypeActual cpa = cpb.getActuals().get(cpb.getActuals().size() - 1);
if (cpa.getSubcomponentType() instanceof DataClassifier) {
return (DataClassifier) cpa.getSubcomponentType();
}
}
}
return null;
}
use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.
the class AadlBaUtils method prototypeBindingResolver.
/**
* Resolves the given prototype binding by returning the binded classifier
* It returns {@code null} if the given prototype binding is not defined.
*
* @param pb the given prototype binding
* @return the binded classifier or {@code null}
*/
public static Classifier prototypeBindingResolver(PrototypeBinding pb) {
Classifier result = null;
if (pb instanceof ComponentPrototypeBinding) {
ComponentPrototypeBinding cpb;
cpb = (ComponentPrototypeBinding) pb;
// Takes the last binding.
ComponentPrototypeActual cpa = cpb.getActuals().get(cpb.getActuals().size() - 1);
result = (Classifier) cpa.getSubcomponentType();
} else if (pb instanceof FeaturePrototypeBinding) {
FeaturePrototypeBinding fpb;
fpb = (FeaturePrototypeBinding) pb;
FeaturePrototypeActual fpa = fpb.getActual();
if (fpa instanceof AccessSpecification) {
result = ((AccessSpecification) fpa).getClassifier();
} else if (fpa instanceof PortSpecification) {
result = ((PortSpecification) fpa).getClassifier();
} else {
// Reports error.
String errorMsg = "prototypeBindingResolver : " + fpa.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
} else if (pb instanceof FeatureGroupPrototypeBinding) {
FeatureGroupPrototypeBinding fgpb = (FeatureGroupPrototypeBinding) pb;
result = (FeatureGroupType) fgpb.getActual().getFeatureType();
} else {
// Reports error.
String errorMsg = "prototypeBindingResolver : " + pb.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
return result;
}
use of org.osate.aadl2.ComponentPrototypeBinding in project osate2 by osate.
the class Aadl2Utils method getBindedFeature.
private static Feature getBindedFeature(List<PrototypeBinding> bindings, Feature f) {
FeatureClassifier cl = f.getFeatureClassifier();
if ((!(cl instanceof DataPrototype)) || bindings == null || bindings.isEmpty()) {
return f;
}
if ((f instanceof EventPort) || (f instanceof AbstractFeature)) {
return f;
}
DataPrototype proto = (DataPrototype) cl;
for (PrototypeBinding b : bindings) {
if (!(b instanceof ComponentPrototypeBinding)) {
continue;
}
ComponentPrototypeBinding cpb = (ComponentPrototypeBinding) b;
Prototype p = b.getFormal();
if (p.getName().equals(proto.getName())) {
List<ComponentPrototypeActual> actuals = cpb.getActuals();
if (actuals != null && !actuals.isEmpty()) {
ComponentPrototypeActual actual = actuals.get(0);
SubcomponentType st = actual.getSubcomponentType();
if (!(st instanceof DataClassifier)) {
continue;
}
DataClassifier dc = (DataClassifier) st;
return setFeatureClassifier(f, dc);
}
}
}
return f;
}
Aggregations