mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Rename the sixtyfps-compilerlib crate
This commit is contained in:
parent
9494068201
commit
cab22f8355
36 changed files with 169 additions and 158 deletions
|
@ -20,7 +20,7 @@ crate-type = ["cdylib"]
|
|||
name = "sixtyfps_node_native"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { version = "=0.2.0", path="../../../internal/compiler" }
|
||||
slint-compiler-internal = { version = "=0.2.0", path="../../../internal/compiler" }
|
||||
slint-core-internal = { version = "=0.2.0", path="../../../internal/core" }
|
||||
sixtyfps-interpreter = { version = "=0.2.0", path="../../../internal/interpreter", features = ["display-diagnostics"] }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use neon::prelude::*;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_core_internal::model::Model;
|
||||
use std::cell::Cell;
|
||||
use std::rc::{Rc, Weak};
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
use core::cell::RefCell;
|
||||
use neon::prelude::*;
|
||||
use rand::RngCore;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_interpreter::ComponentHandle;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_core_internal::model::{Model, ModelRc};
|
||||
use slint_core_internal::window::WindowHandleAccess;
|
||||
use slint_core_internal::{ImageInner, SharedVector};
|
||||
|
@ -154,7 +154,7 @@ fn create<'cx>(
|
|||
|
||||
fn to_eval_value<'cx>(
|
||||
val: Handle<'cx, JsValue>,
|
||||
ty: sixtyfps_compilerlib::langtype::Type,
|
||||
ty: slint_compiler_internal::langtype::Type,
|
||||
cx: &mut impl Context<'cx>,
|
||||
persistent_context: &persistent_context::PersistentContext<'cx>,
|
||||
) -> NeonResult<sixtyfps_interpreter::Value> {
|
||||
|
|
|
@ -19,7 +19,7 @@ path = "lib.rs"
|
|||
default = []
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { version = "=0.2.0", path = "../../../internal/compiler", features = ["rust", "display-diagnostics"] }
|
||||
slint-compiler-internal = { version = "=0.2.0", path = "../../../internal/compiler", features = ["rust", "display-diagnostics"] }
|
||||
|
||||
spin_on = "0.1"
|
||||
thiserror = "1"
|
||||
|
|
|
@ -54,18 +54,18 @@ use std::env;
|
|||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
|
||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
||||
|
||||
/// The structure for configuring aspects of the compilation of `.60` markup files to Rust.
|
||||
pub struct CompilerConfiguration {
|
||||
config: sixtyfps_compilerlib::CompilerConfiguration,
|
||||
config: slint_compiler_internal::CompilerConfiguration,
|
||||
}
|
||||
|
||||
impl Default for CompilerConfiguration {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
config: sixtyfps_compilerlib::CompilerConfiguration::new(
|
||||
sixtyfps_compilerlib::generator::OutputFormat::Rust,
|
||||
config: slint_compiler_internal::CompilerConfiguration::new(
|
||||
slint_compiler_internal::generator::OutputFormat::Rust,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ pub fn compile_with_config(
|
|||
.join(path.as_ref());
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse_file(&path, &mut diag);
|
||||
let syntax_node = slint_compiler_internal::parser::parse_file(&path, &mut diag);
|
||||
|
||||
if diag.has_error() {
|
||||
let vec = diag.to_string_vec();
|
||||
|
@ -222,7 +222,7 @@ pub fn compile_with_config(
|
|||
let syntax_node = syntax_node.expect("diags contained no compilation errors");
|
||||
|
||||
// 'spin_on' is ok here because the compiler in single threaded and does not block if there is no blocking future
|
||||
let (doc, diag) = spin_on::spin_on(sixtyfps_compilerlib::compile_syntax_node(
|
||||
let (doc, diag) = spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
|
||||
syntax_node,
|
||||
diag,
|
||||
compiler_config,
|
||||
|
@ -244,7 +244,7 @@ pub fn compile_with_config(
|
|||
|
||||
let file = std::fs::File::create(&output_file_path).map_err(CompileError::SaveError)?;
|
||||
let mut code_formatter = CodeFormatter { indentation: 0, in_string: false, sink: file };
|
||||
let generated = sixtyfps_compilerlib::generator::rust::generate(&doc);
|
||||
let generated = slint_compiler_internal::generator::rust::generate(&doc);
|
||||
|
||||
for x in &diag.all_loaded_files {
|
||||
if x.is_absolute() {
|
||||
|
|
|
@ -17,7 +17,7 @@ proc-macro = true
|
|||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { version = "=0.2.0", path = "../../../internal/compiler", features = ["proc_macro_span", "rust", "display-diagnostics"] }
|
||||
slint-compiler-internal = { version = "=0.2.0", path = "../../../internal/compiler", features = ["proc_macro_span", "rust", "display-diagnostics"] }
|
||||
|
||||
proc-macro2 = "1.0.17"
|
||||
quote = "1.0"
|
||||
|
|
|
@ -21,9 +21,9 @@ use std::path::Path;
|
|||
|
||||
use proc_macro::{Spacing, TokenStream, TokenTree};
|
||||
use quote::quote;
|
||||
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
|
||||
use sixtyfps_compilerlib::parser::SyntaxKind;
|
||||
use sixtyfps_compilerlib::*;
|
||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
||||
use slint_compiler_internal::parser::SyntaxKind;
|
||||
use slint_compiler_internal::*;
|
||||
|
||||
/// Returns true if the two token are touching. For example the two token `foo`and `-` are touching if
|
||||
/// it was written like so in the source code: `foo-` but not when written like so `foo -`
|
||||
|
@ -337,7 +337,7 @@ pub fn sixtyfps(stream: TokenStream) -> TokenStream {
|
|||
|
||||
//println!("{:#?}", syntax_node);
|
||||
let mut compiler_config =
|
||||
CompilerConfiguration::new(sixtyfps_compilerlib::generator::OutputFormat::Rust);
|
||||
CompilerConfiguration::new(slint_compiler_internal::generator::OutputFormat::Rust);
|
||||
|
||||
if std::env::var_os("SIXTYFPS_STYLE").is_none() {
|
||||
// This file is written by the slint-backend-selector-internal's built script.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
[package]
|
||||
name = "sixtyfps-compilerlib"
|
||||
name = "slint-compiler-internal"
|
||||
version = "0.2.0"
|
||||
authors = ["SixtyFPS <info@sixtyfps.io>"]
|
||||
edition = "2021"
|
||||
|
|
|
@ -59,7 +59,7 @@ fn process_file(path: &std::path::Path) -> std::io::Result<bool> {
|
|||
}
|
||||
|
||||
fn process_diagnostics(
|
||||
compile_diagnostics: &sixtyfps_compilerlib::diagnostics::BuildDiagnostics,
|
||||
compile_diagnostics: &slint_compiler_internal::diagnostics::BuildDiagnostics,
|
||||
path: &Path,
|
||||
source: &str,
|
||||
silent: bool,
|
||||
|
@ -108,8 +108,8 @@ fn process_diagnostics(
|
|||
} + column;
|
||||
|
||||
let expected_diag_level = match warning_or_error {
|
||||
"warning" => sixtyfps_compilerlib::diagnostics::DiagnosticLevel::Warning,
|
||||
"error" => sixtyfps_compilerlib::diagnostics::DiagnosticLevel::Error,
|
||||
"warning" => slint_compiler_internal::diagnostics::DiagnosticLevel::Warning,
|
||||
"error" => slint_compiler_internal::diagnostics::DiagnosticLevel::Error,
|
||||
_ => panic!("Unsupported diagnostic level {}", warning_or_error),
|
||||
};
|
||||
|
||||
|
@ -135,7 +135,7 @@ fn process_diagnostics(
|
|||
|
||||
#[cfg(feature = "display-diagnostics")]
|
||||
if !silent {
|
||||
let mut to_report = sixtyfps_compilerlib::diagnostics::BuildDiagnostics::default();
|
||||
let mut to_report = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
|
||||
for d in diags {
|
||||
to_report.push_compiler_error(d.clone());
|
||||
}
|
||||
|
@ -156,16 +156,16 @@ fn process_file_source(
|
|||
source: String,
|
||||
silent: bool,
|
||||
) -> std::io::Result<bool> {
|
||||
let mut parse_diagnostics = sixtyfps_compilerlib::diagnostics::BuildDiagnostics::default();
|
||||
let mut parse_diagnostics = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
|
||||
let syntax_node =
|
||||
sixtyfps_compilerlib::parser::parse(source.clone(), Some(path), &mut parse_diagnostics);
|
||||
slint_compiler_internal::parser::parse(source.clone(), Some(path), &mut parse_diagnostics);
|
||||
let has_parse_error = parse_diagnostics.has_error();
|
||||
let mut compiler_config = sixtyfps_compilerlib::CompilerConfiguration::new(
|
||||
sixtyfps_compilerlib::generator::OutputFormat::Interpreter,
|
||||
let mut compiler_config = slint_compiler_internal::CompilerConfiguration::new(
|
||||
slint_compiler_internal::generator::OutputFormat::Interpreter,
|
||||
);
|
||||
compiler_config.style = Some("fluent".into());
|
||||
let compile_diagnostics = if !parse_diagnostics.has_error() {
|
||||
let (_, build_diags) = spin_on::spin_on(sixtyfps_compilerlib::compile_syntax_node(
|
||||
let (_, build_diags) = spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
|
||||
syntax_node.clone(),
|
||||
parse_diagnostics,
|
||||
compiler_config.clone(),
|
||||
|
@ -190,7 +190,7 @@ fn process_file_source(
|
|||
|
||||
if has_parse_error {
|
||||
// Still try to compile to make sure it doesn't panic
|
||||
spin_on::spin_on(sixtyfps_compilerlib::compile_syntax_node(
|
||||
spin_on::spin_on(slint_compiler_internal::compile_syntax_node(
|
||||
syntax_node,
|
||||
compile_diagnostics,
|
||||
compiler_config,
|
||||
|
|
|
@ -27,7 +27,7 @@ default = ["std", "backend-gl", "x11", "backend-qt", "compat-0-2-0"]
|
|||
compat-0-2-0 = []
|
||||
|
||||
## enable the [`print_diagnostics`] function to show diagnostic in the console output
|
||||
display-diagnostics = ["sixtyfps-compilerlib/display-diagnostics"]
|
||||
display-diagnostics = ["slint-compiler-internal/display-diagnostics"]
|
||||
|
||||
# (internal) export C++ FFI functions
|
||||
ffi = ["spin_on", "slint-core-internal/ffi"]
|
||||
|
@ -53,7 +53,7 @@ x11 = ["slint-backend-selector-internal/x11", "backend-gl"]
|
|||
wayland = ["slint-backend-selector-internal/wayland", "backend-gl"]
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { version = "=0.2.0", path = "../compiler" }
|
||||
slint-compiler-internal = { version = "=0.2.0", path = "../compiler" }
|
||||
slint-core-internal = { version = "=0.2.0", path = "../core", features = ["rtti"] }
|
||||
slint-backend-selector-internal = { version = "=0.2.0", path = "../../internal/backends/selector" }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use core::convert::TryInto;
|
||||
use sixtyfps_compilerlib::langtype::Type as LangType;
|
||||
use slint_compiler_internal::langtype::Type as LangType;
|
||||
use slint_core_internal::graphics::Image;
|
||||
use slint_core_internal::model::{Model, ModelRc};
|
||||
use slint_core_internal::{Brush, PathData, SharedString, SharedVector};
|
||||
|
@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
|
|||
use std::rc::Rc;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use sixtyfps_compilerlib::diagnostics::{Diagnostic, DiagnosticLevel};
|
||||
pub use slint_compiler_internal::diagnostics::{Diagnostic, DiagnosticLevel};
|
||||
|
||||
pub use slint_core_internal::api::*;
|
||||
|
||||
|
@ -429,15 +429,15 @@ impl FromIterator<(String, Value)> for Struct {
|
|||
/// ComponentCompiler is the entry point to the SixtyFPS interpreter that can be used
|
||||
/// to load .60 files or compile them on-the-fly from a string.
|
||||
pub struct ComponentCompiler {
|
||||
config: sixtyfps_compilerlib::CompilerConfiguration,
|
||||
config: slint_compiler_internal::CompilerConfiguration,
|
||||
diagnostics: Vec<Diagnostic>,
|
||||
}
|
||||
|
||||
impl Default for ComponentCompiler {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
config: sixtyfps_compilerlib::CompilerConfiguration::new(
|
||||
sixtyfps_compilerlib::generator::OutputFormat::Interpreter,
|
||||
config: slint_compiler_internal::CompilerConfiguration::new(
|
||||
slint_compiler_internal::generator::OutputFormat::Interpreter,
|
||||
),
|
||||
diagnostics: vec![],
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ impl ComponentCompiler {
|
|||
path: P,
|
||||
) -> Option<ComponentDefinition> {
|
||||
let path = path.as_ref();
|
||||
let source = match sixtyfps_compilerlib::diagnostics::load_from_path(path) {
|
||||
let source = match slint_compiler_internal::diagnostics::load_from_path(path) {
|
||||
Ok(s) => s,
|
||||
Err(d) => {
|
||||
self.diagnostics = vec![d];
|
||||
|
@ -612,7 +612,7 @@ impl ComponentDefinition {
|
|||
#[doc(hidden)]
|
||||
pub fn properties_and_callbacks(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + '_ {
|
||||
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_ {
|
||||
// We create here a 'static guard, because unfortunately the returned type would be restricted to the guard lifetime
|
||||
// which is not required, but this is safe because there is only one instance of the unerased type
|
||||
let guard = unsafe { generativity::Guard::new(generativity::Id::new()) };
|
||||
|
@ -706,7 +706,7 @@ impl ComponentDefinition {
|
|||
/// This function is available when the `display-diagnostics` is enabled.
|
||||
#[cfg(feature = "display-diagnostics")]
|
||||
pub fn print_diagnostics(diagnostics: &[Diagnostic]) {
|
||||
let mut build_diagnostics = sixtyfps_compilerlib::diagnostics::BuildDiagnostics::default();
|
||||
let mut build_diagnostics = slint_compiler_internal::diagnostics::BuildDiagnostics::default();
|
||||
for d in diagnostics {
|
||||
build_diagnostics.push_compiler_error(d.clone())
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ use crate::{api::Value, dynamic_type, eval};
|
|||
use core::convert::TryInto;
|
||||
use core::ptr::NonNull;
|
||||
use dynamic_type::{Instance, InstanceBox};
|
||||
use sixtyfps_compilerlib::expression_tree::{Expression, NamedReference};
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::object_tree::ElementRc;
|
||||
use sixtyfps_compilerlib::*;
|
||||
use sixtyfps_compilerlib::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
|
||||
use slint_compiler_internal::expression_tree::{Expression, NamedReference};
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::object_tree::ElementRc;
|
||||
use slint_compiler_internal::*;
|
||||
use slint_compiler_internal::{diagnostics::BuildDiagnostics, object_tree::PropertyDeclaration};
|
||||
use slint_core_internal::api::Window;
|
||||
use slint_core_internal::component::{Component, ComponentRef, ComponentRefPin, ComponentVTable};
|
||||
use slint_core_internal::item_tree::{
|
||||
|
@ -293,7 +293,7 @@ pub struct ComponentDescription<'id> {
|
|||
|
||||
fn internal_properties_to_public<'a>(
|
||||
prop_iter: impl Iterator<Item = (&'a String, &'a PropertyDeclaration)> + 'a,
|
||||
) -> impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + 'a {
|
||||
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + 'a {
|
||||
prop_iter.filter(|(_, v)| v.expose_in_public_api).map(|(s, v)| {
|
||||
let name = v
|
||||
.node
|
||||
|
@ -320,7 +320,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
/// We try to preserve the dashes and underscore as written in the property declaration
|
||||
pub fn properties(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + '_ {
|
||||
) -> impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_ {
|
||||
internal_properties_to_public(self.public_properties.iter())
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
pub fn global_properties(
|
||||
&self,
|
||||
name: &str,
|
||||
) -> Option<impl Iterator<Item = (String, sixtyfps_compilerlib::langtype::Type)> + '_> {
|
||||
) -> Option<impl Iterator<Item = (String, slint_compiler_internal::langtype::Type)> + '_> {
|
||||
self.exported_globals_by_name
|
||||
.get(crate::normalize_identifier(name).as_ref())
|
||||
.and_then(|global_idx| self.compiled_globals.get(*global_idx))
|
||||
|
@ -684,8 +684,10 @@ pub async fn load(
|
|||
path: std::path::PathBuf,
|
||||
mut compiler_config: CompilerConfiguration,
|
||||
guard: generativity::Guard<'_>,
|
||||
) -> (Result<Rc<ComponentDescription<'_>>, ()>, sixtyfps_compilerlib::diagnostics::BuildDiagnostics)
|
||||
{
|
||||
) -> (
|
||||
Result<Rc<ComponentDescription<'_>>, ()>,
|
||||
slint_compiler_internal::diagnostics::BuildDiagnostics,
|
||||
) {
|
||||
if compiler_config.style.is_none() && std::env::var("SIXTYFPS_STYLE").is_err() {
|
||||
// Defaults to native if it exists:
|
||||
compiler_config.style = Some(if slint_backend_selector_internal::HAS_NATIVE_STYLE {
|
||||
|
@ -1053,16 +1055,16 @@ pub(crate) fn generate_component<'id>(
|
|||
|
||||
pub fn animation_for_property(
|
||||
component: InstanceRef,
|
||||
animation: &Option<sixtyfps_compilerlib::object_tree::PropertyAnimation>,
|
||||
animation: &Option<slint_compiler_internal::object_tree::PropertyAnimation>,
|
||||
) -> AnimatedBindingKind {
|
||||
match animation {
|
||||
Some(sixtyfps_compilerlib::object_tree::PropertyAnimation::Static(anim_elem)) => {
|
||||
Some(slint_compiler_internal::object_tree::PropertyAnimation::Static(anim_elem)) => {
|
||||
AnimatedBindingKind::Animation(eval::new_struct_with_bindings(
|
||||
&anim_elem.borrow().bindings,
|
||||
&mut eval::EvalLocalContext::from_component_instance(component),
|
||||
))
|
||||
}
|
||||
Some(sixtyfps_compilerlib::object_tree::PropertyAnimation::Transition {
|
||||
Some(slint_compiler_internal::object_tree::PropertyAnimation::Transition {
|
||||
animations,
|
||||
state_ref,
|
||||
}) => {
|
||||
|
|
|
@ -11,11 +11,11 @@ use corelib::model::{Model, ModelRc};
|
|||
use corelib::rtti::AnimatedBindingKind;
|
||||
use corelib::window::{WindowHandleAccess, WindowRc};
|
||||
use corelib::{Brush, Color, PathData, SharedString, SharedVector};
|
||||
use sixtyfps_compilerlib::expression_tree::{
|
||||
use slint_compiler_internal::expression_tree::{
|
||||
BuiltinFunction, EasingCurve, Expression, Path as ExprPath, PathElement as ExprPathElement,
|
||||
};
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::object_tree::ElementRc;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::object_tree::ElementRc;
|
||||
use slint_core_internal as corelib;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
|
@ -519,13 +519,13 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
|||
}
|
||||
Expression::ImageReference{ resource_ref, .. } => {
|
||||
Value::Image(match resource_ref {
|
||||
sixtyfps_compilerlib::expression_tree::ImageReference::None => {
|
||||
slint_compiler_internal::expression_tree::ImageReference::None => {
|
||||
Ok(Default::default())
|
||||
}
|
||||
sixtyfps_compilerlib::expression_tree::ImageReference::AbsolutePath(path) => {
|
||||
slint_compiler_internal::expression_tree::ImageReference::AbsolutePath(path) => {
|
||||
corelib::graphics::Image::load_from_path(std::path::Path::new(path))
|
||||
}
|
||||
sixtyfps_compilerlib::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
|
||||
slint_compiler_internal::expression_tree::ImageReference::EmbeddedData { resource_id, extension } => {
|
||||
let toplevel_instance = match local_context.component_instance {
|
||||
ComponentInstance::InstanceRef(instance) => instance.toplevel_instance(),
|
||||
ComponentInstance::GlobalComponent(_) => unimplemented!(),
|
||||
|
@ -533,7 +533,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
|||
let extra_data = toplevel_instance.component_type.extra_data_offset.apply(toplevel_instance.as_ref());
|
||||
let path = extra_data.embedded_file_resources.get(resource_id).expect("internal error: invalid resource id");
|
||||
|
||||
let virtual_file = sixtyfps_compilerlib::fileaccess::load_file(std::path::Path::new(path)).unwrap(); // embedding pass ensured that the file exists
|
||||
let virtual_file = slint_compiler_internal::fileaccess::load_file(std::path::Path::new(path)).unwrap(); // embedding pass ensured that the file exists
|
||||
|
||||
if let (std::borrow::Cow::Borrowed(static_path), Some(static_data)) = (virtual_file.path, virtual_file.builtin_contents) {
|
||||
let virtual_file_extension = std::path::Path::new(static_path).extension().unwrap().to_str().unwrap();
|
||||
|
@ -550,7 +550,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
|
|||
|
||||
}
|
||||
}
|
||||
sixtyfps_compilerlib::expression_tree::ImageReference::EmbeddedTexture { .. } => {
|
||||
slint_compiler_internal::expression_tree::ImageReference::EmbeddedTexture { .. } => {
|
||||
todo!()
|
||||
}
|
||||
}.unwrap_or_else(|_| {
|
||||
|
@ -1054,7 +1054,7 @@ pub(crate) fn enclosing_component_instance_for_element<'a, 'old_id, 'new_id>(
|
|||
}
|
||||
|
||||
pub fn new_struct_with_bindings<ElementType: 'static + Default + corelib::rtti::BuiltinItem>(
|
||||
bindings: &sixtyfps_compilerlib::object_tree::BindingsMap,
|
||||
bindings: &slint_compiler_internal::object_tree::BindingsMap,
|
||||
local_context: &mut EvalLocalContext,
|
||||
) -> ElementType {
|
||||
let mut element = ElementType::default();
|
||||
|
@ -1068,8 +1068,8 @@ pub fn new_struct_with_bindings<ElementType: 'static + Default + corelib::rtti::
|
|||
}
|
||||
|
||||
fn convert_from_lyon_path<'a>(
|
||||
events_it: impl IntoIterator<Item = &'a sixtyfps_compilerlib::expression_tree::Expression>,
|
||||
points_it: impl IntoIterator<Item = &'a sixtyfps_compilerlib::expression_tree::Expression>,
|
||||
events_it: impl IntoIterator<Item = &'a slint_compiler_internal::expression_tree::Expression>,
|
||||
points_it: impl IntoIterator<Item = &'a slint_compiler_internal::expression_tree::Expression>,
|
||||
local_context: &mut EvalLocalContext,
|
||||
) -> PathData {
|
||||
let events = events_it
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
use crate::dynamic_component::InstanceRef;
|
||||
use crate::eval::{self, ComponentInstance, EvalLocalContext};
|
||||
use crate::Value;
|
||||
use sixtyfps_compilerlib::expression_tree::Expression;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::layout::{Layout, LayoutConstraints, LayoutGeometry, Orientation};
|
||||
use sixtyfps_compilerlib::namedreference::NamedReference;
|
||||
use sixtyfps_compilerlib::object_tree::ElementRc;
|
||||
use slint_compiler_internal::expression_tree::Expression;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::layout::{Layout, LayoutConstraints, LayoutGeometry, Orientation};
|
||||
use slint_compiler_internal::namedreference::NamedReference;
|
||||
use slint_compiler_internal::object_tree::ElementRc;
|
||||
use slint_core_internal::items::DialogButtonRole;
|
||||
use slint_core_internal::layout::{self as core_layout};
|
||||
use slint_core_internal::model::RepeatedComponent;
|
||||
|
@ -174,7 +174,7 @@ fn padding_and_spacing(
|
|||
|
||||
/// return the celldata, the padding, and the spacing of a grid layout
|
||||
fn grid_layout_data(
|
||||
grid_layout: &sixtyfps_compilerlib::layout::GridLayout,
|
||||
grid_layout: &slint_compiler_internal::layout::GridLayout,
|
||||
orientation: Orientation,
|
||||
component: InstanceRef,
|
||||
expr_eval: &impl Fn(&NamedReference) -> f32,
|
||||
|
@ -203,7 +203,7 @@ fn grid_layout_data(
|
|||
}
|
||||
|
||||
fn box_layout_data(
|
||||
box_layout: &sixtyfps_compilerlib::layout::BoxLayout,
|
||||
box_layout: &slint_compiler_internal::layout::BoxLayout,
|
||||
orientation: Orientation,
|
||||
component: InstanceRef,
|
||||
expr_eval: &impl Fn(&NamedReference) -> f32,
|
||||
|
|
|
@ -794,8 +794,10 @@ pub unsafe extern "C" fn sixtyfps_interpreter_component_compiler_get_diagnostics
|
|||
line,
|
||||
column,
|
||||
level: match diagnostic.level() {
|
||||
sixtyfps_compilerlib::diagnostics::DiagnosticLevel::Error => DiagnosticLevel::Error,
|
||||
sixtyfps_compilerlib::diagnostics::DiagnosticLevel::Warning => {
|
||||
slint_compiler_internal::diagnostics::DiagnosticLevel::Error => {
|
||||
DiagnosticLevel::Error
|
||||
}
|
||||
slint_compiler_internal::diagnostics::DiagnosticLevel::Warning => {
|
||||
DiagnosticLevel::Warning
|
||||
}
|
||||
_ => DiagnosticLevel::Warning,
|
||||
|
|
|
@ -8,16 +8,16 @@ use std::rc::Rc;
|
|||
use crate::api::Value;
|
||||
use crate::dynamic_component::{ErasedComponentBox, ErasedComponentDescription};
|
||||
use crate::SetPropertyError;
|
||||
use sixtyfps_compilerlib::namedreference::NamedReference;
|
||||
use sixtyfps_compilerlib::object_tree::PropertyDeclaration;
|
||||
use sixtyfps_compilerlib::{langtype::Type, object_tree::Component};
|
||||
use slint_compiler_internal::namedreference::NamedReference;
|
||||
use slint_compiler_internal::object_tree::PropertyDeclaration;
|
||||
use slint_compiler_internal::{langtype::Type, object_tree::Component};
|
||||
use slint_core_internal::component::ComponentVTable;
|
||||
use slint_core_internal::rtti;
|
||||
|
||||
pub enum CompiledGlobal {
|
||||
Builtin {
|
||||
name: String,
|
||||
element: Rc<sixtyfps_compilerlib::langtype::BuiltinElement>,
|
||||
element: Rc<slint_compiler_internal::langtype::BuiltinElement>,
|
||||
// dummy needed for iterator accessor
|
||||
public_properties: BTreeMap<String, PropertyDeclaration>,
|
||||
},
|
||||
|
|
|
@ -14,7 +14,7 @@ path = "main.rs"
|
|||
name = "doctests"
|
||||
|
||||
[dev-dependencies]
|
||||
sixtyfps-compilerlib = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||
slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||
sixtyfps-interpreter = { path = "../../internal/interpreter" }
|
||||
sixtyfps = { path = "../../api/sixtyfps-rs" }
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ name = "test-driver-cpp"
|
|||
sixtyfps-cpp = { path = "../../../api/cpp", features = ["testing"] }
|
||||
|
||||
[dev-dependencies]
|
||||
sixtyfps-compilerlib = { path = "../../../internal/compiler", features = ["cpp", "display-diagnostics"] }
|
||||
slint-compiler-internal = { path = "../../../internal/compiler", features = ["cpp", "display-diagnostics"] }
|
||||
|
||||
cc = "1.0.54"
|
||||
scopeguard = "1.1.0"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use sixtyfps_compilerlib::{diagnostics::BuildDiagnostics, *};
|
||||
use slint_compiler_internal::{diagnostics::BuildDiagnostics, *};
|
||||
use std::error::Error;
|
||||
use std::io::Write;
|
||||
use std::ops::Deref;
|
||||
|
|
|
@ -14,14 +14,14 @@ path = "main.rs"
|
|||
name = "test-driver-rust"
|
||||
|
||||
[features]
|
||||
build-time = ["sixtyfps-compilerlib", "spin_on"]
|
||||
build-time = ["slint-compiler-internal", "spin_on"]
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../../api/sixtyfps-rs" }
|
||||
slint-backend-testing-internal = { path = "../../../internal/backends/testing" }
|
||||
|
||||
[build-dependencies]
|
||||
sixtyfps-compilerlib = { path = "../../../internal/compiler", features = ["rust", "display-diagnostics"], optional = true }
|
||||
slint-compiler-internal = { path = "../../../internal/compiler", features = ["rust", "display-diagnostics"], optional = true }
|
||||
|
||||
spin_on = { version = "0.1", optional = true}
|
||||
test_driver_lib = { path = "../driverlib" }
|
||||
|
|
|
@ -97,7 +97,7 @@ fn generate_source(
|
|||
output: &mut std::fs::File,
|
||||
testcase: test_driver_lib::TestCase,
|
||||
) -> Result<(), std::io::Error> {
|
||||
use sixtyfps_compilerlib::{diagnostics::BuildDiagnostics, *};
|
||||
use slint_compiler_internal::{diagnostics::BuildDiagnostics, *};
|
||||
|
||||
let include_paths = test_driver_lib::extract_include_paths(source)
|
||||
.map(std::path::PathBuf::from)
|
||||
|
|
|
@ -17,7 +17,7 @@ name = "sixtyfps-compiler"
|
|||
path = "main.rs"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { version = "=0.2.0", path = "../../internal/compiler", features = ["display-diagnostics", "cpp", "rust"]}
|
||||
slint-compiler-internal = { version = "=0.2.0", path = "../../internal/compiler", features = ["display-diagnostics", "cpp", "rust"]}
|
||||
|
||||
clap = { version = "3.0.5", features=["derive", "wrap_help"] }
|
||||
proc-macro2 = "1.0.11"
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use clap::Parser;
|
||||
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
|
||||
use sixtyfps_compilerlib::*;
|
||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
||||
use slint_compiler_internal::*;
|
||||
use std::io::Write;
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
|
@ -15,7 +15,7 @@ categories = ["gui", "development-tools"]
|
|||
keywords = ["formatter", "gui", "ui", "toolkit"]
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||
slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||
|
||||
clap = { version = "3.0.5", features=["derive", "wrap_help"] }
|
||||
codemap = "0.1"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use crate::TokenWriter;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, NodeOrToken, SyntaxKind, SyntaxNode};
|
||||
use slint_compiler_internal::parser::{syntax_nodes, NodeOrToken, SyntaxKind, SyntaxNode};
|
||||
|
||||
pub(crate) fn format_document(
|
||||
doc: syntax_nodes::Document,
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
LSP wants just the edits , not the full file
|
||||
*/
|
||||
|
||||
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxNode, SyntaxToken};
|
||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxNode, SyntaxToken};
|
||||
use std::io::Write;
|
||||
|
||||
use clap::Parser;
|
||||
|
@ -93,7 +93,7 @@ fn process_rust_file(source: String, mut file: impl Write) -> std::io::Result<()
|
|||
source_slice = &source_slice[idx - 1..];
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let syntax_node = slint_compiler_internal::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let len = syntax_node.text_range().end().into();
|
||||
visit_node(syntax_node, &mut file, &mut State::default())?;
|
||||
if diag.has_error() {
|
||||
|
@ -123,7 +123,7 @@ fn process_markdown_file(source: String, mut file: impl Write) -> std::io::Resul
|
|||
source_slice = &source_slice[code_end..];
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let syntax_node = slint_compiler_internal::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let len = syntax_node.text_range().end().into();
|
||||
visit_node(syntax_node, &mut file, &mut State::default())?;
|
||||
if diag.has_error() {
|
||||
|
@ -146,7 +146,8 @@ fn process_file(
|
|||
}
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse(source.clone(), Some(&path), &mut diag);
|
||||
let syntax_node =
|
||||
slint_compiler_internal::parser::parse(source.clone(), Some(&path), &mut diag);
|
||||
let len = syntax_node.node.text_range().end().into();
|
||||
visit_node(syntax_node, &mut file, &mut State::default())?;
|
||||
if diag.has_error() {
|
||||
|
|
|
@ -30,7 +30,7 @@ x11 = ["sixtyfps-interpreter/x11"]
|
|||
default = ["sixtyfps-backend-qt", "sixtyfps-backend-gl", "x11"]
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { version = "=0.2.0", path = "../../internal/compiler"}
|
||||
slint-compiler-internal = { version = "=0.2.0", path = "../../internal/compiler"}
|
||||
slint-core-internal = { version = "=0.2.0", path = "../../internal/core"}
|
||||
sixtyfps-interpreter = { version = "=0.2.0", path = "../../internal/interpreter", default-features = false, features = ["compat-0-2-0"] }
|
||||
slint-backend-selector-internal = { version = "=0.2.0", path="../../internal/backends/selector" }
|
||||
|
|
|
@ -8,11 +8,11 @@ use super::DocumentCache;
|
|||
use lsp_types::{
|
||||
CompletionClientCapabilities, CompletionItem, CompletionItemKind, InsertTextFormat,
|
||||
};
|
||||
use sixtyfps_compilerlib::diagnostics::Spanned;
|
||||
use sixtyfps_compilerlib::expression_tree::Expression;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::lookup::{LookupCtx, LookupObject, LookupResult};
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxKind, SyntaxToken};
|
||||
use slint_compiler_internal::diagnostics::Spanned;
|
||||
use slint_compiler_internal::expression_tree::Expression;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::lookup::{LookupCtx, LookupObject, LookupResult};
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxKind, SyntaxToken};
|
||||
|
||||
pub(crate) fn completion_at(
|
||||
document_cache: &DocumentCache,
|
||||
|
@ -171,8 +171,9 @@ pub(crate) fn completion_at(
|
|||
if first.as_ref().map_or(true, |f| f.token == token.token) {
|
||||
return resolve_expression_scope(ctx);
|
||||
}
|
||||
let first = sixtyfps_compilerlib::parser::normalize_identifier(first?.text());
|
||||
let global = sixtyfps_compilerlib::lookup::global_lookup();
|
||||
let first =
|
||||
slint_compiler_internal::parser::normalize_identifier(first?.text());
|
||||
let global = slint_compiler_internal::lookup::global_lookup();
|
||||
let mut expr_it = global.lookup(ctx, &first)?;
|
||||
let mut has_dot = false;
|
||||
for t in it {
|
||||
|
@ -184,7 +185,7 @@ pub(crate) fn completion_at(
|
|||
continue;
|
||||
}
|
||||
has_dot = false;
|
||||
let str = sixtyfps_compilerlib::parser::normalize_identifier(t.text());
|
||||
let str = slint_compiler_internal::parser::normalize_identifier(t.text());
|
||||
expr_it = expr_it.lookup(ctx, &str)?;
|
||||
}
|
||||
has_dot.then(|| {
|
||||
|
@ -245,7 +246,7 @@ fn resolve_element_scope(
|
|||
})
|
||||
.chain(element.PropertyDeclaration().map(|pr| {
|
||||
let mut c = CompletionItem::new_simple(
|
||||
sixtyfps_compilerlib::parser::identifier_text(&pr.DeclaredIdentifier())
|
||||
slint_compiler_internal::parser::identifier_text(&pr.DeclaredIdentifier())
|
||||
.unwrap_or_default(),
|
||||
pr.Type().map(|t| t.text().into()).unwrap_or_else(|| "property".to_owned()),
|
||||
);
|
||||
|
@ -254,14 +255,14 @@ fn resolve_element_scope(
|
|||
}))
|
||||
.chain(element.CallbackDeclaration().map(|cd| {
|
||||
let mut c = CompletionItem::new_simple(
|
||||
sixtyfps_compilerlib::parser::identifier_text(&cd.DeclaredIdentifier())
|
||||
slint_compiler_internal::parser::identifier_text(&cd.DeclaredIdentifier())
|
||||
.unwrap_or_default(),
|
||||
"callback".into(),
|
||||
);
|
||||
c.kind = Some(CompletionItemKind::METHOD);
|
||||
c
|
||||
}))
|
||||
.chain(sixtyfps_compilerlib::typeregister::reserved_properties().filter_map(
|
||||
.chain(slint_compiler_internal::typeregister::reserved_properties().filter_map(
|
||||
|(k, t)| {
|
||||
if matches!(t, Type::Function { .. }) {
|
||||
return None;
|
||||
|
@ -291,7 +292,7 @@ fn resolve_element_scope(
|
|||
|
||||
fn resolve_expression_scope(lookup_context: &LookupCtx) -> Option<Vec<CompletionItem>> {
|
||||
let mut r = Vec::new();
|
||||
let global = sixtyfps_compilerlib::lookup::global_lookup();
|
||||
let global = slint_compiler_internal::lookup::global_lookup();
|
||||
global.for_each_entry(lookup_context, &mut |str, expr| -> Option<()> {
|
||||
r.push(completion_item_from_expression(str, expr));
|
||||
None
|
||||
|
|
|
@ -5,11 +5,11 @@ use std::path::Path;
|
|||
|
||||
use super::DocumentCache;
|
||||
use lsp_types::{GotoDefinitionResponse, LocationLink, Range, Url};
|
||||
use sixtyfps_compilerlib::diagnostics::Spanned;
|
||||
use sixtyfps_compilerlib::expression_tree::Expression;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::lookup::{LookupObject, LookupResult};
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||
use slint_compiler_internal::diagnostics::Spanned;
|
||||
use slint_compiler_internal::expression_tree::Expression;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::lookup::{LookupObject, LookupResult};
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||
|
||||
pub fn goto_definition(
|
||||
document_cache: &mut DocumentCache,
|
||||
|
@ -21,14 +21,16 @@ pub fn goto_definition(
|
|||
let parent = n.parent()?;
|
||||
return match parent.kind() {
|
||||
SyntaxKind::Element | SyntaxKind::Type => {
|
||||
let qual = sixtyfps_compilerlib::object_tree::QualifiedTypeName::from_node(n);
|
||||
let qual =
|
||||
slint_compiler_internal::object_tree::QualifiedTypeName::from_node(n);
|
||||
let doc = document_cache.documents.get_document(node.source_file.path())?;
|
||||
match doc.local_registry.lookup_qualified(&qual.members) {
|
||||
sixtyfps_compilerlib::langtype::Type::Component(c) => {
|
||||
slint_compiler_internal::langtype::Type::Component(c) => {
|
||||
goto_node(document_cache, &*c.root_element.borrow().node.as_ref()?)
|
||||
}
|
||||
sixtyfps_compilerlib::langtype::Type::Struct {
|
||||
node: Some(node), ..
|
||||
slint_compiler_internal::langtype::Type::Struct {
|
||||
node: Some(node),
|
||||
..
|
||||
} => goto_node(document_cache, node.parent().as_ref()?),
|
||||
_ => None,
|
||||
}
|
||||
|
@ -44,13 +46,14 @@ pub fn goto_definition(
|
|||
.filter(|t| t.kind() == SyntaxKind::Identifier);
|
||||
let mut cur_tok = it.next()?;
|
||||
let first_str =
|
||||
sixtyfps_compilerlib::parser::normalize_identifier(cur_tok.text());
|
||||
let global = sixtyfps_compilerlib::lookup::global_lookup();
|
||||
slint_compiler_internal::parser::normalize_identifier(cur_tok.text());
|
||||
let global = slint_compiler_internal::lookup::global_lookup();
|
||||
let mut expr_it = global.lookup(ctx, &first_str)?;
|
||||
while cur_tok.token != token.token {
|
||||
cur_tok = it.next()?;
|
||||
let str =
|
||||
sixtyfps_compilerlib::parser::normalize_identifier(cur_tok.text());
|
||||
let str = slint_compiler_internal::parser::normalize_identifier(
|
||||
cur_tok.text(),
|
||||
);
|
||||
expr_it = expr_it.lookup(ctx, &str)?;
|
||||
}
|
||||
Some(expr_it)
|
||||
|
@ -86,9 +89,9 @@ pub fn goto_definition(
|
|||
};
|
||||
} else if let Some(n) = syntax_nodes::ImportIdentifier::new(node.clone()) {
|
||||
let doc = document_cache.documents.get_document(node.source_file.path())?;
|
||||
let imp_name = sixtyfps_compilerlib::typeloader::ImportedName::from_node(n);
|
||||
let imp_name = slint_compiler_internal::typeloader::ImportedName::from_node(n);
|
||||
return match doc.local_registry.lookup(&imp_name.internal_name) {
|
||||
sixtyfps_compilerlib::langtype::Type::Component(c) => {
|
||||
slint_compiler_internal::langtype::Type::Component(c) => {
|
||||
goto_node(document_cache, &*c.root_element.borrow().node.as_ref()?)
|
||||
}
|
||||
_ => None,
|
||||
|
@ -114,7 +117,7 @@ pub fn goto_definition(
|
|||
let prop_name = token.text();
|
||||
let element = syntax_nodes::Element::new(n.parent()?)?;
|
||||
if let Some(p) = element.PropertyDeclaration().find_map(|p| {
|
||||
(sixtyfps_compilerlib::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
(slint_compiler_internal::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
== prop_name)
|
||||
.then(|| p)
|
||||
}) {
|
||||
|
@ -132,7 +135,7 @@ pub fn goto_definition(
|
|||
}
|
||||
let element = syntax_nodes::Element::new(n.parent()?)?;
|
||||
if let Some(p) = element.PropertyDeclaration().find_map(|p| {
|
||||
(sixtyfps_compilerlib::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
(slint_compiler_internal::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
== prop_name)
|
||||
.then(|| p)
|
||||
}) {
|
||||
|
@ -150,7 +153,7 @@ pub fn goto_definition(
|
|||
}
|
||||
let element = syntax_nodes::Element::new(n.parent()?)?;
|
||||
if let Some(p) = element.CallbackDeclaration().find_map(|p| {
|
||||
(sixtyfps_compilerlib::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
(slint_compiler_internal::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
== prop_name)
|
||||
.then(|| p)
|
||||
}) {
|
||||
|
|
|
@ -24,12 +24,12 @@ use lsp_types::{
|
|||
SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions, ServerCapabilities,
|
||||
SymbolInformation, TextDocumentSyncCapability, Url, WorkDoneProgressOptions,
|
||||
};
|
||||
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||
use sixtyfps_compilerlib::typeloader::TypeLoader;
|
||||
use sixtyfps_compilerlib::typeregister::TypeRegister;
|
||||
use sixtyfps_compilerlib::CompilerConfiguration;
|
||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||
use slint_compiler_internal::typeloader::TypeLoader;
|
||||
use slint_compiler_internal::typeregister::TypeRegister;
|
||||
use slint_compiler_internal::CompilerConfiguration;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
|
@ -183,7 +183,7 @@ fn main_loop(connection: &Connection, params: serde_json::Value) -> Result<(), E
|
|||
let cli_args: Cli = Cli::parse();
|
||||
let params: InitializeParams = serde_json::from_value(params).unwrap();
|
||||
let mut compiler_config =
|
||||
CompilerConfiguration::new(sixtyfps_compilerlib::generator::OutputFormat::Interpreter);
|
||||
CompilerConfiguration::new(slint_compiler_internal::generator::OutputFormat::Interpreter);
|
||||
compiler_config.style =
|
||||
Some(if cli_args.style.is_empty() { "fluent".into() } else { cli_args.style });
|
||||
compiler_config.include_paths = cli_args.include_paths;
|
||||
|
@ -400,7 +400,7 @@ fn maybe_goto_preview(
|
|||
loop {
|
||||
if let Some(component) = syntax_nodes::Component::new(node.clone()) {
|
||||
let component_name =
|
||||
sixtyfps_compilerlib::parser::identifier_text(&component.DeclaredIdentifier())?;
|
||||
slint_compiler_internal::parser::identifier_text(&component.DeclaredIdentifier())?;
|
||||
preview::load_preview(
|
||||
sender,
|
||||
preview::PreviewComponent {
|
||||
|
@ -518,7 +518,7 @@ fn get_code_actions(
|
|||
})?;
|
||||
|
||||
let component_name =
|
||||
sixtyfps_compilerlib::parser::identifier_text(&component.DeclaredIdentifier())?;
|
||||
slint_compiler_internal::parser::identifier_text(&component.DeclaredIdentifier())?;
|
||||
|
||||
Some(vec![CodeActionOrCommand::Command(Command::new(
|
||||
"Show preview".into(),
|
||||
|
@ -540,7 +540,7 @@ fn get_document_color(
|
|||
if token.kind() == SyntaxKind::ColorLiteral {
|
||||
(|| -> Option<()> {
|
||||
let range = token.text_range();
|
||||
let col = sixtyfps_compilerlib::literals::parse_color_literal(token.text())?;
|
||||
let col = slint_compiler_internal::literals::parse_color_literal(token.text())?;
|
||||
let shift = |s: u32| -> f32 { ((col >> s) & 0xff) as f32 / 255. };
|
||||
result.push(ColorInformation {
|
||||
range: Range::new(
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use lsp_types::{
|
||||
SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens, SemanticTokensResult,
|
||||
};
|
||||
use sixtyfps_compilerlib::parser::SyntaxKind;
|
||||
use slint_compiler_internal::parser::SyntaxKind;
|
||||
|
||||
use crate::DocumentCache;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
use sixtyfps_compilerlib::diagnostics::Spanned;
|
||||
use sixtyfps_compilerlib::langtype::Type;
|
||||
use sixtyfps_compilerlib::lookup::LookupCtx;
|
||||
use sixtyfps_compilerlib::object_tree;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxKind, SyntaxNode};
|
||||
use sixtyfps_compilerlib::typeregister::TypeRegister;
|
||||
use slint_compiler_internal::diagnostics::Spanned;
|
||||
use slint_compiler_internal::langtype::Type;
|
||||
use slint_compiler_internal::lookup::LookupCtx;
|
||||
use slint_compiler_internal::object_tree;
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxKind, SyntaxNode};
|
||||
use slint_compiler_internal::typeregister::TypeRegister;
|
||||
|
||||
use crate::DocumentCache;
|
||||
|
||||
|
@ -58,7 +58,8 @@ pub fn with_lookup_ctx<R>(
|
|||
let ty = element
|
||||
.PropertyDeclaration()
|
||||
.find_map(|p| {
|
||||
(sixtyfps_compilerlib::parser::identifier_text(&p.DeclaredIdentifier())? == prop_name)
|
||||
(slint_compiler_internal::parser::identifier_text(&p.DeclaredIdentifier())?
|
||||
== prop_name)
|
||||
.then(|| p)
|
||||
})
|
||||
.and_then(|p| p.Type())
|
||||
|
@ -79,8 +80,9 @@ pub fn with_lookup_ctx<R>(
|
|||
}
|
||||
};
|
||||
|
||||
let component = sixtyfps_compilerlib::parser::identifier_text(&component.DeclaredIdentifier())
|
||||
.map(|component_name| tr.lookup(&component_name))?;
|
||||
let component =
|
||||
slint_compiler_internal::parser::identifier_text(&component.DeclaredIdentifier())
|
||||
.map(|component_name| tr.lookup(&component_name))?;
|
||||
let scope =
|
||||
if let Type::Component(c) = component { vec![c.root_element.clone()] } else { Vec::new() };
|
||||
|
||||
|
@ -97,7 +99,7 @@ fn lookup_expression_context(mut n: SyntaxNode) -> Option<(syntax_nodes::Element
|
|||
let (element, prop_name) = loop {
|
||||
if let Some(decl) = syntax_nodes::PropertyDeclaration::new(n.clone()) {
|
||||
let prop_name =
|
||||
sixtyfps_compilerlib::parser::identifier_text(&decl.DeclaredIdentifier())?;
|
||||
slint_compiler_internal::parser::identifier_text(&decl.DeclaredIdentifier())?;
|
||||
let element = syntax_nodes::Element::new(n.parent()?)?;
|
||||
break (element, prop_name);
|
||||
}
|
||||
|
@ -106,7 +108,7 @@ fn lookup_expression_context(mut n: SyntaxNode) -> Option<(syntax_nodes::Element
|
|||
| SyntaxKind::TwoWayBinding
|
||||
// FIXME: arguments of the callback
|
||||
| SyntaxKind::CallbackConnection => {
|
||||
let prop_name = sixtyfps_compilerlib::parser::identifier_text(&n)?;
|
||||
let prop_name = slint_compiler_internal::parser::identifier_text(&n)?;
|
||||
let element = syntax_nodes::Element::new(n.parent()?)?;
|
||||
break (element, prop_name);
|
||||
}
|
||||
|
@ -126,7 +128,7 @@ fn lookup_expression_context(mut n: SyntaxNode) -> Option<(syntax_nodes::Element
|
|||
Some((element, prop_name))
|
||||
}
|
||||
|
||||
pub fn to_lsp_diag(d: &sixtyfps_compilerlib::diagnostics::Diagnostic) -> lsp_types::Diagnostic {
|
||||
pub fn to_lsp_diag(d: &slint_compiler_internal::diagnostics::Diagnostic) -> lsp_types::Diagnostic {
|
||||
lsp_types::Diagnostic::new(
|
||||
to_range(d.line_column()),
|
||||
Some(to_lsp_diag_level(d.level())),
|
||||
|
@ -147,7 +149,7 @@ fn to_range(span: (usize, usize)) -> lsp_types::Range {
|
|||
}
|
||||
|
||||
fn to_lsp_diag_level(
|
||||
level: sixtyfps_compilerlib::diagnostics::DiagnosticLevel,
|
||||
level: slint_compiler_internal::diagnostics::DiagnosticLevel,
|
||||
) -> lsp_types::DiagnosticSeverity {
|
||||
match level {
|
||||
sixtyfps_interpreter::DiagnosticLevel::Error => lsp_types::DiagnosticSeverity::ERROR,
|
||||
|
|
|
@ -14,7 +14,7 @@ homepage = "https://sixtyfps.io"
|
|||
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-compilerlib = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||
slint-compiler-internal = { path = "../../internal/compiler", features = ["display-diagnostics"] }
|
||||
|
||||
clap = { version = "3.0.5", features=["derive", "wrap_help"] }
|
||||
codemap = "0.1"
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
use std::io::Write;
|
||||
|
||||
use sixtyfps_compilerlib::object_tree;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxNode};
|
||||
use slint_compiler_internal::object_tree;
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxNode};
|
||||
|
||||
/// Replace the 'color' type with 'brush', and the 'resource' type with 'image', and the 'logical_length' to 'length'
|
||||
pub(crate) fn fold_node(
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
use std::io::Write;
|
||||
|
||||
use sixtyfps_compilerlib::object_tree;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxNode};
|
||||
use slint_compiler_internal::object_tree;
|
||||
use slint_compiler_internal::parser::{syntax_nodes, SyntaxNode};
|
||||
|
||||
/// Remove colspan, rowspan, col and row for items not in a GridLayout
|
||||
pub(crate) fn fold_node(
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
//! cargo run --bin syntax_updater -- --from 0.0.5 -i **/*.md
|
||||
//! ````
|
||||
|
||||
use sixtyfps_compilerlib::diagnostics::BuildDiagnostics;
|
||||
use sixtyfps_compilerlib::object_tree;
|
||||
use sixtyfps_compilerlib::parser::{syntax_nodes, NodeOrToken, SyntaxKind, SyntaxNode};
|
||||
use slint_compiler_internal::diagnostics::BuildDiagnostics;
|
||||
use slint_compiler_internal::object_tree;
|
||||
use slint_compiler_internal::parser::{syntax_nodes, NodeOrToken, SyntaxKind, SyntaxNode};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
|
@ -102,7 +102,7 @@ fn process_rust_file(source: String, mut file: impl Write, args: &Cli) -> std::i
|
|||
source_slice = &source_slice[idx - 1..];
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let syntax_node = slint_compiler_internal::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let len = syntax_node.text_range().end().into();
|
||||
visit_node(syntax_node, &mut file, &mut State::default(), args)?;
|
||||
if diag.has_error() {
|
||||
|
@ -131,7 +131,7 @@ fn process_markdown_file(source: String, mut file: impl Write, args: &Cli) -> st
|
|||
source_slice = &source_slice[code_end..];
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let syntax_node = slint_compiler_internal::parser::parse(code.to_owned(), None, &mut diag);
|
||||
let len = syntax_node.text_range().end().into();
|
||||
visit_node(syntax_node, &mut file, &mut State::default(), args)?;
|
||||
if diag.has_error() {
|
||||
|
@ -155,7 +155,7 @@ fn process_file(
|
|||
}
|
||||
|
||||
let mut diag = BuildDiagnostics::default();
|
||||
let syntax_node = sixtyfps_compilerlib::parser::parse(source.clone(), Some(path), &mut diag);
|
||||
let syntax_node = slint_compiler_internal::parser::parse(source.clone(), Some(path), &mut diag);
|
||||
let len = syntax_node.node.text_range().end().into();
|
||||
visit_node(syntax_node, &mut file, &mut State::default(), args)?;
|
||||
if diag.has_error() {
|
||||
|
@ -227,7 +227,7 @@ fn fold_node(
|
|||
}
|
||||
|
||||
fn fold_token(
|
||||
node: sixtyfps_compilerlib::parser::SyntaxToken,
|
||||
node: slint_compiler_internal::parser::SyntaxToken,
|
||||
file: &mut impl Write,
|
||||
#[allow(unused)] state: &mut State,
|
||||
) -> std::io::Result<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue