mod actions;
mod annotations;
mod colors;
mod config;
mod context;
mod fields;
pub(crate) mod highlighting;
mod hints;
mod hooks;
mod index;
mod queries;
use crate::diagnostics::Applicability;
use crate::pointer::PointerSet;
use crate::project::SourceId;
use crate::sources::Scope;
use crate::types::Type;
use std::collections::{HashMap, HashSet};
use std::ops::Range;
use std::sync::Arc;
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Location {
pub source: SourceId,
pub range: Range<usize>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SymbolKind {
Procedure,
ClientScript,
Trigger,
Parameter,
Variable,
Constant,
GameVariable,
Command,
Config,
}
#[derive(Clone, Debug)]
pub struct Symbol {
pub name: String,
pub kind: SymbolKind,
pub detail: String,
pub documentation: String,
pub value_type: Option<Type>,
pub definition: Option<Location>,
pub extent: Option<Location>,
pub parameters: Vec<(String, Type)>,
pub returns: Vec<Type>,
pub(crate) container: Option<(SourceId, usize)>,
pub(crate) scope: Option<Scope>,
pub(crate) key: String,
}
#[derive(Clone, Debug)]
pub struct Completion {
pub label: String,
pub detail: String,
pub kind: SymbolKind,
pub replacement: Range<usize>,
}
#[derive(Clone, Debug)]
pub struct Hover {
pub range: Range<usize>,
pub kind: SymbolKind,
pub detail: String,
pub documentation: String,
}
#[derive(Clone, Debug)]
pub struct SignatureHelp {
pub label: String,
pub parameters: Vec<(String, Type)>,
pub active_parameter: usize,
pub documentation: String,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TextEdit {
pub location: Location,
pub replacement: String,
}
#[derive(Clone, Debug)]
pub struct CodeAction {
pub title: String,
pub kind: &'static str,
pub edits: Vec<TextEdit>,
pub applicability: Applicability,
}
#[derive(Clone, Debug)]
pub struct InlayHint {
pub offset: usize,
pub label: String,
pub parameter: bool,
}
#[derive(Clone, Debug)]
pub struct ScriptPointers {
pub range: Range<usize>,
pub required: PointerSet,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Color {
pub red: f64,
pub green: f64,
pub blue: f64,
pub alpha: f64,
}
#[derive(Clone, Debug, PartialEq)]
pub struct DocumentColor {
pub range: Range<usize>,
pub color: Color,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TokenKind {
Keyword,
Function,
Parameter,
Variable,
Property,
Type,
Number,
String,
Comment,
Operator,
EnumMember,
Namespace,
Decorator,
Macro,
}
#[derive(Clone, Debug)]
pub struct SemanticToken {
pub range: Range<usize>,
pub kind: TokenKind,
pub declaration: bool,
pub readonly: bool,
pub static_: bool,
pub default_library: bool,
}
impl SemanticToken {
fn new(range: Range<usize>, kind: TokenKind) -> Self {
Self {
range,
kind,
declaration: false,
readonly: false,
static_: false,
default_library: false,
}
}
}
pub(crate) struct Reference {
location: Location,
symbol: usize,
declaration: bool,
}
pub(crate) struct Configs {
key: u64,
symbols: Vec<Symbol>,
keys: HashMap<String, usize>,
references: Vec<Reference>,
links: Vec<index::Link>,
compounds: HashSet<String>,
config_types: fields::ConfigTypes,
config_problems: HashMap<SourceId, Vec<(usize, String)>>,
}
pub(crate) struct Index {
configs: Arc<Configs>,
symbols: Vec<Symbol>,
entities: Vec<Symbol>,
references: Vec<Reference>,
compounds: HashSet<String>,
hooks: HashMap<SourceId, Vec<hooks::Hook>>,
}