From f23f8db9946ad7062b2c855edce960dc74a5f10f Mon Sep 17 00:00:00 2001 From: ef3d0c3e Date: Sun, 27 Oct 2024 09:40:12 +0100 Subject: [PATCH] More lua hints --- src/elements/elemstyle.rs | 14 +++++++------- src/elements/script.rs | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/elements/elemstyle.rs b/src/elements/elemstyle.rs index 266fc22..1f7d69c 100644 --- a/src/elements/elemstyle.rs +++ b/src/elements/elemstyle.rs @@ -269,13 +269,13 @@ pub mod tests { ); validate_semantics!(state, source.clone(), 0, - elemstyle_operator { delta_line == 1, delta_start == 0, length == 2 }; - elemstyle_name { delta_line == 0, delta_start == 2, length == 14 }; - elemstyle_equal { delta_line == 0, delta_start == 14, length == 1 }; - elemstyle_value { delta_line == 0, delta_start == 2, length == 2 }; - elemstyle_value { delta_line == 1, delta_start == 0, length == 23 }; - elemstyle_value { delta_line == 1, delta_start == 0, length == 31 }; - elemstyle_value { delta_line == 1, delta_start == 0, length == 2 }; + elemstyle_operator { delta_line == 1, delta_start == 0, length == 2 }; + elemstyle_name { delta_line == 0, delta_start == 2, length == 14 }; + elemstyle_equal { delta_line == 0, delta_start == 14, length == 1 }; + elemstyle_value { delta_line == 0, delta_start == 2, length == 2 }; + elemstyle_value { delta_line == 1, delta_start == 0, length == 23 }; + elemstyle_value { delta_line == 1, delta_start == 0, length == 31 }; + elemstyle_value { delta_line == 1, delta_start == 0, length == 2 }; ); } } diff --git a/src/elements/script.rs b/src/elements/script.rs index da83e83..0570623 100644 --- a/src/elements/script.rs +++ b/src/elements/script.rs @@ -212,15 +212,24 @@ impl RegexRule for ScriptRule { )), ); } + + if let Some(hints) = Hints::from_source(token.source(), &state.shared.lsp) { + hints.add(matches.get(0).unwrap().end(), result); + } } else if kind == 2 // Eval and Parse { + if let Some(hints) = Hints::from_source(token.source(), &state.shared.lsp) { + hints.add(matches.get(0).unwrap().end(), result.clone()); + } + let parse_source = Rc::new(VirtualSource::new( Token::new(0..source.content().len(), source.clone()), format!(":LUA:parse({})", source.name()), result, )) as Rc; + state.with_state(|new_state| { new_state.parser.parse_into( new_state,