From 165d00b567b434789ba93d9b95bfaf7fb737fbc0 Mon Sep 17 00:00:00 2001 From: Jonatan Waern Date: Fri, 6 Mar 2026 14:50:05 +0100 Subject: [PATCH] Always collect templates for indexing, even if not at toplevel Signed-off-by: Jonatan Waern --- CHANGELOG.md | 1 + src/analysis/mod.rs | 7 ++- src/analysis/structure/objects.rs | 5 ++ src/analysis/structure/toplevel.rs | 75 +++++++++++++++++++++--------- 4 files changed, 63 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eac3117..21b09157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - The DLS will now correctly report missing template names in 'in each' constructs - Fixed error where the DLS would fail to match references from within in a template to symbols defined in parents of objects instantiating the template +- The DLS will now index templates declared inside incorrect contexts (objects, methods, etc.). This avoids internal errors in some cases and allows for slightly-better feedback in broken-syntax contexts. ## 0.9.17 - Fixed linter wrongly throwing an error on space after `defined` keyword diff --git a/src/analysis/mod.rs b/src/analysis/mod.rs index 4ae33565..2574f891 100644 --- a/src/analysis/mod.rs +++ b/src/analysis/mod.rs @@ -2311,7 +2311,7 @@ impl DeviceAnalysis { } } - let base_templates = from_device_and_bases(&root, &bases); + let base_templates = templates_from_device_and_bases(&root, &bases); trace!("base template names: {:?}", base_templates.iter() .fold("".to_string(), @@ -2489,15 +2489,14 @@ impl DeviceAnalysis { } } -pub fn from_device_and_bases<'a>(_device: &'a IsolatedAnalysis, +pub fn templates_from_device_and_bases<'a>(_device: &'a IsolatedAnalysis, bases: &'a [IsolatedAnalysis]) -> Vec<&'a ObjectDecl