Commit 9527cb7d authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

signals have a type constraint

refs 2721
parent fdd7e739
......@@ -20,6 +20,7 @@ package org.fortiss.af3.mira;
import org.eclipse.core.runtime.Plugin;
import org.fortiss.af3.mira.constraints.AuthorConstraint;
import org.fortiss.af3.mira.constraints.RequirementContainsTestSuiteConstraint;
import org.fortiss.af3.mira.constraints.SignalConstraints.SignalTypeConstraint;
import org.fortiss.af3.mira.constraints.SignalConstraints.UniqueSignalNameConstraint;
import org.fortiss.af3.mira.relation.IRelationTypeService;
import org.fortiss.af3.mira.relation.RelationTypeService;
......@@ -29,7 +30,7 @@ import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle.
*
* @ConQAT.Rating YELLOW Hash: 84FB4D5E378AEAEA0314DE99F093A111
* @ConQAT.Rating YELLOW Hash: 8EDF2EFF1B5ADBE53E17C327A7F0B54D
*/
public class AF3MiraActivator extends Plugin {
......@@ -56,6 +57,7 @@ public class AF3MiraActivator extends Plugin {
IConstraintService.getInstance().registerConstraint(
RequirementContainsTestSuiteConstraint.class);
IConstraintService.getInstance().registerConstraint(UniqueSignalNameConstraint.class);
IConstraintService.getInstance().registerConstraint(SignalTypeConstraint.class);
}
/** {@inheritDoc} */
......
......@@ -21,16 +21,20 @@ import static org.fortiss.af3.mira.utils.SignalsUtils.getDoubleDefinedSignals;
import static org.fortiss.af3.mira.utils.SignalsUtils.getSignalsPerName;
import static org.fortiss.tooling.kernel.utils.ConstraintsUtils.createSuccessStatus;
import java.util.ArrayList;
import java.util.List;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.functional.DuplicatedSignalsStatus;
import org.fortiss.af3.mira.model.functional.FunctionalFactory;
import org.fortiss.af3.mira.model.functional.ISignalsContainer;
import org.fortiss.af3.mira.model.functional.Signal;
import org.fortiss.af3.mira.model.functional.SignalDuplicates;
import org.fortiss.af3.mira.model.functional.SignalsWithoutTypesStatus;
import org.fortiss.af3.project.utils.ConstraintsProjectUtils.AF3ProjectConstraintCheckerBase;
import org.fortiss.tooling.kernel.model.constraints.IConstrained;
import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
import org.fortiss.tooling.kernel.utils.ConstraintsUtils;
/**
* Constraints related to signals.
......@@ -38,7 +42,7 @@ import org.fortiss.tooling.kernel.model.constraints.IConstraintInstanceStatus;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 6B72386790D562B95571479913AF0584
* @ConQAT.Rating YELLOW Hash: 0381D042217FD8BBAA72DD7F3C40B1E9
*/
public class SignalConstraints {
......@@ -69,4 +73,32 @@ public class SignalConstraints {
return constrained instanceof Analysis;
}
}
/** A signal should have a a type. */
public static class SignalTypeConstraint extends AF3ProjectConstraintCheckerBase {
/** {@inheritDoc} */
@Override
public IConstraintInstanceStatus verify(IConstrained constrained) {
List<Signal> sigsWithoutType = new ArrayList<Signal>();
for(Signal sig : ((ISignalsContainer)constrained).getSignals()) {
if(sig.getType() == null) {
sigsWithoutType.add(sig);
}
}
if(sigsWithoutType.isEmpty()) {
return ConstraintsUtils.createSuccessStatus();
}
SignalsWithoutTypesStatus status =
FunctionalFactory.eINSTANCE.createSignalsWithoutTypesStatus();
status.getSignals().addAll(sigsWithoutType);
return status;
}
/** {@inheritDoc} */
@Override
public boolean isApplicable(IConstrained constrained) {
return constrained instanceof ISignalsContainer;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment