### Eclipse Workspace Patch 1.0 #P org.eclipse.uml2.uml Index: src/org/eclipse/uml2/uml/internal/operations/BehaviorOperations.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/BehaviorOperations.java,v retrieving revision 1.9 diff -u -r1.9 BehaviorOperations.java --- src/org/eclipse/uml2/uml/internal/operations/BehaviorOperations.java 5 Jan 2006 22:43:25 -0000 1.9 +++ src/org/eclipse/uml2/uml/internal/operations/BehaviorOperations.java 28 Mar 2006 22:22:28 -0000 @@ -12,17 +12,20 @@ */ package org.eclipse.uml2.uml.internal.operations; +import java.util.Iterator; import java.util.Map; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; - +import org.eclipse.emf.common.util.EList; import org.eclipse.uml2.uml.Behavior; -import org.eclipse.uml2.uml.UMLPackage; - +import org.eclipse.uml2.uml.BehavioralFeature; import org.eclipse.uml2.uml.BehavioredClassifier; - +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Parameter; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.UMLPlugin; import org.eclipse.uml2.uml.util.UMLValidator; /** @@ -62,30 +65,43 @@ * The parameters of the behavior must match the parameters of the implemented behavioral feature. * true * - * @generated + * @generated NOT */ public static boolean validateParametersMatch(Behavior behavior, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + boolean result = true; + BehavioralFeature feature = behavior.getSpecification(); + if (feature == null) { + return result; + } + EList featureParameters = feature.getOwnedParameters(); + EList behaviorParameters = behavior.getOwnedParameters(); + if (featureParameters.size() != behaviorParameters.size()) { + result = false; + } else { + Iterator parmIter = featureParameters.iterator(); + Iterator otherIter = behaviorParameters.iterator(); + while (parmIter.hasNext() && otherIter.hasNext()) { + if (!ParameterOperations.conformsTo( + (Parameter) parmIter.next(), (Parameter) otherIter.next())) { + result = false; + break; + } + } + } + if (!result) { if (diagnostics != null) { - diagnostics - .add(new BasicDiagnostic( - Diagnostic.ERROR, - UMLValidator.DIAGNOSTIC_SOURCE, - UMLValidator.BEHAVIOR__PARAMETERS_MATCH, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validateParametersMatch", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(behavior, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{behavior})); + diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.BEHAVIOR__PARAMETERS_MATCH, UMLPlugin.INSTANCE + .getString("_UI_Behavior_ParametersMatch_diagnostic", //$NON-NLS-1$ + getMessageSubstitutions(context, behavior)), + new Object[]{behavior})); } - return false; } - return true; + return result; } + /** * @@ -94,29 +110,32 @@ * The implemented behavioral feature must be a feature (possibly inherited) of the context classifier of the behavior. * true * - * @generated + * @generated NOT */ public static boolean validateFeatureOfContextClassifier(Behavior behavior, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { - if (diagnostics != null) { - diagnostics - .add(new BasicDiagnostic( - Diagnostic.ERROR, - UMLValidator.DIAGNOSTIC_SOURCE, - UMLValidator.BEHAVIOR__FEATURE_OF_CONTEXT_CLASSIFIER, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validateFeatureOfContextClassifier", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(behavior, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{behavior})); + boolean result = true; + BehavioralFeature feature = behavior.getSpecification(); + Classifier contextClassifier = behavior.getContext(); + if (feature != null) { + result = (contextClassifier != null) + && contextClassifier.allFeatures().contains(feature); + if (!result) { + if (diagnostics != null) { + diagnostics + .add(new BasicDiagnostic( + Diagnostic.WARNING, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.BEHAVIOR__FEATURE_OF_CONTEXT_CLASSIFIER, + UMLPlugin.INSTANCE + .getString( + "_UI_Behavior_FeatureOfContextClassifier_diagnostic", //$NON-NLS-1$ + getMessageSubstitutions(context, behavior)), + new Object[]{behavior})); + } } - return false; } - return true; + return result; } /** @@ -182,7 +201,7 @@ } return true; } - + /** * * @@ -192,5 +211,6 @@ return (BehavioredClassifier) getOwningElement(behavior, UMLPackage.Literals.BEHAVIORED_CLASSIFIER, false); } + } // BehaviorOperations \ No newline at end of file Index: src/org/eclipse/uml2/uml/internal/operations/InterfaceOperations.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/InterfaceOperations.java,v retrieving revision 1.8 diff -u -r1.8 InterfaceOperations.java --- src/org/eclipse/uml2/uml/internal/operations/InterfaceOperations.java 7 Mar 2006 20:25:18 -0000 1.8 +++ src/org/eclipse/uml2/uml/internal/operations/InterfaceOperations.java 28 Mar 2006 22:22:28 -0000 @@ -12,20 +12,20 @@ */ package org.eclipse.uml2.uml.internal.operations; +import java.util.Iterator; import java.util.Map; import org.eclipse.emf.common.util.BasicDiagnostic; import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; - import org.eclipse.emf.common.util.EList; - +import org.eclipse.uml2.uml.Feature; import org.eclipse.uml2.uml.Interface; - import org.eclipse.uml2.uml.Operation; import org.eclipse.uml2.uml.Property; import org.eclipse.uml2.uml.Type; - +import org.eclipse.uml2.uml.UMLPlugin; +import org.eclipse.uml2.uml.VisibilityKind; import org.eclipse.uml2.uml.util.UMLValidator; /** @@ -63,29 +63,30 @@ * The visibility of all features owned by an interface must be public. * self.feature->forAll(f | f.visibility = #public) * - * @generated + * @generated NOT */ public static boolean validateVisibility(Interface interface_, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + boolean result = true; + for (Iterator iter = interface_.getFeatures().iterator(); iter + .hasNext();) { + Feature feature = (Feature) iter.next(); + if (feature.getVisibility() != VisibilityKind.PUBLIC_LITERAL) { + result = false; + break; + } + } + if (!result) { if (diagnostics != null) { - diagnostics - .add(new BasicDiagnostic( - Diagnostic.ERROR, - UMLValidator.DIAGNOSTIC_SOURCE, - UMLValidator.INTERFACE__VISIBILITY, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validateVisibility", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(interface_, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{interface_})); + diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.INTERFACE__VISIBILITY, UMLPlugin.INSTANCE + .getString("_UI_Interface_Visibility_diagnostic", //$NON-NLS-1$ + getMessageSubstitutions(context, interface_)), + new Object[]{interface_})); } - return false; } - return true; + return result; } /** Index: src/org/eclipse/uml2/uml/internal/operations/PortOperations.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PortOperations.java,v retrieving revision 1.10 diff -u -r1.10 PortOperations.java --- src/org/eclipse/uml2/uml/internal/operations/PortOperations.java 27 Jan 2006 04:55:56 -0000 1.10 +++ src/org/eclipse/uml2/uml/internal/operations/PortOperations.java 28 Mar 2006 22:22:28 -0000 @@ -18,18 +18,17 @@ import org.eclipse.emf.common.util.Diagnostic; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EList; - import org.eclipse.emf.common.util.UniqueEList; import org.eclipse.emf.ecore.InternalEObject; - import org.eclipse.uml2.common.util.UnionEObjectEList; +import org.eclipse.uml2.uml.AggregationKind; import org.eclipse.uml2.uml.BehavioredClassifier; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Interface; import org.eclipse.uml2.uml.Port; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLPackage; - +import org.eclipse.uml2.uml.UMLPlugin; import org.eclipse.uml2.uml.util.UMLValidator; /** @@ -102,25 +101,18 @@ * Port.aggregation must be composite. * true * - * @generated + * @generated NOT */ public static boolean validatePortAggregation(Port port, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + if (port.getAggregation() != AggregationKind.COMPOSITE_LITERAL) { if (diagnostics != null) { - diagnostics - .add(new BasicDiagnostic( - Diagnostic.ERROR, - UMLValidator.DIAGNOSTIC_SOURCE, - UMLValidator.PORT__PORT_AGGREGATION, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validatePortAggregation", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(port, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{port})); + diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.PORT__PORT_AGGREGATION, UMLPlugin.INSTANCE + .getString("_UI_Class_PortAggregation_diagnostic", //$NON-NLS-1$ + getMessageSubstitutions(context, port)), + new Object[]{port})); } return false; } @@ -166,25 +158,19 @@ * A defaultValue for port cannot be specified when the type of the Port is an Interface * true * - * @generated + * @generated NOT */ public static boolean validateDefaultValue(Port port, DiagnosticChain diagnostics, Map context) { - // TODO: implement this method - // -> specify the condition that violates the invariant - // -> verify the details of the diagnostic, including severity and message - // Ensure that you remove @generated or mark it @generated NOT - if (false) { + + if ((port.getType() instanceof Interface) && (port.getDefaultValue() != null)) { if (diagnostics != null) { - diagnostics - .add(new BasicDiagnostic( - Diagnostic.ERROR, - UMLValidator.DIAGNOSTIC_SOURCE, - UMLValidator.PORT__DEFAULT_VALUE, - org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE - .getString( - "_UI_GenericInvariant_diagnostic", new Object[]{"validateDefaultValue", org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(port, context)}), //$NON-NLS-1$ //$NON-NLS-2$ - new Object[]{port})); + diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, + UMLValidator.DIAGNOSTIC_SOURCE, + UMLValidator.PORT__DEFAULT_VALUE, UMLPlugin.INSTANCE + .getString("_UI_Port_DefaultValue_diagnostic", //$NON-NLS-1$ + getMessageSubstitutions(context, port)), + new Object[]{port})); } return false; } Index: src/org/eclipse/uml2/uml/internal/operations/ParameterOperations.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/ParameterOperations.java,v retrieving revision 1.15 diff -u -r1.15 ParameterOperations.java --- src/org/eclipse/uml2/uml/internal/operations/ParameterOperations.java 9 Mar 2006 21:30:34 -0000 1.15 +++ src/org/eclipse/uml2/uml/internal/operations/ParameterOperations.java 28 Mar 2006 22:22:28 -0000 @@ -347,5 +347,26 @@ UMLPackage.Literals.LITERAL_NULL); } } + + /** + * + * + * @generated NOT + */ + public static boolean conformsTo(Parameter a, Parameter b) { + if ((a.getType() == null) || (b.getType() == null)) { + return false; + } + if (!a.getType().conformsTo(b.getType())) { + return false; + } + if (!(a.includesMultiplicity(b) && b.includesMultiplicity(a))) { + return false; + } + if (a.isOrdered() != b.isOrdered()) { + return false; + } + return true; + } } // ParameterOperations \ No newline at end of file Index: src/org/eclipse/uml2/uml/internal/impl/ParameterImpl.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/impl/ParameterImpl.java,v retrieving revision 1.27 diff -u -r1.27 ParameterImpl.java --- src/org/eclipse/uml2/uml/internal/impl/ParameterImpl.java 15 Mar 2006 19:33:59 -0000 1.27 +++ src/org/eclipse/uml2/uml/internal/impl/ParameterImpl.java 28 Mar 2006 22:22:28 -0000 @@ -658,6 +658,15 @@ public String getDefault() { return ParameterOperations.getDefault(this); } + + /** + * + * + * @generated NOT + */ + public boolean conformsTo(Parameter otherParameter) { + return ParameterOperations.conformsTo(this, otherParameter); + } /** * Index: plugin.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.uml2/plugins/org.eclipse.uml2.uml/plugin.properties,v retrieving revision 1.5 diff -u -r1.5 plugin.properties --- plugin.properties 28 Mar 2006 18:26:14 -0000 1.5 +++ plugin.properties 28 Mar 2006 22:22:24 -0000 @@ -128,6 +128,7 @@ _UI_Package_ElementsPublicOrPrivate_diagnostic = Element ''{0}'', owned by package ''{1}'', has visibility that is neither public nor private. + _UI_Property_SubsettingContextConforms_diagnostic = The context of the subsetting property ''{0}'' does not conform to the context of subsetted property ''{1}''. _UI_Property_NavigableReadOnly_diagnostic = Non-navigable property ''{0}'' is marked as read-only. _UI_Property_DerivedUnionIsDerived_diagnostic = Derived union ''{0}'' is not derived. @@ -140,7 +141,16 @@ _UI_RedefinableElement_RedefinitionConsistent_diagnostic = Redefining element ''{0}'' is not consistent with redefined element ''{1}''. _UI_RedefinableElement_RedefinitionContextValid_diagnostic = None of the redefinition contexts of redefining element ''{0}'' is a specialization of at least one of the redefinition contexts for redefined element ''{1}''. +_UI_Interface_Visibility_diagnostic = The interface ''{0}''has at least one feature which is not public. + _UI_UseCase_MustHaveName_diagnostic = Use case ''{0}'' must have a name. _UI_UseCase_BinaryAssociations_diagnostic = Use case ''{0}'' can only be involved in binary associations. _UI_UseCase_NoAssociationToUseCase_diagnostic = Use case ''{0}'' is involved in an association with another use case ''{1}'' having the same subject. _UI_UseCase_CannotIncludeSelf_diagnostic = Use case ''{0}'' cannot include itself. + + +_UI_Behavior_ParametersMatch_diagnostic = One or more parameters of the behavior ''{0}'' do not match. +_UI_Behavior_FeatureOfContextClassifier_diagnostic = The behavioral feature ''{0}'' must be a feature of the context classifier of the behavior. + +_UI_Port_PortAggregation_diagnostic = Port ''{0}'' must have composite aggregation kind. +_UI_Port_DefaultValue_diagnostic = Port ''{0}'' must not have a default value if it is typed by an interface.