use of org.osate.aadl2.impl.AccessImpl in project osate-plugin by sireum.
the class Visitor method buildFeature.
private org.sireum.hamr.ir.Feature buildFeature(FeatureInstance featureInst, List<String> path) {
final Feature f = featureInst.getFeature();
final List<String> currentPath = VisitorUtil.add(path, featureInst.getName());
org.sireum.hamr.ir.Classifier classifier = null;
if (f.getFeatureClassifier() != null) {
if (f.getFeatureClassifier() instanceof NamedElement) {
if (((NamedElement) f.getFeatureClassifier()).getQualifiedName() != null) {
classifier = factory.classifier(((NamedElement) f.getFeatureClassifier()).getQualifiedName().toString());
} else {
System.out.println("failing here");
}
} else {
throw new RuntimeException("Unexepcted classifier " + f.getFeatureClassifier() + " for feature " + featureInst.getQualifiedName());
}
}
final List<org.sireum.hamr.ir.Property> properties = featureInst.getOwnedPropertyAssociations().stream().map(pa -> buildProperty(pa, currentPath)).collect(Collectors.toList());
AadlASTJavaFactory.FeatureCategory category = null;
switch(featureInst.getCategory()) {
case ABSTRACT_FEATURE:
category = AadlASTJavaFactory.FeatureCategory.AbstractFeature;
break;
case BUS_ACCESS:
category = AadlASTJavaFactory.FeatureCategory.BusAccess;
break;
case DATA_ACCESS:
category = AadlASTJavaFactory.FeatureCategory.DataAccess;
break;
case DATA_PORT:
category = AadlASTJavaFactory.FeatureCategory.DataPort;
break;
case EVENT_PORT:
category = AadlASTJavaFactory.FeatureCategory.EventPort;
break;
case EVENT_DATA_PORT:
category = AadlASTJavaFactory.FeatureCategory.EventDataPort;
break;
case FEATURE_GROUP:
category = AadlASTJavaFactory.FeatureCategory.FeatureGroup;
break;
case PARAMETER:
category = AadlASTJavaFactory.FeatureCategory.Parameter;
break;
case SUBPROGRAM_ACCESS:
category = AadlASTJavaFactory.FeatureCategory.SubprogramAccess;
break;
case SUBPROGRAM_GROUP_ACCESS:
category = AadlASTJavaFactory.FeatureCategory.SubprogramAccessGroup;
break;
default:
throw new RuntimeException("Unexpected category: " + featureInst.getCategory());
}
switch(featureInst.getCategory()) {
case DATA_ACCESS:
case DATA_PORT:
case EVENT_DATA_PORT:
case PARAMETER:
if (f.getClassifier() instanceof DataClassifier) {
processDataType((DataClassifier) f.getClassifier());
}
// do nothing
default:
}
org.sireum.hamr.ir.Name identifier = factory.name(currentPath, VisitorUtil.buildPosInfo(featureInst.getInstantiatedObjects().get(0)));
final List<FeatureInstance> featureInstances = featureInst.getFeatureInstances();
if (featureInstances.isEmpty()) {
if (f instanceof AccessImpl) {
final AccessImpl accessImpl = (AccessImpl) f;
final AadlASTJavaFactory.AccessType accessType = accessImpl.getKind() == AccessType.PROVIDES ? AadlASTJavaFactory.AccessType.Provides : AadlASTJavaFactory.AccessType.Requires;
AadlASTJavaFactory.AccessCategory accessCategory = null;
switch(accessImpl.getCategory()) {
case BUS:
accessCategory = AadlASTJavaFactory.AccessCategory.Bus;
break;
case DATA:
accessCategory = AadlASTJavaFactory.AccessCategory.Data;
break;
case SUBPROGRAM:
accessCategory = AadlASTJavaFactory.AccessCategory.Subprogram;
break;
case SUBPROGRAM_GROUP:
accessCategory = AadlASTJavaFactory.AccessCategory.SubprogramGroup;
break;
case VIRTUAL_BUS:
accessCategory = AadlASTJavaFactory.AccessCategory.VirtualBus;
break;
}
return factory.featureAccess(identifier, category, classifier, accessType, accessCategory, properties, VisitorUtil.getUriFragment(featureInst));
} else if (f instanceof DirectedFeatureImpl) {
final AadlASTJavaFactory.Direction direction = handleDirection(featureInst.getDirection());
return factory.featureEnd(identifier, direction, category, classifier, properties, VisitorUtil.getUriFragment(featureInst));
} else {
throw new RuntimeException("Not expecting feature: " + featureInst);
}
} else {
final boolean isInverse = ((FeatureGroupImpl) f).isInverse();
final List<org.sireum.hamr.ir.Feature> features = featureInstances.stream().map(fi -> buildFeature(fi, currentPath)).collect(Collectors.toList());
return factory.featureGroup(identifier, features, isInverse, category, properties, VisitorUtil.getUriFragment(featureInst));
}
}
Aggregations