diff --git a/examples/basic.rs b/examples/basic.rs index aa39114..7d2f88f 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,9 +1,7 @@ //! A simple example -use bevy::{ - log::{Level, LogPlugin}, - prelude::*, -}; +use bevy::log::{Level, LogPlugin}; +use bevy::prelude::*; use bevy_dev_console::prelude::*; fn main() { diff --git a/examples/custom_functions.rs b/examples/custom_functions.rs index d9a6eed..35e6906 100644 --- a/examples/custom_functions.rs +++ b/examples/custom_functions.rs @@ -1,14 +1,10 @@ //! A simple exmaple -use bevy::{ - log::{Level, LogPlugin}, - prelude::*, -}; -use bevy_dev_console::{ - builtin_parser::{Environment, Number, RunError, Spanned, StrongRef, Value}, - prelude::*, - register, -}; +use bevy::log::{Level, LogPlugin}; +use bevy::prelude::*; +use bevy_dev_console::builtin_parser::{Environment, Number, RunError, Spanned, StrongRef, Value}; +use bevy_dev_console::prelude::*; +use bevy_dev_console::register; // Declare the functions we want to create: diff --git a/examples/resource.rs b/examples/resource.rs index 3e13b64..87a426a 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -2,7 +2,8 @@ //! //! **Warning:** This is very experimental, might not work. -use bevy::{log::LogPlugin, prelude::*}; +use bevy::log::LogPlugin; +use bevy::prelude::*; use bevy_dev_console::prelude::*; #[derive(Resource, Reflect, Default, Debug)] diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..c1578aa --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +imports_granularity = "Module" diff --git a/src/builtin_parser.rs b/src/builtin_parser.rs index 83d79ee..7d9ad0c 100644 --- a/src/builtin_parser.rs +++ b/src/builtin_parser.rs @@ -9,7 +9,8 @@ use logos::Span; use crate::command::{CommandParser, DefaultCommandParser}; -use self::{lexer::TokenStream, parser::parse}; +use self::lexer::TokenStream; +use self::parser::parse; pub(crate) mod lexer; pub(crate) mod number; @@ -17,7 +18,10 @@ pub(crate) mod parser; pub(crate) mod runner; pub use number::*; -pub use runner::{environment::Environment, error::RunError, unique_rc::*, Value}; +pub use runner::environment::Environment; +pub use runner::error::RunError; +pub use runner::unique_rc::*; +pub use runner::Value; /// Additonal traits for span. pub trait SpanExtension { diff --git a/src/builtin_parser/parser.rs b/src/builtin_parser/parser.rs index 0d1368a..dfad75b 100644 --- a/src/builtin_parser/parser.rs +++ b/src/builtin_parser/parser.rs @@ -1,14 +1,13 @@ //! Generates an abstract syntax tree from a list of tokens. use logos::Span; -use std::{collections::HashMap, num::IntErrorKind}; +use std::collections::HashMap; +use std::num::IntErrorKind; -use super::{ - lexer::{FailedToLexCharacter, Token, TokenStream}, - number::Number, - runner::environment::Function, - Environment, Spanned, -}; +use super::lexer::{FailedToLexCharacter, Token, TokenStream}; +use super::number::Number; +use super::runner::environment::Function; +use super::{Environment, Spanned}; /// An [Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree). /// @@ -456,10 +455,9 @@ fn parse_object( #[cfg(test)] mod tests { - use super::{ - super::{lexer::TokenStream, Environment}, - parse, - }; + use super::super::lexer::TokenStream; + use super::super::Environment; + use super::parse; #[test] fn var_assign() { diff --git a/src/builtin_parser/runner.rs b/src/builtin_parser/runner.rs index c065baa..fb4e42e 100644 --- a/src/builtin_parser/runner.rs +++ b/src/builtin_parser/runner.rs @@ -1,25 +1,22 @@ //! Executes the abstract syntax tree. -use std::{cell::RefCell, collections::HashMap, rc::Rc}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; use environment::Environment; -use crate::{command::CommandHints, ui::COMMAND_RESULT_NAME}; - -use self::{ - error::RunError, - reflection::{object_to_dynamic_struct, CreateRegistration, IntoResource}, - unique_rc::{UniqueRc, WeakRef}, -}; - -use super::{ - parser::{Ast, Expression, Operator}, - Number, SpanExtension, Spanned, -}; -use bevy::{ - prelude::*, - reflect::{DynamicEnum, ReflectMut, TypeInfo, TypeRegistration, VariantInfo}, -}; +use crate::command::CommandHints; +use crate::ui::COMMAND_RESULT_NAME; + +use self::error::RunError; +use self::reflection::{object_to_dynamic_struct, CreateRegistration, IntoResource}; +use self::unique_rc::{UniqueRc, WeakRef}; + +use super::parser::{Ast, Expression, Operator}; +use super::{Number, SpanExtension, Spanned}; +use bevy::prelude::*; +use bevy::reflect::{DynamicEnum, ReflectMut, TypeInfo, TypeRegistration, VariantInfo}; pub mod environment; pub mod error; diff --git a/src/builtin_parser/runner/environment.rs b/src/builtin_parser/runner/environment.rs index ffe3c5b..38f7e0a 100644 --- a/src/builtin_parser/runner/environment.rs +++ b/src/builtin_parser/runner/environment.rs @@ -1,19 +1,20 @@ //! Environment and function registeration -use std::{collections::HashMap, fmt::Debug}; +use std::collections::HashMap; +use std::fmt::Debug; -use bevy::{ecs::world::World, log::warn, reflect::TypeRegistration}; +use bevy::ecs::world::World; +use bevy::log::warn; +use bevy::reflect::TypeRegistration; use logos::Span; use crate::builtin_parser::SpanExtension; -use super::{ - super::{parser::Expression, Spanned}, - error::RunError, - eval_expression, stdlib, - unique_rc::UniqueRc, - EvalParams, Value, -}; +use super::super::parser::Expression; +use super::super::Spanned; +use super::error::RunError; +use super::unique_rc::UniqueRc; +use super::{eval_expression, stdlib, EvalParams, Value}; /// Macro for mass registering functions. /// diff --git a/src/builtin_parser/runner/error.rs b/src/builtin_parser/runner/error.rs index f9a397e..8fc7d93 100644 --- a/src/builtin_parser/runner/error.rs +++ b/src/builtin_parser/runner/error.rs @@ -2,10 +2,9 @@ use std::borrow::Cow; use logos::Span; -use crate::{ - builtin_parser::{number::Number, Spanned}, - command::{CommandHint, CommandHintColor}, -}; +use crate::builtin_parser::number::Number; +use crate::builtin_parser::Spanned; +use crate::command::{CommandHint, CommandHintColor}; use super::Value; diff --git a/src/builtin_parser/runner/reflection.rs b/src/builtin_parser/runner/reflection.rs index 587c644..fe35283 100644 --- a/src/builtin_parser/runner/reflection.rs +++ b/src/builtin_parser/runner/reflection.rs @@ -1,9 +1,8 @@ -use std::{any::TypeId, collections::HashMap}; +use std::any::TypeId; +use std::collections::HashMap; -use bevy::{ - prelude::*, - reflect::{DynamicStruct, ReflectFromPtr, TypeRegistration}, -}; +use bevy::prelude::*; +use bevy::reflect::{DynamicStruct, ReflectFromPtr, TypeRegistration}; use super::Value; diff --git a/src/builtin_parser/runner/stdlib.rs b/src/builtin_parser/runner/stdlib.rs index ef111f4..78f7063 100644 --- a/src/builtin_parser/runner/stdlib.rs +++ b/src/builtin_parser/runner/stdlib.rs @@ -1,8 +1,13 @@ -use crate::{builtin_parser::runner::environment::Variable, register}; -use bevy::{ecs::world::World, log::info, reflect::TypeRegistration}; -use std::{cell::Ref, ops::Range}; +use crate::builtin_parser::runner::environment::Variable; +use crate::register; +use bevy::ecs::world::World; +use bevy::log::info; +use bevy::reflect::TypeRegistration; +use std::cell::Ref; +use std::ops::Range; -use super::{error::RunError, Environment, Spanned, Value}; +use super::error::RunError; +use super::{Environment, Spanned, Value}; fn print( value: Spanned, diff --git a/src/builtin_parser/runner/unique_rc.rs b/src/builtin_parser/runner/unique_rc.rs index 1fb3f47..bbb5e84 100644 --- a/src/builtin_parser/runner/unique_rc.rs +++ b/src/builtin_parser/runner/unique_rc.rs @@ -1,9 +1,7 @@ -use std::{ - cell::{Ref, RefCell, RefMut}, - fmt::Debug, - ops::{Deref, DerefMut}, - rc::{Rc, Weak}, -}; +use std::cell::{Ref, RefCell, RefMut}; +use std::fmt::Debug; +use std::ops::{Deref, DerefMut}; +use std::rc::{Rc, Weak}; /// A uniquely owned [`Rc`] with interior mutability. Interior mutability is abstracted away with [`WeakRef`]. /// diff --git a/src/builtin_parser/runner/value.rs b/src/builtin_parser/runner/value.rs index 08df394..c929bab 100644 --- a/src/builtin_parser/runner/value.rs +++ b/src/builtin_parser/runner/value.rs @@ -1,14 +1,16 @@ +use std::cell::RefCell; use std::collections::HashMap; use std::fmt::Debug; -use std::{cell::RefCell, rc::Rc}; +use std::rc::Rc; use crate::builtin_parser::number::Number; use crate::builtin_parser::{Environment, StrongRef}; +use super::super::Spanned; use super::environment::FunctionParam; +use super::error::RunError; use super::reflection::{CreateRegistration, IntoResource}; use super::unique_rc::WeakRef; -use super::{super::Spanned, error::RunError}; use bevy::ecs::world::World; use bevy::reflect::{ diff --git a/src/command.rs b/src/command.rs index 4a46967..2e81dc2 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,8 +1,10 @@ //! Command execution functionality. -use std::{borrow::Cow, ops::Range}; +use std::borrow::Cow; +use std::ops::Range; -use bevy::{ecs::system::Command, prelude::*}; +use bevy::ecs::system::Command; +use bevy::prelude::*; /// The command parser currrently being used by the dev console. #[derive(Resource)] diff --git a/src/config.rs b/src/config.rs index 8a53f89..431008e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,7 @@ //! Configuration structs for the developer console. -use bevy::{log::Level, prelude::*}; +use bevy::log::Level; +use bevy::prelude::*; use bevy_egui::egui::{Color32, FontId, TextFormat}; /// The configuration of the developer console. diff --git a/src/logging/android_tracing.rs b/src/logging/android_tracing.rs index 4145a83..51cd6d9 100644 --- a/src/logging/android_tracing.rs +++ b/src/logging/android_tracing.rs @@ -1,10 +1,11 @@ -use bevy::utils::tracing::{ - field::Field, - span::{Attributes, Record}, - Event, Id, Level, Subscriber, -}; +use bevy::utils::tracing::field::Field; +use bevy::utils::tracing::span::{Attributes, Record}; +use bevy::utils::tracing::{Event, Id, Level, Subscriber}; use std::fmt::{Debug, Write}; -use tracing_subscriber::{field::Visit, layer::Context, registry::LookupSpan, Layer}; +use tracing_subscriber::field::Visit; +use tracing_subscriber::layer::Context; +use tracing_subscriber::registry::LookupSpan; +use tracing_subscriber::Layer; #[derive(Default)] pub(crate) struct AndroidLayer; diff --git a/src/logging/log_plugin.rs b/src/logging/log_plugin.rs index ea684dc..386fa2b 100644 --- a/src/logging/log_plugin.rs +++ b/src/logging/log_plugin.rs @@ -23,21 +23,21 @@ mod android_tracing; static GLOBAL: tracy_client::ProfiledAllocator = tracy_client::ProfiledAllocator::new(std::alloc::System, 100); +use bevy::ecs::event::{Event, EventWriter}; +use bevy::ecs::system::{Res, Resource}; +use bevy::log::trace; use bevy::utils::tracing::Subscriber; pub use bevy::utils::tracing::{warn, Level}; -use bevy::{ - ecs::{ - event::{Event, EventWriter}, - system::{Res, Resource}, - }, - log::trace, -}; use bevy::app::{App, Plugin, Update}; use tracing_log::LogTracer; +use tracing_subscriber::field::Visit; #[cfg(feature = "tracing-chrome")] use tracing_subscriber::fmt::{format::DefaultFields, FormattedFields}; -use tracing_subscriber::{field::Visit, layer::Layer, prelude::*, registry::Registry, EnvFilter}; +use tracing_subscriber::layer::Layer; +use tracing_subscriber::prelude::*; +use tracing_subscriber::registry::Registry; +use tracing_subscriber::EnvFilter; /// [`bevy_dev_console`](crate)'s custom [LogPlugin](bevy::log::LogPlugin). /// This plugin allows [`bevy_dev_console`](crate) to access Bevy logs diff --git a/src/ui.rs b/src/ui.rs index 144b5ed..f944710 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -3,19 +3,16 @@ //! Made with [`bevy_egui`]. use bevy::prelude::*; -use bevy_egui::{ - egui::{text::LayoutJob, Stroke, TextFormat}, - *, -}; +use bevy_egui::egui::text::LayoutJob; +use bevy_egui::egui::{Stroke, TextFormat}; +use bevy_egui::*; use chrono::prelude::*; use web_time::SystemTime; -use crate::{ - command::{CommandHints, ExecuteCommand}, - config::ToColor32, - logging::log_plugin::LogMessage, - prelude::ConsoleConfig, -}; +use crate::command::{CommandHints, ExecuteCommand}; +use crate::config::ToColor32; +use crate::logging::log_plugin::LogMessage; +use crate::prelude::ConsoleConfig; /// Prefix for log messages that show a previous command. pub const COMMAND_MESSAGE_PREFIX: &str = "$ ";