mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
make Parse generic
This commit is contained in:
parent
abe72424a6
commit
a6224f3620
5 changed files with 44 additions and 23 deletions
|
@ -43,7 +43,7 @@ pub(crate) struct CompletionContext<'a> {
|
|||
impl<'a> CompletionContext<'a> {
|
||||
pub(super) fn new(
|
||||
db: &'a db::RootDatabase,
|
||||
original_parse: &'a Parse,
|
||||
original_parse: &'a Parse<ast::SourceFile>,
|
||||
position: FilePosition,
|
||||
) -> Option<CompletionContext<'a>> {
|
||||
let module = source_binder::module_from_position(db, position);
|
||||
|
@ -83,7 +83,7 @@ impl<'a> CompletionContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn fill(&mut self, original_parse: &'a Parse, offset: TextUnit) {
|
||||
fn fill(&mut self, original_parse: &'a Parse<ast::SourceFile>, offset: TextUnit) {
|
||||
// Insert a fake ident to get a valid parse tree. We will use this file
|
||||
// to determine context, though the original_file will be used for
|
||||
// actual completion.
|
||||
|
|
|
@ -9,7 +9,7 @@ use ra_db::{
|
|||
FileTextQuery, SourceRootId,
|
||||
};
|
||||
use ra_prof::{memory_usage, Bytes};
|
||||
use ra_syntax::{AstNode, Parse, SyntaxNode, TreeArc};
|
||||
use ra_syntax::{ast, AstNode, Parse, SyntaxNode, TreeArc};
|
||||
|
||||
use crate::{
|
||||
db::RootDatabase,
|
||||
|
@ -79,10 +79,10 @@ impl fmt::Display for SyntaxTreeStats {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromIterator<TableEntry<FileId, Parse>> for SyntaxTreeStats {
|
||||
impl FromIterator<TableEntry<FileId, Parse<ast::SourceFile>>> for SyntaxTreeStats {
|
||||
fn from_iter<T>(iter: T) -> SyntaxTreeStats
|
||||
where
|
||||
T: IntoIterator<Item = TableEntry<FileId, Parse>>,
|
||||
T: IntoIterator<Item = TableEntry<FileId, Parse<ast::SourceFile>>>,
|
||||
{
|
||||
let mut res = SyntaxTreeStats::default();
|
||||
for entry in iter {
|
||||
|
|
|
@ -169,7 +169,9 @@ impl SymbolIndex {
|
|||
self.map.as_fst().size() + self.symbols.len() * mem::size_of::<FileSymbol>()
|
||||
}
|
||||
|
||||
pub(crate) fn for_files(files: impl ParallelIterator<Item = (FileId, Parse)>) -> SymbolIndex {
|
||||
pub(crate) fn for_files(
|
||||
files: impl ParallelIterator<Item = (FileId, Parse<ast::SourceFile>)>,
|
||||
) -> SymbolIndex {
|
||||
let symbols = files
|
||||
.flat_map(|(file_id, file)| source_file_to_file_symbols(file.tree(), file_id))
|
||||
.collect::<Vec<_>>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue