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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Closed sets of values that tool parameters accept, published as JSON Schema enums so an
//! agent sees the valid choices instead of guessing at a free string.
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
macro_rules! string_enum {
($(#[$meta:meta])* $name:ident { $($(#[$vmeta:meta])* $variant:ident => $text:literal),+ $(,)? }) => {
$(#[$meta])*
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub enum $name {
$($(#[$vmeta])* #[serde(rename = $text)] $variant),+
}
impl $name {
pub fn as_str(self) -> &'static str {
match self { $(Self::$variant => $text),+ }
}
}
};
}
string_enum! {
/// Where `find_references` looks.
ScopeLevel {
/// The resolved project (default).
Project => "project",
/// Every registered workspace project.
WorkspaceAll => "workspace_all",
/// Only the file named by `file_path`.
File => "file",
/// Workspace usages of external crate symbols and their re-exports.
Dependencies => "dependencies",
}
}
string_enum! {
/// Where `search_symbols` looks.
SearchScopeLevel {
/// The resolved project (default).
Project => "project",
/// The project's Cargo dependencies.
Dependencies => "dependencies",
}
}
string_enum! {
/// The kind of use a reference is.
ReferenceRole {
Call => "call",
TypeAnnotation => "type_annotation",
Import => "import",
Reexport => "reexport",
Read => "read",
Write => "write",
Value => "value",
}
}
string_enum! {
/// How `find_references` shapes its answer.
ReferenceView {
/// Every usage site, one line each.
Sites => "sites",
/// Distinct enclosing functions with their first site and a count: who calls it.
Callers => "callers",
/// Distinct files with counts: what must change if it does.
Files => "files",
}
}
string_enum! {
/// How a reference was tied to its target.
ReferenceVia {
/// Through a path, an import or the file's own scopes, and the only symbol that matches.
Exact => "exact",
/// Matched by name alone (a method on an unknown receiver, or a name several symbols share).
Name => "name",
/// Found inside a macro invocation, matched by name.
Macro => "macro",
}
}
string_enum! {
/// Which way `trace_call_hierarchy` follows calls.
CallDirection {
/// Callees: what does this symbol call? (default; `callees` is accepted.)
#[serde(alias = "callees", alias = "out")]
Outbound => "outbound",
/// Callers: who calls this symbol? (`callers` is accepted.)
#[serde(alias = "callers", alias = "in")]
Inbound => "inbound",
}
}
string_enum! {
/// Lifecycle status of an ADR.
AdrStatus {
Proposed => "proposed",
Accepted => "accepted",
Deprecated => "deprecated",
Superseded => "superseded",
}
}