Search in sources :

Example 61 with NamedElement

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();
}
Also used : SystemInstance(org.osate.aadl2.instance.SystemInstance) Resource(org.eclipse.emf.ecore.resource.Resource) AnalysisErrorReporterManager(org.osate.aadl2.modelsupport.errorreporting.AnalysisErrorReporterManager)

Example 62 with NamedElement

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));
                    }
                }
            }
        }
    }
}
Also used : EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) ErrorBehaviorState(org.osate.xtext.aadl2.errormodel.errorModel.ErrorBehaviorState) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) Element(org.osate.aadl2.Element) EMV2PathElement(org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement) SConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.SConditionElement) ConditionElement(org.osate.xtext.aadl2.errormodel.errorModel.ConditionElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) ErrorTypes(org.osate.xtext.aadl2.errormodel.errorModel.ErrorTypes) EMV2Path(org.osate.xtext.aadl2.errormodel.errorModel.EMV2Path) BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ErrorEvent(org.osate.xtext.aadl2.errormodel.errorModel.ErrorEvent) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Property(org.osate.aadl2.Property) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Example 63 with NamedElement

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);
}
Also used : FeatureGroupType(org.osate.aadl2.FeatureGroupType) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) DefaultAnnexSubclause(org.osate.aadl2.DefaultAnnexSubclause) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 64 with NamedElement

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;
}
Also used : ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) InstanceObject(org.osate.aadl2.instance.InstanceObject) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) HashSet(java.util.HashSet)

Example 65 with NamedElement

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;
}
Also used : ErrorType(org.osate.xtext.aadl2.errormodel.errorModel.ErrorType) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

Property (org.osate.aadl2.Property)351 PropertyExpression (org.osate.aadl2.PropertyExpression)291 PropertyNotPresentException (org.osate.aadl2.properties.PropertyNotPresentException)236 NamedElement (org.osate.aadl2.NamedElement)229 BasicProperty (org.osate.aadl2.BasicProperty)90 ListValue (org.osate.aadl2.ListValue)63 EObject (org.eclipse.emf.ecore.EObject)50 UnitLiteral (org.osate.aadl2.UnitLiteral)48 Classifier (org.osate.aadl2.Classifier)46 ArrayList (java.util.ArrayList)45 TimeUnits (org.osate.aadl2.contrib.aadlproject.TimeUnits)41 PropertyAssociation (org.osate.aadl2.PropertyAssociation)38 ComponentClassifier (org.osate.aadl2.ComponentClassifier)37 Subcomponent (org.osate.aadl2.Subcomponent)35 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)32 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)32 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)31 ComponentImplementation (org.osate.aadl2.ComponentImplementation)30 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)28 Element (org.osate.aadl2.Element)28