slint/sixtyfps_compiler/passes/check_public_api.rs
Olivier Goffart a92d1af03c Move the public api check in its own passes
The pass must be done at the begining so that synthetised property don't
become public, and also so that analyses pass can use the public api information
2021-05-20 13:40:51 +02:00

30 lines
1.2 KiB
Rust

/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
//! Pass that check that the public api is ok and mark the property as exposed
use std::rc::Rc;
use crate::diagnostics::{BuildDiagnostics, DiagnosticLevel};
use crate::object_tree::Component;
pub fn check_public_api(root_component: &Rc<Component>, diag: &mut BuildDiagnostics) -> () {
root_component.root_element.borrow_mut().property_declarations.values_mut().for_each(|d| {
if d.property_type.ok_for_public_api() {
d.expose_in_public_api = true
} else {
diag.push_diagnostic(
format!("Properties of type {} are not supported yet for public API. The property will not be exposed.", d.property_type),
&d.type_node(),
DiagnosticLevel::Warning
);
}
});
}