Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 5 additions & 3 deletions kerml/src/examples/Simple Tests/Filtering.kerml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ package Filtering {

package UpperLevelApprovals {
private import DesignModel::**;
filter Annotations::ApprovalAnnotation::approved and
Annotations::ApprovalAnnotation::level > 1;
filter (as Annotations::ApprovalAnnotation).approved and
(as Annotations::ApprovalAnnotation).level > 1;

struct Test :> System;
}

package UpperLevelApprovals1 {
private import Annotations::**;
private import DesignModel::**[@Structure][approved and level > 1];
private import DesignModel::**[@Structure]
[(as Annotations::ApprovalAnnotation).approved and
(as Annotations::ApprovalAnnotation).level > 1];

struct Test :> System;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ package Import_Filtered {
}

package 'Mandatory Features_true_1' {
public import vehicle1_c1::**[Safety::isMandatory];
public import vehicle1_c1::**[(as Safety).isMandatory];
classifier b :> seatBelt;

// XPECT errors --> "Couldn't resolve reference to Classifier 'alarm'." at "alarm"
Expand All @@ -259,7 +259,7 @@ package Import_Filtered {
}

package 'Mandatory Features_true_2' {
public import vehicle1_c1::**[Safety::isMandatory == true];
public import vehicle1_c1::**[(as Safety).isMandatory == true];
classifier b :> seatBelt;

// XPECT errors --> "Couldn't resolve reference to Classifier 'alarm'." at "alarm"
Expand All @@ -281,7 +281,7 @@ package Import_Filtered {
}

package 'Mandatory Features_false' {
public import vehicle1_c1::**[Safety::isMandatory == false];
public import vehicle1_c1::**[(as Safety).isMandatory == false];
classifier j :> antilockBrakes;

// XPECT errors --> "Couldn't resolve reference to Classifier 'alarm'." at "alarm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ package MetadataFeatureTest {

function f { in x; return : ScalarValues::Boolean; }

// XPECT errors --> "Must be model-level evaluable" at "filter f(A::y);"
filter f(A::y);
// XPECT errors --> "Must be model-level evaluable" at "filter ~A::z;"
filter ~A::z;
// XPECT errors --> "Must be model-level evaluable" at "filter A::y->ControlFunctions::collect {in x; x};"
filter A::y->ControlFunctions::collect {in x; x};
// XPECT errors --> "Must be model-level evaluable" at "filter f((as A).y);"
filter f((as A).y);
// XPECT errors --> "Must be model-level evaluable" at "filter ~(as A).z;"
filter ~(as A).z;
// XPECT errors --> "Must be model-level evaluable" at "filter (as A).y->ControlFunctions::collect {in x; x};"
filter (as A).y->ControlFunctions::collect {in x; x};
// XPECT errors --> "Must have a Boolean result" at "filter new A(null, 1, "", false);"
filter new A(null, 1, "", false);

Expand All @@ -66,8 +66,8 @@ package MetadataFeatureTest {
// XPECT errors --> "Must be model-level evaluable" at "= ~3"
x = ~3;
y = "e";
// XPECT errors --> "Must be model-level evaluable" at "= f(A::y)"
z = f(A::y);
// XPECT errors --> "Must be model-level evaluable" at "= f((as A).y)"
z = f((as A).y);
u {
v = 1;
// XPECT errors --> "Must redefine an owning-type feature" at "bad;"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public void testFeatureReferenceEvaluation() throws Exception {

assertEquals(1, evaluateIntegerValue(instance,
checkAnnotatingFeature(instance, "Annotation", "x"),
"Annotation::a"));
"(as Annotation).a"));
}

@Test
Expand All @@ -385,7 +385,7 @@ public void testEnumeratedValueEvaluation() throws Exception {
assertEquals(instance.resolve("E::e"),
evaluateSingleValue(instance,
checkAnnotatingFeature(instance, "Annotation", "x"),
"Annotation::a"));
"(as Annotation).a"));
}

@Test
Expand All @@ -408,8 +408,8 @@ public void testIsTypeEvaluation() throws Exception {
"attribute x {@Annotation{a = E::e; b = 2;}}");

MetadataFeature feature = checkAnnotatingFeature(instance, "Annotation", "x");
assertTrue(evaluateBooleanValue(instance, feature, "Annotation::a istype E"));
assertTrue(evaluateBooleanValue(instance, feature, "Annotation::b istype ScalarValues::Integer"));
assertTrue(evaluateBooleanValue(instance, feature, "(as Annotation).a istype E"));
assertTrue(evaluateBooleanValue(instance, feature, "(as Annotation).b istype ScalarValues::Integer"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ package ElementFilterTest {
}

package 'Mandatory Features' {
public import vehicle1_c1::**[@Safety and PartInfo::isMandatory];
public import vehicle1_c1::**[@Safety and (as PartInfo).isMandatory];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ package Test {

calc def f { in x : ScalarValues::Boolean; }

// XPECT errors --> "Must be model-level evaluable" at "filter f(A::z);"
filter f(A::z);
// XPECT errors --> "Must be model-level evaluable" at "filter ~A::z;"
filter ~A::z;
// XPECT errors --> "Must be model-level evaluable" at "filter A::y->ControlFunctions::collect {in ref x; x};"
filter A::y->ControlFunctions::collect {in ref x; x};
// XPECT errors --> "Must be model-level evaluable" at "filter f((as A).z);"
filter f((as A).z);
// XPECT errors --> "Must be model-level evaluable" at "filter ~(as A).z;"
filter ~(as A).z;
// XPECT errors --> "Must be model-level evaluable" at "filter (as A).y->ControlFunctions::collect {in ref x; x};"
filter (as A).y->ControlFunctions::collect {in ref x; x};
// XPECT errors --> "Must have a Boolean result" at "filter new A(null, 1, "", false);"
filter new A(null, 1, "", false);

Expand All @@ -82,8 +82,8 @@ package Test {
// XPECT errors --> "Must be model-level evaluable" at "= ~3"
x = ~3;
y = E::e;
// XPECT errors --> "Must be model-level evaluable" at "= f(A::z)"
z = f(A::z);
// XPECT errors --> "Must be model-level evaluable" at "= f((as A).z)"
z = f((as A).z);
u {
v = 1;
// XPECT errors --> "Must redefine an owning-type feature" at "bad;"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021, 2022 Model Driven Solutions, Inc.
* Copyright (c) 2021, 2022, 2026 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -63,19 +63,11 @@ protected boolean isInFilterExpression() {
* @satisfies checkFeatureReferenceExpressionBindingConnector
*/
protected void addReferenceConnector() {
/*
* TODO: Update checkFeatureReferenceExpressionBindingConnector?
*
* OCL does not include !isInFilterExpression check.
*
*/
if (!isInFilterExpression()) {
FeatureReferenceExpression target = getTarget();
Feature referent = target.getReferent();
Feature result = target.getResult();
if (referent != null && result != null) {
addBindingConnector(referent, result);
}
FeatureReferenceExpression target = getTarget();
Feature referent = target.getReferent();
Feature result = target.getResult();
if (referent != null && result != null) {
addBindingConnector(referent, result);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ package SimpleVehicleModel{
package MandatorySafetyGroup {
/* Parts that contribute to safety AND are mandatory. */
public import vehicle_b::**;
filter @Safety and Safety::isMandatory;
filter (as Safety).isMandatory;
}
Comment thread
seidewitz marked this conversation as resolved.
}
package Views_Viewpoints{
Expand Down
2 changes: 1 addition & 1 deletion sysml/src/training/40. Filtering/Filtering Example-1.sysml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ package 'Filtering Example-1' {
package 'Mandatory Safety Features' {
/* Parts that contribute to safety AND are mandatory. */
public import vehicle::**;
filter @Safety and Safety::isMandatory;
filter @Safety and (as Safety).isMandatory;
}
}
2 changes: 1 addition & 1 deletion sysml/src/training/40. Filtering/Filtering Example-2.sysml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ package 'Filtering Example-2' {

package 'Mandatory Safety Features' {
/* Parts that contribute to safety AND are mandatory. */
public import vehicle::**[@Safety and Safety::isMandatory];
public import vehicle::**[@Safety and (as Safety).isMandatory];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ package '11b-Safety and Security Feaure Views' {

view vehicleMandatorySafetyFeatureView :> vehicleSafetyFeatureView {
expose vehicle::*::**;
filter Safety::isMandatory;
filter (as Safety).isMandatory;
}

view vehicleMandatorySafetyFeatureViewStandalone {
expose vehicle::**[@Safety and Safety::isMandatory];
expose vehicle::**[(as Safety).isMandatory];
render asElementTable;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ package '13b-Safety and Security Features Element Group-1' {
package 'Mandatory Safety Features' {
/* Parts that contribute to safety AND are mandatory. */
public import vehicle::**;
filter @Safety and Safety::isMandatory;
filter @Safety and (as Safety).isMandatory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ package '13b-Safety and Security Features Element Group-2' {

package 'Mandatory Saftey Features' {
/* Parts that contribute to safety AND are mandatory. */
public import vehicle::**[@Safety and Safety::isMandatory];
public import vehicle::**[@Safety and (as Safety).isMandatory];
}
}
Loading