make Parse generic

This commit is contained in:
Aleksey Kladov 2019-07-18 22:29:20 +03:00
parent abe72424a6
commit a6224f3620
5 changed files with 44 additions and 23 deletions

View file

@ -5,7 +5,7 @@ mod input;
use std::{panic, sync::Arc};
use ra_prof::profile;
use ra_syntax::{Parse, SourceFile, TextRange, TextUnit};
use ra_syntax::{ast, Parse, SourceFile, TextRange, TextUnit};
use relative_path::RelativePathBuf;
pub use crate::{
@ -74,7 +74,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug {
fn file_text(&self, file_id: FileId) -> Arc<String>;
// Parses the file into the syntax tree.
#[salsa::invoke(parse_query)]
fn parse(&self, file_id: FileId) -> Parse;
fn parse(&self, file_id: FileId) -> Parse<ast::SourceFile>;
/// Path to a file, relative to the root of its source root.
#[salsa::input]
fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
@ -98,7 +98,7 @@ fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<Cra
Arc::new(res)
}
fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse {
fn parse_query(db: &impl SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
let _p = profile("parse_query");
let text = db.file_text(file_id);
SourceFile::parse(&*text)