Auto merge of #14834 - Veykril:ty-diag-unit, r=Veykril
internal: Less file parsing for symbol index generation
This commit is contained in:
commit
c7b03491cd
@ -764,7 +764,7 @@ impl<'attr> AttrQuery<'attr> {
|
|||||||
.nth(2);
|
.nth(2);
|
||||||
|
|
||||||
match name {
|
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
|
_ => None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -124,6 +124,10 @@ impl AstIdMap {
|
|||||||
FileAstId { raw, _ty: PhantomData }
|
FileAstId { raw, _ty: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get<N: AstNode>(&self, id: FileAstId<N>) -> AstPtr<N> {
|
||||||
|
AstPtr::try_from_raw(self.arena[id.raw].clone()).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
fn erased_ast_id(&self, item: &SyntaxNode) -> ErasedFileAstId {
|
fn erased_ast_id(&self, item: &SyntaxNode) -> ErasedFileAstId {
|
||||||
let ptr = SyntaxNodePtr::new(item);
|
let ptr = SyntaxNodePtr::new(item);
|
||||||
let hash = hash_ptr(&ptr);
|
let hash = hash_ptr(&ptr);
|
||||||
@ -137,10 +141,6 @@ impl AstIdMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get<N: AstNode>(&self, id: FileAstId<N>) -> AstPtr<N> {
|
|
||||||
AstPtr::try_from_raw(self.arena[id.raw].clone()).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId {
|
fn alloc(&mut self, item: &SyntaxNode) -> ErasedFileAstId {
|
||||||
self.arena.alloc(SyntaxNodePtr::new(item))
|
self.arena.alloc(SyntaxNodePtr::new(item))
|
||||||
}
|
}
|
||||||
|
@ -978,6 +978,7 @@ fn ascend_node_border_tokens(
|
|||||||
let first_token = |node: &SyntaxNode| skip_trivia_token(node.first_token()?, Direction::Next);
|
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);
|
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 first = first_token(node)?;
|
||||||
let last = last_token(node)?;
|
let last = last_token(node)?;
|
||||||
let first = ascend_call_token(db, &expansion, InFile::new(file_id, first))?;
|
let first = ascend_call_token(db, &expansion, InFile::new(file_id, first))?;
|
||||||
|
@ -39,11 +39,19 @@ impl DeclarationLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn original_range(&self, db: &dyn HirDatabase) -> FileRange {
|
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);
|
let node = resolve_node(db, self.hir_file_id, &self.ptr);
|
||||||
node.as_ref().original_file_range(db.upcast())
|
node.as_ref().original_file_range(db.upcast())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
|
pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
|
||||||
|
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);
|
let node = resolve_node(db, self.hir_file_id, &self.name_ptr);
|
||||||
node.as_ref().original_file_range_opt(db.upcast())
|
node.as_ref().original_file_range_opt(db.upcast())
|
||||||
}
|
}
|
||||||
|
@ -81,39 +81,14 @@ impl GlobalState {
|
|||||||
match additional_info {
|
match additional_info {
|
||||||
Some(additional_info) => {
|
Some(additional_info) => {
|
||||||
tracing::error!("{}:\n{}", &message, &additional_info);
|
tracing::error!("{}:\n{}", &message, &additional_info);
|
||||||
match self.config.open_server_logs() && tracing::enabled!(tracing::Level::ERROR) {
|
self.show_message(
|
||||||
true => self.send_request::<lsp_types::request::ShowMessageRequest>(
|
lsp_types::MessageType::ERROR,
|
||||||
lsp_types::ShowMessageRequestParams {
|
message,
|
||||||
typ: lsp_types::MessageType::ERROR,
|
tracing::enabled!(tracing::Level::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::<
|
|
||||||
<lsp_types::request::ShowMessageRequest as lsp_types::request::Request>::Result,
|
|
||||||
>(
|
|
||||||
lsp_types::request::ShowMessageRequest::METHOD, &result
|
|
||||||
) {
|
|
||||||
this.send_notification::<lsp_ext::OpenServerLogs>(());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
false => self.send_notification::<lsp_types::notification::ShowMessage>(
|
|
||||||
lsp_types::ShowMessageParams {
|
|
||||||
typ: lsp_types::MessageType::ERROR,
|
|
||||||
message,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
tracing::error!("{}", &message);
|
tracing::error!("{}", &message);
|
||||||
|
|
||||||
self.send_notification::<lsp_types::notification::ShowMessage>(
|
self.send_notification::<lsp_types::notification::ShowMessage>(
|
||||||
lsp_types::ShowMessageParams { typ: lsp_types::MessageType::ERROR, message },
|
lsp_types::ShowMessageParams { typ: lsp_types::MessageType::ERROR, message },
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user