mirror of
https://github.com/oxalica/nil.git
synced 2024-11-22 11:22:46 +03:00
Log properly
This commit is contained in:
parent
f496f10160
commit
a8f8e72856
79
Cargo.lock
generated
79
Cargo.lock
generated
@ -2,12 +2,32 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
@ -58,6 +78,19 @@ version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c97b9233581d84b8e1e689cdd3a47b6f69770084fc246e86a7f78b0d9c1d4a5"
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "expect-test"
|
||||
version = "1.4.0"
|
||||
@ -104,6 +137,21 @@ dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "0.2.3"
|
||||
@ -177,7 +225,9 @@ version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"crossbeam-channel",
|
||||
"env_logger",
|
||||
"indexmap",
|
||||
"log",
|
||||
"lsp-server",
|
||||
"lsp-types",
|
||||
"nil",
|
||||
@ -413,6 +463,17 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.2.0"
|
||||
@ -573,6 +634,15 @@ dependencies = [
|
||||
"rowan",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "text-size"
|
||||
version = "1.1.0"
|
||||
@ -656,6 +726,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
@ -10,7 +10,9 @@ path = "src/main.rs"
|
||||
[dependencies]
|
||||
anyhow = "1.0.58"
|
||||
crossbeam-channel = "0.5.6"
|
||||
env_logger = "0.9.0"
|
||||
indexmap = "1.9.1"
|
||||
log = "0.4.17"
|
||||
lsp-server = "0.6.0"
|
||||
lsp-types = "0.93.0"
|
||||
serde = "1.0.140"
|
||||
|
@ -7,14 +7,13 @@ use lsp_server::{Connection, Message};
|
||||
|
||||
pub fn main_loop(conn: Connection) -> Result<()> {
|
||||
let init_params = conn.initialize(serde_json::to_value(&server_capabilities()).unwrap())?;
|
||||
eprintln!("Init params: {}", init_params);
|
||||
log::info!("Init params: {}", init_params);
|
||||
|
||||
let mut state = State::new(conn.sender.clone());
|
||||
|
||||
eprintln!("Entering main loop");
|
||||
log::info!("Entering main loop");
|
||||
|
||||
for msg in &conn.receiver {
|
||||
eprintln!("Got message: {:?}", msg);
|
||||
match msg {
|
||||
Message::Request(req) => {
|
||||
if conn.handle_shutdown(&req)? {
|
||||
@ -29,8 +28,8 @@ pub fn main_loop(conn: Connection) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Force shutdown of pendign requests?
|
||||
eprintln!("Leaving main loop");
|
||||
// TODO: Force shutdown of pending requests?
|
||||
log::info!("Leaving main loop");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ use anyhow::Result;
|
||||
use lsp_server::Connection;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
env_logger::Builder::from_env("NIL_LOG").init();
|
||||
let (conn, io_threads) = Connection::stdio();
|
||||
lsp::main_loop(conn)?;
|
||||
io_threads.join()?;
|
||||
|
@ -43,7 +43,7 @@ impl State {
|
||||
|
||||
pub fn apply_change(&mut self, change: Change) {
|
||||
if !change.is_empty() {
|
||||
eprintln!("Files changed: {:?}", change);
|
||||
log::debug!("Files changed: {:?}", change);
|
||||
self.host.apply_change(change);
|
||||
}
|
||||
}
|
||||
@ -111,7 +111,6 @@ impl<'s> RequestDispatcher<'s> {
|
||||
let params = serde_json::from_value::<R::Params>(req.params).unwrap();
|
||||
let resp = f(self.0.snapshot(), params);
|
||||
let resp = lsp_server::Response::new_ok(req.id, serde_json::to_value(resp).unwrap());
|
||||
eprintln!("Sent message: {:?}", resp);
|
||||
self.0.responder.send(resp.into()).unwrap();
|
||||
}
|
||||
self
|
||||
|
@ -46,10 +46,6 @@ impl fmt::Debug for Vfs {
|
||||
}
|
||||
|
||||
impl Vfs {
|
||||
pub fn file_id(&self, path: &VfsPath) -> Option<FileId> {
|
||||
self.files.get_index_of(path).map(|id| FileId(id as _))
|
||||
}
|
||||
|
||||
pub fn file_path(&self, file_id: FileId) -> Option<&VfsPath> {
|
||||
self.files.get_index(file_id.0 as _).map(|(path, _)| path)
|
||||
}
|
||||
|
19
src/base.rs
19
src/base.rs
@ -1,6 +1,6 @@
|
||||
use rowan::{TextRange, TextSize};
|
||||
use salsa::Durability;
|
||||
use std::sync::Arc;
|
||||
use std::{fmt, sync::Arc};
|
||||
use syntax::Parse;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
@ -42,7 +42,7 @@ fn parse(db: &dyn SourceDatabase, file_id: FileId) -> InFile<Parse> {
|
||||
InFile::new(file_id, parse)
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Default, Clone, PartialEq, Eq)]
|
||||
pub struct Change {
|
||||
pub file_changes: Vec<(FileId, Option<Arc<str>>)>,
|
||||
}
|
||||
@ -68,3 +68,18 @@ impl Change {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Change {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let modified = self
|
||||
.file_changes
|
||||
.iter()
|
||||
.filter(|(_, content)| content.is_some())
|
||||
.count();
|
||||
let cleared = self.file_changes.len() - modified;
|
||||
f.debug_struct("Change")
|
||||
.field("modified", &modified)
|
||||
.field("cleared", &cleared)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user