diff --git a/crates/lang_srv/src/analysis/analysed_doc.rs b/crates/lang_srv/src/analysis/analysed_doc.rs index 6fd3c884cc..1f8911336c 100644 --- a/crates/lang_srv/src/analysis/analysed_doc.rs +++ b/crates/lang_srv/src/analysis/analysed_doc.rs @@ -52,14 +52,14 @@ impl DocInfo { #[cfg(debug_assertions)] #[allow(unused)] fn debug_log_prefix(&self, offset: usize) { - debug!("prefix source: {:?}", self.source); + debug!("Prefix source: {:?}", self.source); let last_few = self.source.get(offset - 5..offset + 5).unwrap(); let (before, after) = last_few.split_at(5); debug!( - "starting to get completion items at offset: {:?} content: '{:?}|{:?}'", + "Starting to get completion items at offset: {:?} content: '{:?}|{:?}'", offset, before, after ); } @@ -207,7 +207,7 @@ impl AnalyzedDocument { ) -> Option> { let symbol_prefix = latest_doc.get_prefix_at_position(position); debug!( - "starting to get completion items for prefix: {:?} docVersion:{:?}", + "Starting to get completion items for prefix: {:?} docVersion:{:?}", symbol_prefix, latest_doc.version ); let len_diff = latest_doc.source.len() as i32 - self.doc_info.source.len() as i32; @@ -216,7 +216,7 @@ impl AnalyzedDocument { //TODO: this is kind of a hack and should be removed once we can do some minimal parsing without full type checking let mut position = position.to_roc_position(&latest_doc.line_info); position.offset = (position.offset as i32 - len_diff - 1) as u32; - debug!("completion offset: {:?}", position.offset); + debug!("Completion offset: {:?}", position.offset); let AnalyzedModule { module_id, diff --git a/crates/lang_srv/src/analysis/completion.rs b/crates/lang_srv/src/analysis/completion.rs index daf2906d8a..c780e4cb2c 100644 --- a/crates/lang_srv/src/analysis/completion.rs +++ b/crates/lang_srv/src/analysis/completion.rs @@ -60,7 +60,7 @@ impl Visitor for CompletionVisitor<'_> { } impl CompletionVisitor<'_> { fn extract_defs(&mut self, def: &Def) -> Vec<(Symbol, Variable)> { - trace!("completion begin"); + trace!("Completion begin"); def.pattern_vars .iter() .map(|(symbol, var)| (*symbol, *var)) @@ -228,7 +228,7 @@ impl CompletionVisitor<'_> { .flat_map(|(var, _, pat)| self.patterns(&pat.value, var)); //We add in the pattern for the function declaration out.extend(args); - trace!("added function args to completion output =:{:#?}", out); + trace!("Added function args to completion output =:{:#?}", out); } out } @@ -413,10 +413,10 @@ pub fn field_completion( } = get_field_completion_parts(&symbol_prefix)?; debug!( - "getting record field completions: variable: {:?} field: {:?} middle: {:?} ", + "Getting record field completions: variable: {:?} field: {:?} middle: {:?} ", var, field, middle_fields ); - //TODO: this is kind of just a hack. We are getting all the completions and seeing if any match the part before the dot as a way to get the Variable type of the variable before the dot. I imagine there are much faster ways to do this + let completion = get_completions(position, declarations, var.to_string(), interns) .into_iter() .map(|a| (a.0.as_str(interns).to_string(), a.1)) diff --git a/crates/lang_srv/src/registry.rs b/crates/lang_srv/src/registry.rs index 7b00e5c61f..d09cf31bb5 100644 --- a/crates/lang_srv/src/registry.rs +++ b/crates/lang_srv/src/registry.rs @@ -86,7 +86,7 @@ impl Registry { pub async fn apply_changes<'a>(&self, analysed_docs: Vec, updating_url: Url) { let mut documents = self.documents.lock().await; debug!( - "finised doc analysis for doc: {:?}", + "Finished doc analysis for doc: {}", updating_url.to_string() ); @@ -103,7 +103,7 @@ impl Registry { match doc { Some(a) => { debug!( - "set the docInfo for {:?} to version:{:?}", + "Set the docInfo for {:?} to version:{:?}", url.as_str(), info.version ); @@ -113,16 +113,15 @@ impl Registry { latest_document: OnceLock::new(), }; } - None => debug!("no existing docinfo for {:?} ", url.as_str()), + None => debug!("So existing docinfo for {:?} ", url.as_str()), } } async fn document_info_by_url(&self, url: &Url) -> Option { self.documents.lock().await.get(url).map(|a| a.info.clone()) - } - + }U ///Tries to get the latest document from analysis. - ///Gives up and returns none after 5 seconds. + ///Gives up and returns none aft 5 seconds. async fn latest_document_by_url(&self, url: &Url) -> Option> { let duration = std::time::Duration::from_secs(5); tokio::time::timeout(duration, async { @@ -179,13 +178,13 @@ impl Registry { url: &Url, position: Position, ) -> Option { - trace!("starting completion "); + trace!("Starting completion "); let lock = self.documents.lock().await; let pair = lock.get(url)?; let latest_doc_info = &pair.info; info!( - "using document version:{:?} for completion ", + "Using document version:{:?} for completion ", latest_doc_info.version ); diff --git a/crates/lang_srv/src/server.rs b/crates/lang_srv/src/server.rs index 6582f11473..b880fdd147 100644 --- a/crates/lang_srv/src/server.rs +++ b/crates/lang_srv/src/server.rs @@ -94,10 +94,10 @@ impl RocServer { //The analysis task can be cancelled by another change coming in which will update the watched variable if let Err(e) = updating_result { - debug!("cancelled change. Reason:{:?}", e); + debug!("Cancelled change. Reason:{:?}", e); return; } - debug!("applied_change getting and returning diagnostics"); + debug!("Applied_change getting and returning diagnostics"); let diagnostics = self.state.registry.diagnostics(&fi).await; @@ -165,7 +165,7 @@ impl RocServerState { if let Some(latest_version) = latest_version { if latest_version != version { return Err(format!( - "version {0} doesn't match latest: {1} discarding analysis ", + "Version {0} doesn't match latest: {1} discarding analysis", version, latest_version )); } @@ -214,7 +214,6 @@ impl LanguageServer for RocServer { let TextDocumentContentChangeEvent { text, .. } = params.content_changes.into_iter().next().unwrap(); - trace!("got did_change"); self.change(uri, text, version).await; } @@ -309,7 +308,7 @@ impl LanguageServer for RocServer { async fn completion(&self, params: CompletionParams) -> Result> { let doc = params.text_document_position; - trace!("got completion request"); + trace!("Got completion request"); panic_wrapper_async(|| async { self.state @@ -386,7 +385,7 @@ mod tests { .filter_level(log::LevelFilter::Trace) .init(); }); - info!("doc is:\n{0}", doc); + info!("Doc is:\n{0}", doc); let url = Url::parse("file:/Test.roc").unwrap(); let inner = RocServerState::new();