Commit fa8bd2fa authored by Florian Hölzl's avatar Florian Hölzl
Browse files

bugfix, YELLOW

refs 886
parent f587bea4
......@@ -18,6 +18,7 @@ $Id$
package org.fortiss.af3.component.constraint;
import static org.fortiss.af3.component.constraint.ConstraintMessage.createDuplicatePortViolation;
import static org.fortiss.af3.component.constraint.ConstraintMessage.createIllegalNameViolation;
import static org.fortiss.af3.component.constraint.ConstraintMessage.createInitialValueTypeMismatchViolation;
import static org.fortiss.af3.component.constraint.ConstraintMessage.createUnknownTypeViolationWithSource;
import static org.fortiss.af3.project.utils.TypeScopeUtils.getTypeDefinition;
......@@ -35,6 +36,7 @@ import org.fortiss.af3.expression.language.TypeSystemHandler;
import org.fortiss.af3.expression.model.types.TDefinedType;
import org.fortiss.tooling.kernel.extension.base.MultiViolationConstraintCheckerBase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* A constraint checker for {@link Component}s.
......@@ -42,7 +44,7 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 58FE5ED0EDFB020D1AE7ACED26812627
* @ConQAT.Rating YELLOW Hash: 643E54666097B91792EAD23D8F4B60A6
*/
public class ComponentConstraintChecker extends
MultiViolationConstraintCheckerBase<Component, Component> {
......@@ -51,6 +53,7 @@ public class ComponentConstraintChecker extends
@Override
public void collectViolations(Component modelElement,
List<IConstraintViolation<Component>> results) {
performStartsWithNumberNameCheck(modelElement, results);
Set<String> seenPorts = new HashSet<String>();
for(InputPort p : modelElement.getInputPorts()) {
performPortCheck(p, seenPorts, results);
......@@ -60,6 +63,19 @@ public class ComponentConstraintChecker extends
}
}
/** Checks if name starts with a number. */
private void performStartsWithNumberNameCheck(INamedElement modelElement,
List<IConstraintViolation<Component>> results) {
String name = modelElement.getName();
if("".equals(name) || "0123456789".contains("" + name.charAt(0))) {
if(modelElement instanceof Component) {
results.add(createIllegalNameViolation((Component)modelElement, name));
} else if(modelElement instanceof Port) {
results.add(createIllegalNameViolation((Port)modelElement, name));
}
}
}
/** Checks duplicate port name, port type and initial value type. */
private void performPortCheck(Port p, Set<String> seenPorts,
List<IConstraintViolation<Component>> results) {
......@@ -67,6 +83,7 @@ public class ComponentConstraintChecker extends
results.add(createDuplicatePortViolation(p.getComponent(), p.getName()));
} else {
seenPorts.add(p.getName());
performStartsWithNumberNameCheck(p, results);
performTypeCheck(p, results);
}
}
......
......@@ -22,6 +22,7 @@ import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESe
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.Port;
import org.fortiss.af3.component.model.behavior.code.CodeSpecification;
import org.fortiss.af3.component.model.behavior.common.Action;
import org.fortiss.af3.component.model.behavior.common.DataStateVariable;
......@@ -38,7 +39,7 @@ import org.fortiss.tooling.kernel.model.INamedElement;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 0840DABF166CB159AE3CBE15E0EB00E7
* @ConQAT.Rating YELLOW Hash: B1ABD5FD9AA97E9A03764950E6480394
*/
final class ConstraintMessage {
......@@ -48,13 +49,26 @@ final class ConstraintMessage {
" is part of a weakly causal cylce");
}
/** Creates the violation for duplicate enumerations. */
/** Creates the violation for duplicate ports. */
public static ConstraintViolationBase<Component> createDuplicatePortViolation(Component c,
String name) {
return new ConstraintViolationBase<Component>(c, ERROR, "Duplicate port " + name + " in " +
c.getName());
}
/** Creates the violation for illegal component name. */
public static ConstraintViolationBase<Component> createIllegalNameViolation(Component c,
String name) {
return new ConstraintViolationBase<Component>(c, ERROR, "Illegal component name " + name);
}
/** Creates the violation for illegal component name. */
public static ConstraintViolationBase<Component>
createIllegalNameViolation(Port p, String name) {
return new ConstraintViolationBase<Component>(p.getComponent(), ERROR,
"Illegal port name " + name + " in component " + p.getComponent().getName());
}
/** Creates violation for unknown type in component member. */
public static IConstraintViolation<Component> createUnknownTypeViolationWithSource(Component c,
String source, String name) {
......
......@@ -29,7 +29,7 @@ import org.fortiss.tooling.kernel.extension.base.ConstraintViolationBase;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: E0230BEE1B837DC56B4FFF39BD2D9524
* @ConQAT.Rating YELLOW Hash: D55B5CB814ED2E5CC6408CF4FC68A492
*/
final class ConstraintMessage {
......
......@@ -40,7 +40,7 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 1A38A7724A407D43112A654831582B1F
* @ConQAT.Rating YELLOW Hash: 2712669752170D82A55D4EBB35425721
*/
public class StateAutomatonConstraintChecker extends ConstraintCheckerBase<StateAutomaton> {
......
Supports Markdown
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