Skip to content

Commit

Permalink
LS: Move all LS startup logic to its library main function
Browse files Browse the repository at this point in the history
This change gives the LS crate exclusive control on its running
environment and behaviours, like Tokio runtime or logging.

commit-id:548527aa
  • Loading branch information
mkaput committed Feb 7, 2024
1 parent 038f67a commit c1bb4e0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions crates/bin/cairo-language-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@ license-file.workspace = true
description = "Language server executable for the Cairo programming language"

[dependencies]
tokio.workspace = true
log.workspace = true

cairo-lang-language-server = { path = "../../cairo-lang-language-server", version = "2.5.3" }
cairo-lang-utils = { path = "../../cairo-lang-utils", version = "2.5.3", features = [
"env_logger",
] }
9 changes: 2 additions & 7 deletions crates/bin/cairo-language-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
use cairo_lang_language_server::serve_language_service;
use cairo_lang_utils::logging::init_logging;

#[tokio::main]
async fn main() {
init_logging(log::LevelFilter::Warn);
serve_language_service().await;
fn main() {
cairo_lang_language_server::start()
}
2 changes: 1 addition & 1 deletion crates/cairo-lang-language-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cairo-lang-semantic = { path = "../cairo-lang-semantic", version = "2.5.3" }
cairo-lang-starknet = { path = "../cairo-lang-starknet", version = "2.5.3" }
cairo-lang-syntax = { path = "../cairo-lang-syntax", version = "2.5.3" }
cairo-lang-test-plugin = { path = "../cairo-lang-test-plugin", version = "2.5.3" }
cairo-lang-utils = { path = "../cairo-lang-utils", version = "2.5.3" }
cairo-lang-utils = { path = "../cairo-lang-utils", version = "2.5.3", features = ["env_logger"] }
log.workspace = true
salsa.workspace = true
scarb-metadata.workspace = true
Expand Down
6 changes: 5 additions & 1 deletion crates/cairo-lang-language-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use cairo_lang_syntax::node::kind::SyntaxKind;
use cairo_lang_syntax::node::utils::is_grandparent_of_kind;
use cairo_lang_syntax::node::{ast, SyntaxNode, TypedSyntaxNode};
use cairo_lang_test_plugin::test_plugin_suite;
use cairo_lang_utils::logging::init_logging;
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use cairo_lang_utils::ordered_hash_set::OrderedHashSet;
use cairo_lang_utils::{try_extract_matches, OptionHelper, Upcast};
Expand Down Expand Up @@ -79,7 +80,10 @@ pub mod vfs;
const MAX_CRATE_DETECTION_DEPTH: usize = 20;
const DEFAULT_CAIRO_LSP_DB_REPLACE_INTERVAL: u64 = 300;

pub async fn serve_language_service() {
#[tokio::main]
pub async fn start() {
init_logging(log::LevelFilter::Warn);

let (stdin, stdout) = (tokio::io::stdin(), tokio::io::stdout());

let db = configured_db();
Expand Down

0 comments on commit c1bb4e0

Please sign in to comment.