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
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021 Model Driven Solutions, Inc.
* Copyright (c) 2021, 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 All @@ -22,7 +22,6 @@
package org.omg.sysml.adapter;

import org.omg.sysml.lang.sysml.AssignmentActionUsage;
import org.omg.sysml.util.TypeUtil;

public class AssignmentActionUsageAdapter extends ActionUsageAdapter {

Expand All @@ -34,18 +33,4 @@ public AssignmentActionUsage getTarget() {
return (AssignmentActionUsage)super.getTarget();
}

/**
* @satisfies checkAssignmentActionUsageReferentRedefinition
* @satisfies checkAssignmentActionUsageAccessedFeatureRedefinition
* @satisfies checkAssignmentActionUsageStartingAtRedefinition
*/
protected void addTargetRedefinitions() {
AssignmentActionUsage target = getTarget();
addFeatureWriteTypes(TypeUtil.getOwnedParametersOf(target), target.getReferent());
}

public void doTransform() {
super.doTransform();
addTargetRedefinitions();
}
}
62 changes: 39 additions & 23 deletions org.omg.sysml/src/org/omg/sysml/adapter/FeatureAdapter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* SysML 2 Pilot Implementation
* Copyright (c) 2021-2025 Model Driven Solutions, Inc.
* Copyright (c) 2021-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 @@ -35,6 +35,7 @@
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.omg.sysml.lang.sysml.AssignmentActionUsage;
import org.omg.sysml.lang.sysml.Association;
import org.omg.sysml.lang.sysml.BindingConnector;
import org.omg.sysml.lang.sysml.Connector;
Expand Down Expand Up @@ -216,7 +217,6 @@ protected Feature getBoundValueResult() {
* @satisfies checkFeatureCrossingSpecialization
* @satisfies checkFeatureOwnedCrossFeatureSpecialization
* @satisfies checkFeatureOwnedCrossFeatureRedefinitionSpecialization
*
*/
@Override
public void addDefaultGeneralType() {
Expand Down Expand Up @@ -592,10 +592,47 @@ public void addComputedRedefinitions(Element skip) {
// NOTE: Set flag before adding redefinitions, to avoid possible infinite
// recursion if computeImplicitGeneralTypes is called again on this Feature.
isComputeRedefinitions = false;
addFeatureWriteTypes();
addRedefinitions(skip);
}
}

/**
* @satisfies checkAssignmentActionUsageReferentRedefinition
* @satisfies checkAssignmentActionUsageAccessedFeatureRedefinition
* @satisfies checkAssignmentActionUsageStartingAtRedefinition
*/
protected void addFeatureWriteTypes() {
Feature feature = getTarget();
if (isStartingAtFeature(feature)) {
addDefaultGeneralType(SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("startingAt"));
} else if (isAccessedFeature(feature)) {
addDefaultGeneralType(SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("accessedFeature"));
AssignmentActionUsage actionUsage = (AssignmentActionUsage)(feature.getOwner().getOwner().getOwner());
Feature referent = actionUsage.getReferent();
if (referent != null) {
addImplicitGeneralType(SysMLPackage.eINSTANCE.getRedefinition(), referent);
}
}
}

public static boolean isStartingAtFeature(Feature feature) {
Type owningType = feature.getOwningType();
if (owningType instanceof Feature) {
Type actionUsage = ((Feature)owningType).getOwningType();
if (actionUsage instanceof AssignmentActionUsage) {
return ((AssignmentActionUsage)actionUsage).getParameter().indexOf(owningType) == 0;
}
}
return false;
}

public static boolean isAccessedFeature(Feature feature) {
Type owningType = feature.getOwningType();
return owningType instanceof Feature && isStartingAtFeature((Feature)owningType) &&
owningType.getOwnedFeature().indexOf(feature) == 0;
}

/**
* Compute relevant Redefinitions and add them to this Feature. By default, if this Feature is relevant for its
* owning Type, then it is paired with relevant Features in the same position in Generalizations of the
Expand Down Expand Up @@ -789,27 +826,6 @@ protected BindingConnector addBindingConnector(Collection<Type> featuringTypes,
return connector;
}

protected void addFeatureWriteTypes(List<Feature> parameters, Feature referent) {
if (!parameters.isEmpty()) {
Feature targetFeature = parameters.get(0);
List<Feature> features = targetFeature.getOwnedFeature();
if (!features.isEmpty()) {
Feature startingAtFeature = features.get(0);
TypeUtil.addDefaultGeneralTypeTo(startingAtFeature, SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("startingAt"));
TypeUtil.setIsAddImplicitGeneralTypesFor(startingAtFeature, false);
features = startingAtFeature.getOwnedFeature();
if (!features.isEmpty()) {
Feature accessedFeature = features.get(0);
TypeUtil.addDefaultGeneralTypeTo(accessedFeature, SysMLPackage.eINSTANCE.getRedefinition(), getDefaultSupertype("accessedFeature"));
if (referent != null) {
TypeUtil.addImplicitGeneralTypeTo(accessedFeature, SysMLPackage.eINSTANCE.getRedefinition(), referent);
}
TypeUtil.setIsAddImplicitGeneralTypesFor(accessedFeature, false);
}
}
}
}

/**
* @satisfies checkFeatureValueBindingConnector
*/
Expand Down
20 changes: 11 additions & 9 deletions org.omg.sysml/src/org/omg/sysml/adapter/TypeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,17 @@ public void removeUnnecessaryImplicitGeneralTypes() {
implicitGeneralTypes.values().forEach(implicitGenerals::addAll);
for (Object eClass: implicitGeneralTypes.keySet().toArray()) {
List<Type> implicitEClassGenerals = implicitGeneralTypes.get(eClass);
if (eClass == SysMLPackage.eINSTANCE.getRedefinition()) {
implicitEClassGenerals.removeAll(redefinedFeatures);
} else {
implicitEClassGenerals.removeIf(gen->
generals.stream().anyMatch(type->specializesExcludingTarget(type, gen)) ||
implicitGenerals.stream().anyMatch(type->type != gen && specializesExcludingTarget(type, gen)));
}
if (implicitEClassGenerals.isEmpty()) {
implicitGeneralTypes.remove(eClass);
if (implicitEClassGenerals != null) {
if (eClass == SysMLPackage.eINSTANCE.getRedefinition()) {
implicitEClassGenerals.removeAll(redefinedFeatures);
} else {
implicitEClassGenerals.removeIf(gen->
generals.stream().anyMatch(type->specializesExcludingTarget(type, gen)) ||
implicitGenerals.stream().anyMatch(type->type != gen && specializesExcludingTarget(type, gen)));
}
if (implicitEClassGenerals.isEmpty()) {
implicitGeneralTypes.remove(eClass);
}
}
}

Expand Down
Loading