checkError(expansionElem.anonymousExpansion && expansionElem.dontOuputSource, sourceCase);
checkError(expansionElem.expansionId == null && expansionElem.dontOuputSource, sourceCase);
checkError(expansionElem.expansionId == null && expansionElem.arguments == null, sourceCase);
ArrayList<Argument> arguments = expansionElem.arguments;
TspExpansionElement definedExpansionElem = null;
if(expansionId != null) {
definedExpansionElem = sourceCase.getExpansion(expansionId);
if(arguments == null) {
checkError(definedExpansionElem == null, UNDEFINED_REFER, expansionElem);
arguments = definedExpansionElem.arguments;
} else {
// We allow a "redefinition" only if the element is exactly the same
checkError(definedExpansionElem != null && definedExpansionElem != expansionElem,
StandardErrors.REDEFINITION, expansionElem);
putExpansion(sourceCase, expansionId, expansionElem);
}
}
checkError(arguments.size() == 0, StandardErrors.NO_ARGUMENTS, expansionElem);
if(expansionElem.defineOnly || sourceCase.isHeaderCase) {
// TODO: situation where there is a pairedExpansionId has no test cases that test it
return false;
}
String secondaryIdToActivate = expansionElem.anonymousExpansion ? null : expansionId;
String pairedIdToActivate = null;
Integer pairedExpansionIx = null;
TspExpansionElement referredExpansion = null;
if(expansionElem.pairedExpansionId == null) {
if(definedExpansionElem != null && expansionElem.anonymousExpansion == false) {
pairedIdToActivate = definedExpansionElem.pairedExpansionId;
if(pairedIdToActivate == null) {
pairedIdToActivate = expansionId;