From ce5b078130135b630676737c3c720f0e4a63948b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Dani=C5=82o?= Date: Fri, 27 Jan 2023 23:39:37 +0100 Subject: [PATCH] Dependency cleaning (#4092) --- Cargo.lock | 262 ++-------- Cargo.toml | 40 +- app/gui/Cargo.toml | 23 +- app/gui/analytics/Cargo.toml | 2 +- app/gui/config/Cargo.toml | 3 +- .../double-representation/Cargo.toml | 13 +- .../src/alias_analysis.rs | 8 +- .../src/alias_analysis/test_utils.rs | 6 +- .../double-representation/src/definition.rs | 2 +- .../double-representation/src/graph.rs | 8 +- .../double-representation/src/identifier.rs | 4 +- .../double-representation/src/lib.rs | 1 - .../double-representation/src/module.rs | 2 +- .../double-representation/src/node.rs | 10 +- .../double-representation/src/text.rs | 4 +- app/gui/controller/engine-protocol/Cargo.toml | 13 +- .../engine-protocol/src/binary/client.rs | 9 +- .../engine-protocol/src/binary/message.rs | 6 +- .../controller/engine-protocol/src/handler.rs | 26 +- app/gui/controller/engine-protocol/src/lib.rs | 2 - .../controller/engine-protocol/src/types.rs | 2 +- app/gui/language/ast/impl/Cargo.toml | 9 +- app/gui/language/ast/impl/src/crumbs.rs | 4 +- app/gui/language/ast/impl/src/lib.rs | 25 +- app/gui/language/ast/impl/src/macros.rs | 10 +- app/gui/language/parser/Cargo.toml | 15 +- app/gui/language/parser/src/api.rs | 7 +- .../parser/src/bin/run-scala-parser.rs | 18 +- app/gui/language/parser/src/lib.rs | 6 +- app/gui/language/parser/src/test_utils.rs | 2 +- app/gui/language/parser/src/wsclient.rs | 4 +- app/gui/language/span-tree/Cargo.toml | 2 +- app/gui/language/span-tree/example/Cargo.toml | 1 - app/gui/language/span-tree/example/src/lib.rs | 2 +- app/gui/src/controller/graph.rs | 26 +- app/gui/src/controller/graph/executed.rs | 21 +- app/gui/src/controller/ide/desktop.rs | 18 +- app/gui/src/controller/ide/plain.rs | 8 +- app/gui/src/controller/module.rs | 22 +- app/gui/src/controller/project.rs | 13 +- app/gui/src/controller/searcher.rs | 18 +- app/gui/src/controller/searcher/component.rs | 2 +- app/gui/src/controller/text.rs | 29 +- app/gui/src/controller/upload.rs | 38 +- app/gui/src/controller/visualization.rs | 14 +- app/gui/src/ide/initializer.rs | 16 +- .../model/execution_context/synchronized.rs | 15 +- app/gui/src/model/module.rs | 4 +- app/gui/src/model/module/synchronized.rs | 4 +- app/gui/src/model/project/synchronized.rs | 66 +-- app/gui/src/model/undo_redo.rs | 32 +- app/gui/src/presenter/graph.rs | 12 +- app/gui/src/presenter/graph/visualization.rs | 3 - .../presenter/graph/visualization/manager.rs | 12 +- app/gui/src/presenter/project.rs | 4 - app/gui/src/presenter/searcher.rs | 12 +- app/gui/src/test.rs | 27 +- app/gui/src/transport/web.rs | 25 +- app/gui/suggestion-database/Cargo.toml | 8 +- app/gui/tests/language_server.rs | 6 +- app/gui/tests/project_manager.rs | 3 +- app/gui/view/Cargo.toml | 11 +- .../component-list-panel/Cargo.toml | 2 +- .../component-list-panel/grid/Cargo.toml | 4 +- .../component-list-panel/icons/Cargo.toml | 2 +- .../component-list-panel-view/Cargo.toml | 2 +- .../text-grid-visualization/Cargo.toml | 6 +- .../view/debug_scene/visualization/Cargo.toml | 6 +- app/gui/view/documentation/Cargo.toml | 3 +- app/gui/view/documentation/src/lib.rs | 18 +- app/gui/view/graph-editor/Cargo.toml | 33 +- .../visualization/native/bubble_chart.rs | 8 +- .../src/builtin/visualization/native/error.rs | 4 +- .../native/text_visualization.rs | 6 +- .../graph-editor/src/component/breadcrumbs.rs | 3 - .../src/component/breadcrumbs/breadcrumb.rs | 4 +- .../view/graph-editor/src/component/edge.rs | 18 +- .../view/graph-editor/src/component/node.rs | 5 +- .../graph-editor/src/component/node/error.rs | 4 +- .../src/component/node/input/area.rs | 14 +- .../src/component/node/output/area.rs | 12 +- .../src/component/visualization/container.rs | 26 +- .../visualization/container/fullscreen.rs | 9 +- .../src/component/visualization/definition.rs | 4 +- .../foreign/java_script/instance.rs | 9 +- .../src/component/visualization/instance.rs | 4 +- .../src/component/visualization/registry.rs | 12 +- app/gui/view/graph-editor/src/lib.rs | 64 +-- app/gui/view/src/debug_mode_popup.rs | 4 +- app/gui/view/src/open_dialog.rs | 4 +- app/gui/view/src/open_dialog/project_list.rs | 4 +- app/gui/view/src/project.rs | 3 - app/gui/view/src/root.rs | 4 +- app/gui/view/src/searcher.rs | 4 +- app/gui/view/src/status_bar.rs | 16 +- app/gui/view/src/window_control_buttons.rs | 4 +- app/gui/view/welcome-screen/src/lib.rs | 8 +- app/gui/view/welcome-screen/src/side_menu.rs | 10 +- .../view/welcome-screen/src/template_cards.rs | 10 +- build/base/Cargo.toml | 6 +- build/build/Cargo.toml | 21 +- build/build/src/aws.rs | 2 +- build/build/src/engine.rs | 2 +- build/build/src/programs.rs | 11 - build/build/src/project/gui.rs | 2 +- build/build/src/version.rs | 4 +- build/ci_utils/Cargo.toml | 24 +- .../ci_utils/src/actions/artifacts/context.rs | 2 +- build/ci_utils/src/deploy/runner.rs | 6 +- build/ci_utils/src/github.rs | 2 +- build/ci_utils/src/github/repo.rs | 6 +- build/ci_utils/src/lib.rs | 3 +- build/ci_utils/src/paths.rs | 6 +- build/ci_utils/src/program/command.rs | 15 +- build/ci_utils/src/programs/docker.rs | 3 +- build/ci_utils/src/programs/java.rs | 2 +- build/ci_utils/src/programs/wasm_opt.rs | 2 +- build/cli/Cargo.toml | 10 +- build/macros/Cargo.toml | 6 +- build/macros/src/lib.rs | 2 +- build/macros/src/program_args.rs | 6 +- integration-test/tests/engine.rs | 2 +- lib/rust/automata/Cargo.toml | 2 +- lib/rust/data-structures/Cargo.toml | 6 +- lib/rust/data-structures/src/opt_vec.rs | 3 +- lib/rust/debug-api/Cargo.toml | 6 +- lib/rust/ensogl/component/button/src/lib.rs | 4 +- .../ensogl/component/drop-manager/Cargo.toml | 3 +- .../ensogl/component/drop-manager/src/lib.rs | 2 - .../ensogl/component/file-browser/src/lib.rs | 4 +- .../ensogl/component/flame-graph/Cargo.toml | 4 +- .../ensogl/component/grid-view/Cargo.toml | 2 +- lib/rust/ensogl/component/gui/Cargo.toml | 1 - .../ensogl/component/gui/src/component.rs | 4 +- .../ensogl/component/list-view/src/entry.rs | 2 +- .../component/list-view/src/entry/list.rs | 15 +- .../ensogl/component/list-view/src/lib.rs | 3 +- .../component/sequence-diagram/Cargo.toml | 8 +- .../component/sequence-diagram/src/lib.rs | 2 +- lib/rust/ensogl/component/text/Cargo.toml | 10 +- .../text/src/font/embedded/Cargo.toml | 2 +- .../component/text/src/font/family/Cargo.toml | 4 +- .../component/text/src/font/msdf/Cargo.toml | 10 +- lib/rust/ensogl/core/Cargo.toml | 14 +- .../core/src/animation/frp/animation.rs | 4 +- .../src/animation/frp/animation/delayed.rs | 2 +- .../src/animation/frp/animation/hysteretic.rs | 2 +- .../src/animation/frp/animation/overshoot.rs | 2 +- lib/rust/ensogl/core/src/application.rs | 11 +- .../ensogl/core/src/application/command.rs | 12 +- .../ensogl/core/src/application/shortcut.rs | 19 +- lib/rust/ensogl/core/src/application/view.rs | 5 +- lib/rust/ensogl/core/src/control/io/mouse.rs | 4 +- .../ensogl/core/src/control/io/mouse/event.rs | 4 +- lib/rust/ensogl/core/src/data/bounding_box.rs | 12 +- .../ensogl/core/src/data/color/gradient.rs | 18 +- lib/rust/ensogl/core/src/data/dirty.rs | 4 +- .../ensogl/core/src/data/seq/observable.rs | 4 +- lib/rust/ensogl/core/src/debug/monitor.rs | 6 +- .../core/src/display/navigation/navigator.rs | 19 +- .../ensogl/core/src/display/render/pass.rs | 2 +- .../src/display/render/passes/pixel_read.rs | 2 +- .../core/src/display/render/passes/symbols.rs | 14 +- lib/rust/ensogl/core/src/display/scene.rs | 2 +- lib/rust/ensogl/core/src/display/scene/dom.rs | 2 +- .../ensogl/core/src/display/scene/layer.rs | 2 +- .../src/display/shape/primitive/def/class.rs | 2 +- .../display/shape/primitive/def/primitive.rs | 2 +- .../src/display/shape/primitive/def/var.rs | 12 +- .../display/shape/primitive/shader/builder.rs | 4 +- .../display/shape/primitive/shader/canvas.rs | 45 +- .../ensogl/core/src/display/style/sheet.rs | 8 +- .../ensogl/core/src/display/style/theme.rs | 4 +- .../ensogl/core/src/display/symbol/dom.rs | 4 +- .../ensogl/core/src/display/symbol/gpu.rs | 6 +- .../gpu/geometry/compound/mask_composer.rs | 4 +- .../symbol/gpu/geometry/compound/screen.rs | 2 +- .../symbol/gpu/geometry/compound/sprite.rs | 2 +- .../core/src/display/symbol/gpu/material.rs | 7 +- lib/rust/ensogl/core/src/display/world.rs | 5 +- lib/rust/ensogl/core/src/gui/cursor.rs | 4 +- lib/rust/ensogl/core/src/lib.rs | 4 - .../ensogl/core/src/system/gpu/context.rs | 4 +- .../core/src/system/gpu/shader/compiler.rs | 8 +- .../ensogl/core/src/system/gpu/shader/glsl.rs | 37 +- .../ensogl/core/src/system/web/dom/shape.rs | 4 +- .../ensogl/example/auto-layout/Cargo.toml | 2 +- .../example/complex-shape-system/src/lib.rs | 44 +- .../example/custom-shape-system/src/lib.rs | 4 +- .../ensogl/example/dom-symbols/Cargo.toml | 2 +- .../ensogl/example/dom-symbols/src/lib.rs | 2 +- lib/rust/ensogl/example/drop-down/Cargo.toml | 2 +- .../ensogl/example/drop-manager/src/lib.rs | 10 +- .../ensogl/example/easing-animator/Cargo.toml | 4 +- lib/rust/ensogl/example/grid-view/Cargo.toml | 2 +- lib/rust/ensogl/example/grid-view/src/lib.rs | 5 +- lib/rust/ensogl/example/list-view/src/lib.rs | 2 +- .../ensogl/example/mouse-events/src/lib.rs | 4 +- .../example/profiling-run-graph/Cargo.toml | 2 +- .../example/profiling-run-graph/src/lib.rs | 10 +- .../render-profile-flamegraph/Cargo.toml | 2 +- .../render-profile-flamegraph/src/lib.rs | 6 +- .../sprite-system-benchmark/Cargo.toml | 2 +- lib/rust/frp/Cargo.toml | 3 +- lib/rust/frp/src/data/watch.rs | 4 +- lib/rust/frp/src/debug.rs | 21 +- lib/rust/frp/src/future.rs | 4 +- lib/rust/frp/src/io/mouse.rs | 2 +- lib/rust/frp/src/lib.rs | 2 - lib/rust/frp/src/stream.rs | 7 +- lib/rust/generics/Cargo.toml | 2 +- lib/rust/json-rpc/Cargo.toml | 5 +- lib/rust/json-rpc/src/macros.rs | 2 +- lib/rust/json-rpc/src/messages.rs | 21 +- lib/rust/logger/Cargo.toml | 29 -- lib/rust/logger/README.md | 3 - lib/rust/logger/src/entry.rs | 139 ------ lib/rust/logger/src/entry/level.rs | 180 ------- lib/rust/logger/src/entry/message.rs | 48 -- lib/rust/logger/src/lib.rs | 351 -------------- lib/rust/logger/src/macros.rs | 110 ----- lib/rust/logger/src/processor.rs | 459 ------------------ lib/rust/logger/src/processor/consumer.rs | 36 -- .../src/processor/consumer/js_console.rs | 87 ---- .../src/processor/consumer/native_console.rs | 58 --- lib/rust/logger/src/processor/formatter.rs | 64 --- .../src/processor/formatter/js_console.rs | 61 --- .../src/processor/formatter/native_console.rs | 42 -- lib/rust/metamodel/Cargo.toml | 4 +- lib/rust/metamodel/lexpr/Cargo.toml | 2 +- lib/rust/parser/Cargo.toml | 2 +- lib/rust/parser/generate-java/Cargo.toml | 2 +- lib/rust/parser/jni/Cargo.toml | 2 +- lib/rust/parser/src/source/code.rs | 4 +- lib/rust/prelude/Cargo.toml | 42 +- lib/rust/prelude/src/debug.rs | 16 +- lib/rust/prelude/src/debug/logging.rs | 107 ---- .../src/debug/logging/manually_expanded.rs | 79 --- lib/rust/prelude/src/lib.rs | 32 +- lib/rust/prelude/src/phantom.rs | 4 - lib/rust/profiler/Cargo.toml | 2 +- lib/rust/profiler/data/Cargo.toml | 6 +- lib/rust/profiler/demo-data/Cargo.toml | 2 +- lib/rust/profiler/flame-graph/Cargo.toml | 2 +- lib/rust/reflect/Cargo.toml | 2 +- lib/rust/shapely/Cargo.toml | 7 +- lib/rust/shapely/macros/Cargo.toml | 6 +- lib/rust/shapely/src/lib.rs | 2 + lib/rust/shortcuts/Cargo.toml | 7 +- lib/rust/shortcuts/example/Cargo.toml | 7 +- lib/rust/shortcuts/example/src/lib.rs | 18 +- lib/rust/shortcuts/src/lib.rs | 5 - lib/rust/types/Cargo.toml | 4 +- lib/rust/web/Cargo.toml | 13 +- tools/language-server/logstat/Cargo.toml | 2 +- tools/language-server/wstest/Cargo.toml | 2 +- 256 files changed, 892 insertions(+), 3285 deletions(-) delete mode 100644 lib/rust/logger/Cargo.toml delete mode 100644 lib/rust/logger/README.md delete mode 100644 lib/rust/logger/src/entry.rs delete mode 100644 lib/rust/logger/src/entry/level.rs delete mode 100644 lib/rust/logger/src/entry/message.rs delete mode 100644 lib/rust/logger/src/lib.rs delete mode 100644 lib/rust/logger/src/macros.rs delete mode 100644 lib/rust/logger/src/processor.rs delete mode 100644 lib/rust/logger/src/processor/consumer.rs delete mode 100644 lib/rust/logger/src/processor/consumer/js_console.rs delete mode 100644 lib/rust/logger/src/processor/consumer/native_console.rs delete mode 100644 lib/rust/logger/src/processor/formatter.rs delete mode 100644 lib/rust/logger/src/processor/formatter/js_console.rs delete mode 100644 lib/rust/logger/src/processor/formatter/native_console.rs delete mode 100644 lib/rust/prelude/src/debug/logging.rs delete mode 100644 lib/rust/prelude/src/debug/logging/manually_expanded.rs diff --git a/Cargo.lock b/Cargo.lock index 3f5ab999d53..084e873381d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,7 +147,6 @@ dependencies = [ "regex", "serde", "serde_json", - "shrinkwraprs 0.2.3", "uuid 0.8.2", ] @@ -750,7 +749,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.29.0", + "object", "rustc-demangle", ] @@ -1129,17 +1128,6 @@ dependencies = [ "enso-prelude", ] -[[package]] -name = "colored" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" -dependencies = [ - "atty", - "lazy_static", - "winapi 0.3.9", -] - [[package]] name = "combine" version = "3.8.1" @@ -1266,12 +1254,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "convert_case" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" - [[package]] name = "convert_case" version = "0.6.0" @@ -1335,7 +1317,7 @@ dependencies = [ "clap 2.34.0", "criterion-plot", "csv", - "itertools 0.10.5", + "itertools", "lazy_static", "num-traits", "oorandom", @@ -1357,7 +1339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" dependencies = [ "cast", - "itertools 0.10.5", + "itertools", ] [[package]] @@ -1756,12 +1738,11 @@ dependencies = [ "const_format", "engine-protocol", "enso-data-structures", - "enso-logger", "enso-prelude", "enso-profiler", "enso-text", "failure", - "itertools 0.10.5", + "itertools", "parser-scala", "regex", "serde", @@ -1781,12 +1762,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" -[[package]] -name = "enclose" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1056f553da426e9c025a662efa48b52e62e0a3a7648aa2d15aeaaf7f0d329357" - [[package]] name = "encode_unicode" version = "0.3.6" @@ -1810,7 +1785,6 @@ dependencies = [ "chrono", "enso-build-utilities", "enso-data-structures", - "enso-logger", "enso-prelude", "enso-shapely", "enso-text", @@ -1877,14 +1851,14 @@ dependencies = [ "ide-ci", "indexmap", "indicatif", - "itertools 0.10.5", + "itertools", "lazy_static", "mime 0.3.16", "new_mime_guess", "nix", "octocrab", "ouroboros", - "paste 1.0.9", + "paste", "path-absolutize", "path-slash", "pin-project", @@ -1900,7 +1874,6 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "shrinkwraprs 0.3.0", "strum", "sysinfo", "tar", @@ -1977,13 +1950,13 @@ name = "enso-build-macros" version = "0.1.0" dependencies = [ "convert_case 0.6.0", + "derive_more", "enso-build-base", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", "regex", "serde_yaml", - "shrinkwraprs 0.3.0", "syn", ] @@ -2021,7 +1994,6 @@ name = "enso-config" version = "0.1.0" dependencies = [ "config-reader", - "enso-logger", "enso-prelude", "ensogl", "semver 1.0.14", @@ -2034,7 +2006,7 @@ dependencies = [ "criterion", "enso-prelude", "failure", - "itertools 0.9.0", + "itertools", "rustversion", "serde", "typenum", @@ -2089,7 +2061,6 @@ dependencies = [ "Inflector", "enso-callback", "enso-generics", - "enso-logger", "enso-prelude", "enso-profiler", "enso-web", @@ -2118,7 +2089,7 @@ dependencies = [ "bimap", "console_error_panic_hook", "const_format", - "convert_case 0.5.0", + "convert_case 0.6.0", "double-representation", "engine-protocol", "enso-callback", @@ -2128,7 +2099,6 @@ dependencies = [ "enso-debug-scene", "enso-executor", "enso-frp", - "enso-logger", "enso-notification", "enso-prelude", "enso-profiler", @@ -2147,7 +2117,7 @@ dependencies = [ "futures 0.3.24", "fuzzly", "ide-view", - "itertools 0.10.5", + "itertools", "js-sys", "json-rpc", "mockall", @@ -2184,18 +2154,6 @@ dependencies = [ "wasm-bindgen-test", ] -[[package]] -name = "enso-logger" -version = "0.3.1" -dependencies = [ - "enso-prelude", - "enso-shapely", - "ifmt", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "enso-logging" version = "0.3.1" @@ -2305,7 +2263,7 @@ dependencies = [ name = "enso-parser-jni" version = "0.1.0" dependencies = [ - "bincode 1.3.3", + "bincode 2.0.0-rc.1", "enso-parser", "enso-prelude", "jni", @@ -2329,11 +2287,8 @@ dependencies = [ "assert_approx_eq", "backtrace", "boolinator", - "cfg-if 1.0.0", - "colored", "derivative", "derive_more", - "enclose", "enso-logging", "enso-reflect", "enso-shapely", @@ -2341,15 +2296,11 @@ dependencies = [ "failure", "futures 0.3.24", "gen-iter", - "ifmt", - "itertools 0.10.5", + "itertools", "lazy_static", - "num", - "object 0.24.0", - "paste 1.0.9", + "paste", "serde", "serde_json", - "shrinkwraprs 0.3.0", "smallvec 1.9.0", "wasm-bindgen", "wasm-bindgen-test", @@ -2446,9 +2397,8 @@ dependencies = [ "derivative", "enso-prelude", "enso-shapely-macros", - "paste 0.1.18", + "paste", "rustversion", - "shrinkwraprs 0.3.0", "wasm-bindgen", "wasm-bindgen-test", "web-sys", @@ -2461,8 +2411,8 @@ dependencies = [ "Inflector", "boolinator", "enso-macro-utils", - "itertools 0.8.2", - "paste 1.0.9", + "itertools", + "paste", "proc-macro2", "quote", "syn", @@ -2475,7 +2425,6 @@ version = "0.1.0" dependencies = [ "enso-automata", "enso-frp", - "enso-logger", "enso-prelude", "enso-web", "js-sys", @@ -2491,7 +2440,7 @@ name = "enso-suggestion-database" version = "0.1.0" dependencies = [ "ast", - "convert_case 0.5.0", + "convert_case 0.6.0", "double-representation", "engine-protocol", "enso-data-structures", @@ -2525,7 +2474,7 @@ dependencies = [ "enso-reflect", "nalgebra", "num-traits", - "paste 1.0.9", + "paste", "serde", ] @@ -2600,7 +2549,6 @@ dependencies = [ "enso-debug-api", "enso-frp", "enso-generics", - "enso-logger", "enso-prelude", "enso-profiler", "enso-shapely", @@ -2610,7 +2558,7 @@ dependencies = [ "ensogl-text-embedded-fonts", "enum_dispatch", "failure", - "itertools 0.10.5", + "itertools", "js-sys", "nalgebra", "num-traits", @@ -2618,7 +2566,6 @@ dependencies = [ "rustc-hash", "semver 1.0.14", "serde", - "shrinkwraprs 0.3.0", "smallvec 1.9.0", "typenum", "wasm-bindgen", @@ -2663,7 +2610,6 @@ name = "ensogl-drop-manager" version = "0.1.0" dependencies = [ "enso-frp", - "enso-logger", "enso-prelude", "enso-web", "js-sys", @@ -2773,7 +2719,7 @@ dependencies = [ "ensogl-grid-view", "ensogl-hardcoded-theme", "ensogl-text-msdf", - "itertools 0.10.5", + "itertools", "wasm-bindgen", ] @@ -2959,7 +2905,7 @@ dependencies = [ "ensogl-scroll-area", "ensogl-shadow", "ensogl-text", - "itertools 0.10.5", + "itertools", "segment-tree", ] @@ -2968,7 +2914,6 @@ name = "ensogl-gui-component" version = "0.1.0" dependencies = [ "enso-frp", - "enso-logger", "ensogl-core", "float_eq", "wasm-bindgen-test", @@ -4061,10 +4006,9 @@ dependencies = [ "headers", "heck", "http-serde", - "ifmt", "indexmap", "indicatif", - "itertools 0.10.5", + "itertools", "lazy_static", "log 0.4.17", "mime 0.3.16", @@ -4072,7 +4016,7 @@ dependencies = [ "new_mime_guess", "nix", "octocrab", - "paste 1.0.9", + "paste", "path-absolutize", "path-slash", "pathdiff", @@ -4091,7 +4035,6 @@ dependencies = [ "serde_json", "serde_yaml", "sha2", - "shrinkwraprs 0.3.0", "strum", "symlink", "syn", @@ -4121,7 +4064,6 @@ dependencies = [ "engine-protocol", "enso-config", "enso-frp", - "enso-logger", "enso-prelude", "enso-shapely", "ensogl", @@ -4222,7 +4164,6 @@ version = "0.1.0" dependencies = [ "double-representation", "enso-frp", - "enso-logger", "enso-prelude", "enso-suggestion-database", "ensogl", @@ -4249,7 +4190,6 @@ dependencies = [ "engine-protocol", "enso-config", "enso-frp", - "enso-logger", "enso-prelude", "enso-shapely", "enso-text", @@ -4306,30 +4246,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" -[[package]] -name = "ifmt" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd0f8e1404f15475d8a2ca84c2942aa00ac17804ce555294a96f6b5cdf80750" -dependencies = [ - "ifmt-impl", - "proc-macro-hack", -] - -[[package]] -name = "ifmt-impl" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e50385662f423431a619ab28ba2beeab3063b581a0d1a943765e23911c502904" -dependencies = [ - "lazy_static", - "proc-macro-hack", - "proc-macro2", - "quote", - "regex", - "syn", -] - [[package]] name = "indexmap" version = "1.9.1" @@ -4398,24 +4314,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" -[[package]] -name = "itertools" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.10.5" @@ -4479,7 +4377,6 @@ dependencies = [ "futures 0.3.24", "serde", "serde_json", - "shrinkwraprs 0.3.0", ] [[package]] @@ -4887,8 +4784,8 @@ checksum = "476d1d59fe02fe54c86356e91650cd892f392782a1cb9fc524ec84f7aa9e1d06" dependencies = [ "approx 0.4.0", "matrixmultiply", - "num-complex 0.3.1", - "num-rational 0.3.2", + "num-complex", + "num-rational", "num-traits", "serde", "simba", @@ -4988,20 +4885,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-bigint", - "num-complex 0.4.2", - "num-integer", - "num-iter", - "num-rational 0.4.1", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.3" @@ -5023,15 +4906,6 @@ dependencies = [ "serde", ] -[[package]] -name = "num-complex" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" -dependencies = [ - "num-traits", -] - [[package]] name = "num-integer" version = "0.1.45" @@ -5042,17 +4916,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg 1.1.0", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.3.2" @@ -5064,18 +4927,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg 1.1.0", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -5132,15 +4983,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" -[[package]] -name = "object" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" -dependencies = [ - "flate2", -] - [[package]] name = "object" version = "0.29.0" @@ -5357,7 +5199,6 @@ dependencies = [ "reqwest", "serde", "serde_json", - "shrinkwraprs 0.2.3", "tokio", "uuid 0.8.2", "wasm-bindgen", @@ -5365,31 +5206,12 @@ dependencies = [ "websocket", ] -[[package]] -name = "paste" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - [[package]] name = "paste" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] - [[package]] name = "path-absolutize" version = "3.0.13" @@ -5717,7 +5539,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7345d5f0e08c0536d7ac7229952590239e77abf0a0100a1b1d890add6ea96364" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", "syn", @@ -6554,32 +6376,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shrinkwraprs" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83695fde96cbe9e08f0e4eb96b1b56fdbd44f2098ee27462dda964c7745fddc7" -dependencies = [ - "bitflags", - "itertools 0.8.2", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "shrinkwraprs" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63e6744142336dfb606fe2b068afa2e1cca1ee6a5d8377277a92945d81fa331" -dependencies = [ - "bitflags", - "itertools 0.8.2", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -6596,9 +6392,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5132a955559188f3d13c9ba831e77c802ddc8782783f050ed0c52f5988b95f4c" dependencies = [ "approx 0.4.0", - "num-complex 0.3.1", + "num-complex", "num-traits", - "paste 1.0.9", + "paste", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a70d1be3b7a..d6d29212eb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,15 +72,49 @@ debug = true debug-assertions = true [workspace.dependencies] +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# !!!!!!!!!! WARNING !!!!!!!!!! +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# We are tryingto maintain minimum set of dependencies. Before adding a new dependency, consult it +# with the core development team. Thank you! console-subscriber = "0.1.8" nix = "0.26.1" octocrab = { git = "https://github.com/enso-org/octocrab", default-features = false, features = [ "rustls" ] } -regex = "1.6.0" -serde_yaml = "0.9.16" -serde-wasm-bindgen = "0.4.5" +regex = { version = "1.6.0" } +serde_yaml = { version = "0.9.16" } +serde-wasm-bindgen = { version = "0.4.5" } tokio = { version = "1.23.0", features = ["full", "tracing"] } tokio-util = { version = "0.7.4", features = ["full"] } wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } wasm-bindgen-test = { version = "0.3.33" } +anyhow = { version = "1.0.66" } +failure = { version = "0.1.8" } +derive_more = { version = "0.99" } +assert_approx_eq = { version = "1.1.0" } +backtrace = { version = "0.3.53" } +boolinator = { version = "2.4.0" } +derivative = { version = "2.2" } +futures = { version = "0.3" } +itertools = { version = "0.10.5" } +lazy_static = { version = "1.4" } +paste = { version = "1.0" } +serde_json = { version = "1.0" } +smallvec = { version = "1.0.0" } +weak-table = { version = "0.3.0" } +gen-iter = { version = "0.2.1" } +js-sys = { version = "0.3" } +owned_ttf_parser = { version = "0.15.1" } +nalgebra = { version = "0.26.1", features = ["serde-serialize"] } +const_format = { version = "0.2.22" } +convert_case = { version = "0.6.0" } +multi-map = { version = "1.3.0" } +ordered-float = { version = "3.0.0" } +rustybuzz = { version = "0.5.1" } +bincode = { version = "2.0.0-rc.1" } +byte-unit = { version = "4.0.14", features = ["serde"] } +bytes = { version = "1.1.0" } +matches = { version = "0.1" } +console_error_panic_hook = { version = "0.1.6" } +reqwest = { version = "0.11.5" } diff --git a/app/gui/Cargo.toml b/app/gui/Cargo.toml index acc4bcbee88..2f3f38f689c 100644 --- a/app/gui/Cargo.toml +++ b/app/gui/Cargo.toml @@ -8,15 +8,14 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -analytics = { version = "0.1.0", path = "analytics" } -double-representation = { version = "0.1.0", path = "controller/double-representation" } +analytics = { path = "analytics" } +double-representation = { path = "controller/double-representation" } enso-config = { path = "config" } enso-callback = { path = "../../lib/rust/callback" } enso-data-structures = { path = "../../lib/rust/data-structures" } enso-debug-api = { path = "../../lib/rust/debug-api" } enso-debug-scene = { path = "view/debug_scene" } enso-frp = { path = "../../lib/rust/frp" } -enso-logger = { path = "../../lib/rust/logger" } enso-prelude = { path = "../../lib/rust/prelude" } enso-profiler = { path = "../../lib/rust/profiler" } enso-executor = { path = "../../lib/rust/executor" } @@ -39,19 +38,19 @@ json-rpc = { path = "../../lib/rust/json-rpc" } parser-scala = { path = "language/parser" } span-tree = { path = "language/span-tree" } bimap = { version = "0.4.0" } -console_error_panic_hook = { version = "0.1.6" } -const_format = { version = "0.2.22" } -convert_case = { version = "0.5.0" } -failure = { version = "0.1.6" } +console_error_panic_hook = { workspace = true } +const_format = { workspace = true } +convert_case = { workspace = true } +failure = { workspace = true } flo_stream = { version = "0.4.0" } -futures = { version = "0.3.1" } -itertools = { version = "0.10.0" } -js-sys = { version = "0.3.28" } +futures = { workspace = true } +itertools = { workspace = true } +js-sys = { workspace = true } mockall = { version = "0.7.1", features = ["nightly"] } -nalgebra = { version = "0.26.1", features = ["serde-serialize"] } +nalgebra = { workspace = true } semver = { version = "1.0.0", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } +serde_json = { workspace = true } sha3 = { version = "0.8.2" } uuid = { version = "0.8", features = ["serde", "v4", "wasm-bindgen"] } # wasm-bindgen version 0.2.79 is causing issues with clippy. diff --git a/app/gui/analytics/Cargo.toml b/app/gui/analytics/Cargo.toml index b7f069bbe43..5865d3fb06a 100644 --- a/app/gui/analytics/Cargo.toml +++ b/app/gui/analytics/Cargo.toml @@ -5,5 +5,5 @@ authors = ["Enso Team "] edition = "2021" [dependencies] -js-sys = { version = "0.3.28" } +js-sys = { workspace = true } wasm-bindgen = { workspace = true } diff --git a/app/gui/config/Cargo.toml b/app/gui/config/Cargo.toml index 8a543d04b38..72b504e4ae7 100644 --- a/app/gui/config/Cargo.toml +++ b/app/gui/config/Cargo.toml @@ -7,8 +7,7 @@ edition = "2021" [dependencies] ensogl = { path = "../../../lib/rust/ensogl" } enso-prelude = { path = "../../../lib/rust/prelude" } -enso-logger = { path = "../../../lib/rust/logger" } semver = "1.0.0" [build-dependencies] -config-reader = { version = "0.1.0", path = "../../../lib/rust/config-reader" } +config-reader = { path = "../../../lib/rust/config-reader" } diff --git a/app/gui/controller/double-representation/Cargo.toml b/app/gui/controller/double-representation/Cargo.toml index 76b277c9a9a..f7a65b94d6a 100644 --- a/app/gui/controller/double-representation/Cargo.toml +++ b/app/gui/controller/double-representation/Cargo.toml @@ -8,17 +8,16 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -ast = { version = "0.1.0", path = "../../language/ast/impl" } -engine-protocol = { version = "0.1.0", path = "../engine-protocol" } -parser-scala = { version = "0.1.0", path = "../../language/parser" } +ast = { path = "../../language/ast/impl" } +engine-protocol = { path = "../engine-protocol" } +parser-scala = { path = "../../language/parser" } enso-data-structures = { path = "../../../../lib/rust/data-structures" } -enso-logger = { path = "../../../../lib/rust/logger" } enso-prelude = { path = "../../../../lib/rust/prelude" } enso-profiler = { path = "../../../../lib/rust/profiler" } enso-text = { path = "../../../../lib/rust/text" } -const_format = { version = "0.2.22" } -failure = { version = "0.1.6" } -itertools = { version = "0.10.0" } +const_format = { workspace = true } +failure = { workspace = true } +itertools = { workspace = true } serde = { version = "1.0", features = ["derive"] } uuid = { version = "0.8", features = ["serde", "v4", "wasm-bindgen"] } diff --git a/app/gui/controller/double-representation/src/alias_analysis.rs b/app/gui/controller/double-representation/src/alias_analysis.rs index 5fe5593cc96..644f3adace1 100644 --- a/app/gui/controller/double-representation/src/alias_analysis.rs +++ b/app/gui/controller/double-representation/src/alias_analysis.rs @@ -387,18 +387,18 @@ mod tests { /// Runs the test for the given test case description. fn run_case(parser: &parser_scala::Parser, case: Case) { - DEBUG!("\n===========================================================================\n"); - DEBUG!("Case: " case.code); + debug!("\n===========================================================================\n"); + debug!("Case: {}", case.code); let ast = parser.parse_line_ast(&case.code).unwrap(); let result = analyze_ast(&ast); - DEBUG!("Analysis results: {result:?}"); + debug!("Analysis results: {result:?}"); validate_identifiers("introduced", &ast, case.expected_introduced, &result.introduced); validate_identifiers("used", &ast, case.expected_used, &result.used); } /// Runs the test for the test case expressed using markdown notation. See `Case` for details. fn run_markdown_case(parser: &parser_scala::Parser, marked_code: impl AsRef) { - DEBUG!("Running test case for " marked_code.as_ref()); + debug!("Running test case for {}", marked_code.as_ref()); let case = Case::from_markdown(marked_code.as_ref()); run_case(parser, case) } diff --git a/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs b/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs index 8922eb55e37..8d7f1965f2e 100644 --- a/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs +++ b/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs @@ -135,7 +135,7 @@ impl<'a> IdentifierValidator<'a> { /// Marks given identifier as checked. pub fn validate_identifier(&mut self, name: &str) { - let err = iformat!("{self.name}: unexpected identifier `{name}` validated"); + let err = format!("{}: unexpected identifier `{name}` validated", self.name); let used = self.validations.get_mut(name).expect(&err); *used = HasBeenValidated::Yes; } @@ -151,7 +151,7 @@ impl<'a> IdentifierValidator<'a> { let crumbs = &identifier.crumbs; let ast_result = self.ast.get_traversing(crumbs); let ast = ast_result.expect("failed to retrieve ast from crumb"); - let name_err = || ipanic!("Failed to use AST {ast.repr()} as an identifier name"); + let name_err = || panic!("Failed to use AST {} as an identifier name", ast.repr()); let name = ast::identifier::name(ast).unwrap_or_else(name_err); assert_eq!(name, identifier.item) } @@ -172,7 +172,7 @@ impl<'a> Drop for IdentifierValidator<'a> { ) } } else { - DEBUG!("Skipping identifier validation, because thread is already in panic."); + debug!("Skipping identifier validation, because thread is already in panic."); } } } diff --git a/app/gui/controller/double-representation/src/definition.rs b/app/gui/controller/double-representation/src/definition.rs index 581593aaff1..025d5dd73a5 100644 --- a/app/gui/controller/double-representation/src/definition.rs +++ b/app/gui/controller/double-representation/src/definition.rs @@ -618,7 +618,7 @@ mod tests { } fn indented(line: impl Display) -> String { - iformat!(" {line}") + format!(" {line}") } #[wasm_bindgen_test] diff --git a/app/gui/controller/double-representation/src/graph.rs b/app/gui/controller/double-representation/src/graph.rs index e30a7b083ed..b60006cc23b 100644 --- a/app/gui/controller/double-representation/src/graph.rs +++ b/app/gui/controller/double-representation/src/graph.rs @@ -46,7 +46,7 @@ pub enum LocationHint { // ================= /// Description of the graph, based on information available in AST. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct GraphInfo { /// The definition providing this graph. pub source: DefinitionInfo, @@ -450,12 +450,12 @@ main = main = foo = 2 + 2"; let mut graph = main_graph(&parser, program); - DEBUG!("aa"); + debug!("aa"); let (node,) = graph.nodes().expect_tuple(); assert_eq!(node.expression().repr(), "2 + 2"); - DEBUG!("vv"); + debug!("vv"); graph.remove_node(node.id()).unwrap(); - DEBUG!("zz"); + debug!("zz"); let (node,) = graph.nodes().expect_tuple(); assert_eq!(node.expression().repr(), ast::constants::keywords::NOTHING); diff --git a/app/gui/controller/double-representation/src/identifier.rs b/app/gui/controller/double-representation/src/identifier.rs index 46182b98e08..5d0938a593f 100644 --- a/app/gui/controller/double-representation/src/identifier.rs +++ b/app/gui/controller/double-representation/src/identifier.rs @@ -35,7 +35,7 @@ pub struct IdentifierCannotBeEmpty; /// Comparisons compare the underlying name strings. /// /// Invariants: can get identifier name, the name is non-empty. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct Identifier(Ast); impl Identifier { @@ -200,7 +200,7 @@ pub fn generate_name( let unavailable = unavailable.into_iter().filter(is_relevant).collect::>(); let name = (1..) .find_map(|i| { - let candidate = iformat!("{base}{i}"); + let candidate = format!("{base}{i}"); let available = !unavailable.contains(&candidate); available.as_some(candidate) }) diff --git a/app/gui/controller/double-representation/src/lib.rs b/app/gui/controller/double-representation/src/lib.rs index 5d9864fa59d..ad2e8dc2d78 100644 --- a/app/gui/controller/double-representation/src/lib.rs +++ b/app/gui/controller/double-representation/src/lib.rs @@ -62,7 +62,6 @@ pub mod text; /// Common types that should be visible across the whole IDE crate. pub mod prelude { pub use ast::prelude::*; - pub use enso_logger::*; pub use enso_prelude::*; pub use enso_profiler as profiler; pub use enso_profiler::prelude::*; diff --git a/app/gui/controller/double-representation/src/module.rs b/app/gui/controller/double-representation/src/module.rs index 90fe4011fd5..41a276942d7 100644 --- a/app/gui/controller/double-representation/src/module.rs +++ b/app/gui/controller/double-representation/src/module.rs @@ -340,7 +340,7 @@ pub enum Placement { /// location. /// /// Internally it is `definition::ChildDefinition` with only a single `ModuleCrumb` as location. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct ChildDefinition(definition::ChildDefinition); impl ChildDefinition { diff --git a/app/gui/controller/double-representation/src/node.rs b/app/gui/controller/double-representation/src/node.rs index 6fb4336726b..6d48a0f3b83 100644 --- a/app/gui/controller/double-representation/src/node.rs +++ b/app/gui/controller/double-representation/src/node.rs @@ -88,12 +88,12 @@ impl NodeLocation { // =============== /// Information about the node coupled with its location within a block. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct LocatedNode { /// Line index in the block. Zero for inline definition nodes. pub index: NodeLocation, - #[shrinkwrap(main_field)] /// Information about the node. + #[deref] pub node: NodeInfo, } @@ -201,13 +201,13 @@ impl<'a, T: Iterator)> + 'a> Iterator for Node /// Information about node, including both its main line (i.e. line with expression) and optionally /// attached documentation comment. -#[derive(Clone, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, Debug, Deref, DerefMut)] pub struct NodeInfo { /// If the node has doc comment attached, it will be represented here. pub documentation: Option, /// Primary node AST that contains node's expression and optional pattern binding. - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] pub main_line: MainLine, } diff --git a/app/gui/controller/double-representation/src/text.rs b/app/gui/controller/double-representation/src/text.rs index 1c35584d94a..6edc193d7ee 100644 --- a/app/gui/controller/double-representation/src/text.rs +++ b/app/gui/controller/double-representation/src/text.rs @@ -257,8 +257,8 @@ mod test { fn assert_same_node_ids(&self, ast1: &ast::known::Module, ast2: &ast::known::Module) { let ids1 = main_nodes(ast1); let ids2 = main_nodes(ast2); - DEBUG!("IDs1: {ids1:?}"); - DEBUG!("IDs2: {ids2:?}"); + debug!("IDs1: {ids1:?}"); + debug!("IDs2: {ids2:?}"); assert_eq!(ids1, ids2, "Node ids mismatch in {:?}", self); } } diff --git a/app/gui/controller/engine-protocol/Cargo.toml b/app/gui/controller/engine-protocol/Cargo.toml index f69d34948e4..1c3653c10fb 100644 --- a/app/gui/controller/engine-protocol/Cargo.toml +++ b/app/gui/controller/engine-protocol/Cargo.toml @@ -10,18 +10,17 @@ crate-type = ["cdylib", "rlib"] [dependencies] chrono = { version = "0.4", features = ["serde"] } enso-data-structures = { path = "../../../../lib/rust/data-structures" } -enso-logger = { path = "../../../../lib/rust/logger" } enso-prelude = { path = "../../../../lib/rust/prelude" } enso-shapely = { path = "../../../../lib/rust/shapely" } enso-text = { path = "../../../../lib/rust/text" } -failure = { version = "0.1.8" } +failure = { workspace = true } flatbuffers = { version = "0.5" } -futures = { version = "0.3.1" } +futures = { workspace = true } hex = { version = "0.4.2" } json-rpc = { path = "../../../../lib/rust/json-rpc" } mockall = { version = "0.7.1", features = ["nightly"] } serde = { version = "1.0", features = ["derive"] } -serde_json = { version = "1.0" } +serde_json = { workspace = true } sha3 = { version = "0.8.2" } strum = "0.24.0" strum_macros = "0.24.0" @@ -33,10 +32,10 @@ enso-web = { path = "../../../../lib/rust/web" } [build-dependencies] enso-build-utilities = { path = "../../../../build/deprecated/build-utils" } -bytes = { version = "1.1.0" } +bytes = { workspace = true } flatc-rust = { version = "0.1.2" } -futures = { version = "0.3.1" } -reqwest = { version = "0.11.12" } +futures = { workspace = true } +reqwest = { workspace = true } tokio = { workspace = true } # Zip is needed because the build script downloads and extracts artifacts from the Engine. zip = { version = "0.6.2", default-features = false, features = ["deflate"] } diff --git a/app/gui/controller/engine-protocol/src/binary/client.rs b/app/gui/controller/engine-protocol/src/binary/client.rs index fd034aa9929..af24275772f 100644 --- a/app/gui/controller/engine-protocol/src/binary/client.rs +++ b/app/gui/controller/engine-protocol/src/binary/client.rs @@ -97,7 +97,6 @@ pub trait API { #[derivative(Debug)] pub struct Client { handler: Handler, - logger: Logger, } impl Client { @@ -146,10 +145,9 @@ impl Client { /// Before client is functional: /// * `runner` must be scheduled for execution; /// * `init` must be called or it needs to be wrapped into `Connection`. - pub fn new(parent: impl AnyLogger, transport: impl Transport + 'static) -> Client { - let logger = Logger::new_sub(parent, "binary-protocol-client"); + pub fn new(transport: impl Transport + 'static) -> Client { let processor = Self::processor(); - Client { logger: logger.clone_ref(), handler: Handler::new(transport, logger, processor) } + Client { handler: Handler::new(transport, processor) } } /// Starts a new request, described by the given payload. @@ -267,9 +265,8 @@ mod tests { impl ClientFixture { fn new() -> ClientFixture { - let logger = Logger::new("ClientFixture"); let transport = MockTransport::new(); - let client = Client::new(logger, transport.clone()); + let client = Client::new(transport.clone()); let executor = futures::executor::LocalPool::new(); executor.spawner().spawn_local(client.runner()).unwrap(); ClientFixture { transport, client, executor } diff --git a/app/gui/controller/engine-protocol/src/binary/message.rs b/app/gui/controller/engine-protocol/src/binary/message.rs index ff1150b01d4..1bf187c374a 100644 --- a/app/gui/controller/engine-protocol/src/binary/message.rs +++ b/app/gui/controller/engine-protocol/src/binary/message.rs @@ -32,8 +32,7 @@ pub type MessageToServerRef<'a> = MessageToServer>; // ================ /// A message sent from client to server (`InboundMessage` in the spec). -#[derive(Clone, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, Debug, Deref, DerefMut)] pub struct MessageToServer(pub Message); impl MessageToServer { @@ -44,8 +43,7 @@ impl MessageToServer { } /// A message sent from server to client (`OutboundMessage` in the spec). -#[derive(Clone, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, Debug, Deref, DerefMut)] pub struct MessageFromServer(pub Message); impl MessageFromServer { diff --git a/app/gui/controller/engine-protocol/src/handler.rs b/app/gui/controller/engine-protocol/src/handler.rs index 7fefdc6139c..9f342c21ef4 100644 --- a/app/gui/controller/engine-protocol/src/handler.rs +++ b/app/gui/controller/engine-protocol/src/handler.rs @@ -1,12 +1,10 @@ //! Module with the Enso Procol RPC handler. use crate::prelude::*; -use enso_logger::*; use crate::common::event::Event; use crate::common::ongoing_calls::OngoingCalls; -use enso_logger::WarningLogger as Logger; use futures::channel::mpsc::UnboundedSender; use json_rpc::Transport; use json_rpc::TransportEvent; @@ -73,7 +71,6 @@ where Reply: Debug, { #[derivative(Debug = "ignore")] transport: Box, - logger: Logger, sender: Option>>, ongoing_calls: OngoingCalls, #[derivative(Debug = "ignore")] @@ -86,18 +83,12 @@ where Notification: Debug, Reply: Debug, { - fn new( - transport: T, - logger: &Logger, - processor: P, - ) -> HandlerData + fn new(transport: T, processor: P) -> HandlerData where T: Transport + 'static, - P: FnMut(TransportEvent) -> Disposition + 'static, - { + P: FnMut(TransportEvent) -> Disposition + 'static, { HandlerData { transport: Box::new(transport), - logger: logger.clone_ref(), sender: None, ongoing_calls: OngoingCalls::new(), processor: Box::new(processor), @@ -218,8 +209,7 @@ where Id: Eq + Hash + Debug, Notification: Debug, Reply: Debug, { - logger: Logger, - state: Rc>>, + state: Rc>>, } /// A value that can be used to represent a request to remote RPC server. @@ -243,13 +233,12 @@ where /// Creates a new handler operating over given transport. /// /// `processor` must deal with decoding incoming transport events. - pub fn new(transport: T, logger: Logger, processor: P) -> Self + pub fn new(transport: T, processor: P) -> Self where T: Transport + 'static, P: FnMut(TransportEvent) -> Disposition + 'static, { - let state = Rc::new(RefCell::new(HandlerData::new(transport, &logger, processor))); - let logger = Logger::new_sub(&logger, "handler"); - Handler { logger, state } + let state = Rc::new(RefCell::new(HandlerData::new(transport, processor))); + Handler { state } } /// Starts a new request described by a given message. @@ -297,10 +286,9 @@ mod tests { #[test] fn test_closed_socked_event_passing() { - let logger = Logger::new("RPC_Handler_Test"); let mut transport = MockTransport::new(); let processor = |msg| panic!("Must never be called in this test, but got {:?}!", msg); - let handler = Handler::::new(transport.clone_ref(), logger, processor); + let handler = Handler::::new(transport.clone_ref(), processor); let mut runner = handler.runner().boxed_local(); let mut events = handler.event_stream().boxed_local(); events.expect_pending(); diff --git a/app/gui/controller/engine-protocol/src/lib.rs b/app/gui/controller/engine-protocol/src/lib.rs index 3584fc6fbfc..ea90cf9c354 100644 --- a/app/gui/controller/engine-protocol/src/lib.rs +++ b/app/gui/controller/engine-protocol/src/lib.rs @@ -40,11 +40,9 @@ pub mod types; #[allow(missing_docs)] pub mod prelude { pub use crate::traits::*; - pub use enso_logger::*; pub use enso_prelude::*; pub use json_rpc::prelude::*; - pub use enso_logger::DefaultWarningLogger as Logger; /// We always use local futures in our single-threaded environment pub use futures::future::LocalBoxFuture as BoxFuture; pub use futures::FutureExt; diff --git a/app/gui/controller/engine-protocol/src/types.rs b/app/gui/controller/engine-protocol/src/types.rs index e6196846939..b348ef711bd 100644 --- a/app/gui/controller/engine-protocol/src/types.rs +++ b/app/gui/controller/engine-protocol/src/types.rs @@ -23,7 +23,7 @@ pub type UTCDateTime = chrono::DateTime; // ================ /// SHA3-224 hash digest. -#[derive(Hash, Debug, Display, Clone, PartialEq, Eq, Serialize, Deserialize, Shrinkwrap)] +#[derive(Hash, Debug, Display, Clone, PartialEq, Eq, Serialize, Deserialize, Deref)] pub struct Sha3_224(String); impl Sha3_224 { diff --git a/app/gui/language/ast/impl/Cargo.toml b/app/gui/language/ast/impl/Cargo.toml index 19b106f23ec..a591132ac77 100644 --- a/app/gui/language/ast/impl/Cargo.toml +++ b/app/gui/language/ast/impl/Cargo.toml @@ -8,13 +8,12 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -derive_more = { version = "0.99.16" } -failure = { version = "0.1.5" } -lazy_static = { version = "1.4.0" } +derive_more = { workspace = true } +failure = { workspace = true } +lazy_static = { workspace = true } regex = { workspace = true } serde = { version = "1.0", features = ["derive", "rc"] } -serde_json = { version = "1.0" } -shrinkwraprs = { version = "0.2.1" } +serde_json = { workspace = true } uuid = { version = "0.8.1", features = ["serde", "v4", "wasm-bindgen"] } ast-macros = { path = "../macros" } enso-data-structures = { path = "../../../../../lib/rust/data-structures" } diff --git a/app/gui/language/ast/impl/src/crumbs.rs b/app/gui/language/ast/impl/src/crumbs.rs index 65ef631f988..78d40ae0738 100644 --- a/app/gui/language/ast/impl/src/crumbs.rs +++ b/app/gui/language/ast/impl/src/crumbs.rs @@ -1534,12 +1534,12 @@ pub fn non_empty_line_indices<'a, T: 'a>( // =============== /// Item which location is identified by `Crumbs`. -#[derive(Clone, Debug, Shrinkwrap, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deref)] pub struct Located { /// Crumbs from containing parent. pub crumbs: Crumbs, /// The sub-item representation. - #[shrinkwrap(main_field)] + #[deref] pub item: T, } diff --git a/app/gui/language/ast/impl/src/lib.rs b/app/gui/language/ast/impl/src/lib.rs index 93b3b9af55e..e60f478e4da 100644 --- a/app/gui/language/ast/impl/src/lib.rs +++ b/app/gui/language/ast/impl/src/lib.rs @@ -135,10 +135,10 @@ pub struct Tree { // =============== /// A value of type `T` annotated with offset value `off`. -#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize, Shrinkwrap, Iterator)] -#[shrinkwrap(mutable)] +#[derive(Clone, Eq, PartialEq, Debug, Serialize, Deserialize, Deref, DerefMut, Iterator)] pub struct Shifted { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] pub wrapped: T, pub off: usize, } @@ -180,9 +180,7 @@ impl From for Layered { // === Layered === /// A trivial `Layer` type that is just a strongly typed wrapper over `T`. -#[derive(Debug)] -#[derive(Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Debug, Deref, DerefMut)] pub struct Layered(pub T); impl Layer for Layered { @@ -218,8 +216,7 @@ pub struct Unit {} /// to either of the implementation need to be applied to the other one as well. /// /// Each AST node is annotated with span and an optional ID. -#[derive(CloneRef, Eq, PartialEq, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(CloneRef, Eq, PartialEq, Debug, Deref, DerefMut)] pub struct Ast { pub wrapped: Rc>>>, } @@ -1214,10 +1211,10 @@ pub trait HasID { fn id(&self) -> Option; } -#[derive(Eq, PartialEq, Debug, Shrinkwrap, Serialize, Deserialize)] -#[shrinkwrap(mutable)] +#[derive(Eq, PartialEq, Debug, Deref, DerefMut, Serialize, Deserialize)] pub struct WithID { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] #[serde(flatten)] pub wrapped: T, pub id: Option, @@ -1300,10 +1297,10 @@ pub fn traverse_with_span(ast: &impl HasTokens, mut f: impl FnMut(enso_text::Ran /// /// Even if `T` is `Spanned`, keeping `length` variable is desired for performance /// purposes. -#[derive(Eq, PartialEq, Debug, Shrinkwrap, Serialize, Deserialize)] -#[shrinkwrap(mutable)] +#[derive(Eq, PartialEq, Debug, Deref, DerefMut, Serialize, Deserialize)] pub struct WithLength { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] #[serde(flatten)] pub wrapped: T, pub length: usize, diff --git a/app/gui/language/ast/impl/src/macros.rs b/app/gui/language/ast/impl/src/macros.rs index 88097b6acf8..c334a2299ee 100644 --- a/app/gui/language/ast/impl/src/macros.rs +++ b/app/gui/language/ast/impl/src/macros.rs @@ -100,10 +100,10 @@ impl DocumentationCommentAst { // === Line Description === /// Describes the line with a documentation comment. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct DocumentationCommentLine { /// Stores the documentation AST and the trailing whitespace length. - #[shrinkwrap(main_field)] + #[deref] line: BlockLine, body: crate::MacroPatternMatch>, } @@ -142,10 +142,10 @@ impl DocumentationCommentLine { /// Structure holding the documentation comment AST and related information necessary to deal with /// them. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct DocumentationCommentInfo { /// Description of the line with the documentation comment. - #[shrinkwrap(main_field)] + #[deref] pub line: DocumentationCommentLine, /// The absolute indent of the block that contains the line with documentation comment. pub block_indent: usize, @@ -177,7 +177,7 @@ impl DocumentationCommentInfo { let mut lines = text.lines(); // First line must always exist, even for an empty comment. let first_line = format!("##{}", lines.next().unwrap_or_default()); - let other_lines = lines.map(|line| iformat!("{indent} {line}")); + let other_lines = lines.map(|line| format!("{indent} {line}")); let mut out_lines = std::iter::once(first_line).chain(other_lines); out_lines.join("\n") } diff --git a/app/gui/language/parser/Cargo.toml b/app/gui/language/parser/Cargo.toml index 820ea057b5b..3f8edf83089 100644 --- a/app/gui/language/parser/Cargo.toml +++ b/app/gui/language/parser/Cargo.toml @@ -14,13 +14,12 @@ enso-data-structures = { path = "../../../../lib/rust/data-structures" } enso-prelude = { path = "../../../../lib/rust/prelude" } enso-profiler = { path = "../../../../lib/rust/profiler" } enso-text = { path = "../../../../lib/rust/text" } -console_error_panic_hook = { version = "0.1.6" } -failure = { version = "0.1" } -js-sys = { version = "0.3.28" } -matches = { version = "0.1" } +console_error_panic_hook = { workspace = true } +failure = { workspace = true } +js-sys = { workspace = true } +matches = { workspace = true } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", features = ["unbounded_depth"] } -shrinkwraprs = { version = "0.2.1" } uuid = { version = "0.8", features = ["serde", "v5", "wasm-bindgen"] } wasm-bindgen = { workspace = true } @@ -29,9 +28,9 @@ wasm-bindgen-test = { workspace = true } [build-dependencies] ide-ci = { path = "../../../../build/ci_utils" } -bytes = { version = "1.1.0" } -futures = { version = "0.3.1" } -reqwest = { version = "0.11.12" } +bytes = { workspace = true } +futures = { workspace = true } +reqwest = { workspace = true } tokio = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/app/gui/language/parser/src/api.rs b/app/gui/language/parser/src/api.rs index ec4af3f1086..4adcefcf816 100644 --- a/app/gui/language/parser/src/api.rs +++ b/app/gui/language/parser/src/api.rs @@ -243,9 +243,8 @@ impl ParsedSourceFile { let metadata_start = id_map_start + id_map.len() + before_metadata.len(); let metadata_start_bytes = Byte::from(metadata_start); Ok(SourceFile { - content: iformat!( - "{code}{before_tag}{METADATA_TAG}{before_idmap}{id_map}\ - {before_metadata}{metadata}" + content: format!( + "{code}{before_tag}{METADATA_TAG}{before_idmap}{id_map}{before_metadata}{metadata}" ), code: (0.byte()..code.len().to_byte()).into(), id_map: (id_map_start_bytes..id_map_start_bytes + ByteDiff::from(id_map.len())) @@ -327,7 +326,7 @@ mod test { let expected_json_id_map = JsonIdMap::from_id_map(&source.ast.id_map(), &repr); let expected_id_map = to_json_single_line(&expected_json_id_map).unwrap(); let expected_metadata = to_json_single_line(&source.metadata).unwrap(); - let expected_content = iformat!( + let expected_content = format!( r#"main = 2 + 2 diff --git a/app/gui/language/parser/src/bin/run-scala-parser.rs b/app/gui/language/parser/src/bin/run-scala-parser.rs index d8f52ed66e7..0569457cd69 100644 --- a/app/gui/language/parser/src/bin/run-scala-parser.rs +++ b/app/gui/language/parser/src/bin/run-scala-parser.rs @@ -14,36 +14,36 @@ use enso_prelude::*; fn main() { let default_input = String::from("import Foo.Bar\nfoo = a + 2"); let program = std::env::args().nth(1).unwrap_or(default_input); - DEBUG!("Will parse: " program); + debug!("Will parse: {}", program); let parser = parser_scala::Parser::new_or_panic(); let output = parser.parse(program, default()); match output { - Ok(result) => DEBUG!("Parser responded with: {result:?}"), - Err(e) => DEBUG!("Failed to obtain a response: {e:?}"), + Ok(result) => debug!("Parser responded with: {result:?}"), + Err(e) => debug!("Failed to obtain a response: {e:?}"), } let default_input = String::from("##\n DEPRECATED\n Foo bar baz\ntype Foo\n type Bar"); let program = std::env::args().nth(1).unwrap_or(default_input); - DEBUG!("Will parse: " program); + debug!("Will parse: {}", program); let parser = parser_scala::DocParser::new_or_panic(); let output = parser.generate_html_docs(program); match output { - Ok(result) => DEBUG!("Doc parser responded with: {result:?}"), - Err(e) => DEBUG!("Failed to obtain a response: {e:?}"), + Ok(result) => debug!("Doc parser responded with: {result:?}"), + Err(e) => debug!("Failed to obtain a response: {e:?}"), } let default_input = String::from("Computes the _logical_ conjunction of *two* booleans"); let program = std::env::args().nth(1).unwrap_or(default_input); - DEBUG!("Will parse: " program); + debug!("Will parse: {}", program); let parser = parser_scala::DocParser::new_or_panic(); let output = parser.generate_html_doc_pure(program); match output { - Ok(result) => DEBUG!("Doc parser responded with: {result:?}"), - Err(e) => DEBUG!("Failed to obtain a response: {e:?}"), + Ok(result) => debug!("Doc parser responded with: {result:?}"), + Err(e) => debug!("Failed to obtain a response: {e:?}"), } } diff --git a/app/gui/language/parser/src/lib.rs b/app/gui/language/parser/src/lib.rs index 4fddd3f6be8..b091abef8cd 100644 --- a/app/gui/language/parser/src/lib.rs +++ b/app/gui/language/parser/src/lib.rs @@ -70,8 +70,7 @@ type Client = jsclient::Client; /// Currently this component is implemented as a wrapper over parser written /// in Scala. Depending on compilation target (native or wasm) it uses either /// implementation provided by `wsclient` or `jsclient`. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, CloneRef, Debug, Deref, DerefMut)] pub struct Parser(pub Rc>); impl Parser { @@ -187,8 +186,7 @@ pub fn from_json_str_without_recursion_limit<'de, Value: serde::Deserialize<'de> /// Currently this component is implemented as a wrapper over documentation /// parser written in Scala. Depending on compilation target (native or wasm) /// it uses either implementation provided by `wsclient` or `jsclient`. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, CloneRef, Debug, Deref, DerefMut)] pub struct DocParser(pub Rc>); impl DocParser { diff --git a/app/gui/language/parser/src/test_utils.rs b/app/gui/language/parser/src/test_utils.rs index c9d98782b8f..7fc2eaaf1a9 100644 --- a/app/gui/language/parser/src/test_utils.rs +++ b/app/gui/language/parser/src/test_utils.rs @@ -40,7 +40,7 @@ impl ParserTestExts for Parser { fn parse_testing(&self, program: impl Str) -> Ast { let program = program.into(); - DEBUG!("parsing " program); + debug!("parsing {}", program); let ast = self.parse(program.clone(), default()).unwrap(); assert_eq!(ast.shape().len(), program.len().bytes()); validate_spans(&ast); diff --git a/app/gui/language/parser/src/wsclient.rs b/app/gui/language/parser/src/wsclient.rs index 59692f90403..bacd7a1d248 100644 --- a/app/gui/language/parser/src/wsclient.rs +++ b/app/gui/language/parser/src/wsclient.rs @@ -231,9 +231,9 @@ impl Client { // This parser is used only for native debugging, it is not used in production. // As such, we can use debug macros here. let config = Config::from_env(); - DEBUG!("Connecting to " config.address_string()); + debug!("Connecting to {}", config.address_string()); let client = Client::from_conf(&config)?; - DEBUG!("Established connection with {}" config.address_string()); + debug!("Established connection with {}", config.address_string()); Ok(client) } diff --git a/app/gui/language/span-tree/Cargo.toml b/app/gui/language/span-tree/Cargo.toml index 5ae36e7b0ec..9315d59f029 100644 --- a/app/gui/language/span-tree/Cargo.toml +++ b/app/gui/language/span-tree/Cargo.toml @@ -10,7 +10,7 @@ enso-data-structures = { path = "../../../../lib/rust/data-structures" } enso-text = { path = "../../../../lib/rust/text" } enso-prelude = { path = "../../../../lib/rust/prelude" } enso-profiler = { path = "../../../../lib/rust/profiler" } -failure = { version = "0.1.6" } +failure = { workspace = true } [dev-dependencies] parser-scala = { path = "../parser" } diff --git a/app/gui/language/span-tree/example/Cargo.toml b/app/gui/language/span-tree/example/Cargo.toml index d202e012e9d..0add16ade8c 100644 --- a/app/gui/language/span-tree/example/Cargo.toml +++ b/app/gui/language/span-tree/example/Cargo.toml @@ -13,7 +13,6 @@ enso-text = { path = "../../../../../lib/rust/text" } span-tree = { path = "../../span-tree" } enso-web = { path = "../../../../../lib/rust/web" } enso-prelude = { path = "../../../../../lib/rust/prelude" } -enso-logger = { path = "../../../../../lib/rust/logger" } wasm-bindgen = { workspace = true } uuid = { version = "0.8", features = ["serde", "v4", "wasm-bindgen"] } diff --git a/app/gui/language/span-tree/example/src/lib.rs b/app/gui/language/span-tree/example/src/lib.rs index d4c6f51a1f5..4cb2c87551c 100644 --- a/app/gui/language/span-tree/example/src/lib.rs +++ b/app/gui/language/span-tree/example/src/lib.rs @@ -102,5 +102,5 @@ pub fn main() { }) .new_child(|t| t.size(1.bytes())); - DEBUG!("{input_span_tree2:#?}"); + debug!("{input_span_tree2:#?}"); } diff --git a/app/gui/src/controller/graph.rs b/app/gui/src/controller/graph.rs index de47dcc727d..1fc398065bb 100644 --- a/app/gui/src/controller/graph.rs +++ b/app/gui/src/controller/graph.rs @@ -475,33 +475,29 @@ pub struct Handle { pub module: model::Module, pub suggestion_db: Rc, parser: Parser, - logger: Logger, } impl Handle { /// Creates a new controller. Does not check if id is valid. pub fn new_unchecked( - parent: impl AnyLogger, module: model::Module, suggestion_db: Rc, parser: Parser, id: Id, ) -> Handle { let id = Rc::new(id); - let logger = Logger::new_sub(parent, format!("Graph Controller {}", id)); - Handle { id, module, suggestion_db, parser, logger } + Handle { id, module, suggestion_db, parser } } /// Create a new graph controller. Given ID should uniquely identify a definition in the /// module. Fails if ID cannot be resolved. pub fn new( - parent: impl AnyLogger, module: model::Module, suggestion_db: Rc, parser: Parser, id: Id, ) -> FallibleResult { - let ret = Self::new_unchecked(parent, module, suggestion_db, parser, id); + let ret = Self::new_unchecked(module, suggestion_db, parser, id); // Get and discard definition info, we are just making sure it can be obtained. let _ = ret.definition()?; Ok(ret) @@ -512,7 +508,6 @@ impl Handle { /// Fails if the module is inaccessible or if the module does not contain the given method. #[profile(Task)] pub async fn new_method( - parent: impl AnyLogger, project: &model::Project, method: &language_server::MethodPointer, ) -> FallibleResult { @@ -521,7 +516,7 @@ impl Handle { let module_path = model::module::Path::from_method(root_id, &method)?; let module = project.module(module_path).await?; let definition = module.lookup_method(project.qualified_name(), &method)?; - Self::new(parent, module, project.suggestion_db(), project.parser(), definition) + Self::new(module, project.suggestion_db(), project.parser(), definition) } /// Get the double representation description of the graph. @@ -1101,13 +1096,12 @@ pub mod tests { /// Create a graph controller from the current mock data. pub fn graph(&self) -> Handle { - let logger = Logger::new("Test"); let parser = Parser::new().unwrap(); - let urm = Rc::new(model::undo_redo::Repository::new(&logger)); + let urm = Rc::new(model::undo_redo::Repository::new()); let module = self.module_data().plain(&parser, urm); let id = self.graph_id.clone(); let db = self.suggestion_db(); - Handle::new(logger, module, db, parser, id).unwrap() + Handle::new(module, db, parser, id).unwrap() } pub fn method(&self) -> MethodPointer { @@ -1128,11 +1122,11 @@ pub mod tests { } } - #[derive(Debug, Shrinkwrap)] - #[shrinkwrap(mutable)] + #[derive(Debug, Deref, DerefMut)] pub struct Fixture { pub data: MockData, - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] pub inner: TestWithLocalPoolExecutor, } @@ -1190,7 +1184,7 @@ pub mod tests { fn graph_controller_inline_definition() { let mut test = Fixture::set_up(); const EXPRESSION: &str = "2+2"; - test.data.code = iformat!("main = {EXPRESSION}"); + test.data.code = format!("main = {EXPRESSION}"); test.run(|graph| async move { let nodes = graph.nodes().unwrap(); let (node,) = nodes.expect_tuple(); @@ -1421,7 +1415,7 @@ main = // === Initial nodes === let nodes = graph.nodes().unwrap(); for node in &nodes { - DEBUG!(node.repr()) + debug!("{}", node.repr()) } let (node1, node2) = nodes.expect_tuple(); assert_eq!(node1.info.expression().repr(), "2"); diff --git a/app/gui/src/controller/graph/executed.rs b/app/gui/src/controller/graph/executed.rs index e0361b9b815..2611ab95486 100644 --- a/app/gui/src/controller/graph/executed.rs +++ b/app/gui/src/controller/graph/executed.rs @@ -75,7 +75,6 @@ pub enum Notification { #[derive(Clone, CloneRef, Debug)] pub struct Handle { #[allow(missing_docs)] - pub logger: Logger, /// A handle to basic graph operations. graph: Rc>, /// Execution Context handle, its call stack top contains `graph`'s definition. @@ -91,12 +90,8 @@ pub struct Handle { impl Handle { /// Create handle for the executed graph that will be running the given method. #[profile(Task)] - pub async fn new( - parent: impl AnyLogger, - project: model::Project, - method: MethodPointer, - ) -> FallibleResult { - let graph = controller::Graph::new_method(parent, &project, &method).await?; + pub async fn new(project: model::Project, method: MethodPointer) -> FallibleResult { + let graph = controller::Graph::new_method(&project, &method).await?; let execution = project.create_execution_context(method.clone()).await?; Ok(Self::new_internal(graph, project, execution)) } @@ -120,10 +115,9 @@ impl Handle { project: model::Project, execution_ctx: model::ExecutionContext, ) -> Self { - let logger = Logger::new_sub(&graph.logger, "Executed"); let graph = Rc::new(RefCell::new(graph)); let notifier = default(); - Handle { logger, graph, execution_ctx, project, notifier } + Handle { graph, execution_ctx, project, notifier } } /// See [`model::ExecutionContext::when_ready`]. @@ -226,7 +220,7 @@ impl Handle { pub async fn enter_method_pointer(&self, local_call: &LocalCall) -> FallibleResult { debug!("Entering node {}.", local_call.call); let method_ptr = &local_call.definition; - let graph = controller::Graph::new_method(&self.logger, &self.project, method_ptr); + let graph = controller::Graph::new_method(&self.project, method_ptr); let graph = graph.await?; self.execution_ctx.push(local_call.clone()).await?; debug!("Replacing graph with {graph:?}."); @@ -273,7 +267,7 @@ impl Handle { pub async fn exit_node(&self) -> FallibleResult { let frame = self.execution_ctx.pop().await?; let method = self.execution_ctx.current_method(); - let graph = controller::Graph::new_method(&self.logger, &self.project, &method).await?; + let graph = controller::Graph::new_method(&self.project, &method).await?; self.graph.replace(graph); self.notifier.publish(Notification::SteppedOutOfNode(frame.call)).await; Ok(()) @@ -384,9 +378,8 @@ pub mod tests { impl MockData { pub fn controller(&self) -> Handle { - let logger = Logger::new("test"); let parser = parser_scala::Parser::new_or_panic(); - let repository = Rc::new(model::undo_redo::Repository::new(&logger)); + let repository = Rc::new(model::undo_redo::Repository::new()); let module = self.module.plain(&parser, repository); let method = self.graph.method(); let mut project = model::project::MockAPI::new(); @@ -403,7 +396,7 @@ pub mod tests { let suggestion_db = self.graph.suggestion_db(); model::project::test::expect_suggestion_db(&mut project, suggestion_db); let project = Rc::new(project); - Handle::new(logger, project.clone_ref(), method).boxed_local().expect_ok() + Handle::new(project.clone_ref(), method).boxed_local().expect_ok() } } diff --git a/app/gui/src/controller/ide/desktop.rs b/app/gui/src/controller/ide/desktop.rs index d960906030b..f3690248b4c 100644 --- a/app/gui/src/controller/ide/desktop.rs +++ b/app/gui/src/controller/ide/desktop.rs @@ -38,7 +38,6 @@ const UNNAMED_PROJECT_NAME: &str = "Unnamed"; #[derive(Clone, CloneRef, Derivative)] #[derivative(Debug)] pub struct Handle { - logger: Logger, current_project: Rc>>, #[derivative(Debug = "ignore")] project_manager: Rc, @@ -68,19 +67,11 @@ impl Handle { project_manager: Rc, project: Option, ) -> Self { - let logger = Logger::new("controller::ide::Desktop"); let current_project = Rc::new(CloneCell::new(project)); let status_notifications = default(); let parser = Parser::new_or_panic(); let notifications = default(); - Self { - logger, - current_project, - project_manager, - status_notifications, - parser, - notifications, - } + Self { current_project, project_manager, status_notifications, parser, notifications } } /// Open project with provided name. @@ -139,7 +130,7 @@ impl ManagingProjectAPI for Handle { .await?; let new_project_id = create_result.project_id; let project_mgr = self.project_manager.clone_ref(); - let new_project = Project::new_opened(&self.logger, project_mgr, new_project_id); + let new_project = Project::new_opened(project_mgr, new_project_id); self.current_project.set(Some(new_project.await?)); let notify = self.notifications.publish(Notification::NewProjectCreated); executor::global::spawn(notify); @@ -156,9 +147,8 @@ impl ManagingProjectAPI for Handle { #[profile(Objective)] fn open_project(&self, id: Uuid) -> BoxFuture { async move { - let logger = &self.logger; let project_mgr = self.project_manager.clone_ref(); - let new_project = model::project::Synchronized::new_opened(logger, project_mgr, id); + let new_project = model::project::Synchronized::new_opened(project_mgr, id); self.current_project.set(Some(new_project.await?)); executor::global::spawn(self.notifications.publish(Notification::ProjectOpened)); Ok(()) @@ -171,7 +161,7 @@ impl ManagingProjectAPI for Handle { /// number. fn choose_unique_project_name(existing_names: &HashSet, suggested_name: &str) -> String { let first_candidate = suggested_name.to_owned(); - let nth_project_name = |i| iformat!("{suggested_name}_{i}"); + let nth_project_name = |i| format!("{suggested_name}_{i}"); let candidates = (1..).map(nth_project_name); let mut candidates = iter::once(first_candidate).chain(candidates); // The iterator have no end, so we can safely unwrap. diff --git a/app/gui/src/controller/ide/plain.rs b/app/gui/src/controller/ide/plain.rs index 4831fcd8f27..6c89b4ae138 100644 --- a/app/gui/src/controller/ide/plain.rs +++ b/app/gui/src/controller/ide/plain.rs @@ -37,7 +37,6 @@ pub struct ProjectOperationsNotSupported; #[allow(missing_docs)] #[derive(Clone, CloneRef, Debug)] pub struct Handle { - pub logger: Logger, pub status_notifications: StatusNotificationPublisher, pub parser: Parser, pub project: model::Project, @@ -46,10 +45,9 @@ pub struct Handle { impl Handle { /// Create IDE Controller for a given opened project. pub fn new(project: model::Project) -> Self { - let logger = Logger::new("controller::ide::Plain"); let status_notifications = default(); let parser = Parser::new_or_panic(); - Self { logger, status_notifications, parser, project } + Self { status_notifications, parser, project } } /// Create IDE Controller from Language Server endpoints, describing the opened project. @@ -60,7 +58,6 @@ impl Handle { json_endpoint: String, binary_endpoint: String, ) -> FallibleResult { - let logger = Logger::new("controller::ide::Plain"); let properties = Properties { //TODO [ao]: this should be not the default; instead project model should not need the // id. See https://github.com/enso-org/ide/issues/1572 @@ -69,7 +66,6 @@ impl Handle { engine_version: version, }; let project = model::project::Synchronized::new_connected( - &logger, None, json_endpoint, binary_endpoint, @@ -78,7 +74,7 @@ impl Handle { .await?; let status_notifications = default(); let parser = Parser::new_or_panic(); - Ok(Self { logger, status_notifications, parser, project }) + Ok(Self { status_notifications, parser, project }) } } diff --git a/app/gui/src/controller/module.rs b/app/gui/src/controller/module.rs index 0d9821d995a..b44f6c595d8 100644 --- a/app/gui/src/controller/module.rs +++ b/app/gui/src/controller/module.rs @@ -42,22 +42,16 @@ pub struct Handle { pub model: model::Module, pub language_server: Rc, pub parser: Parser, - pub logger: Logger, } impl Handle { /// Create a module controller for given path. #[profile(Task)] - pub async fn new( - parent: impl AnyLogger, - path: Path, - project: &dyn model::project::API, - ) -> FallibleResult { - let logger = Logger::new_sub(parent, format!("Module Controller {}", path)); + pub async fn new(path: Path, project: &dyn model::project::API) -> FallibleResult { let model = project.module(path).await?; let language_server = project.json_rpc(); let parser = project.parser(); - Ok(Handle { model, language_server, parser, logger }) + Ok(Handle { model, language_server, parser }) } /// Save the module to file. @@ -107,13 +101,7 @@ impl Handle { id: double_representation::graph::Id, suggestion_db: Rc, ) -> FallibleResult { - controller::Graph::new( - &self.logger, - self.model.clone_ref(), - suggestion_db, - self.parser.clone_ref(), - id, - ) + controller::Graph::new(self.model.clone_ref(), suggestion_db, self.parser.clone_ref(), id) } /// Returns a graph controller for graph in this module's subtree identified by `id` without @@ -124,7 +112,6 @@ impl Handle { suggestion_db: Rc, ) -> controller::Graph { controller::Graph::new_unchecked( - &self.logger, self.model.clone_ref(), suggestion_db, self.parser.clone_ref(), @@ -184,11 +171,10 @@ impl Handle { parser: Parser, repository: Rc, ) -> FallibleResult { - let logger = Logger::new("Mocked Module Controller"); let ast = parser.parse(code.to_string(), id_map)?.try_into()?; let metadata = default(); let model = Rc::new(model::module::Plain::new(path, ast, metadata, repository)); - Ok(Handle { model, language_server, parser, logger }) + Ok(Handle { model, language_server, parser }) } #[cfg(test)] diff --git a/app/gui/src/controller/project.rs b/app/gui/src/controller/project.rs index 0994d11b515..9ba41cdf2cf 100644 --- a/app/gui/src/controller/project.rs +++ b/app/gui/src/controller/project.rs @@ -89,7 +89,6 @@ pub struct InitializationResult { #[allow(missing_docs)] #[derive(Clone, CloneRef, Debug)] pub struct Project { - pub logger: Logger, pub model: model::Project, pub status_notifications: StatusNotificationPublisher, } @@ -97,8 +96,7 @@ pub struct Project { impl Project { /// Create a controller of given project. pub fn new(model: model::Project, status_notifications: StatusNotificationPublisher) -> Self { - let logger = Logger::new("controller::Project"); - Self { logger, model, status_notifications } + Self { model, status_notifications } } /// Do the initial setup of opened project. @@ -132,8 +130,8 @@ impl Project { // Here, we should be relatively certain (except race conditions in case of multiple // clients that we currently do not support) that main module exists and contains main // method. Thus, we should be able to successfully create a graph controller for it. - let main_module_text = controller::Text::new(&self.logger, &project, file_path).await?; - let main_graph = controller::ExecutedGraph::new(&self.logger, project, method).await?; + let main_module_text = controller::Text::new(&project, file_path).await?; + let main_graph = controller::ExecutedGraph::new(project, method).await?; self.init_call_stack_from_metadata(&main_module_model, &main_graph).await; self.notify_about_compiling_process(&main_graph); @@ -195,7 +193,7 @@ impl Project { // Push as many frames as possible. We should not be too concerned about failure here. // It is to be assumed that metadata can get broken. if let Err(e) = main_graph.enter_method_pointer(&frame).await { - warning!(self.logger, "Failed to push initial stack frame: {frame:?}: {e}"); + warn!("Failed to push initial stack frame: {frame:?}: {e}"); break; } } @@ -206,12 +204,11 @@ impl Project { let status_notifier = self.status_notifications.clone_ref(); let compiling_process = status_notifier.publish_background_task(COMPILING_STDLIB_LABEL); let execution_ready = graph.when_ready(); - let logger = self.logger.clone_ref(); executor::global::spawn(async move { if execution_ready.await.is_some() { status_notifier.published_background_task_finished(compiling_process); } else { - warning!(logger, "Executed graph dropped before first successful execution!") + warn!("Executed graph dropped before first successful execution!") } }); } diff --git a/app/gui/src/controller/searcher.rs b/app/gui/src/controller/searcher.rs index 94d6618c786..02714c5fddf 100644 --- a/app/gui/src/controller/searcher.rs +++ b/app/gui/src/controller/searcher.rs @@ -577,7 +577,6 @@ impl ComponentsProvider { /// existing node). #[derive(Clone, CloneRef, Debug)] pub struct Searcher { - logger: Logger, data: Rc>, breadcrumbs: Breadcrumbs, notifier: notification::Publisher, @@ -595,14 +594,13 @@ pub struct Searcher { impl Searcher { /// Create new Searcher Controller. pub async fn new( - parent: impl AnyLogger, ide: controller::Ide, project: &model::Project, method: language_server::MethodPointer, mode: Mode, ) -> FallibleResult { - let graph = controller::ExecutedGraph::new(&parent, project.clone_ref(), method).await?; - Self::new_from_graph_controller(parent, ide, project, graph, mode) + let graph = controller::ExecutedGraph::new(project.clone_ref(), method).await?; + Self::new_from_graph_controller(ide, project, graph, mode) } /// Abort editing and perform cleanup. @@ -613,14 +611,12 @@ impl Searcher { /// Create new Searcher Controller, when you have Executed Graph Controller handy. #[profile(Task)] pub fn new_from_graph_controller( - parent: impl AnyLogger, ide: controller::Ide, project: &model::Project, graph: controller::ExecutedGraph, mode: Mode, ) -> FallibleResult { let project = project.clone_ref(); - let logger = Logger::new_sub(parent, "Searcher Controller"); let database = project.suggestion_db(); let data = if let Mode::EditNode { node_id } = mode { Data::new_with_edited_node(&graph.graph(), &database, node_id)? @@ -639,7 +635,6 @@ impl Searcher { }); let breadcrumbs = Breadcrumbs::new(); let ret = Self { - logger, graph, this_arg, ide, @@ -1774,7 +1769,6 @@ pub mod test { let searcher_target = graph.graph().nodes().unwrap().last().unwrap().id(); let this = ThisNode::new(node.info.id(), &graph.graph()); let this = data.selected_node.and_option(this); - let logger = Logger::new("Searcher"); // new_empty let module_name = crate::test::mock::data::module_qualified_name(); let database = suggestion_database_with_mock_entries(code_range); let mut ide = controller::ide::MockAPI::new(); @@ -1793,7 +1787,6 @@ pub mod test { let breadcrumbs = Breadcrumbs::new(); let searcher = Searcher { graph, - logger, database, ide: Rc::new(ide), data: default(), @@ -1999,7 +1992,7 @@ pub mod test { // Known functions cases searcher.set_input("Test.test_method ".to_string()).unwrap(); - searcher.set_input(iformat!("{MODULE_NAME}.test_method ")).unwrap(); + searcher.set_input(format!("{MODULE_NAME}.test_method ")).unwrap(); searcher.set_input("testFunction2 \"str\" ".to_string()).unwrap(); // Unknown functions case @@ -2112,7 +2105,10 @@ pub mod test { assert_matches!(entries.as_slice(), [e1, e2] if e1.name() == entry3.name && e2.name() == entry9.name); } else { - ipanic!("Wrong top modules in Component List: {components.top_modules().collect::>():?}"); + panic!( + "Wrong top modules in Component List: {:?}", + components.top_modules().collect::>() + ); } let favorites = &components.favorites; assert_eq!(favorites.len(), 2); diff --git a/app/gui/src/controller/searcher/component.rs b/app/gui/src/controller/searcher/component.rs index cf8cfd6aa21..8a5f3521db9 100644 --- a/app/gui/src/controller/searcher/component.rs +++ b/app/gui/src/controller/searcher/component.rs @@ -419,7 +419,7 @@ pub(crate) mod tests { .iter() .map(|c| c.match_info.borrow().clone()) .collect_vec(); - DEBUG!("{match_infos:?}"); + debug!("{match_infos:?}"); assert_ids_of_matches_entries(&list.top_modules().next().unwrap()[0], &[2, 4]); assert_ids_of_matches_entries(&list.favorites[0], &[4, 2]); assert_ids_of_matches_entries(&list.local_scope, &[2]); diff --git a/app/gui/src/controller/text.rs b/app/gui/src/controller/text.rs index e5db02f4727..8e31837a7fa 100644 --- a/app/gui/src/controller/text.rs +++ b/app/gui/src/controller/text.rs @@ -46,8 +46,7 @@ enum FileHandle { /// This struct contains all information and handles to do all module controller operations. #[derive(Clone, CloneRef, Debug)] pub struct Handle { - logger: Logger, - file: FileHandle, + file: FileHandle, } impl Handle { @@ -56,23 +55,16 @@ impl Handle { /// This constructor checks what kind of file we read, and load it as a module file or plain /// text file. #[profile(Detail)] - pub async fn new( - parent: impl AnyLogger, - project: &model::Project, - path: FilePath, - ) -> FallibleResult { - let logger = Logger::new_sub(parent, format!("Text Controller {}", path)); + pub async fn new(project: &model::Project, path: FilePath) -> FallibleResult { let file = if let Ok(path) = model::module::Path::from_file_path(path.clone()) { - FileHandle::Module { - controller: controller::Module::new(logger.clone_ref(), path, &**project).await?, - } + FileHandle::Module { controller: controller::Module::new(path, &**project).await? } } else { FileHandle::PlainText { path: Rc::new(path), language_server: project.json_rpc(), } }; - Ok(Self { logger, file }) + Ok(Self { file }) } /// Get clone of file path handled by this controller. @@ -183,10 +175,7 @@ mod test { let module_res = controller::Module::new_mock(path, "main = 2+2", default(), ls, parser, default()); let module = module_res.unwrap(); - let controller = Handle { - logger: Logger::new("Test text controller"), - file: FileHandle::Module { controller: module.clone() }, - }; + let controller = Handle { file: FileHandle::Module { controller: module.clone() } }; let mut sub = controller.subscribe(); let change = enso_text::Change::inserted(8.byte(), "2".to_string()); @@ -202,9 +191,8 @@ mod test { let root_id = default(); let path = FilePath::new(root_id, &["TestPath"]); let another_path = FilePath::new(root_id, &["TestPath2"]); - let log = Logger::new("Test"); - let text_ctrl = Handle::new(&log, &project, path.clone()).await.unwrap(); - let another_ctrl = Handle::new(&log, &project, another_path.clone()).await.unwrap(); + let text_ctrl = Handle::new(&project, path.clone()).await.unwrap(); + let another_ctrl = Handle::new(&project, another_path.clone()).await.unwrap(); assert!(Rc::ptr_eq(&another_ctrl.language_server(), &text_ctrl.language_server())); assert!(Rc::ptr_eq(&another_ctrl.language_server(), &project.json_rpc())); @@ -227,8 +215,7 @@ mod test { model::project::test::expect_parser(project, &parser); }); let file_path = module.path().file_path(); - let log = Logger::new("Test"); - let text_ctrl = controller::Text::new(&log, &project, file_path.clone()).await.unwrap(); + let text_ctrl = controller::Text::new(&project, file_path.clone()).await.unwrap(); let content = text_ctrl.read_content().await.unwrap(); assert_eq!("2 + 2", content.as_str()); }); diff --git a/app/gui/src/controller/upload.rs b/app/gui/src/controller/upload.rs index b8ee96bbc1f..3e17d549476 100644 --- a/app/gui/src/controller/upload.rs +++ b/app/gui/src/controller/upload.rs @@ -171,16 +171,14 @@ impl FileUploadProcess { /// It is responsible for creating node, uploading file and updating the node's metadata. #[derive(Clone, CloneRef, Debug)] pub struct NodeFromDroppedFileHandler { - logger: Logger, project: model::Project, graph: controller::Graph, } impl NodeFromDroppedFileHandler { /// Constructor - pub fn new(parent: impl AnyLogger, project: model::Project, graph: controller::Graph) -> Self { - let logger = Logger::new_sub(parent, "NodeFromDroppedFileHandler"); - Self { logger, project, graph } + pub fn new(project: model::Project, graph: controller::Graph) -> Self { + Self { project, graph } } /// Create a node from dropped file and start uploading file. @@ -252,7 +250,7 @@ impl NodeFromDroppedFileHandler { if let Err(err) = self.graph.module.with_node_metadata(node, Box::new(|md| md.uploading_file = None)) { - warning!(self.logger, "Cannot remove uploading metadata: {err}"); + warn!("Cannot remove uploading metadata: {err}"); } Ok(()) } @@ -264,15 +262,11 @@ impl NodeFromDroppedFileHandler { if let Some(uploading_md) = &mut md.uploading_file { f(uploading_md) } else { - warning!( - self.logger, - "Cannot update upload progress on {node:?}: Metadata are \ - missing." - ); + warn!("Cannot update upload progress on {node:?}: Metadata are missing."); } }); if let Err(err) = self.graph.module.with_node_metadata(node, update_md) { - warning!(self.logger, "Cannot update upload progress: {err}"); + warn!("Cannot update upload progress: {err}"); } } @@ -356,7 +350,7 @@ pub async fn pick_non_colliding_name( let name_stem = extension_sep.map_or(original_name, |i| &original_name[0..i]); let name_ext = extension_sep.map_or("", |i| &original_name[i..]); let first_candidate = std::iter::once(original_name.to_owned()); - let next_candidates = (1..).map(|num| iformat!("{name_stem}_{num}{name_ext}")); + let next_candidates = (1..).map(|num| format!("{name_stem}_{num}{name_ext}")); let mut candidates = first_candidate.chain(next_candidates); Ok(candidates.find(|name| !files_in_data_dir.contains(name)).unwrap()) } @@ -447,7 +441,7 @@ mod test { let path = self.path.clone(); let checksum = Sha3_224::new(&chunk); let chunk_len = chunk.len(); - DEBUG!("Setting expectation {path:?} {chunk:?}"); + debug!("Setting expectation {path:?} {chunk:?}"); binary_client .expect_write_bytes() .withf(move |p, off, ow, ch| *p == path && ch == chunk && *off == offset && !ow) @@ -457,10 +451,11 @@ mod test { offset += chunk_len as u64; } let checksum = self.checksum.clone(); - json_client.expect.file_checksum(enclose!((self.path => path) move |p| { - assert_eq!(*p,path); - Ok(response::FileChecksum{checksum}) - })); + let path = self.path.clone(); + json_client.expect.file_checksum(move |p| { + assert_eq!(*p, path); + Ok(response::FileChecksum { checksum }) + }); } fn file_to_upload(&self) -> FileToUpload { @@ -554,7 +549,6 @@ mod test { #[wasm_bindgen_test] fn creating_node_from_dropped_file() { - let logger = Logger::new("test::creating_node_from_dropped_file"); let data = TestData::new(vec![vec![1, 2, 3, 4], vec![5, 6, 7, 8]]); let mut fixture = mock::Unified::new().fixture_customize(|_, json_rpc, binary_rpc| { json_rpc.expect.file_info(|path| { @@ -570,7 +564,7 @@ mod test { data.setup_uploading_expectations(json_rpc, binary_rpc); }); - let handler = NodeFromDroppedFileHandler::new(logger, fixture.project, fixture.graph); + let handler = NodeFromDroppedFileHandler::new(fixture.project, fixture.graph); let position = model::module::Position::new(45.0, 70.0); let file = data.file_to_upload(); handler.create_node_and_start_uploading(file, position).unwrap(); @@ -581,7 +575,6 @@ mod test { #[wasm_bindgen_test] fn recreating_data_directory() { - let logger = Logger::new("test::recreating_data_directory"); let mut fixture = mock::Unified::new().fixture_customize(|_, json_rpc, _| { json_rpc.expect.file_info(|path| { assert_eq!(*path, data_path()); @@ -598,7 +591,7 @@ mod test { Ok(response::FileList { paths: vec![] }) }); }); - let handler = NodeFromDroppedFileHandler::new(logger, fixture.project, fixture.graph); + let handler = NodeFromDroppedFileHandler::new(fixture.project, fixture.graph); fixture.executor.expect_completion(handler.ensure_data_directory_exists()).unwrap(); } @@ -626,7 +619,6 @@ mod test { fn run(self) { let Case { file_name, other_collision_name, expected_remote_name } = self; - let logger = Logger::new("test::creating_node_from_dropped_file"); let data = TestData::new_with_file_name( vec![vec![1, 2, 3, 4]], file_name.clone(), @@ -651,7 +643,7 @@ mod test { let project = fixture.project; let graph = fixture.graph; - let handler = NodeFromDroppedFileHandler::new(logger, project, graph); + let handler = NodeFromDroppedFileHandler::new(project, graph); let position = model::module::Position::new(45.0, 70.0); let (file, mut provider_sink) = data.file_to_upload_async(); handler.create_node_and_start_uploading(file, position).unwrap(); diff --git a/app/gui/src/controller/visualization.rs b/app/gui/src/controller/visualization.rs index 667aebb37f6..0cd07236ccd 100644 --- a/app/gui/src/controller/visualization.rs +++ b/app/gui/src/controller/visualization.rs @@ -71,8 +71,7 @@ pub enum VisualizationPath { pub type EmbeddedVisualizationName = String; /// Embedded visualizations mapped from name to source code. -#[derive(Shrinkwrap, Debug, Clone, Default)] -#[shrinkwrap(mutable)] +#[derive(Debug, Clone, Default, Deref, DerefMut)] pub struct EmbeddedVisualizations { #[allow(missing_docs)] pub map: HashMap, @@ -90,7 +89,6 @@ pub struct EmbeddedVisualizations { pub struct Handle { language_server_rpc: Rc, embedded_visualizations: Rc>, - logger: Logger, } impl Handle { @@ -98,11 +96,9 @@ impl Handle { pub fn new( language_server_rpc: Rc, embedded_visualizations: EmbeddedVisualizations, - logger: &Logger, ) -> Self { - let logger = logger.sub("VisualizationController"); let embedded_visualizations = Rc::new(RefCell::new(embedded_visualizations)); - Self { language_server_rpc, embedded_visualizations, logger } + Self { language_server_rpc, embedded_visualizations } } async fn list_project_specific_visualizations(&self) -> FallibleResult> { @@ -163,8 +159,7 @@ impl Handle { let sources: &[(&str, &str)] = &[(file_name, &js_code)]; Sources::from_files(sources) } else { - warning!( - self.logger, + warn!( "Unable to get a file name from {path}. Visualization source map will not be provided." ); Sources::empty() @@ -247,8 +242,7 @@ mod tests { let embedded_visualization = builtin::visualization::native::BubbleChart::definition(); embedded_visualizations .insert("[Demo] Bubble Visualization".to_string(), embedded_visualization.clone()); - let logger = Logger::new("Mock logger"); - let vis_controller = Handle::new(language_server, embedded_visualizations, &logger); + let vis_controller = Handle::new(language_server, embedded_visualizations); let visualizations = vis_controller.list_visualizations().await; let visualizations = visualizations.expect("Couldn't list visualizations."); diff --git a/app/gui/src/ide/initializer.rs b/app/gui/src/ide/initializer.rs index 2206958bc43..3f2c08ee449 100644 --- a/app/gui/src/ide/initializer.rs +++ b/app/gui/src/ide/initializer.rs @@ -46,14 +46,12 @@ pub struct ProjectNotFound { #[derive(Clone, Debug)] pub struct Initializer { config: config::Startup, - logger: Logger, } impl Initializer { /// Create [`Initializer`] with given configuration. pub fn new(config: config::Startup) -> Self { - let logger = Logger::new("ide::Initializer"); - Self { config, logger } + Self { config } } /// Initialize all Ide objects and structures (executor, views, controllers, integration etc.) @@ -140,7 +138,7 @@ impl Initializer { &self, endpoint: &str, ) -> FallibleResult> { - let transport = WebSocket::new_opened(self.logger.clone_ref(), endpoint).await?; + let transport = WebSocket::new_opened(endpoint).await?; let mut project_manager = project_manager::Client::new(transport); project_manager.set_timeout(std::time::Duration::from_secs(PROJECT_MANAGER_TIMEOUT_SEC)); executor::global::spawn(project_manager.runner()); @@ -163,7 +161,6 @@ impl Initializer { #[derive(Clone, Derivative)] #[derivative(Debug)] pub struct WithProjectManager { - pub logger: Logger, #[derivative(Debug = "ignore")] pub project_manager: Rc, pub project_name: ProjectName, @@ -172,8 +169,7 @@ pub struct WithProjectManager { impl WithProjectManager { /// Constructor. pub fn new(project_manager: Rc, project_name: ProjectName) -> Self { - let logger = Logger::new("initializer::WithProjectManager"); - Self { logger, project_manager, project_name } + Self { project_manager, project_name } } /// Create and initialize a new Project Model, for a project with name passed in constructor. @@ -181,9 +177,8 @@ impl WithProjectManager { /// If the project with given name does not exist yet, it will be created. pub async fn initialize_project_model(self) -> FallibleResult { let project_id = self.get_project_or_create_new().await?; - let logger = &self.logger; let project_manager = self.project_manager; - model::project::Synchronized::new_opened(logger, project_manager, project_id).await + model::project::Synchronized::new_opened(project_manager, project_id).await } /// Creates a new project and returns its id, so the newly connected project can be opened. @@ -271,7 +266,6 @@ mod test { #[wasm_bindgen_test(async)] async fn get_project_or_create_new() { - let logger = Logger::new("test"); let mock_client = project_manager::MockClient::default(); let project_name = ProjectName::new_unchecked("TestProject"); let project = project_manager::ProjectMetadata { @@ -288,7 +282,7 @@ mod test { expect_call!(mock_client.list_projects(count) => Ok(project_lists)); let project_manager = Rc::new(mock_client); - let initializer = WithProjectManager { logger, project_manager, project_name }; + let initializer = WithProjectManager { project_manager, project_name }; let project = initializer.get_project_or_create_new().await; assert_eq!(expected_id, project.expect("Couldn't get project.")) } diff --git a/app/gui/src/model/execution_context/synchronized.rs b/app/gui/src/model/execution_context/synchronized.rs index 363f1b3b4bc..86dc0d5b2f0 100644 --- a/app/gui/src/model/execution_context/synchronized.rs +++ b/app/gui/src/model/execution_context/synchronized.rs @@ -48,7 +48,6 @@ pub struct ExecutionContext { id: model::execution_context::Id, model: model::execution_context::Plain, language_server: Rc, - logger: Logger, } impl ExecutionContext { @@ -64,17 +63,15 @@ impl ExecutionContext { /// language server. #[profile(Debug)] pub fn create( - parent: impl AnyLogger, language_server: Rc, root_definition: language_server::MethodPointer, ) -> impl Future> { async move { info!("Creating."); let id = language_server.client.create_execution_context().await?.context_id; - let logger = Logger::new_sub(&parent, iformat! {"ExecutionContext {id}"}); let model = model::execution_context::Plain::new(root_definition); info!("Created. Id: {id}."); - let this = Self { id, model, language_server, logger }; + let this = Self { id, model, language_server }; this.push_root_frame().await?; info!("Pushed root frame."); Ok(this) @@ -99,7 +96,7 @@ impl ExecutionContext { /// Load the component groups defined in libraries imported into the execution context. async fn load_component_groups(&self) { let log_group_parsing_error = |err: &failure::Error| { - let msg = iformat!( + let msg = format!( "Failed to parse a component group returned by the Engine. The group will not \ appear in the Favorites section of the Component Browser. Error: {err}" ); @@ -116,7 +113,7 @@ impl ExecutionContext { info!("Loaded component groups."); } Err(err) => { - let msg = iformat!( + let msg = format!( "Failed to load component groups. No groups will appear in the Favorites \ section of the Component Browser. Error: {err}" ); @@ -137,11 +134,10 @@ impl ExecutionContext { let exe_id = self.id; let ast_id = vis.expression_id; let ls = self.language_server.clone_ref(); - let logger = self.logger.clone_ref(); info!("About to detach visualization by id: {vis_id}."); ls.detach_visualisation(&exe_id, &vis_id, &ast_id).await?; if let Err(err) = self.model.detach_visualization(vis_id) { - warning!(logger, "Failed to update model after detaching visualization: {err:?}.") + warn!("Failed to update model after detaching visualization: {err:?}.") } Ok(vis) } @@ -374,9 +370,8 @@ pub mod test { ls_client.require_all_calls(); let connection = language_server::Connection::new_mock_rc(ls_client); let mut test = TestWithLocalPoolExecutor::set_up(); - let logger = Logger::new("Fixture"); let method = data.main_method_pointer(); - let context = ExecutionContext::create(logger, connection, method); + let context = ExecutionContext::create(connection, method); let context = test.expect_completion(context).unwrap(); Fixture { data, context, test } } diff --git a/app/gui/src/model/module.rs b/app/gui/src/model/module.rs index 03193f41455..bae060bb424 100644 --- a/app/gui/src/model/module.rs +++ b/app/gui/src/model/module.rs @@ -89,7 +89,7 @@ pub type TextChange = enso_text::Change; /// * the first one is a source directory in the project (see `SOURCE_DIRECTORY`); /// * the last one is a source file with the module's contents; /// * all the ones between (if present) are names of the parent modules. -#[derive(Clone, CloneRef, Debug, Eq, Hash, PartialEq, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Eq, Hash, PartialEq, Deref)] pub struct Path { file_path: Rc, } @@ -97,7 +97,7 @@ pub struct Path { impl Path { /// Get the file name of the module with given name. pub fn module_filename(name: &str) -> String { - iformat!("{name}.{LANGUAGE_FILE_EXTENSION}") + format!("{name}.{LANGUAGE_FILE_EXTENSION}") } /// Build module's path in a filesystem under given root ID. diff --git a/app/gui/src/model/module/synchronized.rs b/app/gui/src/model/module/synchronized.rs index b0b776b7f59..129f62ef8ae 100644 --- a/app/gui/src/model/module/synchronized.rs +++ b/app/gui/src/model/module/synchronized.rs @@ -55,9 +55,9 @@ impl ContentSummary { /// The information about module's content. In addition to minimal summery defined in /// `ContentSummary` it adds information about sections, what enables efficient updates after code /// and metadata changes. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] struct ParsedContentSummary { - #[shrinkwrap(main_field)] + #[deref] summary: ContentSummary, source: text::Rope, code: Range>, diff --git a/app/gui/src/model/project/synchronized.rs b/app/gui/src/model/project/synchronized.rs index a739dbc29d2..d7c6423bb26 100644 --- a/app/gui/src/model/project/synchronized.rs +++ b/app/gui/src/model/project/synchronized.rs @@ -118,20 +118,15 @@ struct MissingContentRoot { /// A repository of content roots attached to a specific project. #[derive(Clone, Debug)] pub struct ContentRoots { - logger: Logger, - roots: RefCell>>, + roots: RefCell>>, } impl ContentRoots { /// Create ContentRoots, initializing with the roots retrieved during connection initialization. - pub fn new_from_connection( - parent: impl AnyLogger, - connection: &language_server::Connection, - ) -> Self { - let logger = Logger::new_sub(parent, "ContentRoots"); + pub fn new_from_connection(connection: &language_server::Connection) -> Self { let roots_vec = connection.content_roots().map(|r| (r.id(), Rc::new(r.clone()))).collect(); let roots = RefCell::new(roots_vec); - Self { logger, roots } + Self { roots } } /// Return all content roots. @@ -145,11 +140,7 @@ impl ContentRoots { pub fn add(&self, content_root: ContentRoot) { let content_root = Rc::new(content_root); if let Some(existing) = self.roots.borrow_mut().insert(content_root.id(), content_root) { - warning!( - self.logger, - "Adding content root: there is already content root with given \ - id: {existing:?}" - ); + warn!("Adding content root: there is already content root with given id: {existing:?}"); } } @@ -163,7 +154,7 @@ impl ContentRoots { /// If there is no content root with such id, a warning will be printed. pub fn remove(&self, id: Uuid) { if self.roots.borrow_mut().remove(&id).is_none() { - warning!(self.logger, "Removing content root: no content root with given id: {id}"); + warn!("Removing content root: no content root with given id: {id}"); } } } @@ -276,7 +267,6 @@ pub struct Project { pub suggestion_db: Rc, pub content_roots: Rc, pub parser: Parser, - pub logger: Logger, pub notifications: notification::Publisher, pub urm: Rc, } @@ -285,14 +275,12 @@ impl Project { /// Create a new project model. #[profile(Detail)] pub async fn new( - parent: impl AnyLogger, project_manager: Option>, language_server_rpc: Rc, language_server_bin: Rc, properties: Properties, ) -> FallibleResult { let wrap = UnsupportedEngineVersion::error_wrapper(&properties); - let logger = Logger::new_sub(parent, "Project Controller"); info!("Creating a model of project {}", properties.name); let binary_protocol_events = language_server_bin.event_stream(); let json_rpc_events = language_server_rpc.events(); @@ -301,15 +289,15 @@ impl Project { let module_registry = default(); let execution_contexts = default(); let visualization = - controller::Visualization::new(language_server, embedded_visualizations, &logger); + controller::Visualization::new(language_server, embedded_visualizations); let parser = Parser::new_or_panic(); let language_server = &*language_server_rpc; let suggestion_db = SuggestionDatabase::create_synchronized(language_server); let suggestion_db = Rc::new(suggestion_db.await.map_err(&wrap)?); - let content_roots = ContentRoots::new_from_connection(&logger, language_server); + let content_roots = ContentRoots::new_from_connection(language_server); let content_roots = Rc::new(content_roots); let notifications = notification::Publisher::default(); - let urm = Rc::new(model::undo_redo::Manager::new(&logger)); + let urm = Rc::new(model::undo_redo::Manager::new()); let properties = Rc::new(RefCell::new(properties)); let ret = Project { @@ -323,7 +311,6 @@ impl Project { suggestion_db, content_roots, parser, - logger, notifications, urm, }; @@ -342,7 +329,6 @@ impl Project { /// Initializes the json and binary connection to Language Server, and creates a Project Model #[profile(Detail)] pub async fn new_connected( - parent: impl AnyLogger, project_manager: Option>, language_server_rpc: String, language_server_bin: String, @@ -350,10 +336,10 @@ impl Project { ) -> FallibleResult { let wrap = UnsupportedEngineVersion::error_wrapper(&properties); let client_id = Uuid::new_v4(); - let json_ws = WebSocket::new_opened(&parent, &language_server_rpc).await?; - let binary_ws = WebSocket::new_opened(&parent, &language_server_bin).await?; + let json_ws = WebSocket::new_opened(&language_server_rpc).await?; + let binary_ws = WebSocket::new_opened(&language_server_bin).await?; let client_json = language_server::Client::new(json_ws); - let client_binary = binary::Client::new(&parent, binary_ws); + let client_binary = binary::Client::new(binary_ws); crate::executor::global::spawn(client_json.runner()); crate::executor::global::spawn(client_binary.runner()); let connection_json = @@ -362,14 +348,9 @@ impl Project { binary::Connection::new(client_binary, client_id).await.map_err(&wrap)?; let language_server_rpc = Rc::new(connection_json); let language_server_bin = Rc::new(connection_binary); - let model = Self::new( - parent, - project_manager, - language_server_rpc, - language_server_bin, - properties, - ) - .await?; + let model = + Self::new(project_manager, language_server_rpc, language_server_bin, properties) + .await?; Ok(Rc::new(model)) } @@ -377,7 +358,6 @@ impl Project { /// the received json and binary connections. #[profile(Detail)] pub async fn new_opened( - parent: &Logger, project_manager: Rc, id: Uuid, ) -> FallibleResult { @@ -393,8 +373,7 @@ impl Project { name: project::QualifiedName::new(namespace, name), engine_version: semver::Version::parse(&opened.engine_version)?, }; - Self::new_connected(parent, project_manager, json_endpoint, binary_endpoint, properties) - .await + Self::new_connected(project_manager, json_endpoint, binary_endpoint, properties).await } /// Returns a handling function capable of processing updates from the binary protocol. @@ -672,9 +651,8 @@ impl model::project::API for Project { root_definition: MethodPointer, ) -> BoxFuture> { async move { - let logger = &self.logger; let ls_rpc = self.language_server_rpc.clone_ref(); - let context = execution_context::Synchronized::create(&logger, ls_rpc, root_definition); + let context = execution_context::Synchronized::create(ls_rpc, root_definition); let context = Rc::new(context.await?); self.execution_contexts.insert(context.clone_ref()); let context: model::ExecutionContext = context; @@ -768,20 +746,14 @@ mod test { let json_connection = Rc::new(language_server::Connection::new_mock(json_client)); let binary_connection = Rc::new(binary::Connection::new_mock(binary_client)); let project_manager = Rc::new(project_manager); - let logger = Logger::new("Fixture"); let properties = Properties { id: Uuid::new_v4(), name: crate::test::mock::data::project_qualified_name(), engine_version: semver::Version::new(0, 2, 1), }; - let project_fut = Project::new( - logger, - Some(project_manager), - json_connection, - binary_connection, - properties, - ) - .boxed_local(); + let project_fut = + Project::new(Some(project_manager), json_connection, binary_connection, properties) + .boxed_local(); let project = test.expect_completion(project_fut).unwrap(); Fixture { test, project, binary_events_sender, json_events_sender } } diff --git a/app/gui/src/model/undo_redo.rs b/app/gui/src/model/undo_redo.rs index 51bf6f500f3..887cc1235ae 100644 --- a/app/gui/src/model/undo_redo.rs +++ b/app/gui/src/model/undo_redo.rs @@ -72,17 +72,15 @@ pub trait Aware { #[derive(Debug)] pub struct Transaction { #[allow(missing_docs)] - pub logger: Logger, - frame: RefCell, - urm: Weak, - ignored: Cell, + frame: RefCell, + urm: Weak, + ignored: Cell, } impl Transaction { /// Create a new transaction, that will add to the given's repository undo stack on destruction. pub fn new(urm: &Rc, name: String) -> Self { Self { - logger: Logger::new_sub(&urm.logger, "Transaction"), frame: RefCell::new(Frame { name, ..default() }), urm: Rc::downgrade(urm), ignored: default(), @@ -212,23 +210,15 @@ pub struct Data { /// /// `Repository`, unlike [`Manager`] does not keep any modules (or other model entities) alive and /// can be shared with no consequence on project state. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Repository { - logger: Logger, - data: RefCell, -} - - -impl Default for Repository { - fn default() -> Self { - Self::new(Logger::new("")) - } + data: RefCell, } impl Repository { /// Create a new repository. - pub fn new(parent: impl AnyLogger) -> Self { - Self { logger: Logger::new_sub(parent, "Repository"), data: default() } + pub fn new() -> Self { + default() } /// Get the currently open transaction. [`None`] if there is none. @@ -351,10 +341,9 @@ impl Repository { /// Undo-Redo manager. Allows undoing or redoing recent actions. /// /// Owns [`Repository`] and keeps track of open modules. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Manager { #[allow(missing_docs)] - pub logger: Logger, /// Repository with undo and redo stacks. pub repository: Rc, /// Currently available modules. @@ -369,9 +358,8 @@ impl Aware for Manager { impl Manager { /// Create a new undo-redo manager. - pub fn new(parent: impl AnyLogger) -> Self { - let logger = Logger::new_sub(parent, "URM"); - Self { repository: Rc::new(Repository::new(&logger)), modules: default(), logger } + pub fn new() -> Self { + default() } /// Register a new opened module in the manager. diff --git a/app/gui/src/presenter/graph.rs b/app/gui/src/presenter/graph.rs index b58bd4f8675..88f08f586ba 100644 --- a/app/gui/src/presenter/graph.rs +++ b/app/gui/src/presenter/graph.rs @@ -76,7 +76,6 @@ pub fn default_node_position() -> Vector2 { #[derive(Debug)] struct Model { - logger: Logger, project: model::Project, controller: controller::ExecutedGraph, view: view::graph_editor::GraphEditor, @@ -91,7 +90,6 @@ impl Model { controller: controller::ExecutedGraph, view: view::graph_editor::GraphEditor, ) -> Self { - let logger = Logger::new("presenter::Graph"); let state: Rc = default(); let visualization = Visualization::new( project.clone_ref(), @@ -102,7 +100,6 @@ impl Model { let execution_stack = CallStack::new(controller.clone_ref(), view.clone_ref(), state.clone_ref()); Self { - logger, project, controller, view, @@ -335,7 +332,7 @@ impl Model { data: file, }; let position = model::module::Position { vector: position }; - let handler = NodeFromDroppedFileHandler::new(&self.logger, project, graph); + let handler = NodeFromDroppedFileHandler::new(project, graph); if let Err(err) = handler.create_node_and_start_uploading(to_upload, position) { error!("Error when creating node from dropped file: {err}"); } @@ -369,17 +366,14 @@ impl Model { .graph() .set_node_position(node.id(), next_default_position) { - warning!( - self.logger, - "Failed to initialize position of node {node.id()}: {err}" - ); + warn!("Failed to initialize position of node {}: {err}", node.id()); } next_default_position.y -= offset; } } } Err(err) => { - warning!(self.logger, "Failed to initialize nodes positions: {err}"); + warn!("Failed to initialize nodes positions: {err}"); } } } diff --git a/app/gui/src/presenter/graph/visualization.rs b/app/gui/src/presenter/graph/visualization.rs index ca45b7f3d3c..c8983000067 100644 --- a/app/gui/src/presenter/graph/visualization.rs +++ b/app/gui/src/presenter/graph/visualization.rs @@ -30,7 +30,6 @@ pub mod manager; #[derive(Clone, CloneRef, Debug)] struct Model { - logger: Logger, controller: controller::Visualization, graph_view: view::graph_editor::GraphEditor, manager: Rc, @@ -173,14 +172,12 @@ impl Visualization { view: view::graph_editor::GraphEditor, state: Rc, ) -> Self { - let logger = Logger::new("presenter::graph::Visualization"); let network = frp::Network::new("presenter::graph::Visualization"); let controller = project.visualization().clone_ref(); let (manager, notifications) = Manager::new(graph.clone_ref()); let (error_manager, error_notifications) = Manager::new(graph.clone_ref()); let model = Rc::new(Model { - logger, controller, graph_view: view.clone_ref(), manager: manager.clone_ref(), diff --git a/app/gui/src/presenter/graph/visualization/manager.rs b/app/gui/src/presenter/graph/visualization/manager.rs index edb4c6812f9..e57a9e841b4 100644 --- a/app/gui/src/presenter/graph/visualization/manager.rs +++ b/app/gui/src/presenter/graph/visualization/manager.rs @@ -500,10 +500,10 @@ mod tests { use std::assert_matches::assert_matches; use wasm_bindgen_test::wasm_bindgen_test; - #[derive(Shrinkwrap)] - #[shrinkwrap(mutable)] + #[derive(Deref, DerefMut)] struct Fixture { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] inner: crate::test::mock::Fixture, node_id: ast::Id, } @@ -537,10 +537,10 @@ mod tests { Modify { id: VisualizationId, method_pointer: Option }, } - #[derive(Shrinkwrap)] - #[shrinkwrap(mutable)] + #[derive(Deref, DerefMut)] struct VisOperationsTester { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] pub inner: Fixture, pub is_ready: Synchronized, pub manager: Rc, diff --git a/app/gui/src/presenter/project.rs b/app/gui/src/presenter/project.rs index afdb3b3063f..5a5ff7ee972 100644 --- a/app/gui/src/presenter/project.rs +++ b/app/gui/src/presenter/project.rs @@ -24,7 +24,6 @@ use model::project::VcsStatus; #[allow(unused)] #[derive(Debug)] struct Model { - logger: Logger, controller: controller::Project, module_model: model::Module, graph_controller: controller::ExecutedGraph, @@ -45,7 +44,6 @@ impl Model { view: view::project::View, status_bar: view::status_bar::View, ) -> Self { - let logger = Logger::new("presenter::Project"); let graph_controller = init_result.main_graph; let text_controller = init_result.main_module_text; let module_model = init_result.main_module_model; @@ -57,7 +55,6 @@ impl Model { let code = presenter::Code::new(text_controller, &view); let searcher = default(); Model { - logger, controller, module_model, graph_controller, @@ -72,7 +69,6 @@ impl Model { fn setup_searcher_presenter(&self, params: SearcherParams) { let new_presenter = presenter::Searcher::setup_controller( - &self.logger, self.ide_controller.clone_ref(), self.controller.clone_ref(), self.graph_controller.clone_ref(), diff --git a/app/gui/src/presenter/searcher.rs b/app/gui/src/presenter/searcher.rs index 36ab7d0311e..511e7abaa3e 100644 --- a/app/gui/src/presenter/searcher.rs +++ b/app/gui/src/presenter/searcher.rs @@ -80,7 +80,6 @@ fn doc_placeholder_for(suggestion: &model::suggestion_database::Entry) -> String #[derive(Clone, CloneRef, Debug)] struct Model { - logger: Logger, controller: controller::Searcher, view: view::project::View, provider: Rc>>, @@ -90,14 +89,12 @@ struct Model { impl Model { #[profile(Debug)] fn new( - parent: impl AnyLogger, controller: controller::Searcher, view: view::project::View, input_view: ViewNodeId, ) -> Self { - let logger = parent.sub("presenter::Searcher"); let provider = default(); - Self { logger, controller, view, provider, input_view } + Self { controller, view, provider, input_view } } #[profile(Debug)] @@ -335,12 +332,11 @@ impl Searcher { /// Constructor. The returned structure works right away. #[profile(Task)] pub fn new( - parent: impl AnyLogger, controller: controller::Searcher, view: view::project::View, input_view: ViewNodeId, ) -> Self { - let model = Rc::new(Model::new(parent, controller, view, input_view)); + let model = Rc::new(Model::new(controller, view, input_view)); let network = frp::Network::new("presenter::Searcher"); let graph = &model.view.graph().frp; @@ -500,7 +496,6 @@ impl Searcher { /// presenter handling it. #[profile(Task)] pub fn setup_controller( - parent: impl AnyLogger, ide_controller: controller::Ide, project_controller: controller::Project, graph_controller: controller::ExecutedGraph, @@ -516,7 +511,6 @@ impl Searcher { )?; let searcher_controller = controller::Searcher::new_from_graph_controller( - &parent, ide_controller, &project_controller.model, graph_controller, @@ -534,7 +528,7 @@ impl Searcher { } let input = parameters.input; - Ok(Self::new(parent, searcher_controller, view, input)) + Ok(Self::new(searcher_controller, view, input)) } /// Commit editing in the old Node Searcher. diff --git a/app/gui/src/test.rs b/app/gui/src/test.rs index feb1ee834ca..6f3a9f728d4 100644 --- a/app/gui/src/test.rs +++ b/app/gui/src/test.rs @@ -130,7 +130,6 @@ pub mod mock { /// calling [set_code] or [set_inline_code]. #[derive(Clone, Debug)] pub struct Unified { - pub logger: Logger, pub project_name: project::QualifiedName, pub module_path: model::module::Path, pub suggestions: HashMap, @@ -163,7 +162,6 @@ pub mod mock { let mut suggestions = HashMap::new(); suggestions.insert(1, suggestion_entry_foo()); suggestions.insert(2, suggestion_entry_bar()); - let logger = Logger::new("UnifiedMock"); Unified { suggestions, project_name: project_qualified_name(), @@ -174,12 +172,11 @@ pub mod mock { context_id: CONTEXT_ID, root_definition: definition_name(), parser: parser_scala::Parser::new_or_panic(), - logger, } } pub fn undo_redo_manager(&self) -> Rc { - Rc::new(model::undo_redo::Manager::new(&self.logger)) + Rc::new(model::undo_redo::Manager::new()) } pub fn module(&self, urm: Rc) -> crate::model::Module { @@ -211,7 +208,6 @@ pub mod mock { /// Create a graph controller from the current mock data. pub fn graph( &self, - logger: impl AnyLogger, module: model::Module, db: Rc, ) -> crate::controller::Graph { @@ -219,7 +215,7 @@ pub mod mock { let method = self.method_pointer(); let definition = module.lookup_method(self.project_name.clone(), &method).expect("Lookup failed."); - crate::controller::Graph::new(logger, module, db, parser, definition) + crate::controller::Graph::new(module, db, parser, definition) .expect("Graph could not be created") } @@ -271,12 +267,11 @@ pub mod mock { controller::searcher::test::expect_completion(&mut json_client, &[]); customize_rpc(self, &mut json_client, &mut binary_client); - let logger = self.logger.clone_ref(); let urm = self.undo_redo_manager(); let module = self.module(urm.clone()); let suggestion_db = Rc::new(model::SuggestionDatabase::new_from_entries(&self.suggestions)); - let graph = self.graph(&logger, module.clone_ref(), suggestion_db.clone_ref()); + let graph = self.graph(module.clone_ref(), suggestion_db.clone_ref()); let execution = self.execution_context(); let project = self.project( urm, @@ -297,7 +292,6 @@ pub mod mock { let searcher_target = executed_graph.graph().nodes().unwrap().last().unwrap().id(); let searcher_mode = controller::searcher::Mode::EditNode { node_id: searcher_target }; let searcher = controller::Searcher::new_from_graph_controller( - &logger, ide.clone_ref(), &project, executed_graph.clone_ref(), @@ -306,7 +300,6 @@ pub mod mock { .unwrap(); executor.run_until_stalled(); Fixture { - logger, executor, data, module, @@ -355,10 +348,8 @@ pub mod mock { } } - #[derive(Debug, Shrinkwrap)] - #[shrinkwrap(mutable)] + #[derive(Debug, Deref, DerefMut)] pub struct Fixture { - pub logger: Logger, pub data: Unified, pub module: model::Module, pub graph: controller::Graph, @@ -368,7 +359,8 @@ pub mod mock { pub project: model::Project, pub ide: controller::Ide, pub searcher: controller::Searcher, - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] pub executor: TestWithLocalPoolExecutor, // Last to drop the executor as last. } @@ -408,7 +400,6 @@ pub mod mock { language_server: self.project.json_rpc(), model: model.clone(), parser: self.data.parser.clone(), - logger: Logger::new_sub(&self.data.logger, "MockModuleController"), }; (model, controller) } @@ -419,7 +410,7 @@ pub mod mock { } pub fn indent(line: impl AsRef) -> String { - iformat!(" {line.as_ref()}") + format!(" {}", line.as_ref()) } pub fn main_from_lines(lines: impl IntoIterator>) -> String { @@ -431,7 +422,7 @@ pub mod mock { lines: impl IntoIterator>, ) -> String { let body = lines.into_iter().map(indent).join("\n"); - iformat!("{name} =\n{body}") + format!("{name} =\n{body}") } } @@ -532,7 +523,7 @@ impl Runner { /// Calls the `test` function once. The executor behavior is defined by the `n` parameter. /// Returns the number of calls made to `perhaps_run_until_stalled`. pub fn run_nth(n: u32, test: impl FnMut(&mut Runner)) -> u32 { - DEBUG!("Runner: Iteration " n); + debug!("Runner: Iteration {}", n); Self::run_with(BitField32 { raw: n }, test) } } diff --git a/app/gui/src/transport/web.rs b/app/gui/src/transport/web.rs index 0ee6bc72ad7..18f88e31a08 100644 --- a/app/gui/src/transport/web.rs +++ b/app/gui/src/transport/web.rs @@ -165,7 +165,6 @@ struct Model { pub on_error: Slot, // === Internal === - pub logger: Logger, pub socket: web_sys::WebSocket, /// Special callback on "close" event. As it must be invoked after `on_close`, care should be /// taken to keep it registered as an event listener *after* `on_close` registration. @@ -177,7 +176,7 @@ struct Model { impl Model { /// Wraps given WebSocket object. - pub fn new(socket: web_sys::WebSocket, logger: Logger) -> Model { + pub fn new(socket: web_sys::WebSocket) -> Model { socket.set_binary_type(BinaryType::Arraybuffer); Model { on_close: Slot::new(&socket), @@ -186,7 +185,6 @@ impl Model { on_error: Slot::new(&socket), on_close_internal: Slot::new(&socket), auto_reconnect: true, - logger, socket, } } @@ -215,7 +213,6 @@ impl Model { on_close_internal, // Explicitly ignored non-slot fields. auto_reconnect: _, - logger: _, socket: _, } = self; // We don't care if removing actually removed anything. @@ -269,26 +266,21 @@ impl Drop for Model { #[derive(Clone, CloneRef, Debug)] pub struct WebSocket { #[allow(missing_docs)] - pub logger: Logger, - model: Rc>, + model: Rc>, } impl WebSocket { /// Wrap given raw JS WebSocket object. - pub fn new(ws: web_sys::WebSocket, parent: impl AnyLogger) -> WebSocket { - let logger = Logger::new_sub(parent, ws.url()); - let model = Rc::new(RefCell::new(Model::new(ws, logger.clone()))); - WebSocket { logger, model } + pub fn new(ws: web_sys::WebSocket) -> WebSocket { + let model = Rc::new(RefCell::new(Model::new(ws))); + WebSocket { model } } /// Establish connection with endpoint defined by the given URL and wrap it. /// Asynchronous, because it waits until connection is established. - pub async fn new_opened( - parent: impl AnyLogger, - url: &str, - ) -> Result { + pub async fn new_opened(url: &str) -> Result { let ws = web_sys::WebSocket::new(url).map_err(ConnectingError::construction_error)?; - let mut wst = WebSocket::new(ws, &parent); + let mut wst = WebSocket::new(ws); wst.wait_until_open().await?; Ok(wst) } @@ -461,11 +453,10 @@ mod tests { #[allow(dead_code)] async fn websocket_tests() { executor::web::test::setup_and_forget(); - let logger = DefaultTraceLogger::new("Test"); info!("Started"); // Create WebSocket - let ws = WebSocket::new_opened(&logger, "ws://localhost:30445").await; + let ws = WebSocket::new_opened("ws://localhost:30445").await; let mut ws = ws.expect("Couldn't connect to WebSocket server."); info!("WebSocket opened: {ws:?}"); diff --git a/app/gui/suggestion-database/Cargo.toml b/app/gui/suggestion-database/Cargo.toml index ef3d502e14f..9304da6dada 100644 --- a/app/gui/suggestion-database/Cargo.toml +++ b/app/gui/suggestion-database/Cargo.toml @@ -9,19 +9,19 @@ crate-type = ["cdylib", "rlib"] [dependencies] enso-prelude = { path = "../../../lib/rust/prelude" } -convert_case = { version = "0.5.0" } +convert_case = { workspace = true } span-tree = { path = "../language/span-tree" } ast = { path = "../language/ast/impl" } parser-scala = { path = "../language/parser" } enso-text = { path = "../../../lib/rust/text" } -double-representation = { version = "0.1.0", path = "../controller/double-representation" } +double-representation = { path = "../controller/double-representation" } engine-protocol = { path = "../controller/engine-protocol" } enso-data-structures = { path = "../../../lib/rust/data-structures" } flo_stream = { version = "0.4.0" } -failure = { version = "0.1.6" } +failure = { workspace = true } enso-notification = { path = "../../../lib/rust/notification" } [dev-dependencies] -futures = { version = "0.3.1" } +futures = { workspace = true } enso-executor = { path = "../../../lib/rust/executor" } wasm-bindgen-test = { workspace = true } diff --git a/app/gui/tests/language_server.rs b/app/gui/tests/language_server.rs index 5618ff00c27..67c5d9ce5ec 100644 --- a/app/gui/tests/language_server.rs +++ b/app/gui/tests/language_server.rs @@ -254,8 +254,7 @@ async fn ls_text_protocol_test() { // #[wasm_bindgen_test::wasm_bindgen_test(async)] #[allow(dead_code)] async fn file_events() { - let logger = Logger::new("test"); - let ws = WebSocket::new_opened(logger, SERVER_ENDPOINT).await; + let ws = WebSocket::new_opened(SERVER_ENDPOINT).await; let ws = ws.expect("Couldn't connect to WebSocket server."); let client = Client::new(ws); let mut stream = client.events(); @@ -352,13 +351,12 @@ async fn binary_visualization_updates_test_hlp() { use controller::project::MAIN_DEFINITION_NAME; use ensogl::system::web::sleep; - let logger = Logger::new("Test"); let module_path = enso_gui::initial_module_path(&project); let method = module_path.method_pointer(project.qualified_name(), MAIN_DEFINITION_NAME); let module_qualified_name = project.qualified_module_name(&module_path); let module = project.module(module_path).await.unwrap(); info!("Got module: {module:?}"); - let graph_executed = controller::ExecutedGraph::new(&logger, project, method).await.unwrap(); + let graph_executed = controller::ExecutedGraph::new(project, method).await.unwrap(); let the_node = graph_executed.graph().nodes().unwrap()[0].info.clone(); graph_executed.graph().set_expression(the_node.id(), "10+20").unwrap(); diff --git a/app/gui/tests/project_manager.rs b/app/gui/tests/project_manager.rs index 4c7e7a21105..5069f784b18 100644 --- a/app/gui/tests/project_manager.rs +++ b/app/gui/tests/project_manager.rs @@ -24,8 +24,7 @@ mod tests { //#[wasm_bindgen_test::wasm_bindgen_test(async)] #[allow(dead_code)] async fn project_life_cycle() { - let logger = Logger::new("test"); - let ws = WebSocket::new_opened(logger, "ws://localhost:30535").await; + let ws = WebSocket::new_opened("ws://localhost:30535").await; let ws = ws.expect("Couldn't connect to WebSocket server."); let client = Client::new(ws); let _executor = enso_executor::setup_global_executor(); diff --git a/app/gui/view/Cargo.toml b/app/gui/view/Cargo.toml index 8218e0c4e1b..37e5107a108 100644 --- a/app/gui/view/Cargo.toml +++ b/app/gui/view/Cargo.toml @@ -11,7 +11,6 @@ crate-type = ["cdylib", "rlib"] ast = { path = "../language/ast/impl" } enso-config = { path = "../config" } enso-frp = { path = "../../../lib/rust/frp" } -enso-logger = { path = "../../../lib/rust/logger" } enso-prelude = { path = "../../../lib/rust/prelude" } enso-shapely = { path = "../../../lib/rust/shapely" } engine-protocol = { path = "../controller/engine-protocol" } @@ -26,11 +25,11 @@ ide-view-documentation = { path = "documentation" } ide-view-graph-editor = { path = "graph-editor" } parser-scala = { path = "../language/parser" } span-tree = { path = "../language/span-tree" } -js-sys = { version = "0.3.28" } -multi-map = { version = "1.3.0" } -nalgebra = { version = "0.26.1", features = ["serde-serialize"] } -ordered-float = { version = "3.0.0" } -serde_json = { version = "1.0" } +js-sys = { workspace = true } +multi-map = { workspace = true } +nalgebra = { workspace = true } +ordered-float = { workspace = true } +serde_json = { workspace = true } serde = { version = "1.0", features = ["derive"] } uuid = { version = "0.8", features = ["serde", "v4", "wasm-bindgen"] } wasm-bindgen = { workspace = true } diff --git a/app/gui/view/component-browser/component-list-panel/Cargo.toml b/app/gui/view/component-browser/component-list-panel/Cargo.toml index 7da760497d9..0228dd664e4 100644 --- a/app/gui/view/component-browser/component-list-panel/Cargo.toml +++ b/app/gui/view/component-browser/component-list-panel/Cargo.toml @@ -22,7 +22,7 @@ ensogl-tooltip = { path = "../../../../../lib/rust/ensogl/component/tooltip/" } ide-view-component-list-panel-breadcrumbs = { path = "breadcrumbs" } ide-view-component-list-panel-grid = { path = "grid" } ide-view-component-list-panel-icons = { path = "icons" } -ordered-float = "3.0.0" +ordered-float = { workspace = true } [dev-dependencies] approx = "0.5.1" diff --git a/app/gui/view/component-browser/component-list-panel/grid/Cargo.toml b/app/gui/view/component-browser/component-list-panel/grid/Cargo.toml index f13d2b39c76..4bcc519b045 100644 --- a/app/gui/view/component-browser/component-list-panel/grid/Cargo.toml +++ b/app/gui/view/component-browser/component-list-panel/grid/Cargo.toml @@ -12,7 +12,7 @@ ensogl-hardcoded-theme = { path = "../../../../../../lib/rust/ensogl/app/theme/h ensogl-text = { path = "../../../../../../lib/rust/ensogl/component/text" } ensogl-grid-view = { path = "../../../../../../lib/rust/ensogl/component/grid-view" } ensogl-gui-component = { path = "../../../../../../lib/rust/ensogl/component/gui" } -ensogl-shadow = { version = "0.1.0", path = "../../../../../../lib/rust/ensogl/component/shadow" } +ensogl-shadow = { path = "../../../../../../lib/rust/ensogl/component/shadow" } ide-view-component-list-panel-icons = { path = "../icons" } -failure = "0.1.8" +failure = { workspace = true } num_enum = "0.5.1" diff --git a/app/gui/view/component-browser/component-list-panel/icons/Cargo.toml b/app/gui/view/component-browser/component-list-panel/icons/Cargo.toml index e0a4661af45..05d9df07bcf 100644 --- a/app/gui/view/component-browser/component-list-panel/icons/Cargo.toml +++ b/app/gui/view/component-browser/component-list-panel/icons/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" [dependencies] ensogl-core = { path = "../../../../../../lib/rust/ensogl/core" } -failure = "0.1.8" +failure = { workspace = true } diff --git a/app/gui/view/debug_scene/component-list-panel-view/Cargo.toml b/app/gui/view/debug_scene/component-list-panel-view/Cargo.toml index f0711a70cc6..26ebd6efa21 100644 --- a/app/gui/view/debug_scene/component-list-panel-view/Cargo.toml +++ b/app/gui/view/debug_scene/component-list-panel-view/Cargo.toml @@ -17,7 +17,7 @@ ensogl-text = { path = "../../../../../lib/rust/ensogl/component/text" } ensogl-text-msdf = { path = "../../../../../lib/rust/ensogl/component/text/src/font/msdf" } ide-view-component-list-panel = { path = "../../component-browser/component-list-panel" } wasm-bindgen = { workspace = true } -js-sys = { version = "0.3" } +js-sys = { workspace = true } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. [package.metadata.wasm-pack.profile.release] diff --git a/app/gui/view/debug_scene/text-grid-visualization/Cargo.toml b/app/gui/view/debug_scene/text-grid-visualization/Cargo.toml index 5bd6bb1783f..c1bf13ca7e1 100644 --- a/app/gui/view/debug_scene/text-grid-visualization/Cargo.toml +++ b/app/gui/view/debug_scene/text-grid-visualization/Cargo.toml @@ -13,9 +13,9 @@ ensogl = { path = "../../../../../lib/rust/ensogl" } ensogl-hardcoded-theme = { path = "../../../../../lib/rust/ensogl/app/theme/hardcoded" } ensogl-text-msdf = { path = "../../../../../lib/rust/ensogl/component/text/src/font/msdf" } ide-view = { path = "../.." } -js-sys = { version = "0.3.28" } -nalgebra = { version = "0.26.1" } -serde_json = { version = "1.0" } +js-sys = { workspace = true } +nalgebra = { workspace = true } +serde_json = { workspace = true } wasm-bindgen = { workspace = true } ensogl-list-view = { path = "../../../../../lib/rust/ensogl/component/list-view" } ensogl-grid-view = { path = "../../../../../lib/rust/ensogl/component/grid-view" } diff --git a/app/gui/view/debug_scene/visualization/Cargo.toml b/app/gui/view/debug_scene/visualization/Cargo.toml index deaaff5c6e0..672e4e5201e 100644 --- a/app/gui/view/debug_scene/visualization/Cargo.toml +++ b/app/gui/view/debug_scene/visualization/Cargo.toml @@ -13,9 +13,9 @@ ensogl = { path = "../../../../../lib/rust/ensogl" } ensogl-hardcoded-theme = { path = "../../../../../lib/rust/ensogl/app/theme/hardcoded" } ensogl-text-msdf = { path = "../../../../../lib/rust/ensogl/component/text/src/font/msdf" } ide-view = { path = "../.." } -js-sys = { version = "0.3.28" } -nalgebra = { version = "0.26.1" } -serde_json = { version = "1.0" } +js-sys = { workspace = true } +nalgebra = { workspace = true } +serde_json = { workspace = true } wasm-bindgen = { workspace = true } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. diff --git a/app/gui/view/documentation/Cargo.toml b/app/gui/view/documentation/Cargo.toml index d428fd714cc..bd3e5d35c1c 100644 --- a/app/gui/view/documentation/Cargo.toml +++ b/app/gui/view/documentation/Cargo.toml @@ -9,7 +9,6 @@ crate-type = ["cdylib", "rlib"] [dependencies] enso-frp = { path = "../../../../lib/rust/frp" } -enso-logger = { path = "../../../../lib/rust/logger" } enso-prelude = { path = "../../../../lib/rust/prelude" } ensogl = { path = "../../../../lib/rust/ensogl" } ensogl-component = { path = "../../../../lib/rust/ensogl/component" } @@ -17,7 +16,7 @@ ensogl-hardcoded-theme = { path = "../../../../lib/rust/ensogl/app/theme/hardcod ensogl-derive-theme = { path = "../../../../lib/rust/ensogl/app/theme/derive" } ide-view-graph-editor = { path = "../graph-editor" } wasm-bindgen = { workspace = true } -serde_json = { version = "1.0" } +serde_json = { workspace = true } horrorshow = "0.8.4" enso-suggestion-database = { path = "../../suggestion-database" } double-representation = { path = "../../controller/double-representation" } diff --git a/app/gui/view/documentation/src/lib.rs b/app/gui/view/documentation/src/lib.rs index 7beb407b012..e73242c6057 100644 --- a/app/gui/view/documentation/src/lib.rs +++ b/app/gui/view/documentation/src/lib.rs @@ -115,7 +115,6 @@ type CodeCopyClosure = Closure; #[derive(Clone, CloneRef, Debug)] #[allow(missing_docs)] pub struct Model { - logger: Logger, outer_dom: DomSymbol, caption_dom: DomSymbol, inner_dom: DomSymbol, @@ -130,7 +129,6 @@ pub struct Model { impl Model { /// Constructor. fn new(scene: &Scene) -> Self { - let logger = Logger::new("DocumentationView"); let display_object = display::object::Instance::new(); let outer_div = web::document.create_div_or_panic(); let outer_dom = DomSymbol::new(&outer_div); @@ -167,16 +165,8 @@ impl Model { scene.dom.layers.node_searcher.manage(&caption_dom); let code_copy_closures = default(); - Model { - logger, - outer_dom, - inner_dom, - caption_dom, - overlay, - display_object, - code_copy_closures, - } - .init() + Model { outer_dom, inner_dom, caption_dom, overlay, display_object, code_copy_closures } + .init() } fn init(self) -> Self { @@ -277,10 +267,10 @@ ensogl::define_endpoints! { /// however we're unable to summarize methods and atoms of types. /// /// The default format is the docstring. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] #[allow(missing_docs)] pub struct View { - #[shrinkwrap(main_field)] + #[deref] pub model: Model, pub visualization_frp: visualization::instance::Frp, pub frp: Frp, diff --git a/app/gui/view/graph-editor/Cargo.toml b/app/gui/view/graph-editor/Cargo.toml index 0b143a74cee..4cd1c9324ae 100644 --- a/app/gui/view/graph-editor/Cargo.toml +++ b/app/gui/view/graph-editor/Cargo.toml @@ -8,28 +8,27 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -analytics = { version = "0.1.0", path = "../../analytics" } -ast = { version = "0.1.0", path = "../../language/ast/impl" } +analytics = { path = "../../analytics" } +ast = { path = "../../language/ast/impl" } base64 = "0.13" bimap = { version = "0.4.0" } -enso-config = { version = "0.1.0", path = "../../config" } -enso-frp = { version = "0.1.0", path = "../../../../lib/rust/frp" } -enso-logger = { path = "../../../../lib/rust/logger" } +enso-config = { path = "../../config" } +enso-frp = { path = "../../../../lib/rust/frp" } enso-prelude = { path = "../../../../lib/rust/prelude" } -engine-protocol = { version = "0.1.0", path = "../../controller/engine-protocol" } +engine-protocol = { path = "../../controller/engine-protocol" } enso-shapely = { path = "../../../../lib/rust/shapely" } -enso-text = { version = "0.1.0", path = "../../../../lib/rust/text" } -ensogl = { version = "0.1.0", path = "../../../../lib/rust/ensogl" } +enso-text = { path = "../../../../lib/rust/text" } +ensogl = { path = "../../../../lib/rust/ensogl" } ensogl-component = { path = "../../../../lib/rust/ensogl/component" } -ensogl-text-msdf = { version = "0.1.0", path = "../../../../lib/rust/ensogl/component/text/src/font/msdf" } -ensogl-hardcoded-theme = { version = "0.1.0", path = "../../../../lib/rust/ensogl/app/theme/hardcoded" } -ensogl-drop-manager = { version = "0.1.0", path = "../../../../lib/rust/ensogl/component/drop-manager" } -failure = { version = "0.1.8" } -ordered-float = { version = "3.0.0" } -span-tree = { version = "0.1.0", path = "../../language/span-tree" } -js-sys = { version = "0.3.28" } -nalgebra = { version = "0.26.1", features = ["serde-serialize"] } -serde_json = { version = "1.0" } +ensogl-text-msdf = { path = "../../../../lib/rust/ensogl/component/text/src/font/msdf" } +ensogl-hardcoded-theme = { path = "../../../../lib/rust/ensogl/app/theme/hardcoded" } +ensogl-drop-manager = { path = "../../../../lib/rust/ensogl/component/drop-manager" } +failure = { workspace = true } +ordered-float = { workspace = true } +span-tree = { path = "../../language/span-tree" } +js-sys = { workspace = true } +nalgebra = { workspace = true } +serde_json = { workspace = true } serde = { version = "1.0", features = ["derive"] } sourcemap = "6.0" uuid = { version = "0.8", features = ["serde", "v4", "wasm-bindgen"] } diff --git a/app/gui/view/graph-editor/src/builtin/visualization/native/bubble_chart.rs b/app/gui/view/graph-editor/src/builtin/visualization/native/bubble_chart.rs index d667b9d1d95..762ff7113c6 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/native/bubble_chart.rs +++ b/app/gui/view/graph-editor/src/builtin/visualization/native/bubble_chart.rs @@ -46,7 +46,6 @@ pub struct BubbleChartModel { pub scene: Scene, signature: Signature, views: Rc>>, - logger: Logger, size: Rc>, } @@ -90,10 +89,10 @@ impl BubbleChartModel { // =================== /// Sample implementation of a Bubble Chart. -#[derive(Debug, Shrinkwrap)] +#[derive(Debug, Deref)] #[allow(missing_docs)] pub struct BubbleChart { - #[shrinkwrap(main_field)] + #[deref] model: BubbleChartModel, network: frp::Network, frp: visualization::instance::Frp, @@ -107,7 +106,6 @@ impl BubbleChart { pub fn new(app: &Application) -> Self { let scene = &app.display.default_scene; - let logger = Logger::new("bubble"); let display_object = display::object::Instance::new(); let views = Rc::new(RefCell::new(vec![])); let network = frp::Network::new("bubble_chart"); @@ -115,7 +113,7 @@ impl BubbleChart { let size = default(); let scene = scene.clone_ref(); let signature = Self::signature(); - let model = BubbleChartModel { display_object, scene, signature, views, logger, size }; + let model = BubbleChartModel { display_object, scene, signature, views, size }; BubbleChart { model, network, frp }.init() } diff --git a/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs b/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs index a7b3ab25ecf..94c0be8f947 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs +++ b/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs @@ -155,7 +155,6 @@ impl Error { #[derive(Clone, CloneRef, Debug)] #[allow(missing_docs)] pub struct Model { - logger: Logger, dom: DomSymbol, size: Rc>, // FIXME : StyleWatch is unsuitable here, as it was designed as an internal tool for shape @@ -172,7 +171,6 @@ pub struct Model { impl Model { /// Constructor. fn new(scene: Scene) -> Self { - let logger = Logger::new("RawText"); let div = web::document.create_div_or_panic(); let dom = DomSymbol::new(&div); let size = Rc::new(Cell::new(Vector2(200.0, 200.0))); @@ -193,7 +191,7 @@ impl Model { dom.dom().set_style_or_warn("pointer-events", "auto"); scene.dom.layers.back.manage(&dom); - Model { logger, dom, size, styles, displayed, messages, scene }.init() + Model { dom, size, styles, displayed, messages, scene }.init() } fn init(self) -> Self { diff --git a/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization.rs b/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization.rs index 4557a442fb1..b75c0bbb22b 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization.rs +++ b/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization.rs @@ -43,8 +43,6 @@ use ensogl_component::scrollbar; use ensogl_component::scrollbar::Scrollbar; use ensogl_hardcoded_theme as theme; -pub use entry::Entry; - // ================= @@ -205,10 +203,10 @@ impl Model { // ================ /// Sample visualization that renders the given data as text. Useful for debugging and testing. -#[derive(Debug, Shrinkwrap)] +#[derive(Debug, Deref)] #[allow(missing_docs)] pub struct TextGrid { - #[shrinkwrap(main_field)] + #[deref] model: Rc>, pub frp: visualization::instance::Frp, network: frp::Network, diff --git a/app/gui/view/graph-editor/src/component/breadcrumbs.rs b/app/gui/view/graph-editor/src/component/breadcrumbs.rs index 7e7b0610c3d..146c14d918e 100644 --- a/app/gui/view/graph-editor/src/component/breadcrumbs.rs +++ b/app/gui/view/graph-editor/src/component/breadcrumbs.rs @@ -168,7 +168,6 @@ ensogl::define_endpoints! { /// Breadcrumbs panel model. #[derive(Debug, Clone, CloneRef)] pub struct BreadcrumbsModel { - logger: Logger, /// The breadcrumbs panel display object. display_object: display::object::Instance, background: background::View, @@ -195,7 +194,6 @@ impl BreadcrumbsModel { pub fn new(app: Application, frp: &Frp) -> Self { let scene = &app.display.default_scene; let project_name = app.new_view(); - let logger = Logger::new("Breadcrumbs"); let display_object = display::object::Instance::new(); let root = display::object::Instance::new(); let breadcrumbs_container = display::object::Instance::new(); @@ -210,7 +208,6 @@ impl BreadcrumbsModel { scene.layers.panel.add(&background); Self { - logger, display_object, background, project_name, diff --git a/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs b/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs index 3dc71fb5bf3..1726eb3aa37 100644 --- a/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs +++ b/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs @@ -457,10 +457,10 @@ impl display::Object for BreadcrumbModel { // ================== /// The breadcrumb's view which displays its name and exposes mouse press interactions. -#[derive(Debug, Clone, CloneRef, Shrinkwrap)] +#[derive(Debug, Clone, CloneRef, Deref)] #[allow(missing_docs)] pub struct Breadcrumb { - #[shrinkwrap(main_field)] + #[deref] model: Rc, pub frp: Frp, } diff --git a/app/gui/view/graph-editor/src/component/edge.rs b/app/gui/view/graph-editor/src/component/edge.rs index ca69eed2e54..8b288cef6a4 100644 --- a/app/gui/view/graph-editor/src/component/edge.rs +++ b/app/gui/view/graph-editor/src/component/edge.rs @@ -764,7 +764,6 @@ macro_rules! define_components { #[derive(Debug,Clone,CloneRef)] #[allow(missing_docs)] pub struct $name { - pub logger : Logger, pub display_object : display::object::Instance, pub shape_view_events : Rc>, shape_type_map : Rc>, @@ -774,7 +773,7 @@ macro_rules! define_components { impl $name { /// Constructor. #[allow(clippy::vec_init_then_push)] - pub fn new(logger:Logger) -> Self { + pub fn new() -> Self { let display_object = display::object::Instance::new(); $(let $field = <$field_type>::new();)* $(display_object.add_child(&$field);)* @@ -786,7 +785,7 @@ macro_rules! define_components { $(shape_type_map.insert(EdgeShape::id(&$field), $field_shape_type);)* let shape_type_map = Rc::new(shape_type_map); - Self {logger,display_object,shape_view_events,shape_type_map,$($field),*} + Self {display_object,shape_view_events,shape_type_map,$($field),*} } fn get_shape(&self, id:display::object::Id) -> Option<&dyn EdgeShape> { @@ -801,6 +800,12 @@ macro_rules! define_components { } } + impl Default for $name { + fn default() -> Self { + Self::new() + } + } + impl display::Object for $name { fn display_object(&self) -> &display::object::Instance { &self.display_object @@ -1274,7 +1279,6 @@ pub struct EdgeModel { #[allow(missing_docs)] pub struct EdgeModelData { pub display_object: display::object::Instance, - pub logger: Logger, pub frp: Frp, pub front: Front, pub back: Back, @@ -1295,10 +1299,9 @@ impl EdgeModelData { /// Constructor. #[profile(Debug)] pub fn new(scene: &Scene, network: &frp::Network) -> Self { - let logger = Logger::new("edge"); let display_object = display::object::Instance::new(); - let front = Front::new(Logger::new_sub(&logger, "front")); - let back = Back::new(Logger::new_sub(&logger, "back")); + let front = Front::new(); + let back = Back::new(); let joint = joint::View::new(); display_object.add_child(&front); @@ -1323,7 +1326,6 @@ impl EdgeModelData { let scene = scene.into(); Self { display_object, - logger, frp, front, back, diff --git a/app/gui/view/graph-editor/src/component/node.rs b/app/gui/view/graph-editor/src/component/node.rs index 6224a1489f6..70ace376b43 100644 --- a/app/gui/view/graph-editor/src/component/node.rs +++ b/app/gui/view/graph-editor/src/component/node.rs @@ -440,7 +440,6 @@ impl Deref for Node { pub struct NodeModel { pub app: Application, pub display_object: display::object::Instance, - pub logger: Logger, pub backdrop: backdrop::View, pub background: background::View, pub drag_area: drag_area::View, @@ -485,7 +484,6 @@ impl NodeModel { } let scene = &app.display.default_scene; - let logger = Logger::new("node"); let error_indicator = error_shape::View::new(); let profiling_label = ProfilingLabel::new(app); @@ -502,7 +500,7 @@ impl NodeModel { display_object.add_child(&vcs_indicator); let input = input::Area::new(app); - let visualization = visualization::Container::new(&logger, app, registry); + let visualization = visualization::Container::new(app, registry); display_object.add_child(&visualization); display_object.add_child(&input); @@ -527,7 +525,6 @@ impl NodeModel { Self { app, display_object, - logger, backdrop, background, drag_area, diff --git a/app/gui/view/graph-editor/src/component/node/error.rs b/app/gui/view/graph-editor/src/component/node/error.rs index b707913f9bd..a004d5f5f4d 100644 --- a/app/gui/view/graph-editor/src/component/node/error.rs +++ b/app/gui/view/graph-editor/src/component/node/error.rs @@ -71,7 +71,6 @@ const BORDER_RADIUS: f32 = 14.0; /// The container containing just the error visualization and background. #[derive(Clone, CloneRef, Debug)] pub struct Container { - logger: Logger, visualization: error_visualization::Error, scene: Scene, // TODO : We added a HTML background to the `View`, because "shape" background was @@ -93,7 +92,6 @@ impl Container { /// Constructor of error container. pub fn new(app: &Application) -> Self { let scene = app.display.default_scene.clone_ref(); - let logger = Logger::new("error::Container"); let display_object = display::object::Instance::new(); let background_dom = Self::create_background_dom(&scene); let visualization = error_visualization::Error::new(app); @@ -101,7 +99,7 @@ impl Container { display_object.add_child(&background_dom); display_object.add_child(&visualization); - Self { logger, visualization, scene, background_dom, display_object } + Self { visualization, scene, background_dom, display_object } } fn create_background_dom(scene: &Scene) -> DomSymbol { diff --git a/app/gui/view/graph-editor/src/component/node/input/area.rs b/app/gui/view/graph-editor/src/component/node/input/area.rs index aa76dbfad04..f586f6ca2d4 100644 --- a/app/gui/view/graph-editor/src/component/node/input/area.rs +++ b/app/gui/view/graph-editor/src/component/node/input/area.rs @@ -305,7 +305,7 @@ impl Model { if let Some(id) = node.ast_id { if DEBUG { - DEBUG!("New id mapping: {id} -> {node.crumbs:?}"); + debug!("New id mapping: {id} -> {:?}", node.crumbs); } id_crumbs_map.insert(id, node.crumbs.clone_ref()); } @@ -313,9 +313,13 @@ impl Model { if DEBUG { let indent = " ".repeat(4 * builder.depth); let skipped = if not_a_port { "(skip)" } else { "" }; - DEBUG!( - "{indent}[{node.payload.index},{node.payload.length}] \ - {skipped} {node.kind.variant_name():?} (tp: {node.tp():?}) (id: {node.ast_id:?})" + debug!( + "{indent}[{},{}] {skipped} {:?} (tp: {:?}) (id: {:?})", + node.payload.index, + node.payload.length, + node.kind.variant_name(), + node.tp(), + node.ast_id ); } @@ -675,7 +679,7 @@ impl Model { ) -> Expression { let mut new_expression = Expression::from(new_expression.into()); if DEBUG { - DEBUG!("\n\n=====================\nSET EXPR: " new_expression.code) + debug!("\n\n=====================\nSET EXPR: {}", new_expression.code) } self.set_label_on_new_expression(&new_expression); self.build_port_shapes_on_new_expression(&mut new_expression, area_frp); diff --git a/app/gui/view/graph-editor/src/component/node/output/area.rs b/app/gui/view/graph-editor/src/component/node/output/area.rs index 1734a24d0fe..fcf974d946f 100644 --- a/app/gui/view/graph-editor/src/component/node/output/area.rs +++ b/app/gui/view/graph-editor/src/component/node/output/area.rs @@ -352,8 +352,14 @@ impl Model { if DEBUG { let indent = " ".repeat(4*builder.depth); let skipped = if !is_a_port { "(skip)" } else { "" }; - DEBUG!("{indent}[{node.payload.index},{node.payload.length}] \ - {skipped} {node.kind.variant_name():?} (tp: {node.tp():?}) (id: {node.ast_id:?})"); + debug!( + "{indent}[{},{}] {skipped} {:?} (tp: {:?}) (id: {:?})", + node.payload.index, + node.payload.length, + node.kind.variant_name(), + node.tp(), + node.ast_id + ); } if is_a_port { @@ -412,7 +418,7 @@ impl Model { fn set_expression(&self, new_expression: impl Into) { let new_expression = Expression::from(new_expression.into()); if DEBUG { - DEBUG!("\n\n=====================\nSET EXPR: {new_expression:?}") + debug!("\n\n=====================\nSET EXPR: {new_expression:?}") } self.set_label_on_new_expression(&new_expression); diff --git a/app/gui/view/graph-editor/src/component/visualization/container.rs b/app/gui/view/graph-editor/src/component/visualization/container.rs index c6919871415..7e394d67925 100644 --- a/app/gui/view/graph-editor/src/component/visualization/container.rs +++ b/app/gui/view/graph-editor/src/component/visualization/container.rs @@ -239,7 +239,6 @@ impl display::Object for View { #[derive(Debug)] #[allow(missing_docs)] pub struct ContainerModel { - logger: Logger, display_object: display::object::Instance, /// Internal root for all sub-objects. Will be moved when the visualisation /// container position is changed by dragging. @@ -260,15 +259,14 @@ pub struct ContainerModel { impl ContainerModel { /// Constructor. - pub fn new(logger: &Logger, app: &Application, registry: visualization::Registry) -> Self { + pub fn new(app: &Application, registry: visualization::Registry) -> Self { let scene = &app.display.default_scene; - let logger = Logger::new_sub(logger, "visualization_container"); let display_object = display::object::Instance::new(); let drag_root = display::object::Instance::new(); let visualization = default(); let vis_frp_connection = default(); let view = View::new(scene.clone_ref()); - let fullscreen_view = fullscreen::Panel::new(&logger, scene); + let fullscreen_view = fullscreen::Panel::new(scene); let scene = scene.clone_ref(); let is_fullscreen = default(); let size = default(); @@ -276,7 +274,6 @@ impl ContainerModel { view.add_child(&action_bar); Self { - logger, display_object, drag_root, visualization, @@ -473,18 +470,18 @@ impl display::Object for ContainerModel { /// Container that wraps a `visualization::Instance` for rendering and interaction in the GUI. /// /// The API to interact with the visualization is exposed through the `Frp`. -#[derive(Clone, CloneRef, Debug, Derivative, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Derivative, Deref)] #[allow(missing_docs)] pub struct Container { - #[shrinkwrap(main_field)] + #[deref] pub model: Rc, pub frp: Frp, } impl Container { /// Constructor. - pub fn new(logger: &Logger, app: &Application, registry: visualization::Registry) -> Self { - let model = Rc::new(ContainerModel::new(logger, app, registry)); + pub fn new(app: &Application, registry: visualization::Registry) -> Self { + let model = Rc::new(ContainerModel::new(app, registry)); let frp = Frp::new(); Self { model, frp }.init(app) } @@ -495,7 +492,6 @@ impl Container { let model = &self.model; let scene = &self.model.scene; let scene_shape = scene.shape(); - let logger = &self.model.logger; let action_bar = &model.action_bar.frp; let registry = &model.registry; let selection = Animation::new(network); @@ -531,7 +527,7 @@ impl Container { new_vis_definition <- any(frp.set_visualization,vis_after_cycling); let preprocessor = &frp.source.preprocessor; frp.source.visualisation <+ new_vis_definition.map(f!( - [model,action_bar,app,logger,preprocessor](vis_definition) { + [model,action_bar,app,preprocessor](vis_definition) { if let Some(definition) = vis_definition { match definition.new_instance(&app) { @@ -541,7 +537,7 @@ impl Container { action_bar.set_selected_visualization.emit(path); }, Err(err) => { - warning!(logger,"Failed to instantiate visualization: {err:?}"); + warn!("Failed to instantiate visualization: {err:?}"); }, }; } @@ -621,14 +617,14 @@ impl Container { selected_definition <- action_bar.visualisation_selection.map(f!([registry](path) path.as_ref().and_then(|path| registry.definition_from_path(path)) )); - eval selected_definition([app,model,logger,preprocessor](definition) { + eval selected_definition([app,model,preprocessor](definition) { let vis = definition.as_ref().map(|d| d.new_instance(&app)); match vis { Some(Ok(vis)) => model.set_visualization(vis,&preprocessor), Some(Err(err)) => { - warning!(logger,"Failed to instantiate visualisation: {err:?}"); + warn!("Failed to instantiate visualisation: {err:?}"); }, - None => warning!(logger,"Invalid visualisation selected."), + None => warn!("Invalid visualisation selected."), }; }); frp.source.visualisation <+ selected_definition; diff --git a/app/gui/view/graph-editor/src/component/visualization/container/fullscreen.rs b/app/gui/view/graph-editor/src/component/visualization/container/fullscreen.rs index 226aa7621b9..ac21b29120b 100644 --- a/app/gui/view/graph-editor/src/component/visualization/container/fullscreen.rs +++ b/app/gui/view/graph-editor/src/component/visualization/container/fullscreen.rs @@ -52,16 +52,15 @@ pub mod background { #[derive(Clone, CloneRef, Debug)] #[allow(missing_docs)] pub struct Panel { - logger: Logger, display_object: display::object::Instance, - // background : background::View, pub background_dom: DomSymbol, + // TODO: See TODO above. + // background : background::View, } impl Panel { /// Constructor. - pub fn new(logger: &Logger, scene: &Scene) -> Self { - let logger = Logger::new_sub(logger, "fullscreen_view"); + pub fn new(scene: &Scene) -> Self { let display_object = display::object::Instance::new(); // FIXME : StyleWatch is unsuitable here, as it was designed as an internal tool for shape @@ -89,7 +88,7 @@ impl Panel { display_object.add_child(&background_dom); scene.dom.layers.fullscreen_vis.manage(&background_dom); - Self { logger, display_object, background_dom } + Self { display_object, background_dom } } } diff --git a/app/gui/view/graph-editor/src/component/visualization/definition.rs b/app/gui/view/graph-editor/src/component/visualization/definition.rs index 23efaaeac9d..653804b0a2d 100644 --- a/app/gui/view/graph-editor/src/component/visualization/definition.rs +++ b/app/gui/view/graph-editor/src/component/visualization/definition.rs @@ -16,10 +16,10 @@ use visualization::java_script; // ================= /// General information about a visualization. -#[derive(Clone, CloneRef, Debug, Eq, Hash, PartialEq, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Eq, Hash, PartialEq, Deref)] #[allow(missing_docs)] pub struct Signature { - #[shrinkwrap(main_field)] + #[deref] pub path: visualization::Path, pub input_type: enso::Type, pub input_format: Rc, diff --git a/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs b/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs index afd45d5ae00..8271893800c 100644 --- a/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs +++ b/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs @@ -88,7 +88,6 @@ type PreprocessorCallbackCell = Rc> #[allow(missing_docs)] pub struct InstanceModel { pub root_node: DomSymbol, - pub logger: Logger, on_data_received: Rc>, set_size: Rc>, #[derivative(Debug = "ignore")] @@ -167,7 +166,6 @@ impl InstanceModel { /// Tries to create a InstanceModel from the given visualisation class. pub fn from_class(class: &JsValue, scene: &Scene) -> result::Result { - let logger = Logger::new("Instance"); let root_node = Self::create_root(scene)?; let (preprocessor_change, closure) = Self::preprocessor_change_callback(); let styles = StyleWatch::new(&scene.style_sheet); @@ -181,7 +179,6 @@ impl InstanceModel { let scene = scene.clone_ref(); Ok(InstanceModel { root_node, - logger, on_data_received, set_size, object, @@ -242,7 +239,7 @@ impl InstanceModel { ) -> result::Result<(), JsValue> { if let Some(method) = method { if let Err(error) = method.call1(&self.object, arg) { - warning!(self.logger, "Failed to call method {method:?} with error: {error:?}"); + warn!("Failed to call method {method:?} with error: {error:?}"); return Err(error); } } @@ -261,10 +258,10 @@ impl InstanceModel { // ================ /// Sample visualization that renders the given data as text. Useful for debugging and testing. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] #[allow(missing_docs)] pub struct Instance { - #[shrinkwrap(main_field)] + #[deref] model: InstanceModel, frp: visualization::instance::Frp, network: frp::Network, diff --git a/app/gui/view/graph-editor/src/component/visualization/instance.rs b/app/gui/view/graph-editor/src/component/visualization/instance.rs index d9e846fd004..42a91d63e42 100644 --- a/app/gui/view/graph-editor/src/component/visualization/instance.rs +++ b/app/gui/view/graph-editor/src/component/visualization/instance.rs @@ -137,10 +137,10 @@ pub struct FrpInputs { } /// Visualization FRP network. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] #[allow(missing_docs)] pub struct Frp { - #[shrinkwrap(main_field)] + #[deref] pub inputs: FrpInputs, pub on_preprocessor_change: frp::Sampler, diff --git a/app/gui/view/graph-editor/src/component/visualization/registry.rs b/app/gui/view/graph-editor/src/component/visualization/registry.rs index 0ccfb8fa1ae..4b601b51ce4 100644 --- a/app/gui/view/graph-editor/src/component/visualization/registry.rs +++ b/app/gui/view/graph-editor/src/component/visualization/registry.rs @@ -22,7 +22,6 @@ use enso_prelude::CloneRef; pub struct Registry { path_map: Rc>>, type_map: Rc>>>, - logger: Logger, } impl Registry { @@ -30,8 +29,7 @@ impl Registry { pub fn new() -> Self { let path_map = default(); let type_map = default(); - let logger = Logger::new("Registry"); - Registry { path_map, type_map, logger } + Registry { path_map, type_map } } /// Return a `Registry` pre-populated with default visualizations. @@ -60,13 +58,7 @@ impl Registry { let class = class.into(); match class { Ok(class) => self.add(class), - Err(err) => { - warning!( - &self.logger, - "Failed to add visualization class to registry due to error: \ - {err}" - ) - } + Err(err) => warn!("Failed to add visualization class to registry due to error: {err}"), }; } diff --git a/app/gui/view/graph-editor/src/lib.rs b/app/gui/view/graph-editor/src/lib.rs index 4dff1cc276e..fa72115bca5 100644 --- a/app/gui/view/graph-editor/src/lib.rs +++ b/app/gui/view/graph-editor/src/lib.rs @@ -730,10 +730,10 @@ impl FrpNetworkProvider for GraphEditor { // === Node === // ============ -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] #[allow(missing_docs)] // FIXME[everyone] Public-facing API should be documented. pub struct Node { - #[shrinkwrap(main_field)] + #[deref] pub view: component::Node, pub in_edges: SharedHashSet, pub out_edges: SharedHashSet, @@ -780,10 +780,10 @@ impl Display for NodeId { // === Edge === // ============ -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] #[allow(missing_docs)] // FIXME[everyone] Public-facing API should be documented. pub struct Edge { - #[shrinkwrap(main_field)] + #[deref] pub view: component::Edge, source: Rc>>, target: Rc>>, @@ -940,7 +940,7 @@ impl Display for Type { // As currently there is no good place to wrap Rc into a newtype that can be easily depended on // both by `ide-view` and `ide` crates, we put this as-is. Refactoring should be considered in the // future, once code organization and emerging patterns are more clear. -#[derive(Clone, Debug, Shrinkwrap, PartialEq, Eq)] +#[derive(Clone, Debug, Deref, PartialEq, Eq)] pub struct MethodPointer(pub Rc); impl From for MethodPointer { @@ -1051,10 +1051,9 @@ impl Grid { // === Nodes === // ============= -#[derive(Debug, Clone, CloneRef)] +#[derive(Debug, Clone, CloneRef, Default)] #[allow(missing_docs)] // FIXME[everyone] Public-facing API should be documented. pub struct Nodes { - pub logger: Logger, pub all: SharedHashMap, pub selected: SharedVec, pub grid: Rc>, @@ -1068,13 +1067,9 @@ impl Deref for Nodes { } impl Nodes { - #[allow(missing_docs)] // FIXME[everyone] All pub functions should have docs. - pub fn new(logger: impl AnyLogger) -> Self { - let logger = Logger::new_sub(logger, "nodes"); - let all = default(); - let selected = default(); - let grid = default(); - Self { logger, all, selected, grid } + /// Constructor. + pub fn new() -> Self { + default() } #[allow(missing_docs)] // FIXME[everyone] All pub functions should have docs. @@ -1199,10 +1194,9 @@ impl Nodes { // === Edges === // ============= -#[derive(Debug, Clone, CloneRef)] +#[derive(Debug, Clone, CloneRef, Default)] #[allow(missing_docs)] // FIXME[everyone] Public-facing API should be documented. pub struct Edges { - pub logger: Logger, pub all: SharedHashMap, pub detached_source: SharedHashSet, pub detached_target: SharedHashSet, @@ -1216,13 +1210,9 @@ impl Deref for Edges { } impl Edges { - #[allow(missing_docs)] // FIXME[everyone] All pub functions should have docs. - pub fn new(logger: impl AnyLogger) -> Self { - let logger = Logger::new_sub(logger, "edges"); - let all = default(); - let detached_source = default(); - let detached_target = default(); - Self { logger, all, detached_source, detached_target } + /// Constructor. + pub fn new() -> Self { + default() } #[allow(missing_docs)] // FIXME[everyone] All pub functions should have docs. @@ -1670,7 +1660,6 @@ impl GraphEditorModelWithNetwork { #[derive(Debug, Clone, CloneRef)] #[allow(missing_docs)] // FIXME[everyone] Public-facing API should be documented. pub struct GraphEditorModel { - pub logger: Logger, pub display_object: display::object::Instance, pub app: Application, pub breadcrumbs: component::Breadcrumbs, @@ -1699,10 +1688,9 @@ impl GraphEditorModel { pub fn new(app: &Application, cursor: cursor::Cursor, frp: &Frp) -> Self { let network = frp.network(); let scene = &app.display.default_scene; - let logger = Logger::new("GraphEditor"); let display_object = display::object::Instance::new(); - let nodes = Nodes::new(&logger); - let edges = Edges::new(&logger); + let nodes = Nodes::new(); + let edges = Edges::new(); let vis_registry = visualization::Registry::with_default_visualizations(); let visualisations = default(); let touch_state = TouchState::new(network, &scene.mouse.frp); @@ -1720,7 +1708,6 @@ impl GraphEditorModel { selection::Controller::new(&frp, &app.cursor, &scene.mouse.frp, &touch_state, &nodes); Self { - logger, display_object, app, breadcrumbs, @@ -2223,12 +2210,12 @@ impl GraphEditorModel { fn with_node(&self, id: NodeId, f: impl FnOnce(Node) -> T) -> Option { let out = self.map_node(id, f); - out.map_none(|| warning!(&self.logger, "Trying to access nonexistent node '{id}'")) + out.map_none(|| warn!("Trying to access nonexistent node '{id}'")) } fn with_edge(&self, id: EdgeId, f: impl FnOnce(Edge) -> T) -> Option { let out = self.map_edge(id, f); - out.map_none(|| warning!(&self.logger, "Trying to access nonexistent edge '{id}'")) + out.map_none(|| warn!("Trying to access nonexistent edge '{id}'")) } fn with_edge_map_source(&self, id: EdgeId, f: impl FnOnce(EdgeEndpoint) -> T) -> Option { @@ -2300,9 +2287,9 @@ impl GraphEditorModel { fn with_edge_source(&self, id: EdgeId, f: impl FnOnce(EdgeEndpoint) -> T) -> Option { self.with_edge(id, |edge| { let source = edge.source.borrow().deref().clone(); - source.map(f).map_none(|| { - warning!(&self.logger, "Trying to access nonexistent source of the edge {id}.") - }) + source + .map(f) + .map_none(|| warn!("Trying to access nonexistent source of the edge {id}.")) }) .flatten() } @@ -2310,9 +2297,9 @@ impl GraphEditorModel { fn with_edge_target(&self, id: EdgeId, f: impl FnOnce(EdgeEndpoint) -> T) -> Option { self.with_edge(id, |edge| { let target = edge.target.borrow().deref().clone(); - target.map(f).map_none(|| { - warning!(&self.logger, "Trying to access nonexistent target of the edge {id}.") - }) + target + .map(f) + .map_none(|| warn!("Trying to access nonexistent target of the edge {id}.")) }) .flatten() } @@ -2628,7 +2615,6 @@ fn new_graph_editor(app: &Application) -> GraphEditor { let mouse = &scene.mouse.frp; let touch = &model.touch_state; let vis_registry = &model.vis_registry; - let logger = &model.logger; let out = &frp.private.output; let selection_controller = &model.selection_controller; @@ -3331,14 +3317,14 @@ fn new_graph_editor(app: &Application) -> GraphEditor { // === Vis Set === frp::extend! { network - def _update_vis_data = inputs.set_visualization.map(f!([logger,nodes,vis_registry]((node_id,vis_path)) { + def _update_vis_data = inputs.set_visualization.map(f!([nodes,vis_registry]((node_id,vis_path)) { match (&nodes.get_cloned_ref(node_id), vis_path) { (Some(node), Some(vis_path)) => { let vis_definition = vis_registry.definition_from_path(vis_path); node.model().visualization.frp.set_visualization.emit(vis_definition); }, (Some(node), None) => node.model().visualization.frp.set_visualization.emit(None), - _ => warning!(logger,"Failed to get node: {node_id:?}"), + _ => warn!("Failed to get node: {node_id:?}"), } })); diff --git a/app/gui/view/src/debug_mode_popup.rs b/app/gui/view/src/debug_mode_popup.rs index 36231f290aa..65adbcf74b0 100644 --- a/app/gui/view/src/debug_mode_popup.rs +++ b/app/gui/view/src/debug_mode_popup.rs @@ -104,19 +104,17 @@ impl PopupLabel { struct Model { display_object: display::object::Instance, label: PopupLabel, - logger: Logger, } impl Model { /// Constructor. pub fn new(app: &Application) -> Self { - let logger = Logger::new("DebugModePopup"); let display_object = display::object::Instance::new(); let label = PopupLabel::new(app); label.set_delay(LABEL_VISIBILITY_DELAY_MS); display_object.add_child(&label); - Self { display_object, label, logger } + Self { display_object, label } } /// Show "Debug Mode enabled" label. diff --git a/app/gui/view/src/open_dialog.rs b/app/gui/view/src/open_dialog.rs index d2645ca52b5..0cf864137bb 100644 --- a/app/gui/view/src/open_dialog.rs +++ b/app/gui/view/src/open_dialog.rs @@ -30,7 +30,6 @@ pub mod project_list; #[allow(missing_docs)] #[derive(Clone, CloneRef, Debug)] pub struct OpenDialog { - logger: Logger, network: frp::Network, pub project_list: project_list::ProjectList, pub file_browser: FileBrowser, @@ -41,7 +40,6 @@ pub struct OpenDialog { impl OpenDialog { /// Create Open Dialog component. pub fn new(app: &Application) -> Self { - let logger = Logger::new("OpenDialog"); let network = frp::Network::new("OpenDialog"); let style_watch = StyleWatchFrp::new(&app.display.default_scene.style_sheet); let project_list = project_list::ProjectList::new(app); @@ -71,7 +69,7 @@ impl OpenDialog { eval file_browser_x ((x) file_browser.set_x(*x)); } init.emit(()); - Self { logger, network, project_list, file_browser, display_object, style_watch } + Self { network, project_list, file_browser, display_object, style_watch } } } diff --git a/app/gui/view/src/open_dialog/project_list.rs b/app/gui/view/src/open_dialog/project_list.rs index c267021cc84..71f8deea1b2 100644 --- a/app/gui/view/src/open_dialog/project_list.rs +++ b/app/gui/view/src/open_dialog/project_list.rs @@ -65,7 +65,6 @@ mod background { /// This is a list of projects in a nice frame with title. #[derive(Clone, CloneRef, Debug)] pub struct ProjectList { - logger: Logger, network: frp::Network, display_object: display::object::Instance, background: background::View, //TODO[ao] use Card instead. @@ -85,7 +84,6 @@ impl Deref for ProjectList { impl ProjectList { /// Create Project List Component. pub fn new(app: &Application) -> Self { - let logger = Logger::new("ProjectList"); let network = frp::Network::new("ProjectList"); let display_object = display::object::Instance::new(); let background = background::View::new(); @@ -137,7 +135,7 @@ impl ProjectList { }; init.emit(()); - Self { logger, network, display_object, background, caption, list, style_watch } + Self { network, display_object, background, caption, list, style_watch } } } diff --git a/app/gui/view/src/project.rs b/app/gui/view/src/project.rs index de65e70dcd8..9c4a3f6952f 100644 --- a/app/gui/view/src/project.rs +++ b/app/gui/view/src/project.rs @@ -239,7 +239,6 @@ impl display::Object for SearcherVariant { #[derive(Clone, CloneRef, Debug)] struct Model { app: Application, - logger: Logger, display_object: display::object::Instance, /// These buttons are present only in a cloud environment. window_control_buttons: Immutable>, @@ -253,7 +252,6 @@ struct Model { impl Model { fn new(app: &Application) -> Self { - let logger = Logger::new("project::View"); let scene = &app.display.default_scene; let display_object = display::object::Instance::new(); let searcher = SearcherVariant::new(app); @@ -280,7 +278,6 @@ impl Model { let graph_editor = Rc::new(graph_editor); Self { app, - logger, display_object, window_control_buttons, graph_editor, diff --git a/app/gui/view/src/root.rs b/app/gui/view/src/root.rs index 089c638e1eb..76ddd5d1fe3 100644 --- a/app/gui/view/src/root.rs +++ b/app/gui/view/src/root.rs @@ -32,7 +32,6 @@ enum State { #[derive(Clone, CloneRef, Debug)] pub struct Model { app: Application, - logger: Logger, display_object: display::object::Instance, state: Rc>, status_bar: crate::status_bar::View, @@ -44,7 +43,6 @@ impl Model { /// Constuctor. pub fn new(app: &Application) -> Self { let app = app.clone_ref(); - let logger = Logger::new("RootView"); let display_object = display::object::Instance::new(); let state = Rc::new(CloneCell::new(State::WelcomeScreen)); let status_bar = crate::status_bar::View::new(&app); @@ -53,7 +51,7 @@ impl Model { let project_view = Rc::new(CloneCell::new(None)); display_object.add_child(&welcome_view); - Self { app, logger, display_object, status_bar, welcome_view, project_view, state } + Self { app, display_object, status_bar, welcome_view, project_view, state } } /// Switch displayed view from Project View to Welcome Screen. Project View will not be diff --git a/app/gui/view/src/searcher.rs b/app/gui/view/src/searcher.rs index 2c69e9d5402..3ad96ab4024 100644 --- a/app/gui/view/src/searcher.rs +++ b/app/gui/view/src/searcher.rs @@ -108,7 +108,6 @@ pub type Entry = list_view::entry::GlyphHighlightedLabel; #[derive(Clone, CloneRef, Debug)] struct Model { app: Application, - logger: Logger, display_object: display::object::Instance, list: ListView, documentation: documentation::View, @@ -119,7 +118,6 @@ impl Model { fn new(app: &Application) -> Self { let scene = &app.display.default_scene; let app = app.clone_ref(); - let logger = Logger::new("SearcherView"); let display_object = display::object::Instance::new(); let list = app.new_view::>(); list.deprecated_focus(); @@ -139,7 +137,7 @@ impl Model { list.set_x(ACTION_LIST_X); documentation.set_x(DOCUMENTATION_X); documentation.set_y(-action_list_gap); - Self { app, logger, display_object, list, documentation, doc_provider } + Self { app, display_object, list, documentation, doc_provider } } fn set_height(&self, h: f32) { diff --git a/app/gui/view/src/status_bar.rs b/app/gui/view/src/status_bar.rs index c41e635e664..fc66c27a99f 100644 --- a/app/gui/view/src/status_bar.rs +++ b/app/gui/view/src/status_bar.rs @@ -146,7 +146,6 @@ ensogl::define_endpoints! { /// An internal model of Status Bar component #[derive(Clone, CloneRef, Debug)] struct Model { - logger: Logger, display_object: display::object::Instance, root: display::object::Instance, background: background::View, @@ -160,7 +159,6 @@ struct Model { impl Model { fn new(app: &Application) -> Self { let scene = &app.display.default_scene; - let logger = Logger::new("StatusBar"); let display_object = display::object::Instance::new(); let root = display::object::Instance::new(); let background = background::View::new(); @@ -180,18 +178,8 @@ impl Model { label.frp.set_property(.., text_color); label.frp.set_property_default(text_color); - Self { - logger, - display_object, - root, - background, - label, - events, - processes, - next_process_id, - camera, - } - .init() + Self { display_object, root, background, label, events, processes, next_process_id, camera } + .init() } fn init(self) -> Self { diff --git a/app/gui/view/src/window_control_buttons.rs b/app/gui/view/src/window_control_buttons.rs index 1d38b33615c..c3a079efc43 100644 --- a/app/gui/view/src/window_control_buttons.rs +++ b/app/gui/view/src/window_control_buttons.rs @@ -134,7 +134,6 @@ impl LayoutParams> { #[derive(Clone, CloneRef, Debug)] pub struct Model { app: Application, - logger: Logger, display_object: display::object::Instance, shape: shape::View, close: close::View, @@ -145,7 +144,6 @@ impl Model { /// Constructor. pub fn new(app: &Application) -> Self { let app = app.clone_ref(); - let logger = Logger::new("TopButtons"); let display_object = display::object::Instance::new(); ensogl::shapes_order_dependencies! { @@ -163,7 +161,7 @@ impl Model { let shape = shape::View::new(); display_object.add_child(&shape); - Self { app, logger, display_object, shape, close, fullscreen } + Self { app, display_object, shape, close, fullscreen } } /// Updates positions of the buttons and sizes of the mouse area. diff --git a/app/gui/view/welcome-screen/src/lib.rs b/app/gui/view/welcome-screen/src/lib.rs index 945a234c41f..29f8da0b932 100644 --- a/app/gui/view/welcome-screen/src/lib.rs +++ b/app/gui/view/welcome-screen/src/lib.rs @@ -117,7 +117,6 @@ static STYLESHEET: &str = include_str!("../style.css"); #[derive(Clone, CloneRef, Debug)] pub struct Model { application: Application, - logger: Logger, dom: DomSymbol, display_object: display::object::Instance, side_menu: SideMenu, @@ -128,11 +127,10 @@ impl Model { /// Constructor. `frp` is used to set up event handlers on buttons. pub fn new(app: &Application) -> Self { let application = app.clone_ref(); - let logger = Logger::new("WelcomeScreen"); let display_object = display::object::Instance::new(); - let side_menu = SideMenu::new(&logger); - let template_cards = TemplateCards::new(&logger); + let side_menu = SideMenu::new(); + let template_cards = TemplateCards::new(); let dom = Self::create_dom(&side_menu, &template_cards); display_object.add_child(&dom); @@ -143,7 +141,7 @@ impl Model { style.set_inner_html(STYLESHEET); dom.append_or_warn(&style); - Self { application, logger, dom, display_object, side_menu, template_cards } + Self { application, dom, display_object, side_menu, template_cards } } fn create_dom(side_menu: &SideMenu, template_cards: &TemplateCards) -> DomSymbol { diff --git a/app/gui/view/welcome-screen/src/side_menu.rs b/app/gui/view/welcome-screen/src/side_menu.rs index e76f2a3fe52..168aa959435 100644 --- a/app/gui/view/welcome-screen/src/side_menu.rs +++ b/app/gui/view/welcome-screen/src/side_menu.rs @@ -18,7 +18,6 @@ use ensogl::system::web; #[derive(Clone, CloneRef, Debug)] pub struct Model { - logger: Logger, pub root_dom: web::Element, new_project_button: ClickableElement, projects_list_dom: web::Element, @@ -27,7 +26,7 @@ pub struct Model { impl Model { /// Constructor. - pub fn new(logger: Logger) -> Self { + pub fn new() -> Self { let root_dom = web::document.create_element_or_panic("aside"); root_dom.set_class_name(crate::css_class::SIDE_MENU); let header = Self::create_header("Your projects"); @@ -37,7 +36,7 @@ impl Model { let new_project_button = Self::create_new_project_button(&projects_list_dom); let projects = default(); - Self { logger, root_dom, projects_list_dom, projects, new_project_button } + Self { root_dom, projects_list_dom, projects, new_project_button } } pub fn set_projects_list(&self, projects: &[String], open_project: &frp::Any) { @@ -129,10 +128,9 @@ impl Deref for SideMenu { } impl SideMenu { - pub fn new(logger: &Logger) -> Self { - let logger = Logger::new_sub(logger, "SideMenu"); + pub fn new() -> Self { let frp = Frp::new(); - let model = Model::new(logger); + let model = Model::new(); let network = &frp.network; frp::extend! { network diff --git a/app/gui/view/welcome-screen/src/template_cards.rs b/app/gui/view/welcome-screen/src/template_cards.rs index fe4aa2bb0a4..9fa35039b6a 100644 --- a/app/gui/view/welcome-screen/src/template_cards.rs +++ b/app/gui/view/welcome-screen/src/template_cards.rs @@ -79,14 +79,13 @@ impl Deref for Card { #[derive(Debug, Clone, CloneRef)] pub struct Model { - logger: Logger, pub root_dom: Element, cards: Rc>, } impl Model { /// Constructor. - pub fn new(logger: Logger, open_template: &frp::Any) -> Self { + pub fn new(open_template: &frp::Any) -> Self { let root_dom = web::document.create_element_or_panic("main"); root_dom.set_class_name(crate::css_class::CONTENT); let templates = web::document.create_div_or_panic(); @@ -98,7 +97,7 @@ impl Model { templates.append_or_warn(&cards_dom); root_dom.append_or_warn(&templates); - let model = Self { logger, root_dom, cards: Rc::new(cards) }; + let model = Self { root_dom, cards: Rc::new(cards) }; model.setup_event_listeners(open_template); model } @@ -203,10 +202,9 @@ impl Deref for TemplateCards { } impl TemplateCards { - pub fn new(logger: &Logger) -> Self { - let logger = Logger::new_sub(logger, "TemplateCards"); + pub fn new() -> Self { let frp = Frp::new(); - let model = Model::new(logger, &frp.output.source.open_template); + let model = Model::new(&frp.output.source.open_template); Self { model, frp } } } diff --git a/build/base/Cargo.toml b/build/base/Cargo.toml index f276639d971..fa5a2233e4a 100644 --- a/build/base/Cargo.toml +++ b/build/base/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.65" +anyhow = { workspace = true } fn-error-context = "0.2.0" futures-util = "0.3.24" -futures = "0.3.24" +futures = { workspace = true } serde = "1.0.145" -serde_json = "1.0.85" +serde_json = { workspace = true } serde_yaml = { workspace = true } tracing = "0.1.36" diff --git a/build/build/Cargo.toml b/build/build/Cargo.toml index 2752fda7207..1a6cca89a84 100644 --- a/build/build/Cargo.toml +++ b/build/build/Cargo.toml @@ -5,27 +5,27 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.44" +anyhow = { workspace = true } async-compression = "0.3.12" async-trait = "0.1.51" aws-config = "0.49.0" aws-sdk-ecr = "0.19.0" aws-sdk-s3 = "0.19.0" base64 = "0.13.0" -bytes = "1.0.0" -byte-unit = { version = "4.0.14", features = ["serde"] } +bytes = { workspace = true } +byte-unit = { workspace = true } cached = "0.39.0" cfg-if = "1.0.0" chrono = { version = "0.4.19", features = ["serde"] } clap = { version = "3.1.5", features = ["derive", "env", "wrap_help"] } -derivative = "2.2.0" -derive_more = "0.99" +derivative = { workspace = true } +derive_more = { workspace = true } dirs = "4.0.0" filetime = "0.2.15" flate2 = "1.0.22" flume = "0.10.10" fs_extra = "1.2.0" -futures = "0.3.17" +futures = { workspace = true } futures-util = "0.3.17" glob = "0.3.0" #graphql_client = "0.10.0" @@ -37,15 +37,15 @@ ensogl-pack = { path = "../../lib/rust/ensogl/pack" } ide-ci = { path = "../ci_utils" } indexmap = "1.7.0" indicatif = "0.17.1" -itertools = "0.10.1" -lazy_static = "1.4.0" +itertools = { workspace = true } +lazy_static = { workspace = true } #git2 = "0.13.25" mime = "0.3.16" new_mime_guess = "4.0.1" nix = { workspace = true } octocrab = { workspace = true } ouroboros = "0.15.0" -paste = "1.0.7" +paste = { workspace = true } path-absolutize = "3.0.11" path-slash = "0.2.1" platforms = { version = "3.0.0", features = ["serde"] } @@ -60,10 +60,9 @@ reqwest = { version = "0.11.5", default-features = false, features = [ ] } semver = { version = "1.0.4", features = ["serde"] } serde = { version = "1.0.130", features = ["derive"] } -serde_json = "1.0.68" +serde_json = { workspace = true } serde_yaml = { workspace = true } scopeguard = "1.1.0" -shrinkwraprs = "0.3.0" strum = { version = "0.24.0", features = ["derive"] } sysinfo = "0.26.2" tar = "0.4.37" diff --git a/build/build/src/aws.rs b/build/build/src/aws.rs index 928fb0b6276..a31576b10f5 100644 --- a/build/build/src/aws.rs +++ b/build/build/src/aws.rs @@ -26,7 +26,7 @@ pub const MANIFEST_FILENAME: &str = "manifest.yaml"; -#[derive(Clone, Debug, Display, Serialize, Deserialize, Shrinkwrap)] +#[derive(Clone, Debug, Display, Serialize, Deserialize, Deref)] pub struct Edition(pub String); impl AsRef for Edition { diff --git a/build/build/src/engine.rs b/build/build/src/engine.rs index 15c7d19d2e8..a88f970f8b1 100644 --- a/build/build/src/engine.rs +++ b/build/build/src/engine.rs @@ -145,7 +145,7 @@ impl From for BuildConfigurationResolved { } } -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct BuildConfigurationResolved(BuildConfigurationFlags); impl BuildConfigurationResolved { diff --git a/build/build/src/programs.rs b/build/build/src/programs.rs index 756c727eafa..825ec2e4660 100644 --- a/build/build/src/programs.rs +++ b/build/build/src/programs.rs @@ -31,15 +31,4 @@ pub mod project_manager { command.stdin(Stdio::piped()); command } - // #[derive(Shrinkwrap)] - // #[shrinkwrap(mutable)] - // pub struct Command(pub ide_ci::program::Command); - // - // impl From for Command { - // fn from(inner: ide_ci::prelude::Command) -> Self { - // Self(inner) - // } - // } - // - // impl MyCommand

for Command {} } diff --git a/build/build/src/project/gui.rs b/build/build/src/project/gui.rs index dc839f2b01d..f8ab92f18a4 100644 --- a/build/build/src/project/gui.rs +++ b/build/build/src/project/gui.rs @@ -21,7 +21,7 @@ use ide_ci::ok_ready_boxed; -#[derive(Clone, Debug, PartialEq, Eq, Hash, Shrinkwrap)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Deref)] pub struct Artifact(crate::paths::generated::RepoRootDistGui); impl AsRef for Artifact { diff --git a/build/build/src/version.rs b/build/build/src/version.rs index 8a6bd379130..d5f781b441d 100644 --- a/build/build/src/version.rs +++ b/build/build/src/version.rs @@ -76,13 +76,13 @@ pub async fn latest_nightly_release(repo: &github::repo::Handle) -> /// Keeps the version of Enso, edition name and whether this version should be treated as a release. /// /// Basically this is everything that is needed to define the version of the build. -#[derive(Clone, Derivative, Serialize, Deserialize, Shrinkwrap, PartialEq, Eq)] +#[derive(Clone, Derivative, Serialize, Deserialize, Deref, PartialEq, Eq)] #[derivative(Debug)] pub struct Versions { /// The version of Enso. /// /// Currently it also doubles as the edition name. In future we might want to separate them. - #[shrinkwrap(main_field)] + #[deref] #[derivative(Debug(format_with = "std::fmt::Display::fmt"))] pub version: Version, diff --git a/build/ci_utils/Cargo.toml b/build/ci_utils/Cargo.toml index 274e4a41397..d1db2504737 100644 --- a/build/ci_utils/Cargo.toml +++ b/build/ci_utils/Cargo.toml @@ -5,47 +5,46 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.44" +anyhow = { workspace = true } async-compression = { version = "0.3.12", features = ["tokio", "gzip"] } async-trait = "0.1.51" bincode = "1.3.3" -byte-unit = "4.0.14" -bytes = "1.0.0" +byte-unit = { workspace = true } +bytes = { workspace = true } cached = "0.39.0" -convert_case = "0.6.0" +convert_case = { workspace = true } cfg-if = "1.0.0" chrono = { version = "0.4.19", features = ["serde"] } clap = { version = "3.1.5", features = ["derive", "env"] } cron = "0.12.0" data-encoding = "2.3.2" dependency_runner = "1.0.0" -derivative = "2.2.0" -derive_more = "0.99" +derivative = { workspace = true } +derive_more = { workspace = true } dirs = "4.0.0" enso-build-base = { path = "../base" } filetime = "0.2.15" flate2 = "1.0.22" flume = "0.10.10" fs_extra = "1.2.0" -futures = "0.3.17" +futures = { workspace = true } futures-util = "0.3.17" glob = "0.3.0" graphql_client = "0.11.0" headers = "0.3.7" heck = "0.4.0" http-serde = "1.1.0" -ifmt = "0.3.3" indexmap = "1.7.0" indicatif = "0.17.1" -itertools = "0.10.1" -lazy_static = "1.4.0" +itertools = { workspace = true } +lazy_static = { workspace = true } log = "0.4.14" mime = "0.3.16" multimap = "0.8.3" new_mime_guess = "4.0.0" nix = { workspace = true } octocrab = { workspace = true } -paste = "1.0.7" +paste = { workspace = true } path-absolutize = "3.0.11" pathdiff = "0.2.1" path-slash = "0.2.1" @@ -62,11 +61,10 @@ reqwest = { version = "0.11.5", default-features = false, features = [ ] } semver = { version = "1.0.4", features = ["serde"] } serde = { version = "1.0.130", features = ["derive"] } -serde_json = "1.0.68" +serde_json = { workspace = true } serde_yaml = { workspace = true } scopeguard = "1.1.0" sha2 = "0.10.2" -shrinkwraprs = "0.3.0" strum = { version = "0.24.0", features = ["derive"] } symlink = "0.1.0" syn = "1.0" diff --git a/build/ci_utils/src/actions/artifacts/context.rs b/build/ci_utils/src/actions/artifacts/context.rs index 9c11181b98c..56d884490cd 100644 --- a/build/ci_utils/src/actions/artifacts/context.rs +++ b/build/ci_utils/src/actions/artifacts/context.rs @@ -42,7 +42,7 @@ impl Context { let mut headers = HeaderMap::new(); headers.insert( reqwest::header::ACCEPT, - iformat!("{accept_mime};api-version={self.api_version}").parse()?, + format!("{accept_mime};api-version={}", self.api_version).parse()?, ); headers.insert( reqwest::header::AUTHORIZATION, diff --git a/build/ci_utils/src/deploy/runner.rs b/build/ci_utils/src/deploy/runner.rs index 1fd5a0f4009..19cf9ae94cb 100644 --- a/build/ci_utils/src/deploy/runner.rs +++ b/build/ci_utils/src/deploy/runner.rs @@ -33,10 +33,10 @@ impl Config { /// Pretty printed triple with repository owner, repository name and runner name. pub fn qualified_name(&self) -> String { let location_prefix = match &self.location { - RunnerLocation::Organization(org) => iformat!("{org.name}"), - RunnerLocation::Repository(repo) => iformat!("{repo.owner}-{repo.name}"), + RunnerLocation::Organization(org) => org.name.to_string(), + RunnerLocation::Repository(repo) => format!("{}-{}", repo.owner, repo.name), }; - iformat!("{location_prefix}-{self.runner.name}-{self.server_name}-{self.index}") + format!("{location_prefix}-{}-{}-{}", self.runner.name, self.server_name, self.index) } /// The custom labels that the runner will be registered with. diff --git a/build/ci_utils/src/github.rs b/build/ci_utils/src/github.rs index 7f6c0e827d9..9044f8f5b2e 100644 --- a/build/ci_utils/src/github.rs +++ b/build/ci_utils/src/github.rs @@ -125,7 +125,7 @@ pub trait IsOrganization { /// The organization's URL. fn url(&self) -> Result { - let url_text = iformat!("https://github.com/{self.name()}"); + let url_text = format!("https://github.com/{}", self.name()); Url::from_str(&url_text) } } diff --git a/build/ci_utils/src/github/repo.rs b/build/ci_utils/src/github/repo.rs index d8e4d246ae8..e7c4b2a9a27 100644 --- a/build/ci_utils/src/github/repo.rs +++ b/build/ci_utils/src/github/repo.rs @@ -139,7 +139,7 @@ pub trait IsRepo: Display { /// ``` fn url(&self) -> Result { // Note the trailing `/`. It allows us to join further paths to the URL using Url::join. - let url_text = iformat!("https://github.com/{self.owner()}/{self.name()}/"); + let url_text = format!("https://github.com/{}/{}/", self.owner(), self.name()); Url::parse(&url_text) .with_context(|| format!("Failed to parse URL from string '{url_text}'.")) .with_context(|| format!("Failed to generate URL for the repository {self}.")) @@ -196,7 +196,7 @@ impl Handle { /// Generate a token that can be used to register a new runner for this repository. pub async fn generate_runner_registration_token(&self) -> Result { let path = - iformat!("/repos/{self.owner()}/{self.name()}/actions/runners/registration-token"); + format!("/repos/{}/{}/actions/runners/registration-token", self.owner(), self.name()); let url = self.octocrab.absolute_url(path)?; self.octocrab.post(url, EMPTY_REQUEST_BODY).await.with_context(|| { format!("Failed to generate a runner registration token for the {self} repository.") @@ -338,7 +338,7 @@ impl Handle { /// Generate cacheable action that downloads asset with a given id. pub fn download_asset_job(&self, asset_id: AssetId) -> DownloadFile { - let path = iformat!("/repos/{self.owner()}/{self.name()}/releases/assets/{asset_id}"); + let path = format!("/repos/{}/{}/releases/assets/{asset_id}", self.owner(), self.name()); // Unwrap will work, because we are appending relative URL constant. let url = self.octocrab.absolute_url(path).unwrap(); DownloadFile { diff --git a/build/ci_utils/src/lib.rs b/build/ci_utils/src/lib.rs index b32bf7951f6..5af3f0c235e 100644 --- a/build/ci_utils/src/lib.rs +++ b/build/ci_utils/src/lib.rs @@ -72,13 +72,13 @@ pub mod serde; pub mod prelude { + pub use derive_more::*; pub use enso_build_base::prelude::*; pub use async_trait::async_trait; pub use bytes::Bytes; pub use derivative::Derivative; pub use derive_more::Display; - pub use ifmt::iformat; pub use itertools::Itertools; pub use lazy_static::lazy_static; pub use octocrab::Octocrab; @@ -86,7 +86,6 @@ pub mod prelude { pub use platforms::target::Arch; pub use platforms::target::OS; pub use semver::Version; - pub use shrinkwraprs::Shrinkwrap; pub use sysinfo::PidExt as _; pub use sysinfo::ProcessExt as _; pub use sysinfo::SystemExt as _; diff --git a/build/ci_utils/src/paths.rs b/build/ci_utils/src/paths.rs index 88afeb24f52..15d4d546547 100644 --- a/build/ci_utils/src/paths.rs +++ b/build/ci_utils/src/paths.rs @@ -45,7 +45,7 @@ lazy_static::lazy_static! { static ref PARAMETER: ParameterRegex = ParameterRegex::new(); } -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct ParameterRegex(Regex); impl ParameterRegex { @@ -308,9 +308,9 @@ impl<'a> Generator<'a> { } } -#[derive(Clone, Debug, PartialEq, Shrinkwrap)] +#[derive(Clone, Debug, PartialEq, Deref)] pub struct Node { - #[shrinkwrap(main_field)] + #[deref] value: String, /// All parameters needed for this node (directly and for the children). parameters: OnceCell>, // Wasteful but paths won't be that huge. diff --git a/build/ci_utils/src/program/command.rs b/build/ci_utils/src/program/command.rs index d93a07738a0..75fd7a5e743 100644 --- a/build/ci_utils/src/program/command.rs +++ b/build/ci_utils/src/program/command.rs @@ -28,10 +28,21 @@ pub mod provider; #[macro_export] macro_rules! new_command_type { ($program_name:ident, $command_name:ident) => { - #[derive(Debug, Shrinkwrap)] - #[shrinkwrap(mutable)] + #[derive(Debug, Deref, DerefMut)] pub struct $command_name(pub $crate::program::command::Command); + impl Borrow<$crate::program::command::Command> for $command_name { + fn borrow(&self) -> &$crate::program::command::Command { + &self.0 + } + } + + impl BorrowMut<$crate::program::command::Command> for $command_name { + fn borrow_mut(&mut self) -> &mut $crate::program::command::Command { + &mut self.0 + } + } + impl From<$crate::program::command::Command> for $command_name { fn from(inner: $crate::program::command::Command) -> Self { $command_name(inner) diff --git a/build/ci_utils/src/programs/docker.rs b/build/ci_utils/src/programs/docker.rs index 91dcc2d3e5b..6f25292c438 100644 --- a/build/ci_utils/src/programs/docker.rs +++ b/build/ci_utils/src/programs/docker.rs @@ -3,7 +3,6 @@ use crate::prelude::*; use crate::env::accessor::TypedVariable; use crate::extensions::child::ChildExt; -use shrinkwraprs::Shrinkwrap; use std::collections::HashMap; use std::fmt::Formatter; use std::process::Stdio; @@ -520,7 +519,7 @@ impl RunOptions { #[derive(Clone, Display, Debug)] pub struct ImageId(pub String); -#[derive(Clone, Debug, Display, Shrinkwrap)] +#[derive(Clone, Debug, Display, Deref, AsRef)] pub struct ContainerId(pub String); impl FromStr for ContainerId { diff --git a/build/ci_utils/src/programs/java.rs b/build/ci_utils/src/programs/java.rs index 6fe7e05cb49..aae9e61abba 100644 --- a/build/ci_utils/src/programs/java.rs +++ b/build/ci_utils/src/programs/java.rs @@ -74,7 +74,7 @@ mod tests { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Shrinkwrap)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Deref)] pub struct LanguageVersion(pub u8); impl std::str::FromStr for LanguageVersion { diff --git a/build/ci_utils/src/programs/wasm_opt.rs b/build/ci_utils/src/programs/wasm_opt.rs index a59b288c7e5..83603f96e15 100644 --- a/build/ci_utils/src/programs/wasm_opt.rs +++ b/build/ci_utils/src/programs/wasm_opt.rs @@ -53,7 +53,7 @@ impl Program for WasmOpt { } // wasm-opt (like the whole binaryen) uses a single number as a version. -#[derive(Clone, Copy, Debug, Display, PartialEq, PartialOrd, Shrinkwrap, Eq)] +#[derive(Clone, Copy, Debug, Display, PartialEq, PartialOrd, Deref, Eq)] pub struct Version(pub u32); impl std::str::FromStr for Version { diff --git a/build/cli/Cargo.toml b/build/cli/Cargo.toml index 4313c5d6c6f..8e0c4025ed3 100644 --- a/build/cli/Cargo.toml +++ b/build/cli/Cargo.toml @@ -5,22 +5,22 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.57" -byte-unit = { version = "4.0.14", features = ["serde"] } +anyhow = { workspace = true } +byte-unit = { workspace = true } clap = { version = "3.2.23", features = ["derive", "env", "wrap_help"] } chrono = "0.4.19" -derivative = "2.2.0" +derivative = { workspace = true } enso-build-base = { path = "../base" } enso-build = { path = "../build" } enso-formatter = { path = "../enso-formatter" } -futures = "0.3.17" +futures = { workspace = true } futures-util = "0.3.17" glob = "0.3.0" humantime = "2.1.0" ide-ci = { path = "../ci_utils" } octocrab = { workspace = true } serde = { version = "1.0.130", features = ["derive"] } -serde_json = "1.0.68" +serde_json = { workspace = true } serde_yaml = { workspace = true } strum = { version = "0.24.0", features = ["derive"] } tempfile = "3.2.0" diff --git a/build/macros/Cargo.toml b/build/macros/Cargo.toml index 817b70bcb15..e9a9e2db710 100644 --- a/build/macros/Cargo.toml +++ b/build/macros/Cargo.toml @@ -8,12 +8,12 @@ proc-macro = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -convert_case = "0.6.0" +convert_case = { workspace = true } enso-build-base = { path = "../base" } -itertools = "0.10.5" +itertools = { workspace = true } proc-macro2 = "1.0" quote = "1.0" regex = { workspace = true } serde_yaml = { workspace = true } -shrinkwraprs = "0.3.0" syn = "1.0" +derive_more = { workspace = true } diff --git a/build/macros/src/lib.rs b/build/macros/src/lib.rs index 35b43130ca8..2519a979411 100644 --- a/build/macros/src/lib.rs +++ b/build/macros/src/lib.rs @@ -13,6 +13,7 @@ mod prelude { + pub use derive_more::*; pub use enso_build_base::prelude::*; pub use convert_case::Case; @@ -21,7 +22,6 @@ mod prelude { pub use proc_macro2::Span; pub use proc_macro2::TokenStream; pub use quote::quote; - pub use shrinkwraprs::Shrinkwrap; pub use syn::parse::Parse; pub use syn::Data; pub use syn::DeriveInput; diff --git a/build/macros/src/program_args.rs b/build/macros/src/program_args.rs index 317af49cdfd..2bd3fbbd4d8 100644 --- a/build/macros/src/program_args.rs +++ b/build/macros/src/program_args.rs @@ -45,10 +45,10 @@ impl<'a> Generator<'a> { } } -#[derive(Clone, Debug, PartialEq, Eq, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, Debug, PartialEq, Eq, Deref, DerefMut)] pub struct EnumGenerator<'a> { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] pub generator: Generator<'a>, pub enum_data: &'a syn::DataEnum, } diff --git a/integration-test/tests/engine.rs b/integration-test/tests/engine.rs index e197873b36c..7f046d27e25 100644 --- a/integration-test/tests/engine.rs +++ b/integration-test/tests/engine.rs @@ -66,5 +66,5 @@ async fn getting_component_groups() { ls_json_connection.push_to_execution_context(&execution_ctx.context_id, &frame).await.unwrap(); sleep(Duration::from_secs(15)).await; let groups = ls_json_connection.get_component_groups(&execution_ctx.context_id).await.unwrap(); - DEBUG!("{groups:?}"); + debug!("{groups:?}"); } diff --git a/lib/rust/automata/Cargo.toml b/lib/rust/automata/Cargo.toml index f1ba7b4faef..cdfab52c4db 100644 --- a/lib/rust/automata/Cargo.toml +++ b/lib/rust/automata/Cargo.toml @@ -15,4 +15,4 @@ publish = true [lib] [dependencies] -enso-prelude = { version = "^0.2.1", path = "../prelude" } +enso-prelude = { path = "../prelude" } diff --git a/lib/rust/data-structures/Cargo.toml b/lib/rust/data-structures/Cargo.toml index 94d34c3b48c..c0268914128 100644 --- a/lib/rust/data-structures/Cargo.toml +++ b/lib/rust/data-structures/Cargo.toml @@ -16,14 +16,14 @@ publish = true crate-type = ["rlib", "cdylib"] [dependencies] -enso-prelude = { version = "^0.2.1", path = "../prelude" } +enso-prelude = { path = "../prelude" } serde = { version = "1.0", features = ["derive"] } typenum = { version = "1.11.2" } rustversion = { version = "1.0" } -failure = { version = "0.1.6" } +failure = { workspace = true } [dev-dependencies] -itertools = "0.9.0" +itertools = { workspace = true } criterion = "0.3" [[bench]] diff --git a/lib/rust/data-structures/src/opt_vec.rs b/lib/rust/data-structures/src/opt_vec.rs index 3c816dff7ce..70e3433de1f 100644 --- a/lib/rust/data-structures/src/opt_vec.rs +++ b/lib/rust/data-structures/src/opt_vec.rs @@ -19,9 +19,8 @@ use std::slice; /// Index have to implement the `Index` trait. #[derive(Derivative)] #[derivative(Default(bound = ""))] -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug)] pub struct OptVec { - #[shrinkwrap(main_field)] items: Vec>, free_ixs: SmallVec<[Index; 128]>, } diff --git a/lib/rust/debug-api/Cargo.toml b/lib/rust/debug-api/Cargo.toml index 1186e12f18c..0a617ae8366 100644 --- a/lib/rust/debug-api/Cargo.toml +++ b/lib/rust/debug-api/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Enso Team "] edition = "2021" [dependencies] -derivative = "2.2.0" -futures = "0.3" -js-sys = { version = "0.3.28" } +derivative = { workspace = true } +futures = { workspace = true } +js-sys = { workspace = true } wasm-bindgen = { workspace = true } web-sys = { version = "0.3.4", features = ["console"] } diff --git a/lib/rust/ensogl/component/button/src/lib.rs b/lib/rust/ensogl/component/button/src/lib.rs index cd31430f942..f38aa485c25 100644 --- a/lib/rust/ensogl/component/button/src/lib.rs +++ b/lib/rust/ensogl/component/button/src/lib.rs @@ -204,7 +204,6 @@ pub mod shape { #[allow(missing_docs)] pub struct Model { app: Application, - logger: Logger, display_object: display::object::Instance, shape: ShapeView, } @@ -213,11 +212,10 @@ impl Model { /// Construct a button's model. pub fn new(app: &Application) -> Self { let app = app.clone_ref(); - let logger = Logger::new(Shape::debug_name()); let display_object = display::object::Instance::new(); let shape = ShapeView::new(); display_object.add_child(&shape); - Self { app, logger, display_object, shape } + Self { app, display_object, shape } } /// Set the background (i.e. the circle) color. diff --git a/lib/rust/ensogl/component/drop-manager/Cargo.toml b/lib/rust/ensogl/component/drop-manager/Cargo.toml index 0b2a2d3c7bf..f1a11900236 100644 --- a/lib/rust/ensogl/component/drop-manager/Cargo.toml +++ b/lib/rust/ensogl/component/drop-manager/Cargo.toml @@ -7,9 +7,8 @@ edition = "2021" [dependencies] enso-web = { path = "../../../web" } enso-frp = { path = "../../../frp" } -enso-logger = { path = "../../../logger" } enso-prelude = { path = "../../../prelude" } -js-sys = { version = "0.3.28" } +js-sys = { workspace = true } wasm-bindgen = { workspace = true } wasm-bindgen-futures = { version = "0.4.8" } diff --git a/lib/rust/ensogl/component/drop-manager/src/lib.rs b/lib/rust/ensogl/component/drop-manager/src/lib.rs index a839d2b3688..bec575b00be 100644 --- a/lib/rust/ensogl/component/drop-manager/src/lib.rs +++ b/lib/rust/ensogl/component/drop-manager/src/lib.rs @@ -20,8 +20,6 @@ /// Commonly used utilities. pub mod prelude { - pub use enso_logger::DefaultWarningLogger as Logger; - pub use enso_logger::*; pub use enso_prelude::*; } diff --git a/lib/rust/ensogl/component/file-browser/src/lib.rs b/lib/rust/ensogl/component/file-browser/src/lib.rs index a308928b629..c772c53070c 100644 --- a/lib/rust/ensogl/component/file-browser/src/lib.rs +++ b/lib/rust/ensogl/component/file-browser/src/lib.rs @@ -77,7 +77,6 @@ ensogl_core::define_endpoints! { /// emits an event when an entry is chosen. #[derive(Clone, CloneRef, Debug)] pub struct FileBrowser { - logger: Logger, frp: Frp, display_object: display::object::Instance, } @@ -93,10 +92,9 @@ impl Deref for FileBrowser { impl FileBrowser { /// Constructore pub fn new() -> Self { - let logger = Logger::new("FileBrowser"); let frp = Frp::new(); let display_object = display::object::Instance::new(); - Self { logger, frp, display_object } + Self { frp, display_object } } } diff --git a/lib/rust/ensogl/component/flame-graph/Cargo.toml b/lib/rust/ensogl/component/flame-graph/Cargo.toml index cdf90661d9a..6ec76909677 100644 --- a/lib/rust/ensogl/component/flame-graph/Cargo.toml +++ b/lib/rust/ensogl/component/flame-graph/Cargo.toml @@ -11,5 +11,5 @@ enso-profiler-flame-graph = { path = "../../../profiler/flame-graph" } enso-profiler = { path = "../../../profiler" } ensogl-hardcoded-theme = { path = "../../app/theme/hardcoded" } ensogl-text = { path = "../text" } -ensogl = { version = "0.1.0", path = "../../../ensogl" } -ensogl-gui-component = { version = "0.1.0", path = "../../component/gui" } +ensogl = { path = "../../../ensogl" } +ensogl-gui-component = { path = "../../component/gui" } diff --git a/lib/rust/ensogl/component/grid-view/Cargo.toml b/lib/rust/ensogl/component/grid-view/Cargo.toml index 71f2179b7e0..b9018054dc0 100644 --- a/lib/rust/ensogl/component/grid-view/Cargo.toml +++ b/lib/rust/ensogl/component/grid-view/Cargo.toml @@ -11,7 +11,7 @@ ensogl-hardcoded-theme = { path = "../../app/theme/hardcoded" } ensogl-shadow = { path = "../shadow" } ensogl-text = { path = "../text" } ensogl-scroll-area = { path = "../scroll-area" } -itertools = "0.10.3" +itertools = { workspace = true } segment-tree = "2.0" [dev-dependencies] diff --git a/lib/rust/ensogl/component/gui/Cargo.toml b/lib/rust/ensogl/component/gui/Cargo.toml index 7ab5b18cbe6..11e9ed3e8f5 100644 --- a/lib/rust/ensogl/component/gui/Cargo.toml +++ b/lib/rust/ensogl/component/gui/Cargo.toml @@ -9,7 +9,6 @@ crate-type = ["rlib", "cdylib"] [dependencies] enso-frp = { path = "../../../frp" } -enso-logger = { path = "../../../logger" } ensogl-core = { path = "../../core" } [dev-dependencies] diff --git a/lib/rust/ensogl/component/gui/src/component.rs b/lib/rust/ensogl/component/gui/src/component.rs index 8631a7d8218..c4f8f49aafd 100644 --- a/lib/rust/ensogl/component/gui/src/component.rs +++ b/lib/rust/ensogl/component/gui/src/component.rs @@ -79,7 +79,6 @@ pub trait Frp: Default + API { #[derivative(Clone(bound = ""))] pub struct ComponentView { widget: Widget, - logger: Logger, } impl ComponentView @@ -89,7 +88,6 @@ where { /// Constructor. pub fn new(app: &Application) -> Self { - let logger = Logger::new(M::label()); let model = Rc::new(M::new(app)); let frp = F::default(); let style = StyleWatchFrp::new(&app.display.default_scene.style_sheet); @@ -97,7 +95,7 @@ where F::init_inputs(frp.public()); let display_object = model.display_object().clone_ref(); let widget = Widget::new(app, frp, model, display_object); - Self { widget, logger } + Self { widget } } /// Get the underlying model diff --git a/lib/rust/ensogl/component/list-view/src/entry.rs b/lib/rust/ensogl/component/list-view/src/entry.rs index b9fcfe2d4e1..75c7e4a9f14 100644 --- a/lib/rust/ensogl/component/list-view/src/entry.rs +++ b/lib/rust/ensogl/component/list-view/src/entry.rs @@ -254,7 +254,7 @@ pub trait ModelProvider: Debug { // === AnyModelProvider === /// A wrapper for shared instance of some Provider of models for `E` entries. -#[derive(Debug, Shrinkwrap)] +#[derive(Debug, Deref)] pub struct AnyModelProvider(Rc>); impl Clone for AnyModelProvider { diff --git a/lib/rust/ensogl/component/list-view/src/entry/list.rs b/lib/rust/ensogl/component/list-view/src/entry/list.rs index fc9c6214de2..b762b5e6fff 100644 --- a/lib/rust/ensogl/component/list-view/src/entry/list.rs +++ b/lib/rust/ensogl/component/list-view/src/entry/list.rs @@ -66,7 +66,6 @@ pub type List = ListData::Params>; #[derivative(Clone(bound = ""))] #[clone_ref(bound = "E:CloneRef")] pub struct ListData { - logger: Logger, app: Application, display_object: display::object::Instance, entries: Rc>>>, @@ -78,25 +77,15 @@ pub struct ListData { impl ListData { /// Entry List View constructor. - pub fn new(parent: impl AnyLogger, app: &Application) -> Self { + pub fn new(app: &Application) -> Self { let app = app.clone_ref(); - let logger = Logger::new_sub(parent, "entry::List"); let entries = default(); let entries_range = Rc::new(CloneCell::new(default()..default())); let entry_params = default(); let display_object = display::object::Instance::new(); let provider = default(); let label_layer = Rc::new(RefCell::new(app.display.default_scene.layers.label.downgrade())); - Self { - logger, - app, - display_object, - entries, - entries_range, - entry_params, - provider, - label_layer, - } + Self { app, display_object, entries, entries_range, entry_params, provider, label_layer } } } diff --git a/lib/rust/ensogl/component/list-view/src/lib.rs b/lib/rust/ensogl/component/list-view/src/lib.rs index 14e9ebdf67c..edd66759a66 100644 --- a/lib/rust/ensogl/component/list-view/src/lib.rs +++ b/lib/rust/ensogl/component/list-view/src/lib.rs @@ -201,10 +201,9 @@ struct Model { impl Model { fn new(app: &Application) -> Self { let app = app.clone_ref(); - let logger = Logger::new("SelectionContainer"); let display_object = display::object::Instance::new(); let scrolled_area = display::object::Instance::new(); - let entries = entry::List::new(logger, &app); + let entries = entry::List::new(&app); let background = background::View::new(); let overlay = overlay::View::new(); let selection = selection::View::new(); diff --git a/lib/rust/ensogl/component/sequence-diagram/Cargo.toml b/lib/rust/ensogl/component/sequence-diagram/Cargo.toml index 7779bdf959a..3bf5e14d88f 100644 --- a/lib/rust/ensogl/component/sequence-diagram/Cargo.toml +++ b/lib/rust/ensogl/component/sequence-diagram/Cargo.toml @@ -8,11 +8,11 @@ edition = "2021" enso-frp = { path = "../../../frp" } enso-profiler = { path = "../../../profiler" } enso-profiler-data = { path = "../../../profiler/data" } -enso-profiler-enso-data = { version = "0.1.0", path = "../../../../../app/gui/enso-profiler-enso-data" } +enso-profiler-enso-data = { path = "../../../../../app/gui/enso-profiler-enso-data" } enso-profiler-flame-graph = { path = "../../../profiler/flame-graph" } -ensogl = { version = "0.1.0", path = "../../../ensogl" } +ensogl = { path = "../../../ensogl" } ensogl-core = { path = "../../core" } -ensogl-gui-component = { version = "0.1.0", path = "../../component/gui" } +ensogl-gui-component = { path = "../../component/gui" } ensogl-hardcoded-theme = { path = "../../app/theme/hardcoded" } ensogl-text = { path = "../text" } -ensogl-tooltip = { version = "0.1.0", path = "../../component/tooltip" } +ensogl-tooltip = { path = "../../component/tooltip" } diff --git a/lib/rust/ensogl/component/sequence-diagram/src/lib.rs b/lib/rust/ensogl/component/sequence-diagram/src/lib.rs index 35dc060f1fc..653a2fbf88f 100644 --- a/lib/rust/ensogl/component/sequence-diagram/src/lib.rs +++ b/lib/rust/ensogl/component/sequence-diagram/src/lib.rs @@ -168,7 +168,7 @@ impl Model { .into_iter() .for_each(|item| item.unset_parent()); } else { - WARNING!("Invalid profile data received"); + warn!("Invalid profile data received"); self.reset() } } diff --git a/lib/rust/ensogl/component/text/Cargo.toml b/lib/rust/ensogl/component/text/Cargo.toml index cf665aa9d6c..7c872c59c53 100644 --- a/lib/rust/ensogl/component/text/Cargo.toml +++ b/lib/rust/ensogl/component/text/Cargo.toml @@ -16,14 +16,14 @@ enso-types = { path = "../../../types" } ensogl-core = { path = "../../core" } ensogl-text-embedded-fonts = { path = "src/font/embedded" } ensogl-text-msdf = { path = "src/font/msdf" } -const_format = "0.2.22" +const_format = { workspace = true } xi-rope = { version = "0.3.0" } -owned_ttf_parser = "0.15.1" -bincode = "2.0.0-rc.1" +owned_ttf_parser = { workspace = true } +bincode = { workspace = true } serde = { version = "1", features = ["rc"] } -ordered-float = "3.0.0" +ordered-float = { workspace = true } ensogl-text-font-family = { path = "src/font/family" } -rustybuzz = "0.5.1" +rustybuzz = { workspace = true } [dev-dependencies] rand = { version = "0.8.5", default-features = false } diff --git a/lib/rust/ensogl/component/text/src/font/embedded/Cargo.toml b/lib/rust/ensogl/component/text/src/font/embedded/Cargo.toml index d967b649e78..e7b464565df 100644 --- a/lib/rust/ensogl/component/text/src/font/embedded/Cargo.toml +++ b/lib/rust/ensogl/component/text/src/font/embedded/Cargo.toml @@ -18,4 +18,4 @@ enso-build = { path = "../../../../../../../../build/build" } enso-build-utilities = { path = "../../../../../../../../build/deprecated/build-utils" } tokio = { workspace = true } zip = { version = "0.6.2", default-features = false, features = ["deflate"] } -owned_ttf_parser = "0.15.1" +owned_ttf_parser = { workspace = true } diff --git a/lib/rust/ensogl/component/text/src/font/family/Cargo.toml b/lib/rust/ensogl/component/text/src/font/family/Cargo.toml index 89da1660ccb..03a616c9b99 100644 --- a/lib/rust/ensogl/component/text/src/font/family/Cargo.toml +++ b/lib/rust/ensogl/component/text/src/font/family/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Enso Team "] edition = "2021" [dependencies] -owned_ttf_parser = "0.15.1" -derive_more = "0.99" +owned_ttf_parser = { workspace = true } +derive_more = { workspace = true } [lib] crate-type = ["cdylib", "rlib"] diff --git a/lib/rust/ensogl/component/text/src/font/msdf/Cargo.toml b/lib/rust/ensogl/component/text/src/font/msdf/Cargo.toml index c2e72d52c51..1a3d7389695 100644 --- a/lib/rust/ensogl/component/text/src/font/msdf/Cargo.toml +++ b/lib/rust/ensogl/component/text/src/font/msdf/Cargo.toml @@ -10,17 +10,17 @@ crate-type = ["cdylib", "rlib"] [dependencies] enso-prelude = { path = "../../../../../../prelude" } enso-types = { path = "../../../../../../types" } -failure = { version = "0.1.6" } -js-sys = { version = "0.3" } -nalgebra = { version = "0.26.1" } +failure = { workspace = true } +js-sys = { workspace = true } +nalgebra = { workspace = true } wasm-bindgen = { workspace = true } serde = { version = "1", features = ["rc", "derive"] } -owned_ttf_parser = "0.15.1" +owned_ttf_parser = { workspace = true } enso-web = { path = "../../../../../../web" } [dev-dependencies] wasm-bindgen-test = { workspace = true } -futures = { version = "0.3.1" } +futures = { workspace = true } ensogl-text-embedded-fonts = { path = "../../../src/font/embedded" } ensogl-text-font-family = { path = "../../../src/font/family" } diff --git a/lib/rust/ensogl/core/Cargo.toml b/lib/rust/ensogl/core/Cargo.toml index 20c803de5e4..136f61c2a59 100644 --- a/lib/rust/ensogl/core/Cargo.toml +++ b/lib/rust/ensogl/core/Cargo.toml @@ -19,7 +19,6 @@ enso-data-structures = { path = "../../data-structures" } enso-debug-api = { path = "../../debug-api" } enso-frp = { path = "../../frp" } enso-generics = { path = "../../generics" } -enso-logger = { path = "../../logger" } enso-prelude = { path = "../../prelude" } enso-profiler = { path = "../../profiler" } enso-shapely = { path = "../../shapely" } @@ -29,20 +28,19 @@ enso-web = { path = "../../web" } ensogl-text-embedded-fonts = { path = "../component/text/src/font/embedded" } bit_field = { version = "0.10.0" } bitflags = { version = "1.3.2" } -console_error_panic_hook = { version = "0.1.6" } +console_error_panic_hook = { workspace = true } enum_dispatch = { version = "0.3.6" } -failure = { version = "0.1.5" } +failure = { workspace = true } Inflector = { version = "0.11.4" } -itertools = { version = "0.10.0" } -js-sys = { version = "0.3.28" } -nalgebra = { version = "0.26.1" } +itertools = { workspace = true } +js-sys = { workspace = true } +nalgebra = { workspace = true } num_enum = { version = "0.5.1" } num-traits = { version = "0.2" } rustc-hash = { version = "1.0.1" } semver = { version = "1.0.9" } serde = { version = "1" } -shrinkwraprs = { version = "0.3.0" } -smallvec = { version = "1.0.0" } +smallvec = { workspace = true } typenum = { version = "1.11.2" } # We require exact version of wasm-bindgen because we do patching final js in our build process, # and this is vulnerable to any wasm-bindgen version change. diff --git a/lib/rust/ensogl/core/src/animation/frp/animation.rs b/lib/rust/ensogl/core/src/animation/frp/animation.rs index fa3891a87bd..cbb6c5a41f8 100644 --- a/lib/rust/ensogl/core/src/animation/frp/animation.rs +++ b/lib/rust/ensogl/core/src/animation/frp/animation.rs @@ -133,13 +133,13 @@ where mix::Repr: inertia::Value /// any animation. This is different behavior from the previous implementation, where even /// setting the value for the first time would create animation between `default()` value and the /// new target. If your code depends on this behavior, it needs to be changed. -#[derive(CloneRef, Derivative, Debug, Shrinkwrap)] +#[derive(CloneRef, Derivative, Debug, Deref)] #[derivative(Clone(bound = ""))] #[allow(missing_docs)] #[allow(non_camel_case_types)] pub struct DEPRECATED_Animation where ::Repr: inertia::Value { - #[shrinkwrap(main_field)] + #[deref] pub simulator: inertia::DynSimulator, pub value: frp::Stream, } diff --git a/lib/rust/ensogl/core/src/animation/frp/animation/delayed.rs b/lib/rust/ensogl/core/src/animation/frp/animation/delayed.rs index ebb83b90bd7..3e0e6265bd3 100644 --- a/lib/rust/ensogl/core/src/animation/frp/animation/delayed.rs +++ b/lib/rust/ensogl/core/src/animation/frp/animation/delayed.rs @@ -41,7 +41,7 @@ crate::define_endpoints! { // ========================= /// Animation that has a delayed onset. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct DelayedAnimation { #[allow(missing_docs)] pub frp: FrpEndpoints, diff --git a/lib/rust/ensogl/core/src/animation/frp/animation/hysteretic.rs b/lib/rust/ensogl/core/src/animation/frp/animation/hysteretic.rs index a02d8568cd8..193379b5bfd 100644 --- a/lib/rust/ensogl/core/src/animation/frp/animation/hysteretic.rs +++ b/lib/rust/ensogl/core/src/animation/frp/animation/hysteretic.rs @@ -54,7 +54,7 @@ crate::define_endpoints! { // =========================== /// Animation that has a delayed onset and offset. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct HystereticAnimation { #[allow(missing_docs)] pub frp: FrpEndpoints, diff --git a/lib/rust/ensogl/core/src/animation/frp/animation/overshoot.rs b/lib/rust/ensogl/core/src/animation/frp/animation/overshoot.rs index 993293b6956..5d2d7b79a2f 100644 --- a/lib/rust/ensogl/core/src/animation/frp/animation/overshoot.rs +++ b/lib/rust/ensogl/core/src/animation/frp/animation/overshoot.rs @@ -93,7 +93,7 @@ crate::define_endpoints! { /// by value set through `set_overshoot_limit` endpoint. Many target value changes can be applied in /// quick succession. After a `set_bounce_delay` amount of time passes since last target change, the /// bounce-back animation is applied by snapping the target value to the closest bound. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct OvershootAnimation { /// Public FRP api. pub frp: FrpEndpoints, diff --git a/lib/rust/ensogl/core/src/application.rs b/lib/rust/ensogl/core/src/application.rs index cfeb53f46e3..46c5a354c52 100644 --- a/lib/rust/ensogl/core/src/application.rs +++ b/lib/rust/ensogl/core/src/application.rs @@ -66,7 +66,6 @@ pub struct Application { #[derive(Debug)] #[allow(missing_docs)] pub struct ApplicationData { - pub logger: Logger, pub cursor: Cursor, pub display: World, pub commands: command::Registry, @@ -87,19 +86,17 @@ impl ApplicationData { impl Application { /// Constructor. pub fn new(dom: impl DomPath) -> Self { - let logger = Logger::new("Application"); let display = World::new(); let scene = &display.default_scene; scene.display_in(dom); - let commands = command::Registry::create(&logger); - let shortcuts = - shortcut::Registry::new(&logger, &scene.mouse.frp, &scene.keyboard.frp, &commands); - let views = view::Registry::create(&logger, &display, &commands, &shortcuts); + let commands = command::Registry::create(); + let shortcuts = shortcut::Registry::new(&scene.mouse.frp, &scene.keyboard.frp, &commands); + let views = view::Registry::create(&display, &commands, &shortcuts); let cursor = Cursor::new(&display.default_scene); display.add_child(&cursor); let frp = Frp::new(); - let data = ApplicationData { logger, cursor, display, commands, shortcuts, views, frp }; + let data = ApplicationData { cursor, display, commands, shortcuts, views, frp }; Self { inner: Rc::new(data) }.init() } diff --git a/lib/rust/ensogl/core/src/application/command.rs b/lib/rust/ensogl/core/src/application/command.rs index 97ce31129c1..d510ccfedc0 100644 --- a/lib/rust/ensogl/core/src/application/command.rs +++ b/lib/rust/ensogl/core/src/application/command.rs @@ -165,18 +165,16 @@ impl ProviderInstance { #[derive(Debug, Clone, CloneRef)] #[allow(missing_docs)] pub struct Registry { - pub logger: Logger, pub name_map: Rc>>>, pub id_map: Rc>>, } impl Registry { /// Constructor. - pub fn create(logger: impl AnyLogger) -> Self { - let logger = Logger::new_sub(logger, "views"); + pub fn create() -> Self { let name_map = default(); let id_map = default(); - Self { logger, name_map, id_map } + Self { name_map, id_map } } /// Registers a gui component as a command provider. @@ -184,7 +182,7 @@ impl Registry { let label = V::label(); let exists = self.name_map.borrow().get(label).is_some(); if exists { - warning!(&self.logger, "The view '{label}' was already registered.") + warn!("The view '{label}' was already registered.") } else { self.name_map.borrow_mut().insert(label.into(), default()); } @@ -219,9 +217,9 @@ impl Registry { let name = name.as_ref(); let id = T::network(target).id(); match self.id_map.borrow_mut().get(&id) { - None => warning!(&self.logger, "The provided component ID is invalid {id}."), + None => warn!("The provided component ID is invalid {id}."), Some(instance) => match instance.command_map.borrow_mut().get_mut(name) { - None => warning!(&self.logger, "The command name {name} is invalid."), + None => warn!("The command name {name} is invalid."), Some(command) => f(command), }, } diff --git a/lib/rust/ensogl/core/src/application/shortcut.rs b/lib/rust/ensogl/core/src/application/shortcut.rs index 7233d197407..20ff2d82a1a 100644 --- a/lib/rust/ensogl/core/src/application/shortcut.rs +++ b/lib/rust/ensogl/core/src/application/shortcut.rs @@ -48,7 +48,7 @@ impl Rule { // =============== /// A command, textual label of action that should be evaluated in the target component. -#[derive(Clone, Debug, Eq, From, Hash, Into, PartialEq, Shrinkwrap)] +#[derive(Clone, Debug, Eq, From, Hash, Into, PartialEq, Deref)] pub struct Command { name: String, } @@ -176,9 +176,9 @@ impl Action { // ================ /// A keyboard shortcut, an `Rule` associated with a `Action`. -#[derive(Clone, Debug, Eq, PartialEq, Hash, Shrinkwrap)] +#[derive(Clone, Debug, Eq, PartialEq, Hash, Deref)] pub struct Shortcut { - #[shrinkwrap(main_field)] + #[deref] action: Action, rule: Rule, } @@ -232,7 +232,6 @@ pub struct Registry { /// Internal representation of `Registry`. #[derive(Clone, CloneRef, Debug)] pub struct RegistryModel { - logger: Logger, keyboard: keyboard::Keyboard, mouse: Mouse, command_registry: command::Registry, @@ -249,12 +248,11 @@ impl Deref for Registry { impl Registry { /// Constructor. pub fn new( - logger: &Logger, mouse: &Mouse, keyboard: &keyboard::Keyboard, cmd_registry: &command::Registry, ) -> Self { - let model = RegistryModel::new(logger, mouse, keyboard, cmd_registry); + let model = RegistryModel::new(mouse, keyboard, cmd_registry); let mouse = &model.mouse; frp::new_network! { network @@ -272,17 +270,15 @@ impl Registry { impl RegistryModel { /// Constructor. pub fn new( - logger: impl AnyLogger, mouse: &Mouse, keyboard: &keyboard::Keyboard, command_registry: &command::Registry, ) -> Self { - let logger = Logger::new_sub(logger, "ShortcutRegistry"); let keyboard = keyboard.clone_ref(); let mouse = mouse.clone_ref(); let command_registry = command_registry.clone_ref(); let shortcuts_registry = default(); - Self { logger, keyboard, mouse, command_registry, shortcuts_registry } + Self { keyboard, mouse, command_registry, shortcuts_registry } } fn process_rules(&self, rules: &[Shortcut]) { @@ -300,10 +296,7 @@ impl RegistryModel { if cmd.enabled { targets.push(cmd.frp.clone_ref()) }, - None => warning!( - &self.logger, - "Command {command_name} was not found on {target}." - ), + None => warn!("Command {command_name} was not found on {target}."), } } } diff --git a/lib/rust/ensogl/core/src/application/view.rs b/lib/rust/ensogl/core/src/application/view.rs index afd47e17f04..47b38ad821c 100644 --- a/lib/rust/ensogl/core/src/application/view.rs +++ b/lib/rust/ensogl/core/src/application/view.rs @@ -26,7 +26,6 @@ pub use command::View; #[derive(Debug, Clone, CloneRef)] #[allow(missing_docs)] pub struct Registry { - pub logger: Logger, pub display: World, pub command_registry: command::Registry, pub shortcut_registry: shortcut::Registry, @@ -36,17 +35,15 @@ pub struct Registry { impl Registry { /// Constructor. pub fn create( - logger: impl AnyLogger, display: &World, command_registry: &command::Registry, shortcut_registry: &shortcut::Registry, ) -> Self { - let logger = Logger::new_sub(logger, "view_registry"); let display = display.clone_ref(); let command_registry = command_registry.clone_ref(); let shortcut_registry = shortcut_registry.clone_ref(); let definitions = default(); - Self { logger, display, command_registry, shortcut_registry, definitions } + Self { display, command_registry, shortcut_registry, definitions } } /// View registration. diff --git a/lib/rust/ensogl/core/src/control/io/mouse.rs b/lib/rust/ensogl/core/src/control/io/mouse.rs index 74a2927e75c..bb243a9854b 100644 --- a/lib/rust/ensogl/core/src/control/io/mouse.rs +++ b/lib/rust/ensogl/core/src/control/io/mouse.rs @@ -29,9 +29,9 @@ pub use event::*; /// A utility which registers JavaScript handlers for mouse events and translates them to Rust /// handlers. It is a top level mouse registry hub. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct MouseManager { - #[shrinkwrap(main_field)] + #[deref] dispatchers: MouseManagerDispatchers, handles: Rc, dom: web::dom::WithKnownShape, diff --git a/lib/rust/ensogl/core/src/control/io/mouse/event.rs b/lib/rust/ensogl/core/src/control/io/mouse/event.rs index 10e596d3fd4..aba3a64f178 100644 --- a/lib/rust/ensogl/core/src/control/io/mouse/event.rs +++ b/lib/rust/ensogl/core/src/control/io/mouse/event.rs @@ -17,9 +17,9 @@ use web::dom::Shape; macro_rules! define_events { ( $( $js_event:ident :: $name:ident ),* $(,)? ) => {$( /// Mouse event wrapper. - #[derive(Debug,Clone,From,Shrinkwrap)] + #[derive(Debug, Clone, From, Deref, AsRef)] pub struct $name { - #[shrinkwrap(main_field)] + #[deref] raw : web::$js_event, shape : Shape, } diff --git a/lib/rust/ensogl/core/src/data/bounding_box.rs b/lib/rust/ensogl/core/src/data/bounding_box.rs index 406629336ac..1b6f9c3a026 100644 --- a/lib/rust/ensogl/core/src/data/bounding_box.rs +++ b/lib/rust/ensogl/core/src/data/bounding_box.rs @@ -189,8 +189,8 @@ mod tests { let bbox2: BoundingBox = $bbox2.into(); let bbox3: BoundingBox = $bbox3.into(); let result = bbox1.concat(bbox2); - let assert_msg = iformat!( - "Concat result was expected to be: " bbox3;? " but got: " result;? " instead."); + let assert_msg = format!( + "Concat result was expected to be: {bbox3:?}, but got: {result:?} instead."); assert_eq!(result.left, bbox3.left, "{}", assert_msg); assert_eq!(result.right, bbox3.right, "{}", assert_msg); assert_eq!(result.top, bbox3.top, "{}", assert_msg); @@ -222,10 +222,10 @@ mod tests { let result = bbox.squared_distance_to_point(point); let result_deviation = (result - $expected_sq_distance).abs(); let result_ok = result_deviation < SQUARED_DISTANCE_COMPARISON_PRECISION; - let assert_msg = iformat!( - "Squared distance between " bbox;? " and " point;? - " expected to approximately equal " $expected_sq_distance - ", but got " result " instead."); + let assert_msg = format!( + "Squared distance between {bbox:?} and {point:?} \ + expected to approximately equal {}, \ + but got {result} instead.", $expected_sq_distance); assert!(result_ok, "{}", assert_msg); }; } diff --git a/lib/rust/ensogl/core/src/data/color/gradient.rs b/lib/rust/ensogl/core/src/data/color/gradient.rs index 177b4e8839e..7262c06e974 100644 --- a/lib/rust/ensogl/core/src/data/color/gradient.rs +++ b/lib/rust/ensogl/core/src/data/color/gradient.rs @@ -73,9 +73,9 @@ where [Color:RefInto] { let args = t.control_points.iter().map(|control_point| { let offset = control_point.offset.glsl(); let color = control_point.color.glsl(); - iformat!("gradient_control_point({offset},{color})") + format!("gradient_control_point({offset},{color})") }).join(","); - iformat!("gradient({args})").into() + format!("gradient({args})").into() } }} @@ -151,16 +151,16 @@ impl ContentRef for SdfSampler { impls! {[G:RefInto] From< SdfSampler> for Glsl { |g| { (&g).into() } }} impls! {[G:RefInto] From<&SdfSampler> for Glsl { |g| { - let size = iformat!("{g.size.glsl()}"); - let offset = iformat!("-shape.sdf.distance + {g.spread.glsl()}"); - let norm = iformat!("clamp(({offset}) / ({size}))"); + let size = format!("{}", g.size.glsl()); + let offset = format!("-shape.sdf.distance + {}", g.spread.glsl()); + let norm = format!("clamp(({offset}) / ({size}))"); let t = match &g.slope { Slope::Linear => norm, - Slope::Smooth => iformat!("smoothstep(0.0,1.0,{norm})"), - Slope::Exponent(exp) => iformat!("pow({norm},{exp.glsl()})"), - Slope::InvExponent(exp) => iformat!("1.0-pow(1.0-{norm},{exp.glsl()})"), + Slope::Smooth => format!("smoothstep(0.0,1.0,{norm})"), + Slope::Exponent(exp) => format!("pow({norm},{})", exp.glsl()), + Slope::InvExponent(exp) => format!("1.0-pow(1.0-{norm},{})", exp.glsl()), }; - let expr = iformat!("sample({g.gradient.glsl()},{t})"); + let expr = format!("sample({},{t})", g.gradient.glsl()); expr.into() } }} diff --git a/lib/rust/ensogl/core/src/data/dirty.rs b/lib/rust/ensogl/core/src/data/dirty.rs index c8a0ef4e82d..9a020147b38 100644 --- a/lib/rust/ensogl/core/src/data/dirty.rs +++ b/lib/rust/ensogl/core/src/data/dirty.rs @@ -669,7 +669,7 @@ define_flag! { pub trait SetItem = Eq + Hash + Debug; /// Internal representation of the [`Set`] flag. -#[derive(Derivative, Shrinkwrap)] +#[derive(Derivative, Deref)] #[derivative(Debug(bound = "Item:SetItem"))] #[derivative(Default(bound = "Item:SetItem"))] #[allow(missing_docs)] @@ -739,7 +739,7 @@ define_flag! { pub trait VectorItem = Debug + PartialEq; /// Internal representation of the [`Vector`] flag. -#[derive(Derivative, Debug, Shrinkwrap)] +#[derive(Derivative, Debug, Deref)] #[derivative(Default(bound = ""))] #[allow(missing_docs)] pub struct VectorData { diff --git a/lib/rust/ensogl/core/src/data/seq/observable.rs b/lib/rust/ensogl/core/src/data/seq/observable.rs index 2419d0f95e9..936ba63177e 100644 --- a/lib/rust/ensogl/core/src/data/seq/observable.rs +++ b/lib/rust/ensogl/core/src/data/seq/observable.rs @@ -14,11 +14,11 @@ use crate::data::function::traits::FnMut1; /// Wrapper for array-like type. It allows attaching callbacks which fire when the underlying /// structure changes. -#[derive(Shrinkwrap)] +#[derive(Deref)] #[derive(Derivative)] #[derivative(Clone, Debug(bound = "T:Debug"))] pub struct Observable { - #[shrinkwrap(main_field)] + #[deref] pub data: T, #[derivative(Debug = "ignore")] pub on_mut: OnMut, diff --git a/lib/rust/ensogl/core/src/debug/monitor.rs b/lib/rust/ensogl/core/src/debug/monitor.rs index f659647f7c6..5da45876320 100644 --- a/lib/rust/ensogl/core/src/debug/monitor.rs +++ b/lib/rust/ensogl/core/src/debug/monitor.rs @@ -135,7 +135,7 @@ impl Config { /// Dom elements of the monitor. Please note that it uses `Rc` to both implement cheap copy as well /// as to use `Drop` to clean the HTML when not used anymore. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct Dom { rc: Rc, } @@ -870,7 +870,7 @@ stats_sampler!( // let tested_value = $test.sampler.value(&prev_frame_stats); // let tested_check = $test.sampler.check(&prev_frame_stats); // assert_approx_eq!(tested_value, $expected_value, -// STAT_VALUE_COMPARISON_PRECISION); let mismatch_msg = iformat!( +// STAT_VALUE_COMPARISON_PRECISION); let mismatch_msg = format!( // "Stat check was expected to return: " $expected_check;? // ", but got: " tested_check;? " instead."); // assert!(matches!(tested_check, $expected_check), "{}", mismatch_msg); @@ -886,7 +886,7 @@ stats_sampler!( // // ($test:expr, None; next: $frame_time:expr, $post_frame_delay:expr) => { // let prev_frame_stats = $test.stats.begin_frame(Duration(*$test.t.t.borrow() as f32)); -// let mismatch_msg = iformat!( +// let mismatch_msg = format!( // "Expected no stats to be returned by begin_frame(), but got: " // prev_frame_stats;? " instead."); // assert!(matches!(prev_frame_stats, None), "{}", mismatch_msg); diff --git a/lib/rust/ensogl/core/src/display/navigation/navigator.rs b/lib/rust/ensogl/core/src/display/navigation/navigator.rs index e1f238d7974..6f392b79db7 100644 --- a/lib/rust/ensogl/core/src/display/navigation/navigator.rs +++ b/lib/rust/ensogl/core/src/display/navigation/navigator.rs @@ -169,15 +169,14 @@ impl NavigatorModel { simulator.update_target_value(|p| p - diff); }); - let resize_callback = - camera.add_screen_update_callback(enclose!((mut simulator,camera) move |_| { - let position = camera.position(); - simulator.set_value(position); - simulator.set_target_value(position); - simulator.set_velocity(default()); - })); + let resize_callback = camera.add_screen_update_callback(f_!([simulator, camera] { + let position = camera.position(); + simulator.set_value(position); + simulator.set_target_value(position); + simulator.set_velocity(default()); + })); - let zoom_callback = f!([camera,simulator,settings] (zoom:ZoomEvent) { + let zoom_callback = f!([camera, simulator, settings] (zoom: ZoomEvent) { let point = zoom.focus; let normalized = normalize_point2(point,camera.screen().into()); let normalized = normalized_to_range2(normalized, -1.0, 1.0); @@ -258,11 +257,11 @@ define_endpoints_2! { // ================= /// Navigator enables camera navigation with mouse interactions. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct Navigator { #[allow(missing_docs)] pub frp: Frp, - #[shrinkwrap(main_field)] + #[deref] model: Rc, } diff --git a/lib/rust/ensogl/core/src/display/render/pass.rs b/lib/rust/ensogl/core/src/display/render/pass.rs index 0082e8e001e..ee91be941f9 100644 --- a/lib/rust/ensogl/core/src/display/render/pass.rs +++ b/lib/rust/ensogl/core/src/display/render/pass.rs @@ -96,7 +96,7 @@ impl Instance { context.bind_framebuffer(*target, None); let framebuffer_status = context.check_framebuffer_status(*Context::FRAMEBUFFER); if framebuffer_status != *Context::FRAMEBUFFER_COMPLETE { - WARNING!("Framebuffer incomplete (status: {framebuffer_status}).") + warn!("Framebuffer incomplete (status: {framebuffer_status}).") } Framebuffer { context, native } } diff --git a/lib/rust/ensogl/core/src/display/render/passes/pixel_read.rs b/lib/rust/ensogl/core/src/display/render/passes/pixel_read.rs index a047f3cafe2..731df217e71 100644 --- a/lib/rust/ensogl/core/src/display/render/passes/pixel_read.rs +++ b/lib/rust/ensogl/core/src/display/render/passes/pixel_read.rs @@ -131,7 +131,7 @@ impl PixelReadPass { context.bind_framebuffer(*target, None); let framebuffer_status = context.check_framebuffer_status(*Context::FRAMEBUFFER); if framebuffer_status != *Context::FRAMEBUFFER_COMPLETE { - WARNING!("Framebuffer incomplete (status: {framebuffer_status}).") + warn!("Framebuffer incomplete (status: {framebuffer_status}).") } let data = PixelReadPassData::new(buffer, framebuffer, format, item_type, js_array); self.data = Some(data); diff --git a/lib/rust/ensogl/core/src/display/render/passes/symbols.rs b/lib/rust/ensogl/core/src/display/render/passes/symbols.rs index 03f0176e5cf..0fc01f3363e 100644 --- a/lib/rust/ensogl/core/src/display/render/passes/symbols.rs +++ b/lib/rust/ensogl/core/src/display/render/passes/symbols.rs @@ -32,7 +32,6 @@ impl Framebuffers { /// Pass for rendering all symbols. The results are stored in the 'color' and 'id' outputs. #[derive(Clone, Debug)] pub struct SymbolsRenderPass { - logger: Logger, layers: scene::HardcodedLayers, framebuffers: Option, mask_composer: MaskComposer, @@ -40,13 +39,12 @@ pub struct SymbolsRenderPass { impl SymbolsRenderPass { /// Constructor. - pub fn new(logger: impl AnyLogger, layers: &scene::HardcodedLayers) -> Self { - let logger = Logger::new_sub(logger, "SymbolsRenderPass"); + pub fn new(layers: &scene::HardcodedLayers) -> Self { let layers = layers.clone_ref(); let framebuffers = default(); let mask_composer = MaskComposer::new("pass_mask_color", "pass_layer_color", "pass_layer_id"); - Self { logger, layers, framebuffers, mask_composer } + Self { layers, framebuffers, mask_composer } } } @@ -94,8 +92,7 @@ impl pass::Definition for SymbolsRenderPass { let mut scissor_stack = default(); self.render_layer(instance, &self.layers.root.clone(), &mut scissor_stack, false); if !scissor_stack.is_empty() { - warning!( - &self.logger, + warn!( "The scissor stack was not cleaned properly. \ This is an internal bug that may lead to visual artifacts. Please report it." ); @@ -145,10 +142,7 @@ impl SymbolsRenderPass { let nested_masking = is_masked && parent_masked; if nested_masking { - warning!( - &self.logger, - "Nested layer masking is not supported yet. Skipping nested masks." - ); + warn!("Nested layer masking is not supported yet. Skipping nested masks."); } else if let Some(mask) = layer_mask { framebuffers.mask.bind(); let black_transparent = [0.0, 0.0, 0.0, 0.0]; diff --git a/lib/rust/ensogl/core/src/display/scene.rs b/lib/rust/ensogl/core/src/display/scene.rs index ec4f240210f..c25e2e4f9c5 100644 --- a/lib/rust/ensogl/core/src/display/scene.rs +++ b/lib/rust/ensogl/core/src/display/scene.rs @@ -105,7 +105,7 @@ impl PointerTargetRegistry { match self.get(target) { Some(target) => Some(f(&target)), None => { - WARNING!("Internal error. Symbol ID {target:?} is not registered."); + warn!("Internal error. Symbol ID {target:?} is not registered."); None } } diff --git a/lib/rust/ensogl/core/src/display/scene/dom.rs b/lib/rust/ensogl/core/src/display/scene/dom.rs index d9cb5033aa2..d626476f9b5 100644 --- a/lib/rust/ensogl/core/src/display/scene/dom.rs +++ b/lib/rust/ensogl/core/src/display/scene/dom.rs @@ -156,7 +156,7 @@ impl DomSceneData { /// To make use of its functionalities, the API user can create a `Css3dSystem` by using /// the `DomScene::new_system` method which creates and manages instances of /// `DomSymbol`s. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct DomScene { data: Rc, } diff --git a/lib/rust/ensogl/core/src/display/scene/layer.rs b/lib/rust/ensogl/core/src/display/scene/layer.rs index cd8fc30c569..b4a427ebd84 100644 --- a/lib/rust/ensogl/core/src/display/scene/layer.rs +++ b/lib/rust/ensogl/core/src/display/scene/layer.rs @@ -29,7 +29,7 @@ use std::any::TypeId; bitflags::bitflags! { /// A set of flags associated with each [`Layer`]. - #[derive(Shrinkwrap)] + #[derive(Deref)] pub struct LayerFlags: u8 { /// When layer is `MAIN_PASS_VISIBLE`, it will be rendered during standard color buffer /// render pass. Layers without this flag are not rendered in main pass, but can still be diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/def/class.rs b/lib/rust/ensogl/core/src/display/shape/primitive/def/class.rs index 50bc610c338..03ea02ff6b6 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/def/class.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/def/class.rs @@ -49,7 +49,7 @@ impl canvas::Draw for AnyShape { // ================ /// Immutable reference to a shape. It is also used to get unique id for each shape. -#[derive(Debug, Derivative, Shrinkwrap)] +#[derive(Debug, Derivative, Deref)] #[derivative(Clone(bound = ""))] pub struct ShapeRef { rc: Rc, diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/def/primitive.rs b/lib/rust/ensogl/core/src/display/shape/primitive/def/primitive.rs index fa263552f72..3d5244e1b7d 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/def/primitive.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/def/primitive.rs @@ -99,7 +99,7 @@ macro_rules! _define_sdf_shape_immutable_part { let args = vec!["vec2 position".to_string(), $( format!("{} {}", <$field_type>::glsl_prim_type(), stringify!($field)) ),*].join(", "); - iformat!("BoundSdf {name} ({args}) {body}") + format!("BoundSdf {name} ({args}) {body}") } } diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs b/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs index 1e05a0ac2ae..65abcb6f3b1 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs @@ -341,7 +341,7 @@ where T: Neg + RefInto fn neg(self) -> Self::Output { match self { Var::Static(t) => Var::Static(-t), - Var::Dynamic(t) => Var::Dynamic(iformat!("neg({t})").into()), + Var::Dynamic(t) => Var::Dynamic(format!("neg({t})").into()), } } } @@ -353,7 +353,7 @@ where &'t T: Neg + Into fn neg(self) -> Self::Output { match self { Var::Static(t) => Var::Static(-t), - Var::Dynamic(t) => Var::Dynamic(iformat!("neg({t})").into()), + Var::Dynamic(t) => Var::Dynamic(format!("neg({t})").into()), } } } @@ -505,8 +505,8 @@ impl Var { let e1 = e1.glsl(); let e2 = e2.glsl(); match self { - Var::Static(t) => Var::Dynamic(iformat!("smoothstep({e1},{e2},{t})").into()), - Var::Dynamic(t) => Var::Dynamic(iformat!("smoothstep({e1},{e2},{t})").into()), + Var::Static(t) => Var::Dynamic(format!("smoothstep({e1},{e2},{t})").into()), + Var::Dynamic(t) => Var::Dynamic(format!("smoothstep({e1},{e2},{t})").into()), } } } @@ -517,8 +517,8 @@ impl Var { let e1 = e1.glsl(); let e2 = e2.glsl(); match self { - Var::Static(t) => Var::Dynamic(iformat!("mix({e1},{e2},{t})").into()), - Var::Dynamic(t) => Var::Dynamic(iformat!("mix({e1},{e2},{t})").into()), + Var::Static(t) => Var::Dynamic(format!("mix({e1},{e2},{t})").into()), + Var::Dynamic(t) => Var::Dynamic(format!("mix({e1},{e2},{t})").into()), } } } diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs b/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs index 679cb4f1059..ca9ba000742 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs @@ -43,7 +43,7 @@ impl Builder { let mut canvas = Canvas::default(); let shape_ref = shape.draw(&mut canvas); let shape_header = header("Shape Definition"); - canvas.add_current_function_code_line(iformat!("return {shape_ref.getter()};")); + canvas.add_current_function_code_line(format!("return {};", shape_ref.getter())); canvas.submit_shape_constructor("run"); let shape_def = overload::allow_overloading(&canvas.to_glsl()); let code = [GLSL_BOILERPLATE.as_str(), "", &shape_header, &shape_def].join("\n\n"); @@ -63,7 +63,7 @@ impl Builder { fn header(label: &str) -> String { let border_len = label.len() + 8; let border = "=".repeat(border_len); - iformat!("// {border}\n// === {label} ===\n// {border}") + format!("// {border}\n// === {label} ===\n// {border}") } diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs b/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs index 3efee363868..821c13bf828 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs @@ -14,7 +14,7 @@ use crate::system::gpu::shader::glsl::Glsl; // ============= /// Immutable reference to a shape defined on `Canvas` with a fast clone. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct Shape { rc: Rc, } @@ -49,7 +49,7 @@ impl ShapeData { /// Getter of the shape as GLSL expression. pub fn getter(&self) -> String { - iformat!("{self.name}(position)") + format!("{}(position)", self.name) } } @@ -110,13 +110,13 @@ impl Canvas { /// Defines a new variable in the GLSL code. pub fn define(&mut self, ty: &str, name: &str, expr: E) { - self.add_current_function_code_line(iformat!("{ty} {name} = {expr.as_ref()};")); + self.add_current_function_code_line(format!("{ty} {name} = {};", expr.as_ref())); } /// Submits the `current_function_lines` as a new shape construction function in the GLSL code. pub fn submit_shape_constructor(&mut self, name: &str) { let body = self.current_function_lines.join("\n "); - let func = iformat!("Shape {name} (vec2 position) {{\n {body}\n}}"); + let func = format!("Shape {name} (vec2 position) {{\n {body}\n}}"); self.current_function_lines = default(); self.functions.push(func); } @@ -145,8 +145,8 @@ impl Canvas { // of shape pointer. This is important for shader caching based on generated GLSL code. let id = this.get_new_id(); let shape = ShapeData::new(id); - this.define("BoundSdf", "sdf", iformat!("{sdf}")); - this.define("Id", "id", iformat!("new_id_layer(sdf,{id})")); + this.define("BoundSdf", "sdf", sdf.to_string()); + this.define("Id", "id", format!("new_id_layer(sdf,{id})")); this.add_current_function_code_line("return shape(id, sdf);"); this.submit_shape_constructor(&shape.name); shape @@ -171,7 +171,7 @@ impl Canvas { /// Create a union shape from the provided shape components. pub fn union(&mut self, num: usize, s1: Shape, s2: Shape) -> Shape { self.if_not_defined(num, |this| { - let expr = iformat!("return unify({s1.getter()},{s2.getter()});"); + let expr = format!("return unify({},{});", s1.getter(), s2.getter()); this.new_shape_from_expr(&expr) }) } @@ -179,7 +179,7 @@ impl Canvas { /// Create a difference shape from the provided shape components. pub fn difference(&mut self, num: usize, s1: Shape, s2: Shape) -> Shape { self.if_not_defined(num, |this| { - let expr = iformat!("return difference({s1.getter()},{s2.getter()});"); + let expr = format!("return difference({},{});", s1.getter(), s2.getter()); this.new_shape_from_expr(&expr) }) } @@ -187,7 +187,7 @@ impl Canvas { /// Create a difference shape from the provided shape components. pub fn intersection(&mut self, num: usize, s1: Shape, s2: Shape) -> Shape { self.if_not_defined(num, |this| { - let expr = iformat!("return intersection({s1.getter()},{s2.getter()});"); + let expr = format!("return intersection({},{});", s1.getter(), s2.getter()); this.new_shape_from_expr(&expr) }) } @@ -201,8 +201,8 @@ impl Canvas { ) -> Shape { self.if_not_defined(num, |this| { let v = v.into().glsl(); - let trans = iformat!("position = translate(position,{v});"); - let expr = iformat!("return {s1.getter()};"); + let trans = format!("position = translate(position,{v});"); + let expr = format!("return {};", s1.getter()); this.add_current_function_code_line(trans); this.new_shape_from_expr(&expr) }) @@ -212,8 +212,8 @@ impl Canvas { pub fn rotation>>(&mut self, num: usize, s1: Shape, angle: A) -> Shape { self.if_not_defined(num, |this| { let angle: Glsl = angle.into().glsl(); - let trans = iformat!("position = rotate(position,{angle});"); - let expr = iformat!("return {s1.getter()};"); + let trans = format!("position = rotate(position,{angle});"); + let expr = format!("return {};", s1.getter()); this.add_current_function_code_line(trans); this.new_shape_from_expr(&expr) }) @@ -223,8 +223,8 @@ impl Canvas { pub fn scale>>(&mut self, num: usize, s1: Shape, value: T) -> Shape { self.if_not_defined(num, |this| { let value: Glsl = value.into().glsl(); - let trans = iformat!("position = scale(position,{value});"); - let expr = iformat!("return resample({s1.getter()},{value});"); + let trans = format!("position = scale(position,{value});"); + let expr = format!("return resample({},{value});", s1.getter()); this.add_current_function_code_line(trans); this.new_shape_from_expr(&expr) }) @@ -239,17 +239,16 @@ impl Canvas { ) -> Shape { self.if_not_defined(num, |this| { let color: Glsl = color.into().glsl(); - this.add_current_function_code_line(iformat!("Shape shape = {s.getter()};")); - this.add_current_function_code_line(iformat!("Srgba color = srgba({color});")); - let expr = iformat!("return set_color(shape,color);"); - this.new_shape_from_expr(&expr) + this.add_current_function_code_line(format!("Shape shape = {};", s.getter())); + this.add_current_function_code_line(format!("Srgba color = srgba({color});")); + this.new_shape_from_expr("return set_color(shape,color);") }) } /// Make the borders of the shape crisp. Please note that it removes any form of antialiasing. pub fn pixel_snap(&mut self, num: usize, s: Shape) -> Shape { self.if_not_defined(num, |this| { - let expr = iformat!("return pixel_snap({s.getter()});"); + let expr = format!("return pixel_snap({});", s.getter()); this.new_shape_from_expr(&expr) }) } @@ -258,7 +257,7 @@ impl Canvas { pub fn grow>>(&mut self, num: usize, s: Shape, value: T) -> Shape { self.if_not_defined(num, |this| { let value: Glsl = value.into().glsl(); - let expr = iformat!("return grow({s.getter()},{value});"); + let expr = format!("return grow({},{value});", s.getter()); this.new_shape_from_expr(&expr) }) } @@ -278,8 +277,8 @@ impl Canvas { ) -> Shape { self.if_not_defined(num, |this| { let value: Glsl = tile_size.into().glsl(); - let repeat = iformat!("position = repeat(position,{value});"); - let expr = iformat!("return with_infinite_bounds({s.getter()});"); + let repeat = format!("position = repeat(position,{value});"); + let expr = format!("return with_infinite_bounds({});", s.getter()); this.add_current_function_code_line(repeat); this.new_shape_from_expr(&expr) }) diff --git a/lib/rust/ensogl/core/src/display/style/sheet.rs b/lib/rust/ensogl/core/src/display/style/sheet.rs index fca7e1e5b66..466e180841d 100644 --- a/lib/rust/ensogl/core/src/display/style/sheet.rs +++ b/lib/rust/ensogl/core/src/display/style/sheet.rs @@ -701,10 +701,10 @@ impl SheetData { let sheet_node_index = node_map.value; let sheet_node = &self.nodes[sheet_node_index]; let value = format!("{:?}", sheet_node.value); - let label = iformat!("sheet_{sheet_node_index}({value})"); - dot.push_str(&iformat!("sheet_{sheet_node_index} [label=\"{label}\"]\n")); + let label = format!("sheet_{sheet_node_index}({value})"); + dot.push_str(&format!("sheet_{sheet_node_index} [label=\"{label}\"]\n")); for (path, child) in &node_map.branches { - let attrs = iformat!("[label=\"{path}\"]"); + let attrs = format!("[label=\"{path}\"]"); Self::sheet_node_sheet_node_link(dot, sheet_node_index, child.value, attrs); self.sheet_node_map_to_graphviz(dot, child); } @@ -720,7 +720,7 @@ impl SheetData { let query = &self.queries[query_index]; let scope = if query.is_external() { "External" } else { "Internal" }; let real_path = path.iter().rev().join("."); - dot.push_str(&iformat!("query_{query_index} [label=\"{scope} Query({real_path})\"]\n")); + dot.push_str(&format!("query_{query_index} [label=\"{scope} Query({real_path})\"]\n")); }); for (segment, child) in &query_map.branches { path.push(segment.into()); diff --git a/lib/rust/ensogl/core/src/display/style/theme.rs b/lib/rust/ensogl/core/src/display/style/theme.rs index 4f75ec60bcd..2c4ee5b3062 100644 --- a/lib/rust/ensogl/core/src/display/style/theme.rs +++ b/lib/rust/ensogl/core/src/display/style/theme.rs @@ -223,7 +223,6 @@ impl From<&style::Sheet> for ManagerData { /// Theme manager. Allows registering themes by names, enabling, and disabling them. #[derive(Clone, CloneRef, Debug)] pub struct Manager { - logger: Logger, data: Rc>, handles: Rc>>, current_dirty: dirty::SharedBool, @@ -234,13 +233,12 @@ pub struct Manager { impl Manager { /// Constructor. pub fn new() -> Self { - let logger = Logger::new("Theme Manager"); let current_dirty = dirty::SharedBool::new(()); let enabled_dirty = dirty::SharedVector::new(()); let data = default(); let handles = default(); let initialized = default(); - Self { logger, data, handles, current_dirty, enabled_dirty, initialized } + Self { data, handles, current_dirty, enabled_dirty, initialized } } /// Return a theme of the given name. diff --git a/lib/rust/ensogl/core/src/display/symbol/dom.rs b/lib/rust/ensogl/core/src/display/symbol/dom.rs index fd4d0b49132..185746dc7a4 100644 --- a/lib/rust/ensogl/core/src/display/symbol/dom.rs +++ b/lib/rust/ensogl/core/src/display/symbol/dom.rs @@ -99,9 +99,9 @@ impl Drop for Guard { // ================= /// A DOM element which is managed by the rendering engine. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct DomSymbol { - #[shrinkwrap(main_field)] + #[deref] dom: HtmlDivElement, display_object: display::object::Instance, size: Rc>>, diff --git a/lib/rust/ensogl/core/src/display/symbol/gpu.rs b/lib/rust/ensogl/core/src/display/symbol/gpu.rs index c4b756ce71d..c1c9786cc50 100644 --- a/lib/rust/ensogl/core/src/display/symbol/gpu.rs +++ b/lib/rust/ensogl/core/src/display/symbol/gpu.rs @@ -125,7 +125,7 @@ impl TextureBinding { /// A safe wrapper for WebGL VertexArrayObject. It releases the VAO from GPU memory as soon as all /// references to this object are dropped. -#[derive(Clone, Debug, Shrinkwrap)] +#[derive(Clone, Debug, Deref)] pub struct VertexArrayObject { rc: Rc, } @@ -189,13 +189,13 @@ impl Drop for VertexArrayObjectData { // =================== /// Wrapper for `Stats` which counts the number of symbols. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct SymbolStats { rc: Rc, } /// Internal representation for `SymbolStats`. -#[derive(Debug, Shrinkwrap)] +#[derive(Debug, Deref)] pub struct SymbolStatsData { stats: Stats, } diff --git a/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/mask_composer.rs b/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/mask_composer.rs index 63b511a66f4..66c29089754 100644 --- a/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/mask_composer.rs +++ b/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/mask_composer.rs @@ -10,7 +10,7 @@ use crate::system::gpu::data::texture; /// A geometry which always covers the whole screen which when rendered outputs an image by /// composing three input textures: mask, color, and id. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] pub struct MaskComposer { screen: Screen, } @@ -31,7 +31,7 @@ impl MaskComposer { let color = color.as_ref(); let id = id.as_ref(); let mut material = Material::new(); - let shader = iformat!( + let shader = format!( " vec4 sample_mask = texture(input_{mask},input_uv); vec4 sample_color = texture(input_{color},input_uv); diff --git a/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/screen.rs b/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/screen.rs index b4925a3eb4f..1cd549512c8 100644 --- a/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/screen.rs +++ b/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/screen.rs @@ -71,7 +71,7 @@ impl Screen { fn identity_painter_surface_material(input: impl AsRef) -> Material { let input = input.as_ref(); let mut material = Material::new(); - let shader = iformat!( + let shader = format!( " vec4 sample_color = texture(input_{input}, input_uv); output_color = sample_color; diff --git a/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/sprite.rs b/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/sprite.rs index 7d3151d8a3c..4524781e32c 100644 --- a/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/sprite.rs +++ b/lib/rust/ensogl/core/src/display/symbol/gpu/geometry/compound/sprite.rs @@ -31,7 +31,7 @@ const DEFAULT_SPRITE_SIZE: (f32, f32) = (10.0, 10.0); // =================== /// Wrapper for `Stats` which counts the number of sprites. -#[derive(Debug, Shrinkwrap)] +#[derive(Debug, Deref)] pub struct SpriteStats { stats: Stats, } diff --git a/lib/rust/ensogl/core/src/display/symbol/gpu/material.rs b/lib/rust/ensogl/core/src/display/symbol/gpu/material.rs index c7f61acddee..b6bb4f97420 100644 --- a/lib/rust/ensogl/core/src/display/symbol/gpu/material.rs +++ b/lib/rust/ensogl/core/src/display/symbol/gpu/material.rs @@ -45,11 +45,10 @@ impl + TryInto> From for VarDecl { // ================ /// Abstraction for look and feel of a `Symbol`. Under the hood, material defines a GLSL shader. -#[derive(Clone, Debug, Default, Shrinkwrap)] -#[shrinkwrap(mutable)] -#[shrinkwrap(unsafe_ignore_visibility)] +#[derive(Clone, Debug, Default, Deref, DerefMut)] pub struct Material { - #[shrinkwrap(main_field)] + #[deref] + #[deref_mut] code: CodeTemplate, inputs: BTreeMap, outputs: BTreeMap, diff --git a/lib/rust/ensogl/core/src/display/world.rs b/lib/rust/ensogl/core/src/display/world.rs index 1dcbe3ae183..f7409723756 100644 --- a/lib/rust/ensogl/core/src/display/world.rs +++ b/lib/rust/ensogl/core/src/display/world.rs @@ -392,7 +392,7 @@ impl WorldData { let stats_monitor = debug::monitor::Monitor::new(); let on = Callbacks::default(); let scene_dirty = dirty::SharedBool::new(()); - let on_change = enclose!((scene_dirty) move || scene_dirty.set()); + let on_change = f!(scene_dirty.set()); let display_mode = Rc::>::default(); let default_scene = Scene::new(&stats, on_change, &display_mode); let uniforms = Uniforms::new(&default_scene.variables); @@ -490,9 +490,8 @@ impl WorldData { pixel_read_pass.set_sync_callback(f!(garbage_collector.pixel_synced())); // TODO: We may want to enable it on weak hardware. // pixel_read_pass.set_threshold(1); - let logger = Logger::new("renderer"); let pipeline = render::Pipeline::new() - .add(SymbolsRenderPass::new(logger, &self.default_scene.layers)) + .add(SymbolsRenderPass::new(&self.default_scene.layers)) .add(ScreenRenderPass::new()) .add(pixel_read_pass); self.default_scene.renderer.set_pipeline(pipeline); diff --git a/lib/rust/ensogl/core/src/gui/cursor.rs b/lib/rust/ensogl/core/src/gui/cursor.rs index 8c042d49d6c..923d96370da 100644 --- a/lib/rust/ensogl/core/src/gui/cursor.rs +++ b/lib/rust/ensogl/core/src/gui/cursor.rs @@ -188,7 +188,6 @@ crate::define_endpoints_2! { #[derive(Clone, CloneRef, Debug)] #[allow(missing_docs)] pub struct CursorModel { - pub logger: Logger, pub scene: Scene, pub display_object: display::object::Instance, pub view: shape::View, @@ -200,7 +199,6 @@ impl CursorModel { /// Constructor. pub fn new(scene: &Scene) -> Self { let scene = scene.clone_ref(); - let logger = Logger::new("cursor"); let display_object = display::object::Instance::new(); let view = shape::View::new(); let port_selection = shape::View::new(); @@ -213,7 +211,7 @@ impl CursorModel { tgt_layer.add(&view); port_selection_layer.add(&port_selection); - Self { logger, scene, display_object, view, port_selection, style } + Self { scene, display_object, view, port_selection, style } } fn for_each_view(&self, f: impl Fn(&shape::View)) { diff --git a/lib/rust/ensogl/core/src/lib.rs b/lib/rust/ensogl/core/src/lib.rs index 37575048c5a..fa0bbdf9395 100644 --- a/lib/rust/ensogl/core/src/lib.rs +++ b/lib/rust/ensogl/core/src/lib.rs @@ -76,10 +76,6 @@ pub mod prelude { pub use crate::shapes_order_dependencies; pub use crate::types::unit2::traits::*; pub use enso_data_structures as data; - pub use enso_logger as logger; - pub use enso_logger::AnyLogger; - pub use enso_logger::DefaultWarningLogger as Logger; - pub use enso_logger::*; pub use enso_prelude::*; pub use enso_profiler as profiler; pub use enso_profiler::prelude::*; diff --git a/lib/rust/ensogl/core/src/system/gpu/context.rs b/lib/rust/ensogl/core/src/system/gpu/context.rs index 40ff865204b..ec88ccc76f5 100644 --- a/lib/rust/ensogl/core/src/system/gpu/context.rs +++ b/lib/rust/ensogl/core/src/system/gpu/context.rs @@ -148,11 +148,11 @@ pub fn init_webgl_2_context( type Handler = web::JsEventHandler; display.set_context(Some(&context)); let lost: Handler = Closure::new(f_!([display] - WARNING!("Lost the WebGL context."); + warn!("Lost the WebGL context."); display.set_context(None) )); let restored: Handler = Closure::new(f_!([display] - WARNING!("Trying to restore the WebGL context."); + warn!("Trying to restore the WebGL context."); display.set_context(Some(&context)) )); let on_lost = web::add_event_listener(hdc, "webglcontextlost", lost); diff --git a/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs b/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs index 178f067d19e..43ed65af310 100644 --- a/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs +++ b/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs @@ -214,7 +214,6 @@ struct CompilerData { jobs: Jobs, cache: ShaderCache, performance: web::Performance, - logger: Logger, } impl Compiler { @@ -256,8 +255,7 @@ impl CompilerData { let jobs = default(); let cache = default(); let performance = web::window.performance_or_panic(); - let logger = Logger::new("Shader Compiler"); - Self { dirty, context, jobs, cache, performance, logger } + Self { dirty, context, jobs, cache, performance } } fn submit( @@ -393,8 +391,8 @@ impl CompilerData { Some(val) => val, None => { if !self.context.is_context_lost() { - REPORTABLE_WARNING!( - "context.getProgramParameter returned non bool value for KHR Parallel \ + reportable_warn!( + "context.getProgramParameter returned non-bool value for KHR Parallel \ Shader Compile status check. This should never happen, however, it \ should not cause visual artifacts. Reverting to non-parallel mode." ); diff --git a/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs b/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs index d8c6e6257a9..1e67e62f2f6 100644 --- a/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs +++ b/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs @@ -50,8 +50,7 @@ impl Version { // ================================================================================================= /// A GLSL code representation. -#[derive(Clone, Debug, Shrinkwrap)] -#[shrinkwrap(mutable)] +#[derive(Clone, Debug, Deref, DerefMut)] pub struct Glsl { /// Raw, textual code representation. pub str: String, @@ -90,7 +89,7 @@ impls! {[T1,T2] From<&(T1,T2)> for Glsl where [ T1:RefInto, T2:RefInto ] { |t| { let v1 = t.0.glsl(); let v2 = t.1.glsl(); - iformat!("vec2({v1},{v2})").into() + format!("vec2({v1},{v2})").into() }}} impls! {[T1,T2,T3] From<&(T1,T2,T3)> for Glsl @@ -98,7 +97,7 @@ where [ T1:RefInto, T2:RefInto, T3:RefInto ] { |t| { let v1 = t.0.glsl(); let v2 = t.1.glsl(); let v3 = t.2.glsl(); - iformat!("vec3({v1},{v2},{v3})").into() + format!("vec3({v1},{v2},{v3})").into() }}} impls! {[T1,T2,T3,T4] From<&(T1,T2,T3,T4)> for Glsl @@ -107,14 +106,14 @@ where [ T1:RefInto, T2:RefInto, T3:RefInto, T4:RefInto ] let v2 = t.1.glsl(); let v3 = t.2.glsl(); let v4 = t.3.glsl(); - iformat!("vec4({v1},{v2},{v3},{v4})").into() + format!("vec4({v1},{v2},{v3},{v4})").into() }}} impls! {[T1,T2] From <(T1,T2)> for Glsl where [ T1:Into, T2:Into ] { |t| { let v1 = t.0.into(); let v2 = t.1.into(); - iformat!("vec2({v1},{v2})").into() + format!("vec2({v1},{v2})").into() }}} impls! {[T1,T2,T3] From <(T1,T2,T3)> for Glsl @@ -122,7 +121,7 @@ where [ T1:Into, T2:Into, T3:Into ] { |t| { let v1 = t.0.into(); let v2 = t.1.into(); let v3 = t.2.into(); - iformat!("vec3({v1},{v2},{v3})").into() + format!("vec3({v1},{v2},{v3})").into() }}} impls! {[T1,T2,T3,T4] From <(T1,T2,T3,T4)> for Glsl @@ -131,7 +130,7 @@ where [ T1:Into, T2:Into, T3:Into, T4:Into ] { |t| { let v2 = t.1.into(); let v3 = t.2.into(); let v4 = t.3.into(); - iformat!("vec4({v1},{v2},{v3},{v4})").into() + format!("vec4({v1},{v2},{v3},{v4})").into() }}} @@ -142,8 +141,8 @@ impls! { From + &From for Glsl { |t| t.to_string().into() } } impls! { From + &From for Glsl { |t| t.to_string().into() } } impls! { From + &From for Glsl { |t| { let is_int = t.fract() == 0.0; - if is_int { iformat!("{t}.0").into() } - else { iformat!("{t}").into() } + if is_int { format!("{t}.0").into() } + else { format!("{t}").into() } }}} impls! { [T,R,C] From + &From > for Glsl @@ -164,19 +163,19 @@ impls! { [T,R,C] From + &From > for Glsl // === From Colors to Glsl === impls! { From + &From for Glsl { - |t| iformat!("srgb({t.red.glsl()},{t.green.glsl()},{t.blue.glsl()})").into() + |t| format!("srgb({},{},{})", t.red.glsl(), t.green.glsl(), t.blue.glsl()).into() } } impls! { From + &From for Glsl { - |t| iformat!("srgba({t.red.glsl()},{t.green.glsl()},{t.blue.glsl()},{t.alpha.glsl()})").into() + |t| format!("srgba({},{},{},{})", t.red.glsl(), t.green.glsl(), t.blue.glsl(), t.alpha.glsl()).into() } } impls! { From + &From for Glsl { - |t| iformat!("rgb({t.red.glsl()},{t.green.glsl()},{t.blue.glsl()})").into() + |t| format!("rgb({},{},{})", t.red.glsl(), t.green.glsl(), t.blue.glsl()).into() } } impls! { From + &From for Glsl { - |t| iformat!("rgba({t.red.glsl()},{t.green.glsl()},{t.blue.glsl()},{t.alpha.glsl()})").into() + |t| format!("rgba({},{},{},{})", t.red.glsl(), t.green.glsl(), t.blue.glsl(), t.alpha.glsl()).into() } } @@ -221,23 +220,23 @@ pub struct NotGlslError; /// Converts a number to a `Radians` struct. pub(crate) fn f32_to_rad(glsl: &Glsl) -> Glsl { - iformat!("Radians({glsl})").into() + format!("Radians({glsl})").into() } /// Extracts a number from a `Radians` struct. pub(crate) fn rad_to_f32(glsl: &Glsl) -> Glsl { - iformat!("value({glsl})").into() + format!("value({glsl})").into() } /// Converts a number to a `Degree` struct. pub(crate) fn f32_to_deg(glsl: &Glsl) -> Glsl { // We just use the radians representation of the degrees. - iformat!("Degrees({glsl})").into() + format!("Degrees({glsl})").into() } /// Extracts a number from a `Degree` struct. The number will be in radians. pub(crate) fn deg_to_f32(glsl: &Glsl) -> Glsl { - iformat!("radians({glsl})").into() + format!("radians({glsl})").into() } @@ -247,7 +246,7 @@ pub(crate) fn deg_to_f32(glsl: &Glsl) -> Glsl { // ================================================================================================= /// Any GLSL expression, like function call, or math operations. -#[derive(Shrinkwrap, Clone, Debug)] +#[derive(Clone, Debug, Deref)] pub struct Expr(Box); impl Expr { diff --git a/lib/rust/ensogl/core/src/system/web/dom/shape.rs b/lib/rust/ensogl/core/src/system/web/dom/shape.rs index 4d2f35bd28c..fe5c2f44433 100644 --- a/lib/rust/ensogl/core/src/system/web/dom/shape.rs +++ b/lib/rust/ensogl/core/src/system/web/dom/shape.rs @@ -90,11 +90,11 @@ impl From<&Shape> for Vector2 { /// A wrapper for `HtmlElement` or anything which derefs to it. It tracks the element size without /// causing browser reflow. -#[derive(Clone, CloneRef, Debug, Shrinkwrap)] +#[derive(Clone, CloneRef, Debug, Deref)] #[clone_ref(bound = "T:CloneRef")] #[allow(missing_docs)] pub struct WithKnownShape { - #[shrinkwrap(main_field)] + #[deref] dom: T, network: frp::Network, pub shape: frp::Sampler, diff --git a/lib/rust/ensogl/example/auto-layout/Cargo.toml b/lib/rust/ensogl/example/auto-layout/Cargo.toml index 16c90d25b8b..fc9a62c17de 100644 --- a/lib/rust/ensogl/example/auto-layout/Cargo.toml +++ b/lib/rust/ensogl/example/auto-layout/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] ensogl-core = { path = "../../core" } wasm-bindgen = { workspace = true } -ensogl-hardcoded-theme = { version = "0.1.0", path = "../../../ensogl/app/theme/hardcoded" } +ensogl-hardcoded-theme = { path = "../../../ensogl/app/theme/hardcoded" } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. [package.metadata.wasm-pack.profile.release] diff --git a/lib/rust/ensogl/example/complex-shape-system/src/lib.rs b/lib/rust/ensogl/example/complex-shape-system/src/lib.rs index 766f30988a2..11e21761b5e 100644 --- a/lib/rust/ensogl/example/complex-shape-system/src/lib.rs +++ b/lib/rust/ensogl/example/complex-shape-system/src/lib.rs @@ -88,7 +88,7 @@ pub fn main() { theme_manager.set_enabled(["theme1".to_string()]); let style_watch = ensogl_core::display::shape::StyleWatch::new(&scene.style_sheet); - // style_watch.set_on_style_change(|| DEBUG!("Style changed!")); + // style_watch.set_on_style_change(|| debug!("Style changed!")); style_watch.get("base_color"); let view1 = shape::View::new(); @@ -134,38 +134,38 @@ pub fn main() { if frame == 50 { // These comments are left for easy debugging in the future. - // DEBUG!("---------------"); - // DEBUG!("{scene.layers.node_searcher:#?}"); - // DEBUG!("{scene.layers.main:#?}"); - // DEBUG!("{scene.layers.mask:#?}"); - // DEBUG!("{scene.layers.node_searcher_mask:#?}"); - // DEBUG!("{scene.layers.viz:#?}"); + // debug!("---------------"); + // debug!("{scene.layers.node_searcher:#?}"); + // debug!("{scene.layers.main:#?}"); + // debug!("{scene.layers.mask:#?}"); + // debug!("{scene.layers.node_searcher_mask:#?}"); + // debug!("{scene.layers.viz:#?}"); } if frame == 100 { - DEBUG!("Adding previously hidden element."); + debug!("Adding previously hidden element."); scene.add_child(&view2); // These comments are left for easy debugging in the future. - // DEBUG!("---------------"); - // DEBUG!("{scene.layers.node_searcher:#?}"); - // DEBUG!("{scene.layers.main:#?}"); - // DEBUG!("{scene.layers.mask:#?}"); - // DEBUG!("{scene.layers.node_searcher_mask:#?}"); - // DEBUG!("{scene.layers.viz:#?}"); + // debug!("---------------"); + // debug!("{scene.layers.node_searcher:#?}"); + // debug!("{scene.layers.main:#?}"); + // debug!("{scene.layers.mask:#?}"); + // debug!("{scene.layers.node_searcher_mask:#?}"); + // debug!("{scene.layers.viz:#?}"); } if frame == 150 { - DEBUG!("Enabling masking."); + debug!("Enabling masking."); // These comments are left for easy debugging in the future. - // DEBUG!("---------------"); - // DEBUG!("{scene.layers.node_searcher:#?}"); - // DEBUG!("{scene.layers.main:#?}"); - // DEBUG!("{scene.layers.mask:#?}"); - // DEBUG!("{scene.layers.node_searcher_mask:#?}"); - // DEBUG!("{scene.layers.viz:#?}"); + // debug!("---------------"); + // debug!("{scene.layers.node_searcher:#?}"); + // debug!("{scene.layers.main:#?}"); + // debug!("{scene.layers.mask:#?}"); + // debug!("{scene.layers.node_searcher_mask:#?}"); + // debug!("{scene.layers.viz:#?}"); scene.layers.main.set_mask(&mask_layer); mask_layer.add(&mask); } if frame == 200 { - DEBUG!("Changing the theme."); + debug!("Changing the theme."); theme_manager.set_enabled(["theme2".to_string()]); } frame += 1; diff --git a/lib/rust/ensogl/example/custom-shape-system/src/lib.rs b/lib/rust/ensogl/example/custom-shape-system/src/lib.rs index cb432b9bb54..3102e5ffec5 100644 --- a/lib/rust/ensogl/example/custom-shape-system/src/lib.rs +++ b/lib/rust/ensogl/example/custom-shape-system/src/lib.rs @@ -74,8 +74,8 @@ pub fn main() { i += 1; if i == 5 { if let Some(program) = view.sprite.borrow().symbol.shader().program() { - DEBUG!("\n\nVERTEX:\n{program.shader.vertex.code}"); - DEBUG!("\n\nFRAGMENT:\n{program.shader.fragment.code}"); + debug!("\n\nVERTEX:\n{}", program.shader.vertex.code); + debug!("\n\nFRAGMENT:\n{}", program.shader.fragment.code); } } }) diff --git a/lib/rust/ensogl/example/dom-symbols/Cargo.toml b/lib/rust/ensogl/example/dom-symbols/Cargo.toml index ec037a44968..519ee1c18a8 100644 --- a/lib/rust/ensogl/example/dom-symbols/Cargo.toml +++ b/lib/rust/ensogl/example/dom-symbols/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] ensogl-core = { path = "../../core" } wasm-bindgen = { workspace = true } -nalgebra = { version = "0.26.1" } +nalgebra = { workspace = true } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. [package.metadata.wasm-pack.profile.release] diff --git a/lib/rust/ensogl/example/dom-symbols/src/lib.rs b/lib/rust/ensogl/example/dom-symbols/src/lib.rs index 19451c8dbe8..18adc527540 100644 --- a/lib/rust/ensogl/example/dom-symbols/src/lib.rs +++ b/lib/rust/ensogl/example/dom-symbols/src/lib.rs @@ -117,7 +117,7 @@ pub fn main() { let r = ((fi + 2.0) * 64.0 / (ELEM_COUNT as f32)) as u8; let g = ((fi + 4.0) * 128.0 / (ELEM_COUNT as f32)) as u8; let b = ((fi + 8.0) * 255.0 / (ELEM_COUNT as f32)) as u8; - let color = iformat!("rgb({r},{g},{b})"); + let color = format!("rgb({r},{g},{b})"); div.set_style_or_warn("background-color", color); object.dom().append_or_warn(&div); dom_symbols.push(object); diff --git a/lib/rust/ensogl/example/drop-down/Cargo.toml b/lib/rust/ensogl/example/drop-down/Cargo.toml index 521124e6397..6477c3ded59 100644 --- a/lib/rust/ensogl/example/drop-down/Cargo.toml +++ b/lib/rust/ensogl/example/drop-down/Cargo.toml @@ -14,7 +14,7 @@ ensogl-hardcoded-theme = { path = "../../app/theme/hardcoded" } ensogl-grid-view = { path = "../../component/grid-view" } ensogl-text-msdf = { path = "../../component/text/src/font/msdf" } ensogl-drop-down = { path = "../../component/drop-down" } -wasm-bindgen = { version = "0.2.78" } +wasm-bindgen = { workspace = true } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. [package.metadata.wasm-pack.profile.release] diff --git a/lib/rust/ensogl/example/drop-manager/src/lib.rs b/lib/rust/ensogl/example/drop-manager/src/lib.rs index c3a762a1276..a1dfeedcb8c 100644 --- a/lib/rust/ensogl/example/drop-manager/src/lib.rs +++ b/lib/rust/ensogl/example/drop-manager/src/lib.rs @@ -33,18 +33,18 @@ use wasm_bindgen_futures::spawn_local; fn download_file(file: ensogl_drop_manager::File) { spawn_local(async move { - INFO!("Received file: {file:?}"); + info!("Received file: {file:?}"); loop { match file.read_chunk().await { Ok(Some(chunk)) => { - INFO!("Received chunk: {chunk:?}"); + info!("Received chunk: {chunk:?}"); } Ok(None) => { - INFO!("All chunks received successfully"); + info!("All chunks received successfully"); break; } Err(err) => { - ERROR!("Error in receiving chunk promise: {err:?}"); + error!("Error in receiving chunk promise: {err:?}"); break; } } @@ -78,7 +78,7 @@ pub fn main() { }) .forget(); - INFO!("Drag and drop file to the scene to test the drop manager functionality."); + info!("Drag and drop file to the scene to test the drop manager functionality."); std::mem::forget(world); std::mem::forget(network); diff --git a/lib/rust/ensogl/example/easing-animator/Cargo.toml b/lib/rust/ensogl/example/easing-animator/Cargo.toml index 68d35c9f238..07ec63cfeef 100644 --- a/lib/rust/ensogl/example/easing-animator/Cargo.toml +++ b/lib/rust/ensogl/example/easing-animator/Cargo.toml @@ -10,8 +10,8 @@ crate-type = ["cdylib", "rlib"] [dependencies] ensogl-core = { path = "../../core" } wasm-bindgen = { workspace = true } -js-sys = { version = "0.3.28" } -nalgebra = { version = "0.26.1" } +js-sys = { workspace = true } +nalgebra = { workspace = true } web-sys = { version = "0.3.4" } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. diff --git a/lib/rust/ensogl/example/grid-view/Cargo.toml b/lib/rust/ensogl/example/grid-view/Cargo.toml index 4ad21028a8f..efadb7120ef 100644 --- a/lib/rust/ensogl/example/grid-view/Cargo.toml +++ b/lib/rust/ensogl/example/grid-view/Cargo.toml @@ -15,7 +15,7 @@ ensogl-grid-view = { path = "../../component/grid-view" } ensogl-text-msdf = { path = "../../component/text/src/font/msdf" } enso-text = { path = "../../../text" } wasm-bindgen = { workspace = true } -itertools = "0.10.3" +itertools = { workspace = true } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. [package.metadata.wasm-pack.profile.release] diff --git a/lib/rust/ensogl/example/grid-view/src/lib.rs b/lib/rust/ensogl/example/grid-view/src/lib.rs index 38aa8c52c4f..47ddde9074e 100644 --- a/lib/rust/ensogl/example/grid-view/src/lib.rs +++ b/lib/rust/ensogl/example/grid-view/src/lib.rs @@ -82,9 +82,8 @@ fn configure_simple_grid_view(view: &grid_view::simple::SimpleGridView) -> frp:: eval view.entry_accepted ([]((row, col)) debug!("ACCEPTED entry ({row}, {col}).")); eval view.selection_movement_out_of_grid_prevented ([](dir) if let Some(dir) = dir { - let msg = iformat!( - "An attempt to select an entry outside of the grid in " dir;? - " direction was prevented." + let msg = format!( + "An attempt to select an entry outside the grid in {dir:?} direction was prevented." ); debug!("{msg}"); } diff --git a/lib/rust/ensogl/example/list-view/src/lib.rs b/lib/rust/ensogl/example/list-view/src/lib.rs index b73d89e1108..6b642bdd21a 100644 --- a/lib/rust/ensogl/example/list-view/src/lib.rs +++ b/lib/rust/ensogl/example/list-view/src/lib.rs @@ -73,7 +73,7 @@ impl list_view::entry::ModelProvider fo if id >= self.entries_count { None } else { - let label = iformat!("Entry {id}"); + let label = format!("Entry {id}"); let highlighted = if id == 10 { vec![(Byte(1)..Byte(3)).into()] } else { vec![] }; Some(list_view::entry::GlyphHighlightedLabelModel { label, highlighted }) } diff --git a/lib/rust/ensogl/example/mouse-events/src/lib.rs b/lib/rust/ensogl/example/mouse-events/src/lib.rs index aee8c934637..c7e94f01260 100644 --- a/lib/rust/ensogl/example/mouse-events/src/lib.rs +++ b/lib/rust/ensogl/example/mouse-events/src/lib.rs @@ -59,7 +59,6 @@ mod shape { #[derive(Clone, CloneRef, Debug)] struct Model { app: Application, - logger: DefaultTraceLogger, display_object: display::object::Instance, shape: shape::View, } @@ -67,12 +66,11 @@ struct Model { impl Model { fn new(app: &Application) -> Self { let app = app.clone_ref(); - let logger = DefaultTraceLogger::new("Button"); let display_object = display::object::Instance::new(); let shape = shape::View::new(); shape.set_size(Vector2::new(100.0, 100.0)); display_object.add_child(&shape); - Self { app, logger, display_object, shape } + Self { app, display_object, shape } } } diff --git a/lib/rust/ensogl/example/profiling-run-graph/Cargo.toml b/lib/rust/ensogl/example/profiling-run-graph/Cargo.toml index e47a2066a8e..a4c2fa4660a 100644 --- a/lib/rust/ensogl/example/profiling-run-graph/Cargo.toml +++ b/lib/rust/ensogl/example/profiling-run-graph/Cargo.toml @@ -22,7 +22,7 @@ ensogl-tooltip = { path = "../../component/tooltip" } ensogl-hardcoded-theme = { path = "../../app/theme/hardcoded" } ensogl-text = { path = "../../component/text" } ensogl-text-msdf = { path = "../../component/text/src/font/msdf" } -futures = "0.3" +futures = { workspace = true } serde = "1" wasm-bindgen = { workspace = true } wasm-bindgen-futures = "0.4" diff --git a/lib/rust/ensogl/example/profiling-run-graph/src/lib.rs b/lib/rust/ensogl/example/profiling-run-graph/src/lib.rs index 144cd6a0892..3e48cf716a8 100644 --- a/lib/rust/ensogl/example/profiling-run-graph/src/lib.rs +++ b/lib/rust/ensogl/example/profiling-run-graph/src/lib.rs @@ -224,7 +224,7 @@ fn make_rendering_performance_blocks( async fn get_data_file() -> Option { let files = enso_debug_api::load_profiles()?.await; if files.len() > 1 { - ERROR!("Entry point profiling-run-graph doesn't support multiple profile file arguments."); + error!("Entry point profiling-run-graph doesn't support multiple profile file arguments."); } files.into_iter().next() } @@ -246,9 +246,9 @@ async fn get_data_http() -> Option { let response = wasm_bindgen_futures::JsFuture::from(response).await.unwrap(); let response: web_sys::Response = response.dyn_into().unwrap(); if !response.ok() { - ERROR!( - "Error retrieving profile file from {url}: {response.status_text()}. \ - Falling back to demo data." + error!( + "Error retrieving profile file from {url}: {}. Falling back to demo data.", + response.status_text() ); return None; } @@ -267,7 +267,7 @@ async fn get_log_data() -> Vec> { .filter_map(|result| match result { Ok(profile) => Some(profile), Err(e) => { - ERROR!(e); + error!("{}", e); None } }) diff --git a/lib/rust/ensogl/example/render-profile-flamegraph/Cargo.toml b/lib/rust/ensogl/example/render-profile-flamegraph/Cargo.toml index 7258679b78f..406ca1e19d5 100644 --- a/lib/rust/ensogl/example/render-profile-flamegraph/Cargo.toml +++ b/lib/rust/ensogl/example/render-profile-flamegraph/Cargo.toml @@ -19,7 +19,7 @@ ensogl-hardcoded-theme = { path = "../../app/theme/hardcoded" } ensogl-text = { path = "../../component/text" } ensogl-text-msdf = { path = "../../component/text/src/font/msdf" } ensogl-tooltip = { path = "../../component/tooltip" } -futures = "0.3" +futures = { workspace = true } wasm-bindgen = { workspace = true } wasm-bindgen-futures = "0.4" diff --git a/lib/rust/ensogl/example/render-profile-flamegraph/src/lib.rs b/lib/rust/ensogl/example/render-profile-flamegraph/src/lib.rs index 862eed2e616..26fde7cc9ba 100644 --- a/lib/rust/ensogl/example/render-profile-flamegraph/src/lib.rs +++ b/lib/rust/ensogl/example/render-profile-flamegraph/src/lib.rs @@ -93,9 +93,9 @@ async fn get_data() -> String { assert!(response.is_instance_of::()); let response: web_sys::Response = response.dyn_into().unwrap(); if !response.ok() { - ERROR!( - "Error retrieving profile file from {url}: {response.status_text()}. \ - Falling back to demo data." + error!( + "Error retrieving profile file from {url}: {}. Falling back to demo data.", + response.status_text() ); return enso_profiler_demo_data::create_data().await; } diff --git a/lib/rust/ensogl/example/sprite-system-benchmark/Cargo.toml b/lib/rust/ensogl/example/sprite-system-benchmark/Cargo.toml index 83d7cfd91f8..45340b12e9c 100644 --- a/lib/rust/ensogl/example/sprite-system-benchmark/Cargo.toml +++ b/lib/rust/ensogl/example/sprite-system-benchmark/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] ensogl-core = { path = "../../core" } -nalgebra = { version = "0.26.1" } +nalgebra = { workspace = true } wasm-bindgen = { workspace = true } # Stop wasm-pack from running wasm-opt, because we run it from our build scripts in order to customize options. diff --git a/lib/rust/frp/Cargo.toml b/lib/rust/frp/Cargo.toml index fafd586f56d..3e64dd53a3d 100644 --- a/lib/rust/frp/Cargo.toml +++ b/lib/rust/frp/Cargo.toml @@ -9,13 +9,12 @@ edition = "2021" [dependencies] enso-callback = { path = "../callback" } enso-generics = { path = "../generics" } -enso-logger = { path = "../logger" } enso-prelude = { path = "../prelude" } enso-profiler = { path = "../profiler" } enso-web = { path = "../web" } Inflector = { version = "0.11.4" } keyboard-types = { version = "0.5.0" } -nalgebra = { version = "0.26.1" } +nalgebra = { workspace = true } percent-encoding = { version = "2.1.0" } unicode-segmentation = { version = "1.6.0" } # We require exact version of wasm-bindgen because we do patching final js in our build process, diff --git a/lib/rust/frp/src/data/watch.rs b/lib/rust/frp/src/data/watch.rs index 79ec01d3a16..9cee7eb5b97 100644 --- a/lib/rust/frp/src/data/watch.rs +++ b/lib/rust/frp/src/data/watch.rs @@ -66,10 +66,10 @@ impl Counter { /// A simple wrapper for anything with attached `Handle`. Could be used as a handy type for /// storing both a reference to a resource and its watch handle. -#[derive(Debug, Shrinkwrap)] +#[derive(Debug, Deref)] pub struct Ref { /// The underlying type. - #[shrinkwrap(main_field)] + #[deref] pub target: T, #[allow(dead_code)] /// This is not accessed in this implementation but it needs to be kept so the handle stays diff --git a/lib/rust/frp/src/debug.rs b/lib/rust/frp/src/debug.rs index 2adc946ba51..48c9a1f52bf 100644 --- a/lib/rust/frp/src/debug.rs +++ b/lib/rust/frp/src/debug.rs @@ -112,11 +112,11 @@ impl Graphviz { "Lambda2" => "d45769", _ => "455054", }; - let fill = iformat!("[fillcolor=\"#{color}\"]"); + let fill = format!("[fillcolor=\"#{color}\"]"); let spacing = "

"; - let variant = iformat!("{node.variant}"); - let label = iformat!("[label=< {node.label} {spacing} {variant} >]"); - let line = iformat!("\n{idx} {fill} {label}"); + let variant = format!("{}", node.variant); + let label = format!("[label=< {} {spacing} {variant} >]", node.label); + let line = format!("\n{idx} {fill} {label}"); code.push_str(&line); } // @@ -131,8 +131,8 @@ impl Graphviz { // _ => "" // }; // let label = if data_type == "()" { "" } else { &data_type }; - // let label = iformat!("[label=\" {label}\"]"); - // let line = iformat!("\n{source} -> {target} {style} {label}"); + // let label = format!("[label=\" {label}\"]"); + // let line = format!("\n{source} -> {target} {style} {label}"); // code.push_str(&line); // } // } @@ -141,11 +141,10 @@ impl Graphviz { let node_shape = "[shape=box penwidth=0 margin=0.12 style=\"rounded,filled\"]"; let node_style = "[fontcolor=white fillcolor=\"#5397dc\"]"; let edge_style = "[arrowsize=.7 fontcolor=\"#555555\"]"; - let graph_cfg = iformat!("rankdir=TD; graph {fonts};"); - let nodes_cfg = iformat!("node {fonts} {node_shape} {node_style};"); - let edges_cfg = iformat!("edge {fonts} {edge_style};"); - iformat!("digraph G {{ \n{graph_cfg} \n{nodes_cfg} \n{edges_cfg} \n{code} \n}}") - // todo!() + let graph_cfg = format!("rankdir=TD; graph {fonts};"); + let nodes_cfg = format!("node {fonts} {node_shape} {node_style};"); + let edges_cfg = format!("edge {fonts} {edge_style};"); + format!("digraph G {{ \n{graph_cfg} \n{nodes_cfg} \n{edges_cfg} \n{code} \n}}") } } diff --git a/lib/rust/frp/src/future.rs b/lib/rust/frp/src/future.rs index 490fcd3cae9..b37752be302 100644 --- a/lib/rust/frp/src/future.rs +++ b/lib/rust/frp/src/future.rs @@ -59,13 +59,13 @@ impl FutureEvent { /// /// Panics if no event was emitted by the node since this structure creation. pub fn expect(self) -> Out { - self.value.take().unwrap_or_else(|| ipanic!("Expected {self.label} event")) + self.value.take().unwrap_or_else(|| panic!("Expected {} event", self.label)) } /// Panics if any event was received. pub fn expect_not(&self) { if self.value.borrow().is_some() { - ipanic!("Expected not {self.label} event"); + panic!("Expected not {} event", self.label); } } } diff --git a/lib/rust/frp/src/io/mouse.rs b/lib/rust/frp/src/io/mouse.rs index 41613df73dd..9555344f126 100644 --- a/lib/rust/frp/src/io/mouse.rs +++ b/lib/rust/frp/src/io/mouse.rs @@ -60,7 +60,7 @@ impl Button { Self::try_from_code(code).unwrap_or_else(|| { let invalid_msg = "The provided mouse button code is invalid"; let revert_msg = "Reverting to the default button."; - WARNING!("{invalid_msg} ({code}). {revert_msg}"); + warn!("{invalid_msg} ({code}). {revert_msg}"); default() }) } diff --git a/lib/rust/frp/src/lib.rs b/lib/rust/frp/src/lib.rs index 1e1ab58babe..45181150e61 100644 --- a/lib/rust/frp/src/lib.rs +++ b/lib/rust/frp/src/lib.rs @@ -189,8 +189,6 @@ pub use stream::Stream; /// Set of often used types and functions. pub mod prelude { - pub use enso_logger::WarningLogger as Logger; - pub use enso_logger::*; pub use enso_prelude::*; pub use enso_profiler as profiler; pub use enso_profiler::prelude::*; diff --git a/lib/rust/frp/src/stream.rs b/lib/rust/frp/src/stream.rs index 12d9af16635..975dc68670d 100644 --- a/lib/rust/frp/src/stream.rs +++ b/lib/rust/frp/src/stream.rs @@ -275,11 +275,10 @@ impl EventEmitter for NodeData { fn emit_event(&self, stack: CallStack, value: &Out) { let new_stack = stack.sub(self.label); if self.ongoing_evaluations.get() > EVALUATIONS_LIMIT { - let logger: Logger = Logger::new("frp"); - warning!(logger, "The recursive evaluations limit exceeded.", || { - warning!(logger, "{new_stack}"); + warn_span!("The recursive evaluations limit exceeded.").in_scope(|| { + warn!("{new_stack}"); }); - WARNING!("{backtrace()}") + warn!("{}", backtrace()) } else { self.ongoing_evaluations.set(self.ongoing_evaluations.get() + 1); if self.use_caching() { diff --git a/lib/rust/generics/Cargo.toml b/lib/rust/generics/Cargo.toml index 3a224d0786e..000de237aa8 100644 --- a/lib/rust/generics/Cargo.toml +++ b/lib/rust/generics/Cargo.toml @@ -16,4 +16,4 @@ publish = true [dependencies] serde = { version = "1.0.0", features = ["derive"] } -nalgebra = { version = "0.26.1", features = ["serde-serialize"] } +nalgebra = { workspace = true } diff --git a/lib/rust/json-rpc/Cargo.toml b/lib/rust/json-rpc/Cargo.toml index cf3bee07601..fc04b507fa4 100644 --- a/lib/rust/json-rpc/Cargo.toml +++ b/lib/rust/json-rpc/Cargo.toml @@ -14,7 +14,6 @@ enso-web = { path = "../web" } enso-profiler-data = { path = "../profiler/data" } enso-profiler = { path = "../profiler" } futures = { version = "0.3.1" } -failure = { version = "0.1.6" } +failure = { workspace = true } serde = { version = "1.0.0", features = ["derive"] } -serde_json = { version = "1.0.0" } -shrinkwraprs = { version = "0.3.0" } +serde_json = { workspace = true } diff --git a/lib/rust/json-rpc/src/macros.rs b/lib/rust/json-rpc/src/macros.rs index 864ff7307e3..85fd0539c42 100644 --- a/lib/rust/json-rpc/src/macros.rs +++ b/lib/rust/json-rpc/src/macros.rs @@ -203,7 +203,7 @@ macro_rules! make_rpc_methods { if self.require_all_calls.get() && !std::thread::panicking() { $( let method = stringify!($method); - let msg = iformat!("An expected call to {method} was not made."); + let msg = format!("An expected call to {method} was not made."); assert!(self.expect.$method.borrow().is_empty(), "{}", msg); )* } diff --git a/lib/rust/json-rpc/src/messages.rs b/lib/rust/json-rpc/src/messages.rs index ff1970993bb..a31a10a20ac 100644 --- a/lib/rust/json-rpc/src/messages.rs +++ b/lib/rust/json-rpc/src/messages.rs @@ -6,7 +6,6 @@ use crate::prelude::*; use serde::Deserialize; use serde::Serialize; -use shrinkwraprs::Shrinkwrap; @@ -15,8 +14,7 @@ use shrinkwraprs::Shrinkwrap; // =============== /// All JSON-RPC messages bear `jsonrpc` version number. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[derive(Shrinkwrap)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Deref)] pub struct Message { /// JSON-RPC Protocol version, should be 2.0. pub jsonrpc: Version, @@ -24,7 +22,7 @@ pub struct Message { /// Payload, either a Request or Response or Notification in direct /// or serialized form. #[serde(flatten)] - #[shrinkwrap(main_field)] + #[deref] pub payload: T, } @@ -94,9 +92,8 @@ impl Message { /// Each request made by client should get a unique id (unique in a context of /// the current session). Auto-incrementing integer is a common choice. #[derive(Serialize, Deserialize)] -#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Deref)] #[derive(Display)] -#[derive(Shrinkwrap)] pub struct Id(pub i64); /// JSON-RPC protocol version. Only 2.0 is supported. @@ -111,13 +108,12 @@ pub enum Version { /// /// `Call` must be a type, that upon JSON serialization provides `method` and /// `params` fields, like `MethodCall`. -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] -#[derive(Shrinkwrap)] +#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Deref)] pub struct Request { /// An identifier for this request that will allow matching the response. pub id: Id, #[serde(flatten)] - #[shrinkwrap(main_field)] + #[deref] /// method and its params pub call: Call, } @@ -220,13 +216,12 @@ pub fn decode_incoming_message(message: &str) -> serde_json::Result { /// Name of the method that is being called. pub method: String, /// Method arguments. - #[shrinkwrap(main_field)] + #[deref] pub params: In, } @@ -304,7 +299,7 @@ mod tests { let notification = Notification(call); let message = Message::new(notification); - DEBUG!(serde_json::to_string(&message).unwrap()); + debug!("{}", serde_json::to_string(&message).unwrap()); let json = serde_json::to_value(message).expect("serialization error"); let json = json.as_object().expect("expected an object"); diff --git a/lib/rust/logger/Cargo.toml b/lib/rust/logger/Cargo.toml deleted file mode 100644 index 967c90b3b65..00000000000 --- a/lib/rust/logger/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "enso-logger" -version = "0.3.1" -authors = ["Enso Team "] -edition = "2021" -description = "An efficient logger for writing applications in Rust." -readme = "README.md" -homepage = "https://github.com/enso-org/enso/lib/rust/logger" -repository = "https://github.com/enso-org/enso" -license-file = "../../LICENSE" -keywords = ["logging"] -categories = ["development-tools::debugging"] -publish = true - -[lib] - -[features] -default = [] - -[dependencies] -enso-prelude = { version = "^0.2.1", path = "../prelude" } -enso-shapely = { version = "^0.2.0", path = "../shapely" } -wasm-bindgen = { workspace = true } -js-sys = { version = "0.3.28" } -ifmt = "0.3.3" - -[dependencies.web-sys] -version = "0.3.4" -features = ['console'] diff --git a/lib/rust/logger/README.md b/lib/rust/logger/README.md deleted file mode 100644 index 17bb8f0d8f5..00000000000 --- a/lib/rust/logger/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Enso Logger - -A flexible logging implementation for building rust applications. diff --git a/lib/rust/logger/src/entry.rs b/lib/rust/logger/src/entry.rs deleted file mode 100644 index a4992760cd7..00000000000 --- a/lib/rust/logger/src/entry.rs +++ /dev/null @@ -1,139 +0,0 @@ -//! Logger entry. Entry can contain message, grouping, time information, etc. - -use crate::prelude::*; - -use message::Message; - - -// ============== -// === Export === -// ============== - -pub mod level; -pub mod message; - -pub use level::filter_from; -pub use level::DefaultFilter; -pub use level::DefaultLevels; - - - -// ============= -// === Entry === -// ============= - -/// Logger entry. Contains the message, log level, and may contain other information in the future, -/// like time, frame number, etc. -/// -/// Please note that grouping is realized by special entries `GroupBegin` and `GroupEnd`. They can -/// be used to define nested groups. See the `macros.rs` module to see example usage. -#[derive(Clone, Debug)] -#[allow(missing_docs)] -pub struct Entry { - pub level: Level, - pub gen_entry: GenericEntry, -} - -/// Internal structure of `Entry`. -#[derive(Clone, Debug)] -#[allow(missing_docs)] -pub struct GenericEntry { - /// A dot-separated names of parent loggers and this logger. - pub path: ImString, - pub content: Content, -} - -/// Content of the entry. Can either contain simple message, or grouping information. -#[derive(Clone, Debug)] -#[allow(missing_docs)] -pub enum Content { - Message(String), - GroupBegin(GroupBegin), - GroupEnd, -} - -// `Content::GroupBegin` representation. -#[derive(Clone, Debug)] -#[allow(missing_docs)] -pub struct GroupBegin { - pub collapsed: bool, - pub message: String, -} - -impl Deref for Entry { - type Target = GenericEntry; - fn deref(&self) -> &Self::Target { - &self.gen_entry - } -} - -impl Deref for GenericEntry { - type Target = Content; - fn deref(&self) -> &Self::Target { - &self.content - } -} - -impl Content { - /// Constructor. - pub fn group_begin(collapsed: bool, message: String) -> Self { - Self::GroupBegin(GroupBegin { collapsed, message }) - } - - /// Message getter. Returns `None` if it was group end. - pub fn message(&self) -> Option<&str> { - match self { - Self::Message(msg) => Some(msg), - Self::GroupBegin(t) => Some(&t.message), - Self::GroupEnd => None, - } - } -} - -impl Entry { - /// Constructor. - pub fn message(level: impl Into, path: ImString, message: impl Message) -> Self { - let level = level.into(); - let gen_entry = GenericEntry::message(path, message); - Self { level, gen_entry } - } - - /// Constructor. - pub fn group_begin( - level: impl Into, - path: ImString, - message: impl Message, - collapsed: bool, - ) -> Self { - let level = level.into(); - let gen_entry = GenericEntry::group_begin(path, message, collapsed); - Self { level, gen_entry } - } - - /// Constructor. - pub fn group_end(level: impl Into, path: ImString) -> Self { - let level = level.into(); - let gen_entry = GenericEntry::group_end(path); - Self { level, gen_entry } - } -} - -impl GenericEntry { - /// Constructor. - pub fn message(path: ImString, message: impl Message) -> Self { - let content = Content::Message(message.get()); - Self { path, content } - } - - /// Constructor. - pub fn group_begin(path: ImString, message: impl Message, collapsed: bool) -> Self { - let content = Content::group_begin(collapsed, message.get()); - Self { path, content } - } - - /// Constructor. - pub fn group_end(path: ImString) -> Self { - let content = Content::GroupEnd; - Self { path, content } - } -} diff --git a/lib/rust/logger/src/entry/level.rs b/lib/rust/logger/src/entry/level.rs deleted file mode 100644 index cf9eef76616..00000000000 --- a/lib/rust/logger/src/entry/level.rs +++ /dev/null @@ -1,180 +0,0 @@ -//! Built-in verbosity level definitions and a set of utilities to define custom levels. Please note -//! that the verbosity level mechanism is completely user-extensible and this implementation can be -//! completely redefined by the user. - -use crate::prelude::*; - -use crate::entry::level; -use crate::entry::Entry; -use crate::processor::formatter; - - - -// ============== -// === Macros === -// ============== - -/// Utility for defining verbosity levels. Each verbosity level is defined as a separate structure. -/// Moreover, it will also define a module `filter_from` containing similar structures, which will -/// be useful for compile time filtering. The meaning of `filter_from::Warning` is meant to be -/// "keep every message with priority higher or equal to warning". -/// -/// For example, for the given input `define_levels!(Trace,Debug,Info,Warning,Error);`, the -/// following output will be generated: -/// -/// ```text -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Trace; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Debug; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Info; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Warning; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Error; -/// pub mod filter_from { -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Trace; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Debug; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Info; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Warning; -/// #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] -/// pub struct Error; -/// } -/// ``` -#[macro_export] -macro_rules! define_levels { - ($($name:ident),*) => { - $( - /// Log level. - #[derive(Clone,Copy,Debug,Default,PartialEq,Eq,Hash)] - pub struct $name; - )* - - /// Allows compile-time filtering of all entries from (more important) than the selected - /// level. For example, `filter_from::Warning` will keep warnings and errors only. - pub mod filter_from { - $( - /// Filtering log level. - #[derive(Clone,Copy,Debug,Default,PartialEq,Eq,Hash)] - pub struct $name; - )* - } - }; -} - - -/// Group levels defined with `define_levels` (possibly several, possibly merging user-defined -/// types) into a common structure for logger parametrization. Also, defines a generic formatter -/// impl for the type, which redirects calls to more specific instances. -/// -/// For example, for `define_levels_group!(DefaultLevels {Trace,Debug,Info,Warning,Error});`, the -/// following code will be generated: -/// -/// ```text -/// #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -/// pub enum DefaultLevels { -/// Trace, -/// Debug, -/// Info, -/// Warning, -/// Error, -/// } -/// impl From for DefaultLevels { -/// fn from(_: Trace) -> Self { -/// Self::Trace -/// } -/// } -/// impl From for DefaultLevels { -/// fn from(_: Debug) -> Self { -/// Self::Debug -/// } -/// } -/// impl From for DefaultLevels { -/// fn from(_: Info) -> Self { -/// Self::Info -/// } -/// } -/// impl From for DefaultLevels { -/// fn from(_: Warning) -> Self { -/// Self::Warning -/// } -/// } -/// impl From for DefaultLevels { -/// fn from(_: Error) -> Self { -/// Self::Error -/// } -/// } -/// -/// impl formatter::GenericDefinition for T -/// where -/// T: formatter::Definition, -/// T: formatter::Definition, -/// T: formatter::Definition, -/// T: formatter::Definition, -/// T: formatter::Definition, -/// { -/// fn generic_format(entry: &Entry) -> Option { -/// match entry.level { -/// DefaultLevels::Trace => formatter::format::(&entry.gen_entry), -/// DefaultLevels::Debug => formatter::format::(&entry.gen_entry), -/// DefaultLevels::Info => formatter::format::(&entry.gen_entry), -/// DefaultLevels::Warning => formatter::format::(&entry.gen_entry), -/// DefaultLevels::Error => formatter::format::(&entry.gen_entry), -/// } -/// } -/// } -/// ``` -#[macro_export] -macro_rules! define_levels_group { - ($group_name:ident { $($name:ident),* $(,)?} ) => { - /// Possible verbosity levels enum. - #[allow(missing_docs)] - #[derive(Clone,Copy,Debug,PartialEq,Eq,Hash)] - pub enum $group_name { - $($name),* - } - - $( - impl From<$name> for $group_name { - fn from(_:$name) -> Self { - Self::$name - } - } - )* - - impl formatter::GenericDefinition for T - where $(T : formatter::Definition),* { - fn generic_format(entry:&Entry) -> Option { - match entry.level { - $( - DefaultLevels::$name => - formatter::format:: (&entry.gen_entry) - ),* - } - } - } - }; -} - - - -// ======================= -// === Built-in Levels === -// ======================= - -define_levels!(Trace, Debug, Info, Warning, Error); -define_levels_group!(DefaultLevels { Trace, Debug, Info, Warning, Error }); - - - -// ===================== -// === DefaultFilter === -// ===================== - -/// Default compile-time logger filtering. Keeps all logs. -pub type DefaultFilter = filter_from::Trace; diff --git a/lib/rust/logger/src/entry/message.rs b/lib/rust/logger/src/entry/message.rs deleted file mode 100644 index c09c41718f4..00000000000 --- a/lib/rust/logger/src/entry/message.rs +++ /dev/null @@ -1,48 +0,0 @@ -//! Abstraction for messages that can be logged. - - - -// =============== -// === Message === -// =============== - -/// Message that can be logged. This trait allow a wide range of input arguments and also, allows -/// the messages to be constructed lazily, from functions. -#[allow(missing_docs)] -pub trait Message { - fn get(self) -> String; -} -impl Message for &str { - fn get(self) -> String { - self.into() - } -} -impl Message for &&str { - fn get(self) -> String { - (*self).into() - } -} -impl Message for String { - fn get(self) -> String { - self - } -} -impl Message for &String { - fn get(self) -> String { - self.clone() - } -} -impl Message for &&String { - fn get(self) -> String { - (*self).clone() - } -} -impl Message for F -where - F: FnOnce() -> S, - S: Message, -{ - fn get(self) -> String { - self().get() - } -} diff --git a/lib/rust/logger/src/lib.rs b/lib/rust/logger/src/lib.rs deleted file mode 100644 index 3c9d7e0d5ad..00000000000 --- a/lib/rust/logger/src/lib.rs +++ /dev/null @@ -1,351 +0,0 @@ -//! Extensible logger implementation. -//! -//! ### Main Features -//! -//! This crate is designed to provide extensible and easy-to-use abstractions for logging -//! arbitrary string messages to (primarily) the DevTools console. The code is designed with the -//! following features in mind: -//! -//! - Customizable hierarchical log levels. -//! - Compile-time level filtering. -//! - Support for JS console features, like message grouping. -//! - Customizable logs processing pipeline. -//! -//! ### How to Use -//! -//! The usage is similar to the [`log`](https://docs.rs/log) logging facade, though there are some -//! important differences. -//! -//! #### Logging Macros -//! -//! First of all, logging macros (like [`info!`]) accept [`AnyLogger`] type as the first argument: -//! -//! ```text -//! # use enso_logger::DefaultInfoLogger as Logger; -//! # use enso_logger::{AnyLogger, info}; -//! # use enso_prelude::iformat; -//! let logger = Logger::new("my_logger"); -//! info!(logger, "Here comes some log message"); -//! ``` -//! -//! Each `Logger` has a so-called `path`, a unique string identifier of the logger, that is -//! attached to each log message. Loggers can create hierarchies with the help of -//! [`AnyLogger::new_sub`] constructor. This allows to semantically distinguish log messages from -//! different modules of the program. -//! -//! The second argument of the logging macros might be any type implementing [`Message`] trait: -//! -//! ```text -//! # use enso_logger::DefaultInfoLogger as Logger; -//! # use enso_logger::{AnyLogger, info}; -//! # use enso_prelude::iformat; -//! # let logger = Logger::new("my_logger"); -//! info!(logger, "String literal"); -//! let string_variable = String::from("Owned string"); -//! info!(logger, string_variable); -//! info!(logger, || "A closure returning string"); -//! let some_var = 3.14; -//! info!(logger, "String interpolation using iformat! macro also works: {some_var}"); -//! // will output "String interpolation using iformat! macro also works: 3.14" -//! ``` -//! -//! #### Message Grouping -//! -//! Also, a third argument may be provided. It groups log messages in the DevTools console under a -//! group with the provided name. For example: -//! -//! ```text -//! # use enso_logger::DefaultInfoLogger as Logger; -//! # use enso_logger::{AnyLogger, info}; -//! # use enso_prelude::iformat; -//! # let logger = Logger::new("my_logger"); -//! # fn some_computation() {} -//! info!(logger, "group name", || { -//! some_computation(); -//! info!(logger, "this message will go into group"); -//! }); -//! ``` -//! You can also use macro-keywords `collapsed` -//! or `expanded` just before `||` to print the group collapsed or expanded by default, -//! respectively. If not provided, the [`warning`] and [`error`] group macros are collapsed by -//! default, while all other group macros are expanded by default. -//! #### Compile-time Log Level Filtering -//! -//! The crate provides a set of predefined loggers that can be used together with reexport -//! mechanism to easily control log level filtering with zero run-time overhead. -//! -//! ```text -//! mod prelude { -//! // Reexport needed loggers in the crate prelude. -//! pub use enso_logger::DefaultInfoLogger as Logger; -//! pub use enso_logger::DefaultTraceLogger as DebugLogger; -//! } -//! -//! // Use it in the code. -//! // Changing this line to `use prelude::DebugLogger as Logger;` -//! // will enable debug logs for this module. -//! use prelude::Logger; -//! # use enso_logger::{AnyLogger, debug, warning}; -//! # use enso_prelude::iformat; -//! -//! let logger = Logger::new("MyModule"); -//! warning!(logger, "This will be printed to the logs"); -//! debug!(logger, "This would not"); -//! ``` -//! -//! ### Extensibility -//! -//! You can define your own log levels (see [`define_levels!`], [`define_levels_group!`] and -//! [`define_compile_time_filtering_rules!`] macros), formatters (see [`processor::formatter`]), and -//! log processing pipelines (see [`processor`]). - -// === Standard Linter Configuration === -#![deny(non_ascii_idents)] -#![warn(unsafe_code)] -#![allow(clippy::bool_to_int_with_if)] -#![allow(clippy::let_and_return)] -// === Non-Standard Linter Configuration === -#![deny(unconditional_recursion)] -#![allow(incomplete_features)] // To be removed, see: https://github.com/enso-org/ide/issues/1559 -#![warn(missing_copy_implementations)] -#![warn(missing_debug_implementations)] -#![warn(missing_docs)] -#![warn(trivial_casts)] -#![warn(trivial_numeric_casts)] -#![warn(unsafe_code)] -#![warn(unused_import_braces)] -#![feature(specialization)] - -pub mod entry; -pub mod macros; -pub mod processor; - -pub use enso_prelude as prelude; -pub use entry::message::Message; - -use prelude::*; - -use crate::entry::DefaultFilter; -use crate::entry::DefaultLevels; -use crate::entry::Entry; -use crate::processor::DefaultProcessor; -use crate::processor::Processor; - -use enso_shapely::CloneRef; - -pub use ifmt::iformat; - - -// ============== -// === Logger === -// ============== - -/// The main logger implementation. It is parametrized by three main types: -/// - Filter, which is used for compile-time message filtering (zero runtime overhead). -/// - Processor, which defines a pipeline of what happens to the logged messages. Read the docs of -/// `Processor` to learn more. -/// - Levels, which is a structure defining all possible verbosity levels this logger should handle. -/// See the `level.rs` module to learn how to define custom verbosity levels. -/// -/// In order to learn how to use the logger, please refer to the docs in `macros.rs`, where a lot -/// of logging utility macros are defined. -#[derive(CloneRef, Derivative)] -#[derivative(Clone(bound = ""))] -#[derivative(Debug(bound = ""))] -pub struct Logger { - path: ImString, - #[derivative(Debug = "ignore")] - filter: PhantomData, - #[derivative(Debug = "ignore")] - levels: PhantomData, - #[derivative(Debug = "ignore")] - processor: Rc>, -} - -impl Logger -where Processor: Default -{ - /// Constructor from another logger keeping the same path. - pub fn new_from(logger: impl AnyLogger) -> Self { - Self::new(logger.path()) - } -} - -impl AnyLogger for Logger -where Processor: Default -{ - type Owned = Self; - - fn new(path: impl Into) -> Self { - let path = path.into(); - let filter = default(); - let levels = default(); - let processor = default(); - Self { path, filter, levels, processor } - } - - fn path(&self) -> &str { - &self.path - } -} - - - -// ================= -// === AnyLogger === -// ================= - -/// A common interface for all loggers. Exposing all information needed to create a particular -/// sub-logger from a given parent logger of any type. -pub trait AnyLogger { - /// The owned type of this logger. As this trait is implemented for logger references, this - /// dependent type just removes the references in this case. - type Owned; - - /// Constructor. - fn new(path: impl Into) -> Self::Owned; - - /// The path that is used as a unique identifier of this logger. - fn path(&self) -> &str; - - /// Create a new logger with this logger as a parent. It can be useful when we need to create - /// a sub-logger for a generic type parameter. - fn sub(&self, id: impl AsRef) -> T - where - T: AnyLogger, - Self: Sized, { - ::new_sub(self, id) - } - - /// Create a new logger with `logger` as a parent. It can be useful when we need to create - /// a sub-logger for a generic type parameter. - fn new_sub(logger: impl AnyLogger, id: impl AsRef) -> Self::Owned - where Self::Owned: AnyLogger { - Self::Owned::new(iformat!("{logger.path()}.{id.as_ref()}")) - } -} - -impl AnyLogger for &T { - type Owned = T::Owned; - fn new(path: impl Into) -> Self::Owned { - T::new(path) - } - fn path(&self) -> &str { - T::path(self) - } -} - - - -// ====================== -// === Logger Aliases === -// ====================== - -macro_rules! define_logger_aliases { - ($($tp:ident $name:ident $default_name:ident;)*) => {$( - #[doc = "A logger which compile-time filters out all messages with log levels smaller than "] - #[doc = stringify!($tp)] - #[doc = "."] - pub type $name = Logger; - - #[doc = "The same as "] - #[doc = stringify!($name)] - #[doc = ", but with all type arguments applied, for convenient usage."] - pub type $default_name = $name; - )*}; -} - -define_logger_aliases! { - Trace TraceLogger DefaultTraceLogger; - Debug DebugLogger DefaultDebugLogger; - Info InfoLogger DefaultInfoLogger; - Warning WarningLogger DefaultWarningLogger; - Error ErrorLogger DefaultErrorLogger; -} - - - -// ================= -// === LoggerOps === -// ================= - -/// Primitive operations on a logger. The type parameter allows for compile-time log level filtering -/// of the messages. -#[allow(missing_docs)] -pub trait LoggerOps { - fn log(&self, level: Level, msg: impl Message); - fn group_begin(&self, level: Level, collapsed: bool, msg: impl Message); - fn group_end(&self, level: Level); -} - - -// === Impl for References === - -impl, Level> LoggerOps for &T { - fn log(&self, level: Level, msg: impl Message) { - LoggerOps::log(*self, level, msg) - } - - fn group_begin(&self, level: Level, collapsed: bool, msg: impl Message) { - LoggerOps::group_begin(*self, level, collapsed, msg) - } - - fn group_end(&self, level: Level) { - LoggerOps::group_end(*self, level) - } -} - - -// === Generic Redirection === - -impl LoggerOps for Logger -where - S: Processor>, - Level: From, -{ - default fn log(&self, level: L, msg: impl Message) { - self.processor.borrow_mut().submit(Entry::message(level, self.path.clone(), msg)); - } - - default fn group_begin(&self, level: L, collapsed: bool, msg: impl Message) { - self.processor.borrow_mut().submit(Entry::group_begin( - level, - self.path.clone(), - msg, - collapsed, - )); - } - - default fn group_end(&self, level: L) { - self.processor.borrow_mut().submit(Entry::group_end(level, self.path.clone())); - } -} - - -// === Compile-time Filtering === - -/// Defines specialized version of compile time filtering rules for the given filtering levels. -/// It defines specialized implementations for the default implementation above. See the usage -/// below to learn more. -#[macro_export] -macro_rules! define_compile_time_filtering_rules { - ($(for level::from::$filter:ident remove $($level:ident),*;)*) => {$($( - impl LoggerOps - for Logger - where S:Processor>, Level:From { - fn log (&self, _lvl:entry::level::$level, _msg:impl Message) {} - fn group_begin (&self, _lvl:entry::level::$level, _collapsed:bool, _msg:impl Message) {} - fn group_end (&self, _lvl:entry::level::$level) {} - } - )*)*}; -} - - -// === Compile-time filtering of built-in levels === - -define_compile_time_filtering_rules! { - for level::from::Debug remove Trace; - for level::from::Info remove Trace,Debug; - for level::from::Warning remove Trace,Debug,Info; - for level::from::Error remove Trace,Debug,Info,Warning; -} diff --git a/lib/rust/logger/src/macros.rs b/lib/rust/logger/src/macros.rs deleted file mode 100644 index 126f82a2c4f..00000000000 --- a/lib/rust/logger/src/macros.rs +++ /dev/null @@ -1,110 +0,0 @@ -//! Utilities for easy logger usage. Defines such macros as `debug!` or `warning!`. - - - -// ============== -// === Macros === -// ============== - -/// Internal utility for logging macros. -#[macro_export] -macro_rules! log_template { - ($expand:ident, $level:path, $logger:expr, $msg:ident) => { - $crate::LoggerOps::<$level>::log(&$logger,$level,$msg) - }; - - ($expand:ident, $level:path, $logger:expr, $msg:tt) => { - $crate::LoggerOps::<$level>::log(&$logger,$level,||$crate::iformat!($msg)) - }; - - ($expand:ident, $level:path, $logger:expr, || $msg:expr) => { - $crate::LoggerOps::<$level>::log(&$logger,$level,|| $msg) - }; - - ($expand:ident, $level:path, $logger:expr, $msg:tt, $new_expand:ident || $($body:tt)*) => { - $crate::log_template!{$new_expand,$level,$logger,$msg,||$($body)*} - }; - - ($expand:ident, $level:path, $logger:expr, || $msg:expr, $new_expand:ident || $($body:tt)*) => { - $crate::log_template!{$new_expand,$level,$logger,|| $msg,||$($body)*} - }; - - ($expand:ident, $level:path, $logger:expr, $msg:ident, || $($body:tt)*) => { - $crate::log_template_group!($expand,$level,$logger,[$msg],||$($body)*) - }; - - ($expand:ident, $level:path, $logger:expr, $msg:tt, || $($body:tt)*) => { - $crate::log_template_group!($expand,$level,$logger,[||$crate::iformat!($msg)],||$($body)*) - }; - - ($expand:ident, $level:path, $logger:expr, || $msg:expr, || $($body:tt)*) => { - $crate::log_template_group!($expand,$level,$logger,[||$msg],||$($body)*) - }; -} - -/// Internal utility for logging macros. -#[macro_export] -macro_rules! log_template_group { - ($expand:ident, $level:path, $logger:expr, [$($msg:tt)*], || $($body:tt)*) => { - { - $crate::LoggerOps::<$level>::group_begin - (&$logger,$level,$crate::collapsed_to_bool!($expand),$($msg)*); - let out = $($body)*; - $crate::LoggerOps::<$level>::group_end(&$logger,$level); - out - } - }; -} - -/// Internal utility for logging macros. -#[macro_export] -macro_rules! collapsed_to_bool { - (collapsed) => { - true - }; - (expanded) => { - false - }; -} - - -// ======================== -// === Macro Generation === -// ======================== - -/// Internal utility for logging macros. Generates all the logging macros. -/// -/// The generated macros can be used in a variety of forms: -/// - `warning!(logger,"literal")`, where literal will be formatted with `iformat`. -/// - `warning!(logger,identifier)`, where identifier is a string-like variable. -/// - `warning!(logger,|| expr)`, where expr returns a string-like variable. -/// -/// Moreover, for each form, you can pass a third parameter. If passed, the macro will become a -/// group, like `warning!(logger,"test",|| { ... })`. You can also use macro-keywords `collapsed` -/// or `expanded` just before `||` to print the group collapsed or expanded by default, -/// respectively. If not provided, the `warning` and `error` group macros are collapsed by default, -/// while all other group macros are expanded by default. -/// -/// # Implementation Details -/// Please note that the special pattern `$d` expands to just `$` in the generated macro from this -/// macro. -macro_rules! define_log_macros { - ($($d:tt $name:ident $tp_name:ident $expand:ident;)*) => {$( - #[doc = stringify!($tp_name)] - #[doc = " logging macro."] - #[macro_export] - macro_rules! $name { - ($d($d ts:tt)*) => { - $crate::log_template!{$expand,$crate::entry::level::$tp_name,$d($d ts)*} - }; - } - )*}; -} - -define_log_macros! { - $ trace Trace expanded; - $ debug Debug expanded; - $ info Info expanded; - $ warning Warning collapsed; - $ error Error collapsed; -} diff --git a/lib/rust/logger/src/processor.rs b/lib/rust/logger/src/processor.rs deleted file mode 100644 index e08e3b6b976..00000000000 --- a/lib/rust/logger/src/processor.rs +++ /dev/null @@ -1,459 +0,0 @@ -//! Logger processor implementation. - -use crate::prelude::*; -use wasm_bindgen::prelude::*; - -use crate::entry::level::DefaultLevels; -use crate::entry::Entry; - - -// ============== -// === Export === -// ============== - -pub mod consumer; -pub mod formatter; - - - -// =========================== -// === JavaScript Bindings === -// =========================== - -mod js { - use super::*; - #[wasm_bindgen(inline_js = " - export function setup_logs_flush(fn) { - let oldShowLogs = window.showLogs - window.showLogs = () => { - if (oldShowLogs) { oldShowLogs() } - fn() - } - } - - export function show_logs() { - window.showLogs() - } - - export function check_auto_flush() { - return (console.autoFlush === true) - } - ")] - extern "C" { - #[allow(unsafe_code)] - pub fn setup_logs_flush(closure: &Closure); - - #[allow(unsafe_code)] - pub fn show_logs(); - - // When the `showLogs` function is evaluated, the `autoFlush` flag is set to true. This - // may happen even before the WASM file is loaded, so it's worth checking whether it - // happened on startup. - #[allow(unsafe_code)] - pub fn check_auto_flush() -> bool; - } -} - - - -// ================= -// === Processor === -// ================= - -/// The most primitive building block of a logger. Processor takes some input and returns some -/// output, forming a message processing pipeline. -/// -/// Processors can be chained together with the use of the `Seq` processor. They can perform both -/// simple actions like formatting the logs or outputting them to console, as well as more complex -/// ones, like buffering them globally and dumping them on demand only. There are a lot of sample -/// processors defined in this module and its sub-modules. -/// -/// Processors always implement the `Default` trait, so it's sufficient to construct them using -/// type-level mechanisms only. For example, one of the simplest usages of processors would be a -/// processor defined as `Seq,Consumer>`, -/// which for each input message first formats it and then prints it to the JavaScript console. -#[allow(missing_docs)] -pub trait Processor { - type Output; - fn submit(&mut self, input: Input) -> Self::Output; -} - - - -// ================================== -// === Processors Implementations === -// ================================== - -// === Seq === - -/// A seq processor builder. It allows defining connected processors in a linear fashion. The macro -/// below generates a special type `Seq` which can accept two or more processors to be connected -/// together. Because it uses default arguments, you are allowed to use it like `Seq`, -/// or `Seq`. -#[derive(Debug, Default)] -#[allow(missing_docs)] -pub struct SeqBuilder { - pub first: First, - pub second: Second, -} - -impl Processor for SeqBuilder -where - First: Processor, - Second: Processor, -{ - type Output = Second::Output; - #[inline(always)] - fn submit(&mut self, input: Input) -> Self::Output { - self.second.submit(self.first.submit(input)) - } -} - - -// === Multi-args Seqs === - -macro_rules! define_seqs { - ($arg:tt,$($args:tt),*) => { - define_sub_seqs!{$arg,$($args),*} - /// A generic seq implementation. See docs of `SeqBuilder` to learn more. - pub type Seq = $arg; - }; -} - -macro_rules! define_sub_seqs { - () => {}; - ($arg:tt) => {}; - ($arg:tt, $($args:tt),*) => { - /// Nested seq. See docs of `SeqBuilder` to learn more. - pub type $arg<$arg,$($args),*> = define_seq_type!{$arg,$($args),*}; - define_sub_seqs! {$($args),*} - }; -} - -macro_rules! define_seq_type { - ($arg1:tt, $arg2:tt) => { - SeqBuilder<$arg1,$arg2> - }; - ($arg:tt $(,$args:tt)*) => { - SeqBuilder<$arg,define_seq_type!{$($args),*}> - }; -} - -define_seqs!(Seq5, Seq4, Seq3, Seq2, Seq1); - - -// === Branch === - -/// A branch processor builder. It passes the incoming input to all of its children. The macro -/// below generates a special type `Branch` which can accept two or more processors to be connected -/// together. Because it uses default arguments, you are allowed to use it like `Branch`, -/// or `Branch`. -#[derive(Debug, Default)] -#[allow(missing_docs)] -pub struct BranchBuilder { - pub first: First, - pub second: Second, -} - -impl Processor for BranchBuilder -where - First: Processor, - Second: Processor, - Input: Clone, -{ - type Output = (); - #[inline(always)] - fn submit(&mut self, input: Input) -> Self::Output { - self.first.submit(input.clone()); - self.second.submit(input); - } -} - - -// === Multi-args Branches === - -macro_rules! define_branches { - ($arg:tt,$($args:tt),*) => { - define_sub_branches!{$arg,$($args),*} - /// A generic seq implementation. See docs of `SeqBuilder` to learn more. - pub type Branch = $arg; - }; -} - -macro_rules! define_sub_branches { - () => {}; - ($arg:tt) => {}; - ($arg:tt, $($args:tt),*) => { - /// Nested seq. See docs of `SeqBuilder` to learn more. - pub type $arg<$arg,$($args),*> = define_branch_type!{$arg,$($args),*}; - define_sub_branches! {$($args),*} - }; -} - -macro_rules! define_branch_type { - ($arg1:tt, $arg2:tt) => { - SeqBuilder<$arg1,$arg2> - }; - ($arg:tt $(,$args:tt)*) => { - SeqBuilder<$arg,define_branch_type!{$($args),*}> - }; -} - -define_branches!(Branch5, Branch4, Branch3, Branch2, Branch1); - - -// === Drop Processor === - -/// Drop processor. Does nothing, just drops the input. -#[derive(Clone, Copy, Debug, Default)] -pub struct Drop; - -impl Processor for Drop { - type Output = (); - #[inline(always)] - fn submit(&mut self, _input: Input) {} -} - - -// === Identity Processor === - -/// Identity processor. It passes its input to output without performing any modification. -#[derive(Clone, Copy, Debug, Default)] -pub struct Identity; - -impl Processor for Identity { - type Output = Input; - #[inline(always)] - fn submit(&mut self, input: Input) -> Self::Output { - input - } -} - - -// === Formatter === - -/// Formatter processor. It uses the provided formatter to format its input. -#[derive(Debug, Default)] -pub struct Formatter { - formatter: PhantomData, -} - -impl Processor> for Formatter -where Fmt: formatter::GenericDefinition -{ - type Output = (Entry, Option); - #[inline(always)] - fn submit(&mut self, entry: Entry) -> Self::Output { - let out = ::generic_format(&entry); - (entry, out) - } -} - - -// === Consumer === - -/// Consumer processor. It uses the provided consumer to consume the results, and probably print -/// them on the screen or write to a file. -#[derive(Debug, Default)] -pub struct Consumer { - consumer: T, -} - -impl Processor<(Entry, Option)> for Consumer -where C: consumer::Definition -{ - type Output = (); - #[inline(always)] - fn submit(&mut self, (entry, message): (Entry, Option)) -> Self::Output { - self.consumer.consume(entry, message) - } -} - - -// === Buffer === - -#[derive(Debug, Derivative)] -#[allow(missing_docs)] -pub struct Buffer { - model: Rc>>, - _closure: Closure, -} - -impl Default for Buffer -where - Input: 'static, - Next: 'static + Default + Processor, -{ - fn default() -> Self { - let model = Rc::new(RefCell::new(BufferModel::::default())); - let closure = Closure::new(f!(model.borrow_mut().flush_and_enable_auto_flush())); - js::setup_logs_flush(&closure); - if cfg!(debug_assertions) { - println!("Debug mode. Logs will be enabled automatically."); - js::show_logs(); - } - Self { model, _closure: closure } - } -} - -impl Processor for Buffer -where Next: Processor -{ - type Output = (); - #[inline(always)] - fn submit(&mut self, input: Input) { - self.model.borrow_mut().submit(input); - } -} - -#[derive(Debug)] -#[allow(missing_docs)] -pub struct BufferModel { - buffer: Vec, - auto_flush: bool, - next: Next, -} - -impl BufferModel -where Next: Processor -{ - /// Constructor. - pub fn new() -> Self - where Next: Default { - let auto_flush = js::check_auto_flush(); - let buffer = default(); - let next = default(); - Self { buffer, auto_flush, next } - } - - /// Submit the input to the buffer or the subsequent processor in case the `auto_flush` is - /// enabled. - pub fn submit(&mut self, input: Input) { - if self.auto_flush { - self.next.submit(input); - } else { - self.buffer.push(input); - } - } - - /// Pass all buffered entries to the subsequent processor. - pub fn flush(&mut self) { - for input in mem::take(&mut self.buffer) { - self.next.submit(input); - } - } - - /// Pass all buffered entries to the subsequent processor and set the `auto_flush` flag to on. - pub fn flush_and_enable_auto_flush(&mut self) { - self.flush(); - self.auto_flush = true; - } -} - -impl Default for BufferModel -where Next: Processor + Default -{ - fn default() -> Self { - Self::new() - } -} - - -// === Global === - -#[derive(Debug, Default)] -#[allow(missing_docs)] -pub struct Global { - processor: PhantomData, -} - -impl Processor for Global

-where - P: GlobalProcessor, - P::Processor: 'static + Processor, -{ - type Output = <

::Processor as Processor>::Output; - #[inline(always)] - fn submit(&mut self, entry: Input) -> Self::Output { - global_processor::

().submit(entry) - } -} - -/// Abstraction for global processors. Global processors may be insanely useful to optimize the -/// logging performance. You can, for example, define a single global processor and redirect all -/// loggers to it. The single global processor can have a buffer layer, which will buffer messages -/// without formatting them and will format all of them and print them to the screen on-demand only. -#[allow(missing_docs)] -pub trait GlobalProcessor { - type Processor; - fn get_mut() -> &'static mut Self::Processor; -} - -/// Get a reference to a global processor. Read docs of `GlobalProcessor` to learn more. -pub fn global_processor() -> &'static mut T::Processor { - T::get_mut() -} - -/// Define a global processor based on the provided type. Read the docs of `GlobalProcessor` to -/// learn more. -#[macro_export] -macro_rules! define_global_processor { - ($name:ident = $tp:ty;) => { - /// Global processor definition. - #[derive(Copy, Clone, Debug, Default)] - pub struct $name; - paste! { - #[allow(non_upper_case_globals)] - static mut [<$name _STATIC_MUT>]: Option<$tp> = None; - } - impl GlobalProcessor for $name { - type Processor = $tp; - paste! { - #[allow(unsafe_code)] - fn get_mut() -> &'static mut Self::Processor { - unsafe { - match &mut [<$name _STATIC_MUT>] { - Some(t) => t, - None => { - let processor = default(); - [<$name _STATIC_MUT>] = Some(processor); - [<$name _STATIC_MUT>].as_mut().unwrap() - } - } - } - } - } - } - }; -} - - - -// ======================== -// === DefaultProcessor === -// ======================== - -/// Default processor implementation. -#[cfg(target_arch = "wasm32")] -pub type DefaultProcessor = DefaultJsProcessor; - -/// Default processor implementation. -#[cfg(not(target_arch = "wasm32"))] -pub type DefaultProcessor = DefaultNativeProcessor; - -#[allow(dead_code)] -type DefaultJsProcessor = Global; - -#[allow(dead_code)] -type DefaultNativeProcessor = - Seq, Consumer>; - -define_global_processor! { - DefaultGlobalJsProcessor = - Buffer, - Seq < - Formatter, - Consumer - > - >; -} diff --git a/lib/rust/logger/src/processor/consumer.rs b/lib/rust/logger/src/processor/consumer.rs deleted file mode 100644 index 9586ad9ba06..00000000000 --- a/lib/rust/logger/src/processor/consumer.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! Log consumer implementation. - -use crate::entry::Entry; - - -// ============== -// === Export === -// ============== - -pub mod js_console; -pub mod native_console; - -pub use js_console::JsConsole; -pub use native_console::NativeConsole; - - - -// ======================== -// === Default Consumer === -// ======================== - -/// Default consumer. -pub type Default = JsConsole; - - -// ================ -// === Consumer === -// ================ - -/// Consumer takes the incoming entry and a message formatted by the used formatter and executes an -/// action, like writing the things to the console, sending them via network, or buffering in a -/// queue. -#[allow(missing_docs)] -pub trait Definition { - fn consume(&mut self, entry: Entry, message: Option); -} diff --git a/lib/rust/logger/src/processor/consumer/js_console.rs b/lib/rust/logger/src/processor/consumer/js_console.rs deleted file mode 100644 index 0a779492094..00000000000 --- a/lib/rust/logger/src/processor/consumer/js_console.rs +++ /dev/null @@ -1,87 +0,0 @@ -//! JavaScript console consumer implementation. - -use wasm_bindgen::prelude::*; - -use crate::entry; -use crate::entry::Entry; -use crate::processor::consumer; - -use web_sys::console; - - - -mod js { - use super::*; - #[wasm_bindgen(inline_js = " - export function console_group_end() { - console.groupEnd() - } - ")] - extern "C" { - // FIXME[WD]: Issue https://github.com/rustwasm/wasm-bindgen/issues/2376 - // This is just the same as `wasm_bindgen::console::group_end` with one important - // difference. It seems that `wasm_bindgen` somehow caches all functions without args on - // initialization, and thus, as we are redefining what `console.group_end` is in JS, the - // function provided by the library, unlike this one, does not reflect the change. - #[allow(unsafe_code)] - pub fn console_group_end(); - } -} - - - -// ========================== -// === JsConsole Consumer === -// ========================== - -/// A simple consumer which uses JavaScript console API to print hierarchical logs in a browser. -#[derive(Clone, Copy, Debug, Default)] -pub struct JsConsole; - -impl consumer::Definition for JsConsole -where Levels: Writer -{ - fn consume(&mut self, event: Entry, message: Option) { - match &event.content { - entry::Content::Message(_) => - if let Some(msg) = message { - event.level.write_by_level(&msg) - }, - entry::Content::GroupBegin(group) => - if let Some(msg) = message { - if group.collapsed { - console::group_collapsed(&msg) - } else { - console::group(&msg) - } - }, - entry::Content::GroupEnd => js::console_group_end(), - } - } -} - -/// Trait that is used to determine how the JS logging is dispatched for different log levels. -/// Default blanket implementation uses `console.log`. -pub trait Writer { - /// Write message using the appropriate console method. - fn write_by_level(&self, message: &js_sys::Array); -} - -impl Writer for T { - default fn write_by_level(&self, message: &js_sys::Array) { - console::log(message) - } -} - -impl Writer for crate::entry::level::DefaultLevels { - fn write_by_level(&self, message: &js_sys::Array) { - use crate::entry::level::DefaultLevels::*; - match *self { - Trace => console::trace(message), - Debug => console::debug(message), - Info => console::info(message), - Warning => console::warn(message), - Error => console::error(message), - } - } -} diff --git a/lib/rust/logger/src/processor/consumer/native_console.rs b/lib/rust/logger/src/processor/consumer/native_console.rs deleted file mode 100644 index b517cb7d14a..00000000000 --- a/lib/rust/logger/src/processor/consumer/native_console.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! Native console consumer implementation. - -use crate::entry; -use crate::entry::Entry; -use crate::processor::consumer; - - - -// =============================== -// === Native Console Consumer === -// =============================== - -/// A simple consumer which uses `println!` to simulate hierarchical logging. -#[derive(Clone, Copy, Debug, Default)] -pub struct NativeConsole { - depth: usize, - collapsed_depth: usize, -} - -impl NativeConsole { - fn print(&self, msg: String) { - if self.collapsed_depth == 0 { - if self.depth == 0 { - println!("{}", msg) - } else { - let pfx = " ".repeat(4 * self.depth); - println!("{}{}", pfx, msg) - } - } - } -} - -impl consumer::Definition for NativeConsole { - fn consume(&mut self, event: Entry, message: Option) { - match &event.content { - entry::Content::Message(_) => - if let Some(msg) = message { - self.print(msg); - }, - entry::Content::GroupBegin(group) => { - if let Some(msg) = message { - self.print(msg); - } - if group.collapsed { - self.collapsed_depth += 1 - } else { - self.depth += 1 - } - } - entry::Content::GroupEnd => - if self.collapsed_depth > 0 { - self.collapsed_depth -= 1 - } else { - self.depth -= 1 - }, - } - } -} diff --git a/lib/rust/logger/src/processor/formatter.rs b/lib/rust/logger/src/processor/formatter.rs deleted file mode 100644 index 394c767ae79..00000000000 --- a/lib/rust/logger/src/processor/formatter.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! Log formatter implementation. - -use crate::entry::Entry; -use crate::entry::GenericEntry; - - -// ============== -// === Export === -// ============== - -pub mod js_console; -pub mod native_console; - -pub use js_console::JsConsole; -pub use native_console::NativeConsole; - - - -// ========================= -// === Default Formatter === -// ========================= - -/// Default log formatter. -pub type Default = JsConsole; - - - -// ================= -// === Formatter === -// ================= - -/// Output of a formatter as a dependent type of the formatter type. Each formatter defines its -/// output type. For example, formatters highly tailored for JavaScript console may output a special -/// console formatting values. -#[allow(missing_docs)] -pub trait Output { - type Output; -} - -/// A formatter allows formatting the incoming entry according to specific rules. The output is -/// optional, as not all entries need to be formatted. For example, some loggers might want to -/// display a visual indicator when a group is closed, while others will use API for that. -/// -/// ## WARNING -/// This trait should be implemented automatically. See the macro `define_levels_group` to learn -/// more. -#[allow(missing_docs)] -pub trait GenericDefinition: Output { - fn generic_format(entry: &Entry) -> Option; -} - -/// A formatter narrowed to a specific type. While `Definition` can be parametrized with a generic -/// type, like `AllPossibleLevels`, this trait is parametrized with a specific level only, like -/// `level::Error`. Read docs of `Definition` to learn more. -#[allow(missing_docs)] -pub trait Definition: Output { - fn format(entry: &GenericEntry) -> Option; -} - -/// Alias to `Definition::format` allowing providing the type parameters on call side. -pub fn format(entry: &GenericEntry) -> Option -where Fmt: Definition { - ::format(entry) -} diff --git a/lib/rust/logger/src/processor/formatter/js_console.rs b/lib/rust/logger/src/processor/formatter/js_console.rs deleted file mode 100644 index 811e5cde330..00000000000 --- a/lib/rust/logger/src/processor/formatter/js_console.rs +++ /dev/null @@ -1,61 +0,0 @@ -//! JavaScript console formatter implementation. - -use crate::prelude::*; - -use crate::entry::level; -use crate::entry::GenericEntry; -use crate::processor::formatter; - - - -// ================= -// === JsConsole === -// ================= - -/// A nicely looking, colorful, basic formatter for a JavaScript console. -#[derive(Clone, Copy, Debug, Default)] -pub struct JsConsole; - -impl formatter::Output for JsConsole { - type Output = js_sys::Array; -} - -impl JsConsole { - fn format_color(path: &str, color: Option<&str>, msg: String) -> js_sys::Array { - let msg = format!("%c {} %c {}", path, msg).into(); - let css1 = "color:#ffffff;background:dimgray;border-radius:4px".into(); - let css2 = color.map(|c| iformat!("color:{c}")).unwrap_or_default().into(); - let arr = js_sys::Array::new(); - arr.push(&msg); - arr.push(&css1); - arr.push(&css2); - arr - } -} - - -// === Impls === - -impl formatter::Definition for JsConsole { - fn format(entry: &GenericEntry) -> Option { - entry - .content - .message() - .map(|msg| Self::format_color(&entry.path, Some("orange"), format!("[W] {}", msg))) - } -} - -impl formatter::Definition for JsConsole { - fn format(entry: &GenericEntry) -> Option { - entry - .content - .message() - .map(|msg| Self::format_color(&entry.path, Some("orangered"), format!("[E] {}", msg))) - } -} - -impl formatter::Definition for JsConsole { - default fn format(entry: &GenericEntry) -> Option { - entry.content.message().map(|msg| Self::format_color(&entry.path, None, msg.to_owned())) - } -} diff --git a/lib/rust/logger/src/processor/formatter/native_console.rs b/lib/rust/logger/src/processor/formatter/native_console.rs deleted file mode 100644 index b9570264894..00000000000 --- a/lib/rust/logger/src/processor/formatter/native_console.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! Native console formatter implementation. - -use crate::prelude::*; - -use crate::entry::level; -use crate::entry::GenericEntry; -use crate::processor::formatter; - - - -// ===================== -// === NativeConsole === -// ===================== - -/// A nicely looking, colorful, basic formatter for a JavaScript console. -#[derive(Clone, Copy, Debug, Default)] -pub struct NativeConsole; - -impl formatter::Output for NativeConsole { - type Output = String; -} - - -// === Impls === - -impl formatter::Definition for NativeConsole { - fn format(entry: &GenericEntry) -> Option { - entry.content.message().map(|msg| format!("[W] {}", msg)) - } -} - -impl formatter::Definition for NativeConsole { - fn format(entry: &GenericEntry) -> Option { - entry.content.message().map(|msg| format!("[E] {}", msg)) - } -} - -impl formatter::Definition for NativeConsole { - default fn format(entry: &GenericEntry) -> Option { - entry.content.message().map(|msg| msg.to_owned()) - } -} diff --git a/lib/rust/metamodel/Cargo.toml b/lib/rust/metamodel/Cargo.toml index bf945dd7778..662cbcf963e 100644 --- a/lib/rust/metamodel/Cargo.toml +++ b/lib/rust/metamodel/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" authors = ["Enso Team "] [dependencies] -derivative = "2.2" -derive_more = "0.99" +derivative = { workspace = true } +derive_more = { workspace = true } [dev-dependencies] bincode = "1.3" diff --git a/lib/rust/metamodel/lexpr/Cargo.toml b/lib/rust/metamodel/lexpr/Cargo.toml index 786e01d22a4..e4b5b8c2482 100644 --- a/lib/rust/metamodel/lexpr/Cargo.toml +++ b/lib/rust/metamodel/lexpr/Cargo.toml @@ -9,7 +9,7 @@ lexpr = "0.2.6" bincode = "1.3" serde = "1" enso-metamodel = { path = "../" } -derivative = "2.2" +derivative = { workspace = true } [dev-dependencies] serde = { version = "1", features = ["derive"] } diff --git a/lib/rust/parser/Cargo.toml b/lib/rust/parser/Cargo.toml index e46d7fd4f43..815caa6c57e 100644 --- a/lib/rust/parser/Cargo.toml +++ b/lib/rust/parser/Cargo.toml @@ -17,7 +17,7 @@ enso-types = { path = "../types" } enso-shapely-macros = { path = "../shapely/macros" } enso-parser-syntax-tree-visitor = { path = "src/syntax/tree/visitor" } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde_json = { workspace = true } uuid = { version = "1.1", features = ["serde"] } bincode = "1.3" diff --git a/lib/rust/parser/generate-java/Cargo.toml b/lib/rust/parser/generate-java/Cargo.toml index 53069e6e717..f4b4c91bc8d 100644 --- a/lib/rust/parser/generate-java/Cargo.toml +++ b/lib/rust/parser/generate-java/Cargo.toml @@ -14,4 +14,4 @@ enso-metamodel = { path = "../../metamodel", features = ["rust", "java"] } enso-prelude = { path = "../../prelude" } enso-parser = { path = ".." } enso-reflect = { path = "../../reflect", features = ["graphviz"] } -derivative = "2.2" +derivative = { workspace = true } diff --git a/lib/rust/parser/jni/Cargo.toml b/lib/rust/parser/jni/Cargo.toml index 6c62bc9d4cc..589b9d5200b 100644 --- a/lib/rust/parser/jni/Cargo.toml +++ b/lib/rust/parser/jni/Cargo.toml @@ -12,7 +12,7 @@ license-file = "../../LICENSE" [dependencies] enso-prelude = { path = "../../prelude" } enso-parser = { path = "../" } -bincode = "1.3" +bincode = { workspace = true } jni = "0.19.0" [lib] diff --git a/lib/rust/parser/src/source/code.rs b/lib/rust/parser/src/source/code.rs index e332d867328..fde5f6f1d66 100644 --- a/lib/rust/parser/src/source/code.rs +++ b/lib/rust/parser/src/source/code.rs @@ -9,13 +9,13 @@ use crate::prelude::*; // ============ /// A code representation. It can either be a borrowed source code or a modified owned one. -#[derive(Clone, Default, Eq, PartialEq, Shrinkwrap, Serialize, Reflect, Deserialize)] +#[derive(Clone, Default, Eq, PartialEq, Serialize, Reflect, Deserialize, Deref)] #[allow(missing_docs)] pub struct Code<'s> { #[serde(serialize_with = "crate::serialization::serialize_cow")] #[serde(deserialize_with = "crate::serialization::deserialize_cow")] #[reflect(as = "crate::serialization::Code", flatten, hide)] - #[shrinkwrap(main_field)] + #[deref] pub repr: Cow<'s, str>, #[reflect(hide)] pub utf16: usize, diff --git a/lib/rust/prelude/Cargo.toml b/lib/rust/prelude/Cargo.toml index 2fd86aaf873..24f1fd1ecb9 100644 --- a/lib/rust/prelude/Cargo.toml +++ b/lib/rust/prelude/Cargo.toml @@ -19,34 +19,24 @@ crate-type = ["rlib"] enso-logging = { path = "../logging" } enso-reflect = { path = "../reflect" } enso-shapely = { path = "../shapely" } -anyhow = "1.0.66" -assert_approx_eq = { version = "1.1.0" } -backtrace = "0.3.53" -boolinator = "2.4.0" -cfg-if = "1.0.0" -colored = "2.0.0" -derivative = "2.2.0" -derive_more = "0.99" -enclose = "1.1.8" -failure = "0.1.5" -futures = { version = "0.3.1" } -ifmt = "0.3.3" -itertools = "0.10.0" -lazy_static = "1.4" -num = "0.4.0" -object = { version = "0.24.0" } -paste = "1.0" -shrinkwraprs = "0.3.0" -serde = { version = "1.0.126", features = ["derive", "rc"] } -serde_json = { version = "1.0" } -smallvec = "1.0.0" -wasm-bindgen = { workspace = true } -weak-table = "0.3.0" enso-web = { path = "../web" } -gen-iter = "0.2.1" - -[target.'cfg(target_arch = "wasm32")'.dependencies] +anyhow = { workspace = true } +assert_approx_eq = { workspace = true } +backtrace = { workspace = true } +boolinator = { workspace = true } +derivative = { workspace = true } +derive_more = { workspace = true } +failure = { workspace = true } +futures = { workspace = true } +itertools = { workspace = true } +lazy_static = { workspace = true } +paste = { workspace = true } +serde = { version = "1.0.126", features = ["derive", "rc"] } +serde_json = { workspace = true } +smallvec = { workspace = true } wasm-bindgen = { workspace = true } +weak-table = { workspace = true } +gen-iter = { workspace = true } [dependencies.web-sys] version = "0.3.4" diff --git a/lib/rust/prelude/src/debug.rs b/lib/rust/prelude/src/debug.rs index 43532d9daf1..0647d1657aa 100644 --- a/lib/rust/prelude/src/debug.rs +++ b/lib/rust/prelude/src/debug.rs @@ -1,14 +1,11 @@ use crate::*; + // ============== // === Export === // ============== -pub mod logging; - - - #[cfg(target_arch = "wasm32")] pub mod internal { use wasm_bindgen::prelude::*; @@ -35,16 +32,13 @@ pub mod internal { #[cfg(not(target_arch = "wasm32"))] mod internal { - use crate::*; - extern crate backtrace as bt; - use bt::Backtrace; /// Print the current backtrace. pub fn backtrace() -> String { let bt = Backtrace::new(); - iformat!("{bt:?}") + format!("{bt:?}") } } @@ -99,7 +93,7 @@ impl Clone for TraceCopies { let handle = self.handle.clone(); if let Some(name) = &*borrow { let bt = backtrace(); - iprintln!("[{name}] Cloning {self.clone_id} -> {clone_id} {bt}"); + println!("[{name}] Cloning {} -> {clone_id} {bt}", self.clone_id); } Self { clone_id, handle } } @@ -112,7 +106,7 @@ impl CloneRef for TraceCopies { let handle = self.handle.clone_ref(); if let Some(name) = &*borrow { let bt = backtrace(); - DEBUG!("[{name}] Cloning {self.clone_id} -> {clone_id} {bt}"); + debug!("[{name}] Cloning {} -> {clone_id} {bt}", self.clone_id); } Self { clone_id, handle } } @@ -124,7 +118,7 @@ impl Drop for TraceCopies { if let Some(name) = &*borrow { let bt = backtrace(); let instances = Rc::strong_count(&self.handle) - 1; - DEBUG!("[{name}] Dropping {self.clone_id}; instances left: {instances} {bt}"); + debug!("[{name}] Dropping {}; instances left: {instances} {bt}", self.clone_id); } } } diff --git a/lib/rust/prelude/src/debug/logging.rs b/lib/rust/prelude/src/debug/logging.rs deleted file mode 100644 index 930a3870fdf..00000000000 --- a/lib/rust/prelude/src/debug/logging.rs +++ /dev/null @@ -1,107 +0,0 @@ -//! This module provides several logging macros. -//! -//! Because in recent Rust toolchain versions it is impossible to redirect standard ouput stream to -//! Web Console. This made impossible to quickly add ad-hoc logs with `println!` during development. -//! Macros provided by this module aim to fill this gap. -//! -//! Macros intentionally defy our naming rules by being in UPPERCASE. They are not to be used in -//! production-ready code, so they should be easy to visually catch during code reviews. -//! Also, this gets us good names that otherwise would be already used. - - - -/// Defines the methods from given names. -/// -/// Must be invoked with arguments `$ [...] [...]...` where [...] is triple `[lower UPPER color]`. -/// `lower` refers to the name of the Web Console function. -/// `UPPER` is the name of the generated logging macro. -/// `color` is the log color that will be used when writing to native (non-web) console output. -/// -/// For each given triple `[lower UPPER color]` two symbols are defined: -/// * a function `$lower` that writes given text to standard output on native targets and to Web -/// Console on wasm targets. -/// * a macro `$UPPER` that wraps the above function with `println`-like syntax. -/// -/// Note: The first argument `$d` must be `$` (dollar sign). It is used to insert dollar sign in the -/// nested macro. -macro_rules! define_debug_macros { - ($d:tt $([$lower:ident $upper:ident $color:ident])*) => {$( - /// Writes given text either to the stdout (non-wasm) or Web Console (wasm). - pub fn $lower(text:impl AsRef) { - cfg_if::cfg_if! { - if #[cfg(target_arch="wasm32")] { - use web_sys::console::*; - concat_idents!($lower,_1)(&wasm_bindgen::JsValue::from_str(text.as_ref())); - } else { - use colored::*; - println!("[{}] {}", stringify!($upper).$color(), text.as_ref()); - } - } - } - - // FIXME [mwu] Should be restored. See [Clippy ICE workaround] - // /// Special logging macro that prints to the Web Console on wasm targets and stdout - // /// otherwise. It is supposed to be used only for development purposes and shouldn't be - // /// present in a production-ready code. - // /// Macro follows `iformat` formatting convention. - // #[macro_export] macro_rules! $upper { - // ($d($d arg:tt)*) => { - // $crate::debug::logging:: $lower($crate::iformat!($d ($d arg)*)) - // } - // } - )*} -} - -// FIXME [mwu] Should be removed. See [Clippy ICE workaround] -mod manually_expanded; - -// Note [Clippy ICE workaround] -// ~~~~~~~~~~~~~~~~~~~~~ -// The recent Clippy introduced ICE that happens when other crate uses debug macros in a lambda. -// To workaround this we need to define them manually, rather than with `define_debug_macros`. -// When https://github.com/rust-lang/rust-clippy/issues/7272 is resolved, we should bump and: -// 1) uncomment the second part of `define_debug_macros`; -// 2) remove the `manually_expanded` module altogether. - -define_debug_macros! {$ - [trace TRACE purple] - [debug DEBUG blue] - [info INFO white] - [warn WARNING yellow] - [error ERROR red] -} - -#[cfg(test)] -mod tests { - use crate::*; - use wasm_bindgen_test::*; - wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); - - // We don't have any convenient means to check what gets written. So at least we check that the - // all macros are present and can be invoked. - - #[test] - fn native_calls() { - let var = 39; - TRACE!("test"); - DEBUG!("Using new iformat syntax: var = " var ". Is that much?"); - INFO!("Using old iformat syntax: var = {var}. Is that much?"); - WARNING!("test"); - ERROR!("test"); - } - #[wasm_bindgen_test] - fn wasm_calls() { - let var = 39; - TRACE!("test"); - DEBUG!("Using new iformat syntax: var = " var ". Is that much?"); - INFO!("Using old iformat syntax: var = {var}. Is that much?"); - WARNING!("test"); - ERROR!("test"); - } -} - -/// Instruction of how to report important errors. -pub const REPORT_INSTRUCTION: &str = "We will be thankful for reporting this error here: \ -https://github.com/enso-org/enso/issues. Please, provide us with as much information as possible, \ -including your system specification, browser version, and a detailed description of the steps you \ -made before this error happened."; diff --git a/lib/rust/prelude/src/debug/logging/manually_expanded.rs b/lib/rust/prelude/src/debug/logging/manually_expanded.rs deleted file mode 100644 index ce145b38ea3..00000000000 --- a/lib/rust/prelude/src/debug/logging/manually_expanded.rs +++ /dev/null @@ -1,79 +0,0 @@ -//! This module contains manually expanded macros that should be defined by `define_debug_macros`. -//! See [Clippy ICE workaround] in [crate::debug::logging]. - - - -/// Special logging macro that prints to the Web Console on wasm targets and stdout -/// otherwise. It is supposed to be used only for development purposes and shouldn't be -/// present in a production-ready code. -/// Macro follows `iformat` formatting convention. -#[macro_export] -macro_rules! TRACE { - ($($arg:tt)*) => { - $crate::debug::logging::trace($crate::iformat!($($arg)*)) - } -} - -/// Special logging macro that prints to the Web Console on wasm targets and stdout -/// otherwise. It is supposed to be used only for development purposes and shouldn't be -/// present in a production-ready code. -/// Macro follows `iformat` formatting convention. -#[macro_export] -macro_rules! DEBUG { - ($($arg:tt)*) => { - $crate::debug::logging::debug($crate::iformat!($($arg)*)) - } -} - -/// Special logging macro that prints to the Web Console on wasm targets and stdout -/// otherwise. It is supposed to be used only for development purposes and shouldn't be -/// present in a production-ready code. -/// Macro follows `iformat` formatting convention. -#[macro_export] -macro_rules! INFO { - ($($arg:tt)*) => { - $crate::debug::logging::info($crate::iformat!($($arg)*)) - } -} - -/// Special logging macro that prints to the Web Console on wasm targets and stdout -/// otherwise. It is supposed to be used only for development purposes and shouldn't be -/// present in a production-ready code. -/// Macro follows `iformat` formatting convention. -#[macro_export] -macro_rules! WARNING { - ($($arg:tt)*) => { - $crate::debug::logging::warn($crate::iformat!($($arg)*)) - } -} - -/// Special logging macro that prints to the Web Console on wasm targets and stdout -/// otherwise. It is supposed to be used only for development purposes and shouldn't be -/// present in a production-ready code. -/// Macro follows `iformat` formatting convention. -#[macro_export] -macro_rules! ERROR { - ($($arg:tt)*) => { - $crate::debug::logging::error($crate::iformat!($($arg)*)) - } -} - -/// A version of [`WARNING`] that informs the user how to report the error. -#[macro_export] -macro_rules! REPORTABLE_WARNING { - ($($arg:tt)*) => { - let user_message = $crate::iformat!($($arg)*); - let message = format!("{} {}",user_message, $crate::debug::logging::REPORT_INSTRUCTION); - $crate::debug::logging::warn(message) - } -} - -/// A version of [`ERROR`] that informs the user how to report the error. -#[macro_export] -macro_rules! REPORTABLE_ERROR { - ($($arg:tt)*) => { - let user_message = $crate::iformat!($($arg)*); - let message = format!("{} {}",user_message, $crate::debug::logging::REPORT_INSTRUCTION); - $crate::debug::logging::error(message) - } -} diff --git a/lib/rust/prelude/src/lib.rs b/lib/rust/prelude/src/lib.rs index e9dcc529a45..7afb7d8fa56 100644 --- a/lib/rust/prelude/src/lib.rs +++ b/lib/rust/prelude/src/lib.rs @@ -87,14 +87,10 @@ pub use assert_approx_eq::assert_approx_eq; pub use boolinator::Boolinator; pub use derivative::Derivative; pub use derive_more::*; -pub use enclose::enclose; pub use failure::Fail; -pub use ifmt::*; pub use itertools::Itertools; pub use lazy_static::lazy_static; -pub use num::Num; pub use paste::paste; -pub use shrinkwraprs::Shrinkwrap; pub use weak_table; pub use weak_table::traits::WeakElement; @@ -162,6 +158,28 @@ pub use enso_logging::trace_span; pub use enso_logging::warn; pub use enso_logging::warn_span; +/// Instruction of how to report important errors. +pub const REPORT_INSTRUCTION: &str = "We will be thankful for reporting this issue here: \ +https://github.com/enso-org/enso/issues. Please, provide us with as much information as possible, \ +including your system specification, browser version, and a detailed description of the steps you \ +made before this error happened."; + +#[macro_export] +macro_rules! reportable_warn { + ($($ts:tt)*) => { + $crate::warn!{$($ts)*} + $crate::warn!("{}", $crate::REPORT_INSTRUCTION) + }; +} + +#[macro_export] +macro_rules! reportable_error { + ($($ts:tt)*) => { + $crate::error!{$($ts)*} + $crate::error!("{}", $crate::REPORT_INSTRUCTION) + }; +} + pub fn init_global() { init_global_internal(); } @@ -396,7 +414,7 @@ impl RefCellOptionOps for RefCell> { default fn set_if_empty_or_warn(&self, val: T) { if self.borrow().is_some() { - WARNING!("Trying to set value that was already set.") + warn!("Trying to set value that was already set.") } *self.borrow_mut() = Some(val); } @@ -405,9 +423,7 @@ impl RefCellOptionOps for RefCell> { impl RefCellOptionOps for RefCell> { fn set_if_empty_or_warn(&self, val: T) { if let Some(ref current) = *self.borrow() { - WARNING!( - "Trying to set value that was already set (current: {current:?}; new: {val:?})." - ) + warn!("Trying to set value that was already set (current: {current:?}; new: {val:?}).") } *self.borrow_mut() = Some(val); } diff --git a/lib/rust/prelude/src/phantom.rs b/lib/rust/prelude/src/phantom.rs index 81a8c410c24..c8e12ae35e7 100644 --- a/lib/rust/prelude/src/phantom.rs +++ b/lib/rust/prelude/src/phantom.rs @@ -3,7 +3,6 @@ use super::std_reexports::*; use derivative::Derivative; -use shrinkwraprs::Shrinkwrap; @@ -39,13 +38,10 @@ pub type PhantomData9 = /// A wrapper adding a phantom type to a structure. #[derive(Derivative)] -#[derive(Shrinkwrap)] -#[shrinkwrap(mutable)] #[derivative(Clone(bound = "T:Clone"))] #[derivative(Default(bound = "T:Default"))] #[derivative(Debug(bound = "T:Debug"))] pub struct WithPhantom { - #[shrinkwrap(main_field)] pub without_phantom: T, phantom: PhantomData

, } diff --git a/lib/rust/profiler/Cargo.toml b/lib/rust/profiler/Cargo.toml index b8652be12e0..7dd823d8872 100644 --- a/lib/rust/profiler/Cargo.toml +++ b/lib/rust/profiler/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" authors = ["Enso Team "] [dependencies] -futures = "0.3" +futures = { workspace = true } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0.59", features = ["raw_value"] } wasm-bindgen = { workspace = true } diff --git a/lib/rust/profiler/data/Cargo.toml b/lib/rust/profiler/data/Cargo.toml index 18ea5c425bd..e54a6d83846 100644 --- a/lib/rust/profiler/data/Cargo.toml +++ b/lib/rust/profiler/data/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" authors = ["Enso Team "] [dependencies] -derivative = "2.2.0" +derivative = { workspace = true } serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde_json = { workspace = true } enso-prelude = { path = "../../prelude" } enso-profiler = { path = "../" } [dev-dependencies] -futures = "0.3" +futures = { workspace = true } diff --git a/lib/rust/profiler/demo-data/Cargo.toml b/lib/rust/profiler/demo-data/Cargo.toml index 1b79d8acd9f..8947e5f4603 100644 --- a/lib/rust/profiler/demo-data/Cargo.toml +++ b/lib/rust/profiler/demo-data/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" authors = ["Enso Team "] [dependencies] -futures = "0.3" +futures = { workspace = true } enso-profiler = { path = ".." } diff --git a/lib/rust/profiler/flame-graph/Cargo.toml b/lib/rust/profiler/flame-graph/Cargo.toml index a77c7df6f1f..5cc19957bd1 100644 --- a/lib/rust/profiler/flame-graph/Cargo.toml +++ b/lib/rust/profiler/flame-graph/Cargo.toml @@ -9,4 +9,4 @@ enso-profiler = { path = "../" } enso-profiler-data = { path = "../data" } [dev-dependencies] -futures = "0.3" +futures = { workspace = true } diff --git a/lib/rust/reflect/Cargo.toml b/lib/rust/reflect/Cargo.toml index 7f5c6d99537..1bbb03c1f68 100644 --- a/lib/rust/reflect/Cargo.toml +++ b/lib/rust/reflect/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Enso Team "] [dependencies] enso-reflect-macros = { path = "macros" } enso-metamodel = { path = "../metamodel", features = ["rust"] } -derivative = "2.2" +derivative = { workspace = true } [features] default = ["graphviz"] diff --git a/lib/rust/shapely/Cargo.toml b/lib/rust/shapely/Cargo.toml index 9bbbe3331f2..482437ab554 100644 --- a/lib/rust/shapely/Cargo.toml +++ b/lib/rust/shapely/Cargo.toml @@ -19,10 +19,9 @@ crate-type = ["rlib"] default = [] [dependencies] -enso-shapely-macros = { version = "^0.2.1", path = "macros" } -paste = { version = "0.1" } -derivative = { version = "2.2.0" } -shrinkwraprs = { version = "0.3.0" } +enso-shapely-macros = { path = "macros" } +paste = { workspace = true } +derivative = { workspace = true } rustversion = { version = "1.0" } wasm-bindgen = { workspace = true } diff --git a/lib/rust/shapely/macros/Cargo.toml b/lib/rust/shapely/macros/Cargo.toml index d4ac9e9ad43..8054cb6aa07 100644 --- a/lib/rust/shapely/macros/Cargo.toml +++ b/lib/rust/shapely/macros/Cargo.toml @@ -23,9 +23,9 @@ enso-macro-utils = { path = "../../macro-utils" } proc-macro2 = "1.0" quote = "1.0" Inflector = "0.11.4" -itertools = "0.8.1" -boolinator = "2.4.0" -paste = "1.0.7" +itertools = { workspace = true } +boolinator = { workspace = true } +paste = { workspace = true } [dependencies.syn] version = "1.0" diff --git a/lib/rust/shapely/src/lib.rs b/lib/rust/shapely/src/lib.rs index a0d873cee65..c58c3249da5 100644 --- a/lib/rust/shapely/src/lib.rs +++ b/lib/rust/shapely/src/lib.rs @@ -31,6 +31,8 @@ pub mod singleton; pub use enso_shapely_macros::*; pub use generator::GeneratingIterator; + + /// A macro which passes its input to its output. #[macro_export] macro_rules! identity { diff --git a/lib/rust/shortcuts/Cargo.toml b/lib/rust/shortcuts/Cargo.toml index a90c9ce8325..60b307680b2 100644 --- a/lib/rust/shortcuts/Cargo.toml +++ b/lib/rust/shortcuts/Cargo.toml @@ -10,14 +10,13 @@ crate-type = ["cdylib", "rlib"] [dependencies] enso-automata = { path = "../automata" } enso-frp = { path = "../frp" } -enso-logger = { path = "../logger" } enso-prelude = { path = "../prelude" } enso-web = { path = "../web" } wasm-bindgen = { workspace = true } -nalgebra = { version = "0.26.1", features = ["serde-serialize"] } -serde_json = { version = "1.0" } +nalgebra = { workspace = true } +serde_json = { workspace = true } serde = { version = "1.0", features = ["derive"] } -js-sys = { version = "0.3.28" } +js-sys = { workspace = true } [dependencies.web-sys] version = "0.3.4" diff --git a/lib/rust/shortcuts/example/Cargo.toml b/lib/rust/shortcuts/example/Cargo.toml index 10d5cd33774..d5064b0180b 100644 --- a/lib/rust/shortcuts/example/Cargo.toml +++ b/lib/rust/shortcuts/example/Cargo.toml @@ -9,16 +9,15 @@ crate-type = ["cdylib", "rlib"] [dependencies] enso-automata = { path = "../../automata" } -enso-logger = { path = "../../logger" } enso-prelude = { path = "../../prelude" } enso-frp = { path = "../../frp" } enso-shortcuts = { path = "../../shortcuts" } enso-web = { path = "../../web" } wasm-bindgen = { workspace = true } -nalgebra = { version = "0.26.1", features = ["serde-serialize"] } -serde_json = { version = "1.0" } +nalgebra = { workspace = true } +serde_json = { workspace = true } serde = { version = "1.0", features = ["derive"] } -js-sys = { version = "0.3.28" } +js-sys = { workspace = true } [dependencies.web-sys] version = "0.3.4" diff --git a/lib/rust/shortcuts/example/src/lib.rs b/lib/rust/shortcuts/example/src/lib.rs index 7504fb7e404..161380c16c0 100644 --- a/lib/rust/shortcuts/example/src/lib.rs +++ b/lib/rust/shortcuts/example/src/lib.rs @@ -25,7 +25,7 @@ pub fn main() { shortcut_registry.add(shortcuts::Press, "ctrl + a", "hello"); shortcut_registry.add(shortcuts::Press, "ctrl + b", "hello"); - DEBUG!(shortcut_registry.nfa_as_graphviz_code()); + debug!(shortcut_registry.nfa_as_graphviz_code()); let logger: Logger = Logger::new("kb"); let kb = Keyboard::new(); @@ -44,13 +44,13 @@ pub fn main() { shortcut_registry.add(shortcuts::Release, "ctrl a", "release ctrl a"); shortcut_registry.add(shortcuts::Press, "a", "press a"); shortcut_registry.add(shortcuts::Release, "a", "release a"); - DEBUG!("\n---------------"); - DEBUG!("-> " shortcut_registry.on_press("ctrl-left");?); - DEBUG!("---"); - DEBUG!("-> " shortcut_registry.on_press("a");?); - DEBUG!("---"); + debug!("\n---------------"); + debug!("-> " shortcut_registry.on_press("ctrl-left");?); + debug!("---"); + debug!("-> " shortcut_registry.on_press("a");?); + debug!("---"); web::simulate_sleep(1000.0); - DEBUG!("-> " shortcut_registry.on_release("ctrl-left");?); - DEBUG!("---"); - DEBUG!("-> " shortcut_registry.on_release("a");?); + debug!("-> " shortcut_registry.on_release("ctrl-left");?); + debug!("---"); + debug!("-> " shortcut_registry.on_release("a");?); } diff --git a/lib/rust/shortcuts/src/lib.rs b/lib/rust/shortcuts/src/lib.rs index fe29eed63be..e66fac1c448 100644 --- a/lib/rust/shortcuts/src/lib.rs +++ b/lib/rust/shortcuts/src/lib.rs @@ -25,11 +25,6 @@ use enso_automata::*; use enso_prelude::*; use enso_web as web; -pub use enso_logger as logger; -pub use enso_logger::AnyLogger; -pub use enso_logger::WarningLogger as Logger; -pub use enso_logger::*; - // ============== diff --git a/lib/rust/types/Cargo.toml b/lib/rust/types/Cargo.toml index f1a8e938234..ce0a6584a5f 100644 --- a/lib/rust/types/Cargo.toml +++ b/lib/rust/types/Cargo.toml @@ -8,9 +8,9 @@ edition = "2021" [dependencies] enso-reflect = { path = "../reflect" } -nalgebra = { version = "0.26.1" } +nalgebra = { workspace = true } num-traits = { version = "0.2" } -paste = "1.0.7" +paste = { workspace = true } serde = { version = "1.0", features = ["derive"] } enso-prelude = { path = "../prelude" } diff --git a/lib/rust/web/Cargo.toml b/lib/rust/web/Cargo.toml index 79780fc4fb9..1f76ec83e08 100644 --- a/lib/rust/web/Cargo.toml +++ b/lib/rust/web/Cargo.toml @@ -6,18 +6,15 @@ edition = "2021" [lib] -[features] -default = ["console_error_panic_hook"] - [dependencies] enso-debug-api = { path = "../debug-api" } -console_error_panic_hook = { version = "0.1.6", optional = true } -failure = { version = "0.1.5" } +console_error_panic_hook = { workspace = true } +failure = { workspace = true } gloo-timers = { version = "0.2.1", features = ["futures"] } -js-sys = { version = "0.3.28" } -nalgebra = { version = "0.26.1" } +js-sys = { workspace = true } +nalgebra = { workspace = true } wasm-bindgen = { workspace = true } -derivative = "2.2.0" +derivative = { workspace = true } enso-logging = { path = "../logging" } enso-shapely = { path = "../shapely" } diff --git a/tools/language-server/logstat/Cargo.toml b/tools/language-server/logstat/Cargo.toml index 23fe9ede82a..dd59b8b2fbc 100644 --- a/tools/language-server/logstat/Cargo.toml +++ b/tools/language-server/logstat/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] clap = { version = "3", features = ["derive"] } -lazy_static = "1.4.0" +lazy_static = { workspace = true } enso-prelude = { path = "../../../lib/rust/prelude" } regex = { workspace = true } time = { version = "0.3", features = ["formatting", "parsing"] } diff --git a/tools/language-server/wstest/Cargo.toml b/tools/language-server/wstest/Cargo.toml index ab4aba16a58..4c5b3930d04 100644 --- a/tools/language-server/wstest/Cargo.toml +++ b/tools/language-server/wstest/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" base64 = "0.13.0" clap = { version = "3", features = ["derive"] } either = "1.7.0" -futures = "0.3" +futures = { workspace = true } enso-prelude = { path = "../../../lib/rust/prelude" } regex = { workspace = true } time = { version = "0.3", features = ["formatting"] }