mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-09 10:55:42 +00:00
add more counts
This commit is contained in:
parent
fc08fdaf5a
commit
b8d50a7414
5 changed files with 10 additions and 4 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -284,9 +284,9 @@ checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "countme"
|
name = "countme"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f8038ded86523aa26c1321dfe8bb432707d0a3e2608f9d0108803727546e089"
|
checksum = "1aa2b26822354da8572983762d79a7ba55981b3fbbc612164a0dbbd0213df7fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ use hir_expand::{
|
||||||
HirFileId, InFile, MacroDefId,
|
HirFileId, InFile, MacroDefId,
|
||||||
};
|
};
|
||||||
use la_arena::{Arena, ArenaMap};
|
use la_arena::{Arena, ArenaMap};
|
||||||
|
use profile::Count;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use syntax::{ast, AstNode, AstPtr};
|
use syntax::{ast, AstNode, AstPtr};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
@ -237,6 +238,7 @@ pub struct Body {
|
||||||
/// The `ExprId` of the actual body expression.
|
/// The `ExprId` of the actual body expression.
|
||||||
pub body_expr: ExprId,
|
pub body_expr: ExprId,
|
||||||
pub item_scope: ItemScope,
|
pub item_scope: ItemScope,
|
||||||
|
_c: Count<Self>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ExprPtr = AstPtr<ast::Expr>;
|
pub type ExprPtr = AstPtr<ast::Expr>;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use hir_expand::{
|
||||||
ExpandError, HirFileId, MacroDefId, MacroDefKind,
|
ExpandError, HirFileId, MacroDefId, MacroDefKind,
|
||||||
};
|
};
|
||||||
use la_arena::Arena;
|
use la_arena::Arena;
|
||||||
|
use profile::Count;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{
|
ast::{
|
||||||
|
|
@ -77,6 +78,7 @@ pub(super) fn lower(
|
||||||
params: Vec::new(),
|
params: Vec::new(),
|
||||||
body_expr: dummy_expr_id(),
|
body_expr: dummy_expr_id(),
|
||||||
item_scope: Default::default(),
|
item_scope: Default::default(),
|
||||||
|
_c: Count::new(),
|
||||||
},
|
},
|
||||||
item_trees: {
|
item_trees: {
|
||||||
let mut map = FxHashMap::default();
|
let mut map = FxHashMap::default();
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use la_arena::{Arena, Idx};
|
use la_arena::{Arena, Idx};
|
||||||
|
use profile::Count;
|
||||||
use syntax::{ast, match_ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr};
|
use syntax::{ast, match_ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr};
|
||||||
|
|
||||||
/// `AstId` points to an AST node in a specific file.
|
/// `AstId` points to an AST node in a specific file.
|
||||||
|
|
@ -62,12 +63,13 @@ type ErasedFileAstId = Idx<SyntaxNodePtr>;
|
||||||
#[derive(Debug, PartialEq, Eq, Default)]
|
#[derive(Debug, PartialEq, Eq, Default)]
|
||||||
pub struct AstIdMap {
|
pub struct AstIdMap {
|
||||||
arena: Arena<SyntaxNodePtr>,
|
arena: Arena<SyntaxNodePtr>,
|
||||||
|
_c: Count<Self>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AstIdMap {
|
impl AstIdMap {
|
||||||
pub(crate) fn from_source(node: &SyntaxNode) -> AstIdMap {
|
pub(crate) fn from_source(node: &SyntaxNode) -> AstIdMap {
|
||||||
assert!(node.parent().is_none());
|
assert!(node.parent().is_none());
|
||||||
let mut res = AstIdMap { arena: Arena::default() };
|
let mut res = AstIdMap::default();
|
||||||
// By walking the tree in breadth-first order we make sure that parents
|
// By walking the tree in breadth-first order we make sure that parents
|
||||||
// get lower ids then children. That is, adding a new child does not
|
// get lower ids then children. That is, adding a new child does not
|
||||||
// change parent's id. This means that, say, adding a new function to a
|
// change parent's id. This means that, say, adding a new function to a
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ once_cell = "1.3.1"
|
||||||
cfg-if = "1"
|
cfg-if = "1"
|
||||||
libc = "0.2.73"
|
libc = "0.2.73"
|
||||||
la-arena = { version = "0.2.0", path = "../../lib/arena" }
|
la-arena = { version = "0.2.0", path = "../../lib/arena" }
|
||||||
countme = { version = "2.0.0", features = ["enable"] }
|
countme = { version = "2.0.1", features = ["enable"] }
|
||||||
jemalloc-ctl = { version = "0.3.3", optional = true }
|
jemalloc-ctl = { version = "0.3.3", optional = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue