use of org.osate.aadl2.NamedElement in project osate2 by osate.
the class AbstractAaxlHandler method actionBody.
protected final void actionBody(final IProgressMonitor monitor, final Element root) {
final Resource resource = root.eResource();
errManager = new AnalysisErrorReporterManager(getAnalysisErrorReporterFactory());
summaryReport = new StringBuffer();
// Root cannot be null (see above)
// init the context object. It is used by the lookup methods for initializing property references
context = root instanceof SystemInstance ? ((SystemInstance) root).getComponentImplementation() : root;
// Init the properties
notFound.clear();
initPropertyReferences();
initializeAction((NamedElement) root);
if (suppressErrorMessages() || !reportPropertyLookupErrors()) {
// Run the command (indirectly)
processAaxlAction(monitor, resource, root);
}
finalizeAction();
}
use of org.osate.aadl2.NamedElement in project osate2 by osate.
the class ErrorModelValidator method checkAssociationAppliesTo.
private void checkAssociationAppliesTo(final EMV2PropertyAssociation pa) {
final Property pn = pa.getProperty();
final EList<EMV2Path> appliesTo = pa.getEmv2Path();
if (appliesTo == null || appliesTo.size() == 0) {
Element element = pa.getOwner();
if (element instanceof NamedElement) {
final boolean applies = ((NamedElement) element).acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + ((NamedElement) element).getName());
// error(pa,
// "Property " + pa.getQualifiedName() +
// " does not apply to " + element.eClass().getName());
}
}
} else {
for (EMV2Path cna : appliesTo) {
EMV2PathElement path = cna.getEmv2Target();
if (path != null) {
// only the last value is interesting to us
final EMV2PathElement ph = EMV2Util.getLast(path);
NamedElement ne = ph.getNamedElement();
if (ne instanceof ErrorTypes) {
ErrorTypes et = (ErrorTypes) ne;
EObject prev = ph.eContainer();
if (prev instanceof EMV2PathElement) {
ne = ((EMV2PathElement) prev).getNamedElement();
boolean noMatch = false;
if (ne instanceof ErrorBehaviorState) {
TypeSet ts = ((ErrorBehaviorState) ne).getTypeSet();
noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
} else if (ne instanceof ErrorPropagation) {
String epname = EMV2Util.getPrintName((ErrorPropagation) ne);
EList<ErrorPropagation> eplist = EMV2Util.getContainingErrorModelSubclause(ne).getPropagations();
Boolean foundType = false;
for (ErrorPropagation ep : eplist) {
if (epname.equalsIgnoreCase(EMV2Util.getPrintName(ep))) {
TypeSet ts = ep.getTypeSet();
if (EMV2TypeSetUtil.contains(ts, et)) {
foundType = true;
break;
}
}
}
noMatch = !foundType;
} else if (ne instanceof ErrorEvent) {
TypeSet ts = ((ErrorEvent) ne).getTypeSet();
noMatch = ts != null && !EMV2TypeSetUtil.contains(ts, et);
}
if (noMatch) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " applies to refers to type " + EMV2Util.getPrintName(et) + " not contained in type set of error propagation " + EMV2Util.getPrintName(ne));
}
}
}
if (!Aadl2Util.isNull(ne)) {
final boolean applies = ph.getNamedElement().acceptsProperty(pn);
if (!applies) {
error(pa, "Property " + pa.getProperty().getQualifiedName() + " does not apply to " + EMV2Util.getPrintName(cna));
}
}
}
}
}
}
use of org.osate.aadl2.NamedElement in project osate2 by osate.
the class ErrorModelValidator method caseErrorModelSubclause.
@Check(CheckType.FAST)
public void caseErrorModelSubclause(ErrorModelSubclause subclause) {
if (EcoreUtil2.getContainerOfType(subclause, FeatureGroupType.class) != null) {
error("Error model subclauses are not permitted in feature group types.", EcoreUtil2.getContainerOfType(subclause, DefaultAnnexSubclause.class), Aadl2Package.eINSTANCE.getNamedElement_Name());
return;
}
checkSubclauseAssociationToClassifier(subclause);
checkDuplicateSubclause(subclause);
checkOnePropagationAndContainmentPoint(subclause);
Collection<NamedElement> names = EMV2Util.getAllNamedElements(subclause);
List<NamedElement> doubles = EMV2Util.findDoubleNamedElementsInList(names);
for (NamedElement namedElement : doubles) {
if (!(namedElement instanceof ErrorPropagation)) {
error(namedElement, "Subclause has more than one element with the name '" + namedElement.getName() + "'.");
}
}
Collection<ErrorPropagation> ins = EMV2Util.getAllIncomingErrorPropagations(subclause.getContainingClassifier());
for (ErrorPropagation errorPropagation : ins) {
checkTypePropagationAndContainment(errorPropagation);
}
Collection<ErrorPropagation> outs = EMV2Util.getAllOutgoingErrorPropagations(subclause.getContainingClassifier());
for (ErrorPropagation errorPropagation : outs) {
checkTypePropagationAndContainment(errorPropagation);
}
checkUseBehavior(subclause);
}
use of org.osate.aadl2.NamedElement in project osate2 by osate.
the class EMV2Util method findDoubleNamedElementsInList.
/**
* Check to see if all NamedElements in the Elist have a unique name.
* Do not account for Error Propagations. They are checked separately.
* this method handles error propagations as well, using their printname.
*
* list can contain object that are not NamedElements.
* @param el EList or NamedElements or other objects
* @return EList of NameElements that are defining a previously defined name
*/
public static List<NamedElement> findDoubleNamedElementsInList(Collection<?> el) {
List<NamedElement> result = new ArrayList<NamedElement>();
final Set<String> seen = new HashSet<String>();
if (el != null) {
for (final Object obj : el) {
if (obj instanceof NamedElement && !(obj instanceof ErrorPropagation)) {
final NamedElement lit = (NamedElement) obj;
String name = lit.getName();
if (name != null && !name.isEmpty()) {
name = name.toLowerCase();
if (!seen.add(name)) {
result.add(lit);
}
}
}
}
}
return result;
}
use of org.osate.aadl2.NamedElement in project osate2 by osate.
the class EMV2Util method getContainmentErrorType.
/**
* get error type (last element of containment path, if present
* Otherwise return null
* @param containedNamedElement Containment path
* @return EList<ErrorType>
*/
public static ErrorType getContainmentErrorType(ContainedNamedElement containedNamedElement) {
EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
if (!cpes.isEmpty()) {
ContainmentPathElement cpe = cpes.get(cpes.size() - 1);
NamedElement appliestome = cpe.getNamedElement();
if (appliestome instanceof ErrorType) {
return ((ErrorType) appliestome);
}
}
return null;
}
Aggregations