Skip to content

Commit 8bae2fd

Browse files
committed
add preprocessor and support function hoisting in language service
1 parent c84972f commit 8bae2fd

32 files changed

+2614
-143
lines changed

.cargo/config renamed to .cargo/config.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ target = "i686-pc-windows-msvc"
55
b = "build --out-dir=..\\..\\exe\\lib -Z unstable-options"
66

77
[target.i686-pc-windows-msvc]
8-
rustflags = ["-Ctarget-feature=+crt-static", "-Zunstable-options"]
8+
rustflags = ["-Ctarget-feature=+crt-static", "-Zunstable-options", "-Adead_code", "-Aunused"]

Cargo.lock

+99-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ version-compare = "0.1.0"
2727
winapi = { version = "0.3", features = ["winver", "winuser"] }
2828
ctor = "0.1.20"
2929
libloading = "0.7.0"
30-
version_info = "0.0.5"
30+
version_info = "0.0.5"
31+
anyhow = "1.0.40"
32+
normpath = "1.2"
33+
lines_lossy = "0.1.0"

src/dictionary/ffi.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
use std::collections::HashMap;
44
use std::ffi::CString;
5+
use std::path::Path;
56

67
use super::config::Config;
78

8-
#[derive(Default)]
9+
#[derive(Debug, Default, Clone)]
910
pub struct Dict<T, U> {
1011
pub map: HashMap<T, U>,
1112
pub config: Config,
@@ -33,7 +34,7 @@ where
3334
}
3435
}
3536

36-
pub fn load_file<'a>(&mut self, file_name: &'a str) -> Option<()> {
37+
pub fn load_file<P: AsRef<Path>>(&mut self, file_name: P) -> Option<()> {
3738
let content = std::fs::read_to_string(file_name).ok()?;
3839
self.parse_file(content)
3940
}

src/language_service/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub unsafe extern "C" fn language_service_find(
121121
) -> bool {
122122
boolclosure! {{
123123
let server = server.as_mut()?;
124-
let s = server.find(pchar_to_str(symbol)?, handle, line_number)?;
124+
let s = server.find(pchar_to_str(symbol)?, handle, line_number as usize)?;
125125
let out_value = out_value.as_mut()?;
126126
out_value._type = s._type;
127127

@@ -155,7 +155,7 @@ pub unsafe extern "C" fn language_service_filter_constants_by_name(
155155
dict: *mut crate::dictionary::dictionary_str_by_str::DictStrByStr,
156156
) -> bool {
157157
boolclosure! {{
158-
let items = server.as_mut()?.filter_constants_by_name(pchar_to_str(needle)?, handle, line_number)?;
158+
let items = server.as_mut()?.filter_constants_by_name(pchar_to_str(needle)?, handle, line_number as usize)?;
159159
for item in items {
160160
dict.as_mut()?.add(CString::new(item).ok()?, CString::new("").ok()?) // todo: use simple list instead of dict
161161
}

0 commit comments

Comments
 (0)