use crate::graph::Graph;
use crate::level::{Level, Thresholds};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::Path;
pub type Options = BTreeMap<String, String>;
#[derive(Debug, Clone, Default)]
pub struct PluginInput {
pub ignore: Vec<String>,
pub ignore_tests: bool,
pub options: Options,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Preset {
pub id: String,
pub label: String,
pub title: String,
pub prompt: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub doc_url: Option<String>,
pub sort_metric: String,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub connections: Vec<String>,
}
pub trait LanguagePlugin {
fn name(&self) -> &str;
fn detect(&self, workspace: &Path, input: &PluginInput) -> bool;
fn levels(&self) -> Vec<Level>;
fn analyze(&self, workspace: &Path, level: &str, input: &PluginInput) -> Result<Graph>;
fn is_test_path(&self, _rel_path: &str) -> bool {
false
}
fn versions(&self, _workspace: &Path, _input: &PluginInput) -> Vec<(String, String)> {
Vec::new()
}
fn presets(&self, defaults: Vec<Preset>, _input: &PluginInput) -> Vec<Preset> {
defaults
}
fn thresholds(&self) -> BTreeMap<String, Thresholds> {
BTreeMap::new()
}
}