Skip to main content

vvv_engine/protocol/
question.rs

1//! The read-only requests, as data: what an interface asks when it wants to
2//! understand rather than change. Each is a command whose answer is the
3//! result type of the same name.
4
5use vvv_core::RelPath;
6
7use serde::{Deserialize, Serialize};
8use vvv_core::Position;
9
10/// `vvv outline <path>`: what a file declares.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
12pub struct OutlineQuery {
13    pub path: RelPath,
14}
15
16/// `vvv deps <path>`: what a file imports and who imports it.
17#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
18pub struct DepsQuery {
19    pub path: RelPath,
20}
21
22/// `vvv explain <path>:<line>:<col>`: what is at a position.
23#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
24pub struct ExplainQuery {
25    pub path: RelPath,
26    pub position: Position,
27}
28
29/// `vvv where <name> [--from <file>]`: where a name is declared, and the
30/// import that reaches each site from `from`.
31#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
32pub struct WhereQuery {
33    pub name: String,
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub from: Option<RelPath>,
36}
37
38/// One file as it is now, with its syntax colouring: what a picker shows.
39#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
40pub struct FileQuery {
41    pub path: RelPath,
42}
43
44/// The applies that can still be undone.
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
46pub struct HistoryQuery;
47
48/// Reverse the most recent apply, provided its files are untouched since.
49#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
50pub struct UndoLast;
51
52/// `vvv surface [package]`: what a package offers to everyone.
53#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
54pub struct SurfaceQuery {
55    #[serde(default, skip_serializing_if = "Option::is_none")]
56    pub package: Option<String>,
57}
58
59/// `vvv impact <name>`: who would feel a change to a declaration.
60#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
61pub struct ImpactQuery {
62    pub name: String,
63    /// The file declaring the symbol meant, when several share the name.
64    #[serde(default, skip_serializing_if = "Option::is_none")]
65    pub declared_in: Option<RelPath>,
66}
67
68/// `vvv dead`: declarations nothing in the workspace refers to.
69#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
70pub struct DeadQuery {
71    #[serde(default, skip_serializing_if = "Option::is_none")]
72    pub language: Option<vvv_core::LanguageId>,
73}
74
75/// `vvv imports [path]`: import statements worth a look.
76#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
77pub struct ImportsQuery {
78    #[serde(default, skip_serializing_if = "Option::is_none")]
79    pub path: Option<RelPath>,
80}