def METHOD_NAME(self, ref: str) -> Optional[str]:
    if ref.startswith('package:'):
        # Resolve as package uri via .packages.
        uri = urlparse(ref)
        (package_name, *path_to_file) = uri.path.split('/', 1)
        package_path = self.packages[package_name]
        if len(path_to_file) == 0:
            return self._make_github_uri(package_path)
        else:
            return self._make_github_uri(
                os.path.join(package_path, path_to_file[0]))
    elif os.path.exists(ref):
        # Resolve as a file link.
        return self._make_github_uri(ref)
    else:
        # Resolve as a symbol.
        loc = self.symbols_index.try_resolve(ref)
        if loc is not None:
            return self._make_github_uri(loc.filename, loc.lineno)
    logging.error('Failed to resolve xref %s', ref)
    return None