ontocore_refactor/
model.rs1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
5#[serde(rename_all = "snake_case")]
6pub enum UsageKind {
7 EntityDeclaration,
8 AxiomSubject,
9 AxiomObject,
10 AnnotationSubject,
11 AnnotationObject,
12 Import,
13 TextReference,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct Usage {
18 pub iri: String,
19 pub referenced_iri: String,
20 pub file: PathBuf,
21 pub line: Option<u64>,
22 pub column: Option<u64>,
23 pub start_byte: Option<u64>,
24 pub end_byte: Option<u64>,
25 pub kind: UsageKind,
26 pub context: String,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct Hunk {
31 pub start_byte: u64,
32 pub end_byte: u64,
33 pub old_text: String,
34 pub new_text: String,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct FileChange {
39 pub path: PathBuf,
40 pub preview_text: String,
41 pub original_text: String,
42 #[serde(default, skip_serializing_if = "Vec::is_empty")]
43 pub hunks: Vec<Hunk>,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct RefactorPlan {
48 pub changes: Vec<FileChange>,
49 #[serde(default, skip_serializing_if = "Vec::is_empty")]
50 pub warnings: Vec<String>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(tag = "kind", rename_all = "snake_case")]
55pub enum RefactorRequest {
56 RenameIri {
57 from_iri: String,
58 to_iri: String,
59 },
60 MigrateNamespace {
61 from_base: String,
62 to_base: String,
63 },
64 MoveEntity {
65 entity_iri: String,
66 target_file: PathBuf,
67 },
68 ExtractModule {
69 entity_iris: Vec<String>,
70 output_file: PathBuf,
71 #[serde(default)]
72 leave_stub: bool,
73 },
74}