Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ class KerMLValidator extends AbstractKerMLValidator {

@Check
def checkFeature(Feature f){
// TODO: Remove?
val types = f.type;
// Note: Use utility method to ensure types are not filtered out by redefinitions of getType.
val types = FeatureUtil.getAllTypesOf(f);
if (types !== null && types.isEmpty)
error(INVALID_FEATURE_HAS_TYPE_MSG, f, SysMLPackage.eINSTANCE.feature_Type, INVALID_FEATURE_HAS_TYPE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,19 @@ package 'ValueProperty Example' {
port p: P;
}
part def Vehicle {
//* XPECT errors ---
"An attribute must be typed by attribute definitions." at "attribute a : A;"
"Features must have at least one type" at "attribute a : A;"
--- */
// XPECT errors ---> "An attribute must be typed by attribute definitions." at "attribute a : A;"
attribute a : A;
// XPECT errors --> "An attribute must be typed by attribute definitions." at "attribute b : A::a;"
// XPECT warnings --> "Duplicate of inherited member name 'self' from DataValue, Part" at "attribute b : A::a;"
attribute b : A::a;
//* XPECT errors ---
"An attribute must be typed by attribute definitions." at "attribute s : P;"
"Features must have at least one type" at "attribute s : P;"
--- */
// XPECT errors ---> "An attribute must be typed by attribute definitions." at "attribute s : P;"
attribute s : P;
// XPECT errors --> "An attribute must be typed by attribute definitions." at "attribute un : A::p;"
// XPECT warnings --> "Duplicate of inherited member name 'self' from DataValue, Port" at "attribute un : A::p;"
attribute un: A::p;
//* XPECT errors ---
"An attribute must be typed by attribute definitions." at "attribute n: AB;"
"Features must have at least one type" at "attribute n: AB;"
--- */
// XPECT errors ---> "An attribute must be typed by attribute definitions." at "attribute n: AB;"
attribute n: AB;
}
}
connection def AB {
end : A;
end : A;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,18 @@ package pkg {
"Duplicate of inherited member name 'done' from Action, Part" at "calc f2 : A;"
--- */
calc f2: A;
/* XPECT errors ---
"A calculation must be typed by one calculation definition." at "calc f3 : f2;"
"Features must have at least one type" at "calc f3 : f2;"
--- */
// XPECT errors ---> "A calculation must be typed by one calculation definition." at "calc f3 : f2;"
//* XPECT warnings ---
"Duplicate of inherited member name 'self' from Calculation, Part" at "calc f3 : f2;"
"Duplicate of inherited member name 'start' from Action, Part" at "calc f3 : f2;"
"Duplicate of inherited member name 'done' from Action, Part" at "calc f3 : f2;"
--- */
calc f3: f2;
/* XPECT errors ---
"A calculation must be typed by one calculation definition." at "calc f4 : A::f1;"
"Features must have at least one type" at "calc f4 : A::f1;"
--- */
// XPECT errors ---> "A calculation must be typed by one calculation definition." at "calc f4 : A::f1;"
calc f4: A::f1;
/* XPECT errors ---
"A calculation must be typed by one calculation definition." at "calc f5 : B;"
--- */
// XPECT errors ---> "A calculation must be typed by one calculation definition." at "calc f5 : B;"
calc f5: B;
/* XPECT errors ---
"A calculation must be typed by one calculation definition." at "calc f6 : bb;"
--- */
// XPECT errors ---> "A calculation must be typed by one calculation definition." at "calc f6 : bb;"
calc f6: bb;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ package EnumerationUsage_invalid {
attribute a3 : E, EE;

enum e1 : E;
//* XPECT errors ---
"An enumeration must be typed by one enumeration definition." at "enum e2 : A;"
"Features must have at least one type" at "enum e2 : A;"
---
*/
// XPECT errors ---> "An enumeration must be typed by one enumeration definition." at "enum e2 : A;"
enum e2 : A;
// XPECT errors --> "An enumeration must be typed by one enumeration definition." at "enum e3 : E, EE;"
enum e3 : E, EE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ package 'Interface Example' {
interface opposite : Fuel connect
x ::> tankAssy.fuelTankPort to
y ::> eng.engineFuelPort;
//*XPECT errors ---
"An interface must be typed by interface definitions." at "interface opposite1 : fi connect eng.engineFuelPort to tankAssy.fuelTankPort;"
"Features must have at least one type" at "interface opposite1 : fi connect eng.engineFuelPort to tankAssy.fuelTankPort;"
---*/
//XPECT errors ---> "An interface must be typed by interface definitions." at "interface opposite1 : fi connect eng.engineFuelPort to tankAssy.fuelTankPort;"
interface opposite1 : fi connect eng.engineFuelPort to tankAssy.fuelTankPort;
interface bad {
//XPECT errors --> "An interface end must be a port." at "end part ::> tankAssy.fuel;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ package pkg {
// XPECT errors ---> "An item must be typed by item definitions." at "item i5: PartDef::aPort;"
// XPECT warnings --> "Duplicate of inherited member name 'self' from Item, Port" at "item i5: PartDef::aPort;"
item i5: PartDef::aPort;
/* XPECT errors ---
"An item must be typed by item definitions." at "item i6: PartDef::aPart;"
"Features must have at least one type" at "item i6: PartDef::aPart;"
--- */
// XPECT errors ---> "An item must be typed by item definitions." at "item i6: PartDef::aPart;"
item i6: PartDef::aPart;
// XPECT errors --> "An item must be typed by item definitions." at "item i7: PartDef, AttDef;"
// XPECT warnings --> "Duplicate of inherited member name 'self' from DataValue, Part" at "item i7: PartDef, AttDef;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ package pkg {
// XPECT errors --> "A part must be typed by item definitions." at "part p5: PartDef::aPort;"
// XPECT warnings --> "Duplicate of inherited member name 'self' from Part, Port" at "part p5: PartDef::aPort;"
part p5: PartDef::aPort;
//* XPECT errors ---
"A part must be typed by item definitions." at "part p6: PartDef::aPart;"
"Features must have at least one type" at "part p6: PartDef::aPart;"
--- */
// XPECT errors ---> "A part must be typed by item definitions." at "part p6: PartDef::aPart;"
part p6: PartDef::aPart;
// XPECT errors --> "A part must be typed by item definitions." at "part p7: PartDef, AttDef;"
// XPECT warnings --> "Duplicate of inherited member name 'self' from DataValue, Part" at "part p7: PartDef, AttDef;"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//*
XPECT_SETUP org.omg.sysml.xpect.tests.validation.invalid.SysMLTests
ResourceSet {
ThisFile {}
File {from ="/library.kernel/Base.kerml"}
File {from ="/library.kernel/Occurrences.kerml"}
File {from ="/library.kernel/Objects.kerml"}
File {from ="/library.kernel/Performances.kerml"}
File {from ="/library.systems/Items.sysml"}
File {from ="/library.systems/Parts.sysml"}
File {from ="/library.systems/Actions.sysml"}
}
Workspace {
JavaProject {
SrcFolder {
ThisFile {}
File {from ="/library.kernel/Base.kerml"}
File {from ="/library.kernel/Occurrences.kerml"}
File {from ="/library.kernel/Objects.kerml"}
File {from ="/library.kernel/Performances.kerml"}
File {from ="/library.systems/Items.sysml"}
File {from ="/library.systems/Parts.sysml"}
File {from ="/library.systems/Actions.sysml"}
}
}
}
END_SETUP
*/
package UsageDefinition_invalid {
attribute def A;
attribute a;
// XPECT errors ---> "A usage must be typed by definitions." at "ref a1 : a, A;"
ref a1 : a, A;
// XPECT errors ---> "A usage must be typed by definitions." at "ref a2 : a;"
ref a2 : a;
// XPECT errors ---> "An attribute must be typed by attribute definitions." at "attribute a3 : a;"
attribute a3 : a;

item def I;
item i;
// XPECT errors ---> "A usage must be typed by definitions." at "ref i1 : i, I;"
ref i1 : i, I;
// XPECT errors ---> "A usage must be typed by definitions." at "ref i2 : i;"
ref i2 : i;
// XPECT errors ---> "An item must be typed by item definitions." at "item i3 : i;"
item i3 : i;

part def P;
part p;
// XPECT errors ---> "A usage must be typed by definitions." at "ref p1 : p, P;"
ref p1 : p, P;
// XPECT errors ---> "A usage must be typed by definitions." at "ref p2 : p;"
ref p2 : p;
// XPECT errors ---> "A part must be typed by item definitions." at "part p3 : p;"
part p3 : p;

action def Ac;
action ac;
// XPECT errors ---> "A usage must be typed by definitions." at "ref ac1 : ac, Ac;"
ref ac1 : ac, Ac;
// XPECT errors ---> "A usage must be typed by definitions." at "ref ac2 : ac;"
ref ac2 : ac;
// XPECT errors ---> "An action must be typed by action definitions." at "action ac3 : ac;"
action ac3 : ac;
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import org.omg.sysml.lang.sysml.FlowUsage
import org.omg.sysml.lang.sysml.Relationship
import org.omg.sysml.util.FeatureUtil
import org.omg.sysml.util.UsageUtil
import org.omg.sysml.lang.sysml.Classifier

/**
* This class contains custom validation rules.
Expand All @@ -149,8 +150,10 @@ class SysMLValidator extends KerMLValidator {
public static val INVALID_DEFINITION_VARIATION_SPECIALIZATION = "validateDefinitionVariationSpecialization"
public static val INVALID_DEFINITION_VARIATION_SPECIALIZATION_MSG = "A variation must not specialize another variation."

public static val INVALID_USAGE_VARIATION_IS_ABSTRACT = "validateUsageVariationIsAbstract"
public static val INVALID_USAGE_VARIATION_IS_ABSTRACT_MSG = "A variation must be abstract."
public static val INVALID_USAGE_TYPE = "validateUsageType_"
public static val INVALID_USAGE_TYPE_MSG = "A usage must be typed by definitions."
public static val INVALID_USAGE_VARIATION_IS_ABSTRACT = "validateUsageVariationIsAbstract"
public static val INVALID_USAGE_VARIATION_IS_ABSTRACT_MSG = "A variation must be abstract."
public static val INVALID_USAGE_VARIATION_MEMBERSHIP = "validateUsageVariationMembership"
public static val INVALID_USAGE_VARIATION_MEMBERSHIP_MSG = "An owned usage of a variation must be a variant."
public static val INVALID_USAGE_VARIATION_SPECIALIZATION = "validateUsageVariationSpecialization"
Expand Down Expand Up @@ -476,6 +479,10 @@ class SysMLValidator extends KerMLValidator {

@Check
def checkUsage(Usage usage) {
// All types must be Classifiers
if (!(usage instanceof AttributeUsage || usage instanceof OccurrenceUsage))
checkAllTypes(usage, Classifier, INVALID_USAGE_TYPE_MSG, SysMLPackage.eINSTANCE.usage_Definition, INVALID_USAGE_TYPE)

// validateUsageIsReferential is satisfied automatically

if (usage.isVariation) {
Expand Down