import coral
import jhelp
L = coral.meta.UML14

def fix(all):
    for e in all.select(lambda x:
                        x.oclIsKindOf(L.Parameter) or
                        x.oclIsKindOf(L.Attribute)
                        ):
        if not e.type:
            e.type = jhelp.java.lang.Object
    
    _s = 0
    for e in all.select(lambda x:
                        x.oclIsKindOf(L.Parameter) or
                        x.oclIsKindOf(L.Attribute) or
                        x.oclIsKindOf(L.Package) or
                        x.oclIsKindOf(L.Classifier) or
                        x.oclIsKindOf(L.AssociationEnd)
                        ):
        if not e.name:
            e.name = "noname" + str(_s)
            _s += 1

    # Create fake methods for Operations
    for op in all.select(lambda x: x.oclIsKindOf(L.Operation)):
        if op.method:
            continue
        L.Method(specification = op, owner = op.owner)

