def METHOD_NAME(
    self, name: str, current_source: str, previous_source: Optional[str]
) -> List[Diagnostic]:
    """
    Compares two strings containing Python source and emits diagnostic
    messages if any identifiers have changed relative positions.
    """
    if previous_source is None:
        # Entire file is new, so nothing to compare!
        return []
    current_nodes = self._parse(current_source, _Visitor(), "items")
    previous_nodes = {
        item: idx
        for (idx, item) in enumerate(
            self._parse(previous_source, _Visitor(), "items")
        )
    }
    diagnostics: List[Diagnostic] = []
    maximum = None
    for item in current_nodes:
        previous_position = previous_nodes.get(item)
        if previous_position is None:
            continue
        if maximum is None or previous_position > maximum:
            maximum = previous_position
        elif previous_position <= maximum:
            diagnostic = Diagnostic(
                message=(
                    f"the item `{item}` in `{name}` has changed "
                    "relative positions"
                )
            )
            diagnostics.append(diagnostic)
    return diagnostics