import itertools

from gaphor.diagram.copypaste import copy, copy_named_element
from gaphor.UML import Association, Class, Interface, Operation


@copy.register(Class)
@copy.register(Interface)
def copy_class(element):
    yield element.id, copy_named_element(element)
    for feature in itertools.chain(
        element.ownedAttribute,
        element.ownedOperation,
    ):
        yield from copy(feature)


@copy.register
def copy_operation(element: Operation):
    yield element.id, copy_named_element(element)
    for feature in element.ownedParameter:
        yield from copy(feature)


@copy.register
def copy_association(element: Association):
    yield element.id, copy_named_element(element)
    for end in element.memberEnd:
        yield from copy(end)

import itertools

from gaphor.diagram.copypaste import copy, copy_named_element
from gaphor.UML import Association, Class, Enumeration, Interface, Operation


@copy.register(Class)
@copy.register(Interface)
def copy_class(element):
    yield element.id, copy_named_element(element)
    for feature in itertools.chain(
        element.ownedAttribute,
        element.ownedOperation,
    ):
        yield from copy(feature)


@copy.register
def copy_enumeration(element: Enumeration):
    yield element.id, copy_named_element(element)
    for literal in element.ownedLiteral:
        yield from copy(literal)


@copy.register
def copy_operation(element: Operation):
    yield element.id, copy_named_element(element)
    for feature in element.ownedParameter:
        yield from copy(feature)


@copy.register
def copy_association(element: Association):
    yield element.id, copy_named_element(element)
    for end in element.memberEnd:
        yield from copy(end)

Copy enumeration literals when pasting an Enumeration
Copy enumeration literals when pasting an Enumeration

Signed-off-by: Dan Yeaw <2591e5f46f28d303f9dc027d475a5c60d8dea17a@yeaw.me>

  import itertools
  
  from gaphor.diagram.copypaste import copy, copy_named_element
- from gaphor.UML import Association, Class, Interface, Operation
+ from gaphor.UML import Association, Class, Enumeration, Interface, Operation
  
  
  @copy.register(Class)
  @copy.register(Interface)
  def copy_class(element):
      yield element.id, copy_named_element(element)
      for feature in itertools.chain(
          element.ownedAttribute,
          element.ownedOperation,
      ):
          yield from copy(feature)
+ 
+ 
+ @copy.register
+ def copy_enumeration(element: Enumeration):
+     yield element.id, copy_named_element(element)
+     for literal in element.ownedLiteral:
+         yield from copy(literal)
  
  
  @copy.register
  def copy_operation(element: Operation):
      yield element.id, copy_named_element(element)
      for feature in element.ownedParameter:
          yield from copy(feature)
  
  
  @copy.register
  def copy_association(element: Association):
      yield element.id, copy_named_element(element)
      for end in element.memberEnd:
          yield from copy(end)
  
Copy enumeration literals when pasting an Enumeration
## Code Before:
import itertools

from gaphor.diagram.copypaste import copy, copy_named_element
from gaphor.UML import Association, Class, Interface, Operation


@copy.register(Class)
@copy.register(Interface)
def copy_class(element):
    yield element.id, copy_named_element(element)
    for feature in itertools.chain(
        element.ownedAttribute,
        element.ownedOperation,
    ):
        yield from copy(feature)


@copy.register
def copy_operation(element: Operation):
    yield element.id, copy_named_element(element)
    for feature in element.ownedParameter:
        yield from copy(feature)


@copy.register
def copy_association(element: Association):
    yield element.id, copy_named_element(element)
    for end in element.memberEnd:
        yield from copy(end)

## Instruction:
Copy enumeration literals when pasting an Enumeration
## Code After:
import itertools

from gaphor.diagram.copypaste import copy, copy_named_element
from gaphor.UML import Association, Class, Enumeration, Interface, Operation


@copy.register(Class)
@copy.register(Interface)
def copy_class(element):
    yield element.id, copy_named_element(element)
    for feature in itertools.chain(
        element.ownedAttribute,
        element.ownedOperation,
    ):
        yield from copy(feature)


@copy.register
def copy_enumeration(element: Enumeration):
    yield element.id, copy_named_element(element)
    for literal in element.ownedLiteral:
        yield from copy(literal)


@copy.register
def copy_operation(element: Operation):
    yield element.id, copy_named_element(element)
    for feature in element.ownedParameter:
        yield from copy(feature)


@copy.register
def copy_association(element: Association):
    yield element.id, copy_named_element(element)
    for end in element.memberEnd:
        yield from copy(end)
