diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/assists/src/utils.rs | 1 | ||||
-rw-r--r-- | crates/assists/src/utils/insert_use.rs | 1 | ||||
-rw-r--r-- | crates/completion/src/item.rs | 2 | ||||
-rw-r--r-- | crates/completion/src/render/enum_variant.rs | 1 | ||||
-rw-r--r-- | crates/completion/src/render/function.rs | 1 | ||||
-rw-r--r-- | crates/completion/src/render/macro_.rs | 1 | ||||
-rw-r--r-- | crates/syntax/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/syntax/src/algo.rs | 13 |
8 files changed, 21 insertions, 0 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs index 66c0cdd5f..048746587 100644 --- a/crates/assists/src/utils.rs +++ b/crates/assists/src/utils.rs | |||
@@ -25,6 +25,7 @@ use crate::{ | |||
25 | pub use insert_use::{insert_use, ImportScope, MergeBehaviour}; | 25 | pub use insert_use::{insert_use, ImportScope, MergeBehaviour}; |
26 | 26 | ||
27 | pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path { | 27 | pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path { |
28 | let _p = profile::span("mod_path_to_ast"); | ||
28 | let mut segments = Vec::new(); | 29 | let mut segments = Vec::new(); |
29 | let mut is_abs = false; | 30 | let mut is_abs = false; |
30 | match path.kind { | 31 | match path.kind { |
diff --git a/crates/assists/src/utils/insert_use.rs b/crates/assists/src/utils/insert_use.rs index 423782a0e..975a08a20 100644 --- a/crates/assists/src/utils/insert_use.rs +++ b/crates/assists/src/utils/insert_use.rs | |||
@@ -95,6 +95,7 @@ pub fn insert_use<'a>( | |||
95 | path: ast::Path, | 95 | path: ast::Path, |
96 | merge: Option<MergeBehaviour>, | 96 | merge: Option<MergeBehaviour>, |
97 | ) -> SyntaxRewriter<'a> { | 97 | ) -> SyntaxRewriter<'a> { |
98 | let _p = profile::span("mod_path_to_ast"); | ||
98 | let mut rewriter = SyntaxRewriter::default(); | 99 | let mut rewriter = SyntaxRewriter::default(); |
99 | let use_item = make::use_(make::use_tree(path.clone(), None, None, false)); | 100 | let use_item = make::use_(make::use_tree(path.clone(), None, None, false)); |
100 | // merge into existing imports if possible | 101 | // merge into existing imports if possible |
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index b13c3f376..7b62c2c4e 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs | |||
@@ -278,6 +278,8 @@ pub(crate) struct Builder { | |||
278 | 278 | ||
279 | impl Builder { | 279 | impl Builder { |
280 | pub(crate) fn build(self) -> CompletionItem { | 280 | pub(crate) fn build(self) -> CompletionItem { |
281 | let _p = profile::span("item::Builder::build"); | ||
282 | |||
281 | let mut label = self.label; | 283 | let mut label = self.label; |
282 | let mut lookup = self.lookup; | 284 | let mut lookup = self.lookup; |
283 | let mut insert_text = self.insert_text; | 285 | let mut insert_text = self.insert_text; |
diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs index 6070e9b1d..64e742b77 100644 --- a/crates/completion/src/render/enum_variant.rs +++ b/crates/completion/src/render/enum_variant.rs | |||
@@ -17,6 +17,7 @@ pub(crate) fn render_enum_variant<'a>( | |||
17 | variant: hir::EnumVariant, | 17 | variant: hir::EnumVariant, |
18 | path: Option<ModPath>, | 18 | path: Option<ModPath>, |
19 | ) -> CompletionItem { | 19 | ) -> CompletionItem { |
20 | let _p = profile::span("render_enum_variant"); | ||
20 | EnumVariantRender::new(ctx, local_name, variant, path).render(import_data) | 21 | EnumVariantRender::new(ctx, local_name, variant, path).render(import_data) |
21 | } | 22 | } |
22 | 23 | ||
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs index 9dd5cd18c..e8b726ad6 100644 --- a/crates/completion/src/render/function.rs +++ b/crates/completion/src/render/function.rs | |||
@@ -15,6 +15,7 @@ pub(crate) fn render_fn<'a>( | |||
15 | local_name: Option<String>, | 15 | local_name: Option<String>, |
16 | fn_: hir::Function, | 16 | fn_: hir::Function, |
17 | ) -> CompletionItem { | 17 | ) -> CompletionItem { |
18 | let _p = profile::span("render_fn"); | ||
18 | FunctionRender::new(ctx, local_name, fn_).render(import_data) | 19 | FunctionRender::new(ctx, local_name, fn_).render(import_data) |
19 | } | 20 | } |
20 | 21 | ||
diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs index fead59e41..91055a296 100644 --- a/crates/completion/src/render/macro_.rs +++ b/crates/completion/src/render/macro_.rs | |||
@@ -16,6 +16,7 @@ pub(crate) fn render_macro<'a>( | |||
16 | name: String, | 16 | name: String, |
17 | macro_: hir::MacroDef, | 17 | macro_: hir::MacroDef, |
18 | ) -> Option<CompletionItem> { | 18 | ) -> Option<CompletionItem> { |
19 | let _p = profile::span("render_macro"); | ||
19 | MacroRender::new(ctx, name, macro_).render(import_data) | 20 | MacroRender::new(ctx, name, macro_).render(import_data) |
20 | } | 21 | } |
21 | 22 | ||
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 1fe907753..ce62babc3 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml | |||
@@ -28,6 +28,7 @@ stdx = { path = "../stdx", version = "0.0.0" } | |||
28 | text_edit = { path = "../text_edit", version = "0.0.0" } | 28 | text_edit = { path = "../text_edit", version = "0.0.0" } |
29 | parser = { path = "../parser", version = "0.0.0" } | 29 | parser = { path = "../parser", version = "0.0.0" } |
30 | test_utils = { path = "../test_utils", version = "0.0.0" } | 30 | test_utils = { path = "../test_utils", version = "0.0.0" } |
31 | profile = { path = "../profile", version = "0.0.0" } | ||
31 | 32 | ||
32 | [dev-dependencies] | 33 | [dev-dependencies] |
33 | walkdir = "2.3.1" | 34 | walkdir = "2.3.1" |
diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 320c430c9..ee89d9867 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs | |||
@@ -127,6 +127,8 @@ pub struct TreeDiff { | |||
127 | 127 | ||
128 | impl TreeDiff { | 128 | impl TreeDiff { |
129 | pub fn into_text_edit(&self, builder: &mut TextEditBuilder) { | 129 | pub fn into_text_edit(&self, builder: &mut TextEditBuilder) { |
130 | let _p = profile::span("into_text_edit"); | ||
131 | |||
130 | for (anchor, to) in self.insertions.iter() { | 132 | for (anchor, to) in self.insertions.iter() { |
131 | let offset = match anchor { | 133 | let offset = match anchor { |
132 | TreeDiffInsertPos::After(it) => it.text_range().end(), | 134 | TreeDiffInsertPos::After(it) => it.text_range().end(), |
@@ -154,6 +156,8 @@ impl TreeDiff { | |||
154 | /// | 156 | /// |
155 | /// This function tries to find a fine-grained diff. | 157 | /// This function tries to find a fine-grained diff. |
156 | pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { | 158 | pub fn diff(from: &SyntaxNode, to: &SyntaxNode) -> TreeDiff { |
159 | let _p = profile::span("diff"); | ||
160 | |||
157 | let mut diff = TreeDiff { | 161 | let mut diff = TreeDiff { |
158 | replacements: FxHashMap::default(), | 162 | replacements: FxHashMap::default(), |
159 | insertions: FxIndexMap::default(), | 163 | insertions: FxIndexMap::default(), |
@@ -467,6 +471,8 @@ impl<'a> SyntaxRewriter<'a> { | |||
467 | } | 471 | } |
468 | 472 | ||
469 | pub fn rewrite(&self, node: &SyntaxNode) -> SyntaxNode { | 473 | pub fn rewrite(&self, node: &SyntaxNode) -> SyntaxNode { |
474 | let _p = profile::span("rewrite"); | ||
475 | |||
470 | if self.f.is_none() && self.replacements.is_empty() && self.insertions.is_empty() { | 476 | if self.f.is_none() && self.replacements.is_empty() && self.insertions.is_empty() { |
471 | return node.clone(); | 477 | return node.clone(); |
472 | } | 478 | } |
@@ -483,6 +489,7 @@ impl<'a> SyntaxRewriter<'a> { | |||
483 | /// | 489 | /// |
484 | /// Returns `None` when there are no replacements. | 490 | /// Returns `None` when there are no replacements. |
485 | pub fn rewrite_root(&self) -> Option<SyntaxNode> { | 491 | pub fn rewrite_root(&self) -> Option<SyntaxNode> { |
492 | let _p = profile::span("rewrite_root"); | ||
486 | fn element_to_node_or_parent(element: &SyntaxElement) -> SyntaxNode { | 493 | fn element_to_node_or_parent(element: &SyntaxElement) -> SyntaxNode { |
487 | match element { | 494 | match element { |
488 | SyntaxElement::Node(it) => it.clone(), | 495 | SyntaxElement::Node(it) => it.clone(), |
@@ -517,6 +524,8 @@ impl<'a> SyntaxRewriter<'a> { | |||
517 | } | 524 | } |
518 | 525 | ||
519 | fn rewrite_children(&self, node: &SyntaxNode) -> SyntaxNode { | 526 | fn rewrite_children(&self, node: &SyntaxNode) -> SyntaxNode { |
527 | let _p = profile::span("rewrite_children"); | ||
528 | |||
520 | // FIXME: this could be made much faster. | 529 | // FIXME: this could be made much faster. |
521 | let mut new_children = Vec::new(); | 530 | let mut new_children = Vec::new(); |
522 | if let Some(elements) = self.insertions(&InsertPos::FirstChildOf(node.clone())) { | 531 | if let Some(elements) = self.insertions(&InsertPos::FirstChildOf(node.clone())) { |
@@ -533,6 +542,8 @@ impl<'a> SyntaxRewriter<'a> { | |||
533 | acc: &mut Vec<NodeOrToken<rowan::GreenNode, rowan::GreenToken>>, | 542 | acc: &mut Vec<NodeOrToken<rowan::GreenNode, rowan::GreenToken>>, |
534 | element: &SyntaxElement, | 543 | element: &SyntaxElement, |
535 | ) { | 544 | ) { |
545 | let _p = profile::span("rewrite_self"); | ||
546 | |||
536 | if let Some(replacement) = self.replacement(&element) { | 547 | if let Some(replacement) = self.replacement(&element) { |
537 | match replacement { | 548 | match replacement { |
538 | Replacement::Single(element) => acc.push(element_to_green(element)), | 549 | Replacement::Single(element) => acc.push(element_to_green(element)), |
@@ -588,6 +599,8 @@ fn with_children( | |||
588 | parent: &SyntaxNode, | 599 | parent: &SyntaxNode, |
589 | new_children: Vec<NodeOrToken<rowan::GreenNode, rowan::GreenToken>>, | 600 | new_children: Vec<NodeOrToken<rowan::GreenNode, rowan::GreenToken>>, |
590 | ) -> SyntaxNode { | 601 | ) -> SyntaxNode { |
602 | let _p = profile::span("with_children"); | ||
603 | |||
591 | let len = new_children.iter().map(|it| it.text_len()).sum::<TextSize>(); | 604 | let len = new_children.iter().map(|it| it.text_len()).sum::<TextSize>(); |
592 | let new_node = rowan::GreenNode::new(rowan::SyntaxKind(parent.kind() as u16), new_children); | 605 | let new_node = rowan::GreenNode::new(rowan::SyntaxKind(parent.kind() as u16), new_children); |
593 | let new_root_node = parent.replace_with(new_node); | 606 | let new_root_node = parent.replace_with(new_node); |