mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Compiler better test coverage in case of error and fix panics
The compile_syntax_node was used by the syntax_test in case of error
to still cover the coverage, but commit e3908cfce6
made this function a noop when there is an error already.
The LSP does try to build an object tree even though there are error in
order to have the most information even in that case, so we must ensure
that it doesn't panic left and right.
This commit also fix some of these panics.
This commit is contained in:
parent
47a61dda10
commit
60e7d54e67
3 changed files with 14 additions and 9 deletions
|
@ -206,10 +206,6 @@ pub async fn compile_syntax_node(
|
|||
) -> (object_tree::Document, diagnostics::BuildDiagnostics, typeloader::TypeLoader) {
|
||||
let mut loader = prepare_for_compile(&mut diagnostics, compiler_config);
|
||||
|
||||
if diagnostics.has_error() {
|
||||
return (crate::object_tree::Document::default(), diagnostics, loader);
|
||||
}
|
||||
|
||||
let doc_node: parser::syntax_nodes::Document = doc_node.into();
|
||||
|
||||
let type_registry =
|
||||
|
|
|
@ -1214,12 +1214,10 @@ impl Element {
|
|||
match token.as_token().unwrap().text() {
|
||||
"pure" => pure = Some(true),
|
||||
"public" => {
|
||||
debug_assert_eq!(visibility, PropertyVisibility::Private);
|
||||
visibility = PropertyVisibility::Public;
|
||||
pure = pure.or(Some(false));
|
||||
}
|
||||
"protected" => {
|
||||
debug_assert_eq!(visibility, PropertyVisibility::Private);
|
||||
visibility = PropertyVisibility::Protected;
|
||||
pure = pure.or(Some(false));
|
||||
}
|
||||
|
|
|
@ -77,10 +77,20 @@ fn resolve_alias(
|
|||
};
|
||||
drop(borrow_mut);
|
||||
|
||||
let nr = match &elem.borrow().bindings[prop].borrow().expression {
|
||||
let borrow = elem.borrow();
|
||||
let Some(binding) = borrow.bindings.get(prop) else {
|
||||
assert!(diag.has_error());
|
||||
return;
|
||||
};
|
||||
let nr = match &binding.borrow().expression {
|
||||
Expression::Uncompiled(node) => {
|
||||
let node = syntax_nodes::TwoWayBinding::new(node.clone())
|
||||
.expect("The parser only avoid missing types for two way bindings");
|
||||
let Some(node) = syntax_nodes::TwoWayBinding::new(node.clone()) else {
|
||||
assert!(
|
||||
diag.has_error(),
|
||||
"The parser only avoid missing types for two way bindings"
|
||||
);
|
||||
return;
|
||||
};
|
||||
let mut lookup_ctx = LookupCtx::empty_context(type_register, diag);
|
||||
lookup_ctx.property_name = Some(prop);
|
||||
lookup_ctx.property_type = old_type.clone();
|
||||
|
@ -89,6 +99,7 @@ fn resolve_alias(
|
|||
}
|
||||
_ => panic!("There should be a Uncompiled expression at this point."),
|
||||
};
|
||||
drop(borrow);
|
||||
|
||||
let mut ty = Type::Invalid;
|
||||
if let Some(nr) = &nr {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue