Commit 0cd5855b authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

updated cocos

parent c5b75073
......@@ -376,14 +376,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -29,47 +29,48 @@ import java.util.function.Predicate;
/**
* @author Crispin Kirchner
*
*
* Implementation of CO1 and CO2
*/
public class ConnectorEndPointCorrectlyQualified
implements EmbeddedMontiArcASTConnectorCoCo {
private void checkEndpointCorrectlyQualified(ASTQualifiedNameWithArray name,
Predicate<Integer> predicate, String errorMessage) {
int i = 0;
if (name.getCompName() != null)
++i;
if (name.getPortName() != null)
++i;
//if (!predicate.test(name.getParts().size())) {
if (!predicate.test(i)){
Log.error(String.format(errorMessage, name.toString()), name.get_SourcePositionStart());
implements EmbeddedMontiArcASTConnectorCoCo {
private void checkEndpointCorrectlyQualified(ASTQualifiedNameWithArray name,
Predicate<Integer> predicate, String errorMessage) {
int i = 0;
if (name.getCompName() != null)
++i;
if (name.getPortName() != null)
++i;
//if (!predicate.test(name.getParts().size())) {
if (!predicate.test(i)) {
Log.error(String.format(errorMessage, name.toString()), name.get_SourcePositionStart());
}
}
}
/**
* Ensure that the connector endpoint is of the form `rootComponentPort' or `subComponent.port'
*/
private void checkEndPointMaximallyTwiceQualified(ASTQualifiedNameWithArray name) {
checkEndpointCorrectlyQualified(name, i -> i <= 2 && i > 0,
"0xDB61C Connector endVal point \"%s\" must only consist of an optional component name and a port name");
}
/**
* @see EmbeddedMontiArcASTConnectorCoCo#check(ASTConnector)
*/
@Override
public void check(ASTConnector node) {
if(node.getSource().isPresent()) {
checkEndPointMaximallyTwiceQualified(node.getSource().get());
}else{
Log.error("Error Connector has no valid source or constant");
/**
* Ensure that the connector endpoint is of the form `rootComponentPort' or `subComponent.port'
*/
private void checkEndPointMaximallyTwiceQualified(ASTQualifiedNameWithArray name) {
checkEndpointCorrectlyQualified(name, i -> i <= 2 && i > 0,
"0xDB61C Connector endVal point \"%s\" must only consist of an optional component name and a port name");
}
for (ASTQualifiedNameWithArray name : node.getTargets()) {
checkEndPointMaximallyTwiceQualified(name);
/**
* @see EmbeddedMontiArcASTConnectorCoCo#check(ASTConnector)
*/
@Override
public void check(ASTConnector node) {
if (node.getSource().isPresent()) {
checkEndPointMaximallyTwiceQualified(node.getSource().get());
} else {
if (!node.getUnitNumberResolution().isPresent() && !node.getBoolLiteral().isPresent())
Log.error("Error Connector has no valid source or constant " + node.toString());
}
for (ASTQualifiedNameWithArray name : node.getTargets()) {
checkEndPointMaximallyTwiceQualified(name);
}
}
}
}
......@@ -36,29 +36,27 @@ import java.util.List;
*/
public class TypeParameterNamesUnique implements EmbeddedMontiArcASTComponentHeadCoCo {
/**
* @see de.monticore.lang.embeddedmontiarc.embeddedmontiarc._cocos.EmbeddedMontiArcASTComponentCoCo#check(de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent)
*/
@Override
public void check(ASTComponentHead node) {
ASTTypeParameters typeParameters = node.getGenericTypeParameters().orElse(null);
if (typeParameters == null) {
return;
/**
* @see de.monticore.lang.embeddedmontiarc.embeddedmontiarc._cocos.EmbeddedMontiArcASTComponentCoCo#check(de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent)
*/
@Override
public void check(ASTComponentHead node) {
ASTTypeParameters typeParameters = node.getGenericTypeParameters().orElse(null);
if (typeParameters == null) {
return;
}
List<String> typeParameterNames = new ArrayList<>();
for (ASTTypeVariableDeclaration typeParameter : typeParameters.getTypeVariableDeclarations()) {
if (typeParameter.getNamingResolution().isPresent() && typeParameterNames.contains(typeParameter.getNamingResolution().get().getName())) {
Log.error(String.format(
"0x35F1A The formal type parameter name \"%s\" is not unique",
typeParameter.getNamingResolution().get().getName()), typeParameter.get_SourcePositionStart());
} else {
//typeParameterNames.add(typeParameter.getNamingResolution().get().getName());
}
}
}
List<String> typeParameterNames = new ArrayList<>();
for (ASTTypeVariableDeclaration typeParameter : typeParameters.getTypeVariableDeclarations()) {
if (typeParameterNames.contains(typeParameter.getNamingResolution().get().getName())) {
Log.error(String.format(
"0x35F1A The formal type parameter name \"%s\" is not unique",
typeParameter.getNamingResolution().get().getName()), typeParameter.get_SourcePositionStart());
}
else {
typeParameterNames.add(typeParameter.getNamingResolution().get().getName());
}
}
}
}
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