1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use std::fmt;
/// Relationship types used in the Neo4j graph.
///
/// Keeping these in one place avoids hard‑coding relationship names in
/// multiple modules and makes the schema easier to evolve.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RelType {
/// File -> Module: file declares a module.
DeclaresModule,
/// File/Module -> Function: parent declares a function.
DeclaresFunction,
/// File -> Class: file declares a class.
DeclaresClass,
/// Class -> Property: type declares a property (C#; CRM-3587).
DeclaresProperty,
/// File -> File: one file depends (imports/includes) on another.
DependsOnFile,
/// Function -> Function: call graph edge.
CallsFunction,
/// ApiEndpoint -> Function: which function handles this API.
HandlesApi,
/// Function -> ExternalApi: function calls an external service/API.
CallsExternalApi,
/// ApiEndpoint -> ExternalApi: same API exposed and called.
SameApi,
/// Function -> Class: function uses this class/type.
UsesClass,
/// Class -> Class: class uses another class (inheritance, composition).
ClassUsesClass,
/// Module -> Behaviour: module implements behaviour contract.
ImplementsBehaviour,
/// Behaviour -> Callback: behaviour declares callback contract.
DeclaresCallback,
/// Function -> Callback: function implements callback contract.
ImplementsCallback,
/// File -> Behaviour: file declares a custom behaviour.
DeclaresBehaviour,
/// Behaviour -> Behaviour: behaviour extends another behaviour.
ExtendsBehaviour,
/// Function -> Callback: function explicitly overrides callback contract.
OverridesCallback,
}
impl fmt::Display for RelType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
RelType::DeclaresModule => "DECLARES_MODULE",
RelType::DeclaresFunction => "DECLARES_FUNCTION",
RelType::DeclaresClass => "DECLARES_CLASS",
RelType::DeclaresProperty => "DECLARES_PROPERTY",
RelType::DependsOnFile => "DEPENDS_ON_FILE",
RelType::CallsFunction => "CALLS_FUNCTION",
RelType::HandlesApi => "HANDLED_BY",
RelType::CallsExternalApi => "CALLS_EXTERNAL_API",
RelType::SameApi => "SAME_API",
RelType::UsesClass => "USES_CLASS",
RelType::ClassUsesClass => "USES_CLASS",
RelType::ImplementsBehaviour => "IMPLEMENTS_BEHAVIOUR",
RelType::DeclaresCallback => "DECLARES_CALLBACK",
RelType::ImplementsCallback => "IMPLEMENTS_CALLBACK",
RelType::DeclaresBehaviour => "DECLARES_BEHAVIOUR",
RelType::ExtendsBehaviour => "EXTENDS_BEHAVIOUR",
RelType::OverridesCallback => "OVERRIDES_CALLBACK",
};
f.write_str(s)
}
}