mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
add profile calls to parsing/expansion routines
This commit is contained in:
parent
67d5927b16
commit
f15bb3c98a
3 changed files with 7 additions and 1 deletions
|
@ -12,4 +12,5 @@ parking_lot = "0.7.0"
|
||||||
|
|
||||||
ra_arena = { path = "../ra_arena" }
|
ra_arena = { path = "../ra_arena" }
|
||||||
ra_syntax = { path = "../ra_syntax" }
|
ra_syntax = { path = "../ra_syntax" }
|
||||||
|
ra_prof = { path = "../ra_prof" }
|
||||||
test_utils = { path = "../test_utils" }
|
test_utils = { path = "../test_utils" }
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::{panic, sync::Arc};
|
||||||
|
|
||||||
use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc};
|
use ra_syntax::{TextUnit, TextRange, SourceFile, TreeArc};
|
||||||
use relative_path::RelativePathBuf;
|
use relative_path::RelativePathBuf;
|
||||||
|
use ra_prof::profile;
|
||||||
|
|
||||||
pub use ::salsa as salsa;
|
pub use ::salsa as salsa;
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
|
@ -72,6 +73,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug {
|
||||||
#[salsa::input]
|
#[salsa::input]
|
||||||
fn file_text(&self, file_id: FileId) -> Arc<String>;
|
fn file_text(&self, file_id: FileId) -> Arc<String>;
|
||||||
// Parses the file into the syntax tree.
|
// Parses the file into the syntax tree.
|
||||||
|
#[salsa::invoke(parse_query)]
|
||||||
fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>;
|
fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>;
|
||||||
/// Path to a file, relative to the root of its source root.
|
/// Path to a file, relative to the root of its source root.
|
||||||
#[salsa::input]
|
#[salsa::input]
|
||||||
|
@ -96,7 +98,8 @@ fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<Cra
|
||||||
Arc::new(res)
|
Arc::new(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> {
|
fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> {
|
||||||
|
let _p = profile("parse_query");
|
||||||
let text = db.file_text(file_id);
|
let text = db.file_text(file_id);
|
||||||
SourceFile::parse(&*text)
|
SourceFile::parse(&*text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::{
|
||||||
|
|
||||||
use ra_db::{FileId, salsa};
|
use ra_db::{FileId, salsa};
|
||||||
use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode};
|
use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode};
|
||||||
|
use ra_prof::profile;
|
||||||
use mbe::MacroRules;
|
use mbe::MacroRules;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -60,6 +61,7 @@ impl HirFileId {
|
||||||
db: &impl DefDatabase,
|
db: &impl DefDatabase,
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
) -> Option<TreeArc<SyntaxNode>> {
|
) -> Option<TreeArc<SyntaxNode>> {
|
||||||
|
let _p = profile("parse_or_expand_query");
|
||||||
match file_id.0 {
|
match file_id.0 {
|
||||||
HirFileIdRepr::File(file_id) => Some(db.parse(file_id).syntax().to_owned()),
|
HirFileIdRepr::File(file_id) => Some(db.parse(file_id).syntax().to_owned()),
|
||||||
HirFileIdRepr::Macro(macro_file) => {
|
HirFileIdRepr::Macro(macro_file) => {
|
||||||
|
|
Loading…
Reference in a new issue