|
| 1 | +use pgt_configuration::RuleSelector; |
| 2 | +use pgt_fs::PgTPath; |
| 3 | +use pgt_text_size::TextRange; |
| 4 | + |
| 5 | +use crate::Workspace; |
| 6 | + |
| 7 | +#[derive(Debug, serde::Serialize, serde::Deserialize)] |
| 8 | +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] |
| 9 | +pub struct CodeActionsParams { |
| 10 | + pub path: PgTPath, |
| 11 | + pub range: Option<TextRange>, |
| 12 | + pub only: Vec<RuleSelector>, |
| 13 | + pub skip: Vec<RuleSelector>, |
| 14 | +} |
| 15 | + |
| 16 | +#[derive(Debug, serde::Serialize, serde::Deserialize)] |
| 17 | +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] |
| 18 | +pub struct CodeActionsResult { |
| 19 | + pub actions: Vec<CodeAction>, |
| 20 | +} |
| 21 | + |
| 22 | +#[derive(Debug, serde::Serialize, serde::Deserialize)] |
| 23 | +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] |
| 24 | +#[serde(rename_all = "camelCase")] |
| 25 | +pub struct CodeAction { |
| 26 | + pub category: CodeActionCategory, |
| 27 | +} |
| 28 | + |
| 29 | +#[derive(Debug, serde::Serialize, serde::Deserialize)] |
| 30 | +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] |
| 31 | +pub enum CodeActionCategory { |
| 32 | + ExecuteCommand(String), |
| 33 | +} |
| 34 | + |
| 35 | +impl CodeActionCategory { |
| 36 | + fn perform(self, workspace: &dyn Workspace) -> Result<(), String> { |
| 37 | + match self { |
| 38 | + Self::ExecuteCommand(stmt) => {} |
| 39 | + } |
| 40 | + Ok(()) |
| 41 | + } |
| 42 | +} |
0 commit comments