<commit_before>import com.redhat.ceylon.compiler.typechecker.model {
    Declaration,
    Unit,
    Module,
    Package,
    ModuleImport
}

shared alias DifferencedModelElement => Module | ModuleImport | Package | Unit | Declaration;

shared interface AbstractDelta of CompilationUnitDelta | ModuleImportDelta | DeclarationDelta {
    "Element for which the delta has been calculated"
    shared formal DifferencedModelElement changedElement;
    
    "String representation of the changedElement"
    shared default String changedElementString => changedElement.string;

        "Deltas related to the members of the  [[model element|AbstractDelta.changedElement]] that might impact some other compilation units"
    shared formal {AbstractDelta*} childrenDeltas;
    
    "Changes on the [[model element|AbstractDelta.changedElement]] that might impact some other compilation units"
    shared formal {ImpactingChange*} changes;
    
    shared actual String string {
        return "`` changedElementString `` {
                  changes = `` changes ``
                  childrenDeltas = {`` ((childrenDeltas.empty) then "}" else "
                  ") + operatingSystem.newline.join {
                          for (childDelta in childrenDeltas) for (line in childDelta.string.lines) "    " + line
                      }
                  + ((! childrenDeltas.empty) then 
               "
                  }" else "") ``
                }";
    }
    shared default actual Boolean equals(Object that) {
        if (is AbstractDelta that) {
            return 
                changedElementString==that.changedElementString && 
                ! anyPair((AbstractDelta first, AbstractDelta second) => first != second, childrenDeltas, that.childrenDeltas) &&
                ! anyPair((ImpactingChange first, ImpactingChange second) => first != second, changes, that.changes);
        }
        else {
            return false;
        }
    }
}

shared interface CompilationUnitDelta of RegularCompilationUnitDelta | ModuleDescriptorDelta | PackageDescriptorDelta satisfies AbstractDelta {}

shared interface ModuleDescriptorDelta satisfies CompilationUnitDelta {
    shared formal actual Module changedElement;
    shared formal actual {ModuleImportDelta*} childrenDeltas;
    shared alias PossibleChange => StructuralChange|ModuleImportAdded;
    shared formal actual {PossibleChange *} changes;
}

shared interface ModuleImportDelta satisfies AbstractDelta {
    shared formal actual ModuleImport changedElement;
    shared actual [] childrenDeltas => [];
    shared alias PossibleChange => <Removed | MadeVisibleOutsideScope | MadeInvisibleOutsideScope>;
    shared formal actual [PossibleChange]|[] changes;
}

shared interface PackageDescriptorDelta satisfies CompilationUnitDelta {
    shared formal actual Package changedElement;
    shared actual [] childrenDeltas => [];
    shared alias PossibleChange => <StructuralChange|MadeVisibleOutsideScope|MadeInvisibleOutsideScope>;
    shared formal actual [<PossibleChange>]|[] changes;
}

shared interface DeclarationDelta of TopLevelDeclarationDelta | NestedDeclarationDelta satisfies AbstractDelta {
    shared formal actual Declaration changedElement;
    shared formal actual {NestedDeclarationDelta*} childrenDeltas;
}

shared interface TopLevelDeclarationDelta satisfies DeclarationDelta {
    shared alias PossibleChange => <StructuralChange | Removed | DeclarationMemberAdded | MadeVisibleOutsideScope | MadeInvisibleOutsideScope>;
    shared formal actual {<PossibleChange>*} changes;
}<commit_msg>Fix string representation and equals functions <commit_after>import com.redhat.ceylon.compiler.typechecker.model {
    Declaration,
    Unit,
    Module,
    Package,
    ModuleImport
}
import ceylon.interop.java {
    javaClassFromInstance
}

shared alias DifferencedModelElement => Module | ModuleImport | Package | Unit | Declaration;

shared interface AbstractDelta of CompilationUnitDelta | ModuleImportDelta | DeclarationDelta {
    "Element for which the delta has been calculated"
    shared formal DifferencedModelElement changedElement;
    
    "String representation of the changedElement"
    shared default String changedElementString => changedElement.string;

        "Deltas related to the members of the  [[model element|AbstractDelta.changedElement]] that might impact some other compilation units"
    shared formal {AbstractDelta*} childrenDeltas;
    
    "Changes on the [[model element|AbstractDelta.changedElement]] that might impact some other compilation units"
    shared formal {ImpactingChange*} changes;
    
    shared actual String string {
        return "`` changedElementString `` {
                  changes = {`` ", ".join(changes) ``}
                  childrenDeltas = {`` ((childrenDeltas.empty) then "}" else "
                  ") + operatingSystem.newline.join {
                          for (childDelta in childrenDeltas) for (line in childDelta.string.lines) "    " + line
                      }
                  + ((! childrenDeltas.empty) then 
               "
                  }" else "") ``
                }";
    }
    shared default actual Boolean equals(Object that) {
        if (is AbstractDelta that) {
            return 
                changedElementString == that.changedElementString && 
                childrenDeltas.size == that.childrenDeltas.size &&
                changes.size == that.changes.size &&
                ! anyPair((AbstractDelta first, AbstractDelta second) => first != second, childrenDeltas, that.childrenDeltas) &&
                ! anyPair((ImpactingChange first, ImpactingChange second) => first != second, changes, that.changes);
        }
        else {
            return false;
        }
    }
}

shared interface CompilationUnitDelta of RegularCompilationUnitDelta | ModuleDescriptorDelta | PackageDescriptorDelta satisfies AbstractDelta {}

shared interface ModuleDescriptorDelta satisfies CompilationUnitDelta {
    shared formal actual Module changedElement;
    shared formal actual {ModuleImportDelta*} childrenDeltas;
    shared alias PossibleChange => StructuralChange|ModuleImportAdded;
    shared formal actual {PossibleChange *} changes;
}

shared interface ModuleImportDelta satisfies AbstractDelta {
    shared formal actual ModuleImport changedElement;
    shared actual [] childrenDeltas => [];
    shared alias PossibleChange => <Removed | MadeVisibleOutsideScope | MadeInvisibleOutsideScope>;
    shared formal actual [PossibleChange]|[] changes;
}

shared interface PackageDescriptorDelta satisfies CompilationUnitDelta {
    shared formal actual Package changedElement;
    shared actual [] childrenDeltas => [];
    shared alias PossibleChange => <StructuralChange|MadeVisibleOutsideScope|MadeInvisibleOutsideScope>;
    shared formal actual [<PossibleChange>]|[] changes;
}

shared interface DeclarationDelta of TopLevelDeclarationDelta | NestedDeclarationDelta satisfies AbstractDelta {
    shared formal actual Declaration changedElement;
    shared default actual String changedElementString => "``javaClassFromInstance(changedElement).simpleName``[``changedElement.nameAsString ``]";
    shared formal actual {NestedDeclarationDelta*} childrenDeltas;
}

shared interface TopLevelDeclarationDelta satisfies DeclarationDelta {
    shared alias PossibleChange => <StructuralChange | Removed | DeclarationMemberAdded | MadeVisibleOutsideScope | MadeInvisibleOutsideScope>;
    shared formal actual {<PossibleChange>*} changes;
}
{'fraction_non_alphanumeric': 0.07330051882399893, 'fraction_numerical': 0.0, 'mean_word_length': 3.4803337306317044, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5401919', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1681, 'n_words': 522}