diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs index f93d8d5c78e8..de515b569dfa 100644 --- a/crates/hir-def/src/attr.rs +++ b/crates/hir-def/src/attr.rs @@ -764,7 +764,7 @@ impl<'attr> AttrQuery<'attr> { .nth(2); match name { - Some(tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal{ref text, ..}))) => Some(text), + Some(tt::TokenTree::Leaf(tt::Leaf::Literal(tt::Literal{ ref text, ..}))) => Some(text), _ => None } }) diff --git a/crates/hir-expand/src/ast_id_map.rs b/crates/hir-expand/src/ast_id_map.rs index e48caca790cf..400442de94b9 100644 --- a/crates/hir-expand/src/ast_id_map.rs +++ b/crates/hir-expand/src/ast_id_map.rs @@ -124,6 +124,10 @@ impl AstIdMap { FileAstId { raw, _ty: PhantomData } } + pub fn get(&self, id: FileAstId) -> AstPtr { + AstPtr::try_from_raw(self.arena[id.raw].clone()).unwrap() + } + fn erased_ast_id(&self, item: &SyntaxNode) -> ErasedFileAstId { let ptr = SyntaxNodePtr::new(item); let hash = hash_ptr(&ptr); @@ -137,10 +141,6 @@ impl AstIdMap { } } - pub fn get(&self, id: FileAstId) -> AstPtr { - AstPtr::try_from_raw(self.arena[id.raw].clone()).unwrap() - } - fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId { self.arena.alloc(SyntaxNodePtr::new(item)) } diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs index c24887e15ff1..c8373778d32b 100644 --- a/crates/hir-expand/src/lib.rs +++ b/crates/hir-expand/src/lib.rs @@ -978,6 +978,7 @@ fn ascend_node_border_tokens( let first_token = |node: &SyntaxNode| skip_trivia_token(node.first_token()?, Direction::Next); let last_token = |node: &SyntaxNode| skip_trivia_token(node.last_token()?, Direction::Prev); + // FIXME: Once the token map rewrite is done, this shouldnt need to rely on syntax nodes and tokens anymore let first = first_token(node)?; let last = last_token(node)?; let first = ascend_call_token(db, &expansion, InFile::new(file_id, first))?; diff --git a/crates/hir/src/symbols.rs b/crates/hir/src/symbols.rs index 5d68aa52e62c..4eaf99e3e73f 100644 --- a/crates/hir/src/symbols.rs +++ b/crates/hir/src/symbols.rs @@ -39,11 +39,19 @@ impl DeclarationLocation { } pub fn original_range(&self, db: &dyn HirDatabase) -> FileRange { + if let Some(file_id) = self.hir_file_id.file_id() { + // fast path to prevent parsing + return FileRange { file_id, range: self.ptr.text_range() }; + } let node = resolve_node(db, self.hir_file_id, &self.ptr); node.as_ref().original_file_range(db.upcast()) } pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option { + if let Some(file_id) = self.hir_file_id.file_id() { + // fast path to prevent parsing + return Some(FileRange { file_id, range: self.ptr.text_range() }); + } let node = resolve_node(db, self.hir_file_id, &self.name_ptr); node.as_ref().original_file_range_opt(db.upcast()) } diff --git a/crates/rust-analyzer/src/lsp_utils.rs b/crates/rust-analyzer/src/lsp_utils.rs index 9a73da153983..74e79e8e6050 100644 --- a/crates/rust-analyzer/src/lsp_utils.rs +++ b/crates/rust-analyzer/src/lsp_utils.rs @@ -81,39 +81,14 @@ impl GlobalState { match additional_info { Some(additional_info) => { tracing::error!("{}:\n{}", &message, &additional_info); - match self.config.open_server_logs() && tracing::enabled!(tracing::Level::ERROR) { - true => self.send_request::( - lsp_types::ShowMessageRequestParams { - typ: lsp_types::MessageType::ERROR, - message, - actions: Some(vec![lsp_types::MessageActionItem { - title: "Open server logs".to_owned(), - properties: Default::default(), - }]), - }, - |this, resp| { - let lsp_server::Response { error: None, result: Some(result), .. } = resp - else { return }; - if let Ok(Some(_item)) = crate::from_json::< - ::Result, - >( - lsp_types::request::ShowMessageRequest::METHOD, &result - ) { - this.send_notification::(()); - } - }, - ), - false => self.send_notification::( - lsp_types::ShowMessageParams { - typ: lsp_types::MessageType::ERROR, - message, - }, - ), - } + self.show_message( + lsp_types::MessageType::ERROR, + message, + tracing::enabled!(tracing::Level::ERROR), + ); } None => { tracing::error!("{}", &message); - self.send_notification::( lsp_types::ShowMessageParams { typ: lsp_types::MessageType::ERROR, message }, );