From f0711d149af25d12f62fc59733692c20bdf1bc84 Mon Sep 17 00:00:00 2001 From: BrettMayson Date: Sun, 15 Oct 2023 14:23:42 -0600 Subject: [PATCH] lsp feature --- libs/common/Cargo.toml | 2 +- libs/common/src/reporting/processed.rs | 14 +++++++------- libs/preprocessor/Cargo.toml | 3 +++ libs/preprocessor/src/processor/defines.rs | 4 ++-- libs/preprocessor/src/processor/directives.rs | 2 +- libs/preprocessor/src/processor/mod.rs | 10 +++++----- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/libs/common/Cargo.toml b/libs/common/Cargo.toml index 35e2031d..7a5bcf67 100644 --- a/libs/common/Cargo.toml +++ b/libs/common/Cargo.toml @@ -15,4 +15,4 @@ tracing = { workspace = true } vfs = { workspace = true } [features] -hls = [] +lsp = [] diff --git a/libs/common/src/reporting/processed.rs b/libs/common/src/reporting/processed.rs index 81f39714..767ae341 100644 --- a/libs/common/src/reporting/processed.rs +++ b/libs/common/src/reporting/processed.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "hls")] +#[cfg(feature = "lsp")] use std::collections::HashMap; use std::rc::Rc; @@ -22,12 +22,12 @@ pub struct Processed { /// string offset(start, stop), source, source position mappings: Vec, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] /// Map of token usage to definition /// (token, definition) declarations: HashMap, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] /// Map of token definition to usage /// (definition, usages) usage: HashMap>, @@ -172,14 +172,14 @@ impl Processed { /// [`Error::Workspace`] if a workspace path could not be read pub fn new( output: Vec, - #[cfg(feature = "hls")] usage: HashMap>, - #[cfg(feature = "hls")] declarations: HashMap, + #[cfg(feature = "lsp")] usage: HashMap>, + #[cfg(feature = "lsp")] declarations: HashMap, warnings: Vec>, ) -> Result { let mut processed = Self { - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] declarations, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] usage, warnings, ..Default::default() diff --git a/libs/preprocessor/Cargo.toml b/libs/preprocessor/Cargo.toml index cd054343..94b239c1 100644 --- a/libs/preprocessor/Cargo.toml +++ b/libs/preprocessor/Cargo.toml @@ -26,6 +26,9 @@ vfs = { workspace = true } criterion = "0.5.1" paste = "1.0.14" +[features] +lsp = ["hemtt-common/lsp"] + [[bench]] name = "ace_dogtags" harness = false diff --git a/libs/preprocessor/src/processor/defines.rs b/libs/preprocessor/src/processor/defines.rs index 350a49fa..3a2cf6ea 100644 --- a/libs/preprocessor/src/processor/defines.rs +++ b/libs/preprocessor/src/processor/defines.rs @@ -255,7 +255,7 @@ impl Processor { }))); } }; - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] self.usage.get_mut(source.position()).map_or_else( || { // println!("missing {:?}", ident.position()); @@ -264,7 +264,7 @@ impl Processor { usage.push(ident.position().clone()); }, ); - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] self.declarations .insert(ident.position().clone(), source.position().clone()); Ok(()) diff --git a/libs/preprocessor/src/processor/directives.rs b/libs/preprocessor/src/processor/directives.rs index 5955bffe..9cf33dbf 100644 --- a/libs/preprocessor/src/processor/directives.rs +++ b/libs/preprocessor/src/processor/directives.rs @@ -208,7 +208,7 @@ impl Processor { Symbol::Newline | Symbol::Eoi => Definition::Unit, _ => Definition::Value(self.define_read_body(stream)), }; - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] self.usage.insert(ident.position().clone(), Vec::new()); self.defines.insert(&ident_string, (ident, definition)); Ok(()) diff --git a/libs/preprocessor/src/processor/mod.rs b/libs/preprocessor/src/processor/mod.rs index b16263b3..52a6dc98 100644 --- a/libs/preprocessor/src/processor/mod.rs +++ b/libs/preprocessor/src/processor/mod.rs @@ -1,4 +1,4 @@ -#[cfg(feature = "hls")] +#[cfg(feature = "lsp")] use std::collections::HashMap; use std::rc::Rc; @@ -29,12 +29,12 @@ pub struct Processor { pub(crate) token_count: usize, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] /// Map of token usage to definition /// (token, definition) pub(crate) declarations: HashMap, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] /// Map of token definition to usage /// (definition, usages) pub(crate) usage: HashMap>, @@ -79,9 +79,9 @@ impl Processor { Processed::new( buffer, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] processor.usage, - #[cfg(feature = "hls")] + #[cfg(feature = "lsp")] processor.declarations, processor.warnings, )