Skip to content
Snippets Groups Projects
Commit e4b765d6 authored by Andrea Enrici's avatar Andrea Enrici
Browse files

added the type checking for msg parameters in both sender and receiver instances

parent bb3501f8
Branches
No related tags found
No related merge requests found
......@@ -308,6 +308,9 @@ public class TMLCPSyntaxChecking {
if( !isParameterDeclared( parameter, receiverInstance, diag ) ) {
addError( "Parameter <<" + parameter.getName() + ">> has not been declared in instance <<" + receiverInstance + ">> in diagram <<" + diag.getName() + ">>", TMLCPError.ERROR_STRUCTURE );
}
if( !checkTypeCoherency( parameter, senderInstance, receiverInstance, diag ) ) {
addError( "Parameter <<" + parameter.getName() + ">> is declared with different types in instance <<" + senderInstance + ">> and in instance <<" + receiverInstance + ">> in diagram <<" + diag.getName() + ">>", TMLCPError.ERROR_STRUCTURE );
}
}
}
}
......@@ -326,6 +329,32 @@ public class TMLCPSyntaxChecking {
return false;
}
private boolean checkTypeCoherency( TMLAttribute parameter, String senderInstance, String receiverInstance, TMLCPSequenceDiagram diag ) {
int typeOfAttributeInSenderInstance = 0;
int typeOfAttributeInReceiverInstance = 0;
for( TMLSDInstance instance: diag.getInstances() ) {
if( instance.getName().equals( senderInstance ) ) {
for( TMLAttribute attribute: instance.getAttributes() ) { //don't use contains() as parameter is created with some partial attributes
if( attribute.getName().equals( parameter.getName() ) ) {
typeOfAttributeInSenderInstance = attribute.getType().getType();
break;
}
}
}
if( instance.getName().equals( receiverInstance ) ) {
for( TMLAttribute attribute: instance.getAttributes() ) { //don't use contains() as parameter is created with some partial attributes
if( attribute.getName().equals( parameter.getName() ) ) {
typeOfAttributeInReceiverInstance = attribute.getType().getType();
break;
}
}
}
}
return ( typeOfAttributeInSenderInstance == typeOfAttributeInReceiverInstance );
}
private void checkInstances( TMLCPSequenceDiagram diag ) {
ArrayList<TMLSDInstance> instances = diag.getInstances();
HashSet hash = new HashSet();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment