From 6e884ba7d35177b2d34338d702ff587cd4dc6b63 Mon Sep 17 00:00:00 2001 From: Christopher Wells Date: Sun, 5 Nov 2023 08:58:32 -0800 Subject: [PATCH] Move keyword docs code into separate file To make the state file less bloated. --- src/lib.rs | 1 + src/server/keyword_docs.rs | 189 ++++++++++++++++++++++++++++++++++++ src/server/state.rs | 190 +------------------------------------ 3 files changed, 192 insertions(+), 188 deletions(-) create mode 100644 src/server/keyword_docs.rs diff --git a/src/lib.rs b/src/lib.rs index 4b13334..95441c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ pub mod grammar { } pub mod server { + pub mod keyword_docs; pub mod server; pub mod state; } diff --git a/src/server/keyword_docs.rs b/src/server/keyword_docs.rs new file mode 100644 index 0000000..a5552d2 --- /dev/null +++ b/src/server/keyword_docs.rs @@ -0,0 +1,189 @@ +use std::collections::HashMap; + +pub fn get_keyword_docs() -> HashMap { + [ + ( + "print".to_string(), + include_str!("keyword_docs/print.txt").to_string(), + ), + ( + "set".to_string(), + include_str!("keyword_docs/set.txt").to_string(), + ), + ( + "startfunction".to_string(), + include_str!("keyword_docs/functions.txt").to_string(), + ), + ( + "endfunction".to_string(), + include_str!("keyword_docs/functions.txt").to_string(), + ), + ( + "callfunction".to_string(), + include_str!("keyword_docs/functions.txt").to_string(), + ), + ( + "endian".to_string(), + include_str!("keyword_docs/endian.txt").to_string(), + ), + ( + "idstring".to_string(), + include_str!("keyword_docs/idstring.txt").to_string(), + ), + ( + "if".to_string(), + include_str!("keyword_docs/if.txt").to_string(), + ), + ( + "elif".to_string(), + include_str!("keyword_docs/if.txt").to_string(), + ), + ( + "else".to_string(), + include_str!("keyword_docs/if.txt").to_string(), + ), + ( + "endif".to_string(), + include_str!("keyword_docs/if.txt").to_string(), + ), + ( + "goto".to_string(), + include_str!("keyword_docs/goto.txt").to_string(), + ), + ( + "for".to_string(), + include_str!("keyword_docs/for.txt").to_string(), + ), + ( + "next".to_string(), + include_str!("keyword_docs/for.txt").to_string(), + ), + ( + "break".to_string(), + include_str!("keyword_docs/label.txt").to_string(), + ), + ( + "continue".to_string(), + include_str!("keyword_docs/label.txt").to_string(), + ), + ( + "cleanexit".to_string(), + include_str!("keyword_docs/cleanexit.txt").to_string(), + ), + ( + "findloc".to_string(), + include_str!("keyword_docs/findloc.txt").to_string(), + ), + ( + "get".to_string(), + include_str!("keyword_docs/get.txt").to_string(), + ), + ( + "math".to_string(), + include_str!("keyword_docs/math.txt").to_string(), + ), + ( + "log".to_string(), + include_str!("keyword_docs/log.txt").to_string(), + ), + ( + "asize".to_string(), + include_str!("keyword_docs/asize.txt").to_string(), + ), + ( + "long".to_string(), + include_str!("keyword_docs/long.txt").to_string(), + ), + ( + "string".to_string(), + include_str!("keyword_docs/string.txt").to_string(), + ), + ( + "getarray".to_string(), + include_str!("keyword_docs/getarray.txt").to_string(), + ), + ( + "putarray".to_string(), + include_str!("keyword_docs/getarray.txt").to_string(), + ), + ( + "encryption".to_string(), + include_str!("keyword_docs/encryption.txt").to_string(), + ), + ( + "reverseshort".to_string(), + include_str!("keyword_docs/reverseshort.txt").to_string(), + ), + ( + "reverselong".to_string(), + include_str!("keyword_docs/reverselong.txt").to_string(), + ), + ( + "reverselonglong".to_string(), + include_str!("keyword_docs/reverselonglong.txt").to_string(), + ), + ( + "filexor".to_string(), + include_str!("keyword_docs/filexor.txt").to_string(), + ), + ( + "append".to_string(), + include_str!("keyword_docs/append.txt").to_string(), + ), + ( + "getvarchr".to_string(), + include_str!("keyword_docs/getvarchr.txt").to_string(), + ), + ( + "putvarchr".to_string(), + include_str!("keyword_docs/putvarchr.txt").to_string(), + ), + ( + "byte".to_string(), + include_str!("keyword_docs/byte.txt").to_string(), + ), + ( + "comtype".to_string(), + include_str!("keyword_docs/comtype.txt").to_string(), + ), + ( + "clog".to_string(), + include_str!("keyword_docs/clog.txt").to_string(), + ), + ( + "padding".to_string(), + include_str!("keyword_docs/padding.txt").to_string(), + ), + ( + "savepos".to_string(), + include_str!("keyword_docs/savepos.txt").to_string(), + ), + ( + "extension".to_string(), + include_str!("keyword_docs/extension.txt").to_string(), + ), + ( + "getdstring".to_string(), + include_str!("keyword_docs/getdstring.txt").to_string(), + ), + ( + "do".to_string(), + include_str!("keyword_docs/do.txt").to_string(), + ), + ( + "while".to_string(), + include_str!("keyword_docs/do.txt").to_string(), + ), + ( + "short".to_string(), + include_str!("keyword_docs/short.txt").to_string(), + ), + ( + "open".to_string(), + include_str!("keyword_docs/open.txt").to_string(), + ), + ] + .iter() + .cloned() + .collect() +} diff --git a/src/server/state.rs b/src/server/state.rs index 0d85135..a644b16 100644 --- a/src/server/state.rs +++ b/src/server/state.rs @@ -11,6 +11,8 @@ use lsp_types::{ use crate::grammar::parsing::{get_quickbms_language, parse, PointLike, RangeLike}; +use crate::server::keyword_docs::get_keyword_docs; + pub struct ServerState { files: HashMap, keyword_docs: HashMap, @@ -363,191 +365,3 @@ impl ServerState { Some(folding_ranges) } } - -pub fn get_keyword_docs() -> HashMap { - [ - ( - "print".to_string(), - include_str!("keyword_docs/print.txt").to_string(), - ), - ( - "set".to_string(), - include_str!("keyword_docs/set.txt").to_string(), - ), - ( - "startfunction".to_string(), - include_str!("keyword_docs/functions.txt").to_string(), - ), - ( - "endfunction".to_string(), - include_str!("keyword_docs/functions.txt").to_string(), - ), - ( - "callfunction".to_string(), - include_str!("keyword_docs/functions.txt").to_string(), - ), - ( - "endian".to_string(), - include_str!("keyword_docs/endian.txt").to_string(), - ), - ( - "idstring".to_string(), - include_str!("keyword_docs/idstring.txt").to_string(), - ), - ( - "if".to_string(), - include_str!("keyword_docs/if.txt").to_string(), - ), - ( - "elif".to_string(), - include_str!("keyword_docs/if.txt").to_string(), - ), - ( - "else".to_string(), - include_str!("keyword_docs/if.txt").to_string(), - ), - ( - "endif".to_string(), - include_str!("keyword_docs/if.txt").to_string(), - ), - ( - "goto".to_string(), - include_str!("keyword_docs/goto.txt").to_string(), - ), - ( - "for".to_string(), - include_str!("keyword_docs/for.txt").to_string(), - ), - ( - "next".to_string(), - include_str!("keyword_docs/for.txt").to_string(), - ), - ( - "break".to_string(), - include_str!("keyword_docs/label.txt").to_string(), - ), - ( - "continue".to_string(), - include_str!("keyword_docs/label.txt").to_string(), - ), - ( - "cleanexit".to_string(), - include_str!("keyword_docs/cleanexit.txt").to_string(), - ), - ( - "findloc".to_string(), - include_str!("keyword_docs/findloc.txt").to_string(), - ), - ( - "get".to_string(), - include_str!("keyword_docs/get.txt").to_string(), - ), - ( - "math".to_string(), - include_str!("keyword_docs/math.txt").to_string(), - ), - ( - "log".to_string(), - include_str!("keyword_docs/log.txt").to_string(), - ), - ( - "asize".to_string(), - include_str!("keyword_docs/asize.txt").to_string(), - ), - ( - "long".to_string(), - include_str!("keyword_docs/long.txt").to_string(), - ), - ( - "string".to_string(), - include_str!("keyword_docs/string.txt").to_string(), - ), - ( - "getarray".to_string(), - include_str!("keyword_docs/getarray.txt").to_string(), - ), - ( - "putarray".to_string(), - include_str!("keyword_docs/getarray.txt").to_string(), - ), - ( - "encryption".to_string(), - include_str!("keyword_docs/encryption.txt").to_string(), - ), - ( - "reverseshort".to_string(), - include_str!("keyword_docs/reverseshort.txt").to_string(), - ), - ( - "reverselong".to_string(), - include_str!("keyword_docs/reverselong.txt").to_string(), - ), - ( - "reverselonglong".to_string(), - include_str!("keyword_docs/reverselonglong.txt").to_string(), - ), - ( - "filexor".to_string(), - include_str!("keyword_docs/filexor.txt").to_string(), - ), - ( - "append".to_string(), - include_str!("keyword_docs/append.txt").to_string(), - ), - ( - "getvarchr".to_string(), - include_str!("keyword_docs/getvarchr.txt").to_string(), - ), - ( - "putvarchr".to_string(), - include_str!("keyword_docs/putvarchr.txt").to_string(), - ), - ( - "byte".to_string(), - include_str!("keyword_docs/byte.txt").to_string(), - ), - ( - "comtype".to_string(), - include_str!("keyword_docs/comtype.txt").to_string(), - ), - ( - "clog".to_string(), - include_str!("keyword_docs/clog.txt").to_string(), - ), - ( - "padding".to_string(), - include_str!("keyword_docs/padding.txt").to_string(), - ), - ( - "savepos".to_string(), - include_str!("keyword_docs/savepos.txt").to_string(), - ), - ( - "extension".to_string(), - include_str!("keyword_docs/extension.txt").to_string(), - ), - ( - "getdstring".to_string(), - include_str!("keyword_docs/getdstring.txt").to_string(), - ), - ( - "do".to_string(), - include_str!("keyword_docs/do.txt").to_string(), - ), - ( - "while".to_string(), - include_str!("keyword_docs/do.txt").to_string(), - ), - ( - "short".to_string(), - include_str!("keyword_docs/short.txt").to_string(), - ), - ( - "open".to_string(), - include_str!("keyword_docs/open.txt").to_string(), - ), - ] - .iter() - .cloned() - .collect() -}