38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from .shared import *
|
|
|
|
class SymbolIndexSerializeMixin:
|
|
@staticmethod
|
|
def _serialize_symbol(row: SymbolDefinition) -> dict[str, Any]:
|
|
return {
|
|
"id": int(row.id),
|
|
"file_path": str(row.file_path or ""),
|
|
"language": str(row.language or ""),
|
|
"symbol_type": str(row.symbol_type or ""),
|
|
"symbol_name": str(row.symbol_name or ""),
|
|
"qualified_name": str(row.qualified_name or ""),
|
|
"start_line": int(row.start_line) if row.start_line is not None else None,
|
|
"end_line": int(row.end_line) if row.end_line is not None else None,
|
|
"signature": str(row.signature or ""),
|
|
"docstring": str(row.docstring or ""),
|
|
"status": str(row.status or ""),
|
|
"updated_at": row.updated_at.isoformat() if row.updated_at else None,
|
|
"last_indexed_at": row.last_indexed_at.isoformat() if row.last_indexed_at else None,
|
|
}
|
|
|
|
@staticmethod
|
|
def _serialize_ref(row: SymbolReference) -> dict[str, Any]:
|
|
return {
|
|
"id": int(row.id),
|
|
"source_symbol_id": int(row.source_symbol_id) if row.source_symbol_id is not None else None,
|
|
"file_path": str(row.file_path or ""),
|
|
"relation_type": str(row.relation_type or ""),
|
|
"target_symbol_name": str(row.target_symbol_name or ""),
|
|
"target_qualified_name": str(row.target_qualified_name or ""),
|
|
"start_line": int(row.start_line) if row.start_line is not None else None,
|
|
"end_line": int(row.end_line) if row.end_line is not None else None,
|
|
"updated_at": row.updated_at.isoformat() if row.updated_at else None,
|
|
}
|
|
|