i_slint_compiler/llr/debug_info.rs
1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4//! Debug information attached to LLR structures.
5//! The interpreter uses it for highlighting, live preview and element picking.
6//!
7//! Populated only when [`crate::CompilerConfiguration::debug_info`] is set.
8//! Treat entries as advisory and tolerate missing data.
9
10use crate::diagnostics::SourceLocation;
11use smol_str::SmolStr;
12use typed_index_collections::TiVec;
13
14use super::item_tree::{ItemInstanceIdx, SubComponentInstanceIdx};
15
16/// Debug info for a single item within a [`SubComponent`](super::SubComponent).
17#[derive(Debug, Clone)]
18pub struct ItemDebugInfo {
19 /// Source range of the element in the `.slint` source.
20 pub source_location: SourceLocation,
21 /// Qualified id of the element, e.g. `MyComponent::my-button`.
22 pub qualified_id: Option<SmolStr>,
23 /// Stable hash identifying the source element across builds.
24 /// See [`crate::object_tree::ElementDebugInfo::element_hash`].
25 pub element_hash: u64,
26 /// Whether the item is an injected wrapper taking over its child's
27 /// geometry. See [`crate::object_tree::Element::is_injected_wrapper_element`].
28 pub is_injected_wrapper_element: bool,
29}
30
31/// Debug info for a [`SubComponent`](super::SubComponent).
32#[derive(Debug, Clone)]
33pub struct SubComponentDebugInfo {
34 /// Source location of the sub-component's root element.
35 pub source_location: SourceLocation,
36 /// One entry per [`ItemInstanceIdx`].
37 pub items: TiVec<ItemInstanceIdx, ItemDebugInfo>,
38 /// Source location of each child sub-component's use-site element,
39 /// one entry per [`SubComponent::sub_components`](super::SubComponent::sub_components).
40 /// Distinguishes the instantiations of a shared sub-component type.
41 pub sub_component_use_sites: TiVec<SubComponentInstanceIdx, SourceLocation>,
42}