rename file_syntax -> source_file

This commit is contained in:
Aleksey Kladov
2018-11-28 02:25:03 +03:00
parent 65c064b2a9
commit ec45dfea1e
6 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ pub(crate) fn completions(
db: &db::RootDatabase,
position: FilePosition,
) -> Cancelable<Option<Vec<CompletionItem>>> {
let original_file = db.file_syntax(position.file_id);
let original_file = db.source_file(position.file_id);
// Insert a fake ident to get a valid parse tree
let file = {
let edit = AtomEdit::insert(position.offset, "intellijRulezz".to_string());
+4 -4
View File
@@ -117,7 +117,7 @@ impl crate::input::FilesDatabase {
fn crate_graph() for crate::input::CrateGraphQuery;
}
impl SyntaxDatabase {
fn file_syntax() for FileSyntaxQuery;
fn source_file() for SourceFileQuery;
fn file_lines() for FileLinesQuery;
}
impl symbol_index::SymbolsDatabase {
@@ -139,8 +139,8 @@ impl hir::db::HirDatabase {
salsa::query_group! {
pub(crate) trait SyntaxDatabase: crate::input::FilesDatabase + BaseDatabase {
fn file_syntax(file_id: FileId) -> SourceFileNode {
type FileSyntaxQuery;
fn source_file(file_id: FileId) -> SourceFileNode {
type SourceFileQuery;
}
fn file_lines(file_id: FileId) -> Arc<LineIndex> {
type FileLinesQuery;
@@ -148,7 +148,7 @@ fn file_lines(file_id: FileId) -> Arc<LineIndex> {
}
}
fn file_syntax(db: &impl SyntaxDatabase, file_id: FileId) -> SourceFileNode {
fn source_file(db: &impl SyntaxDatabase, file_id: FileId) -> SourceFileNode {
let text = db.file_text(file_id);
SourceFileNode::parse(&*text)
}
+2 -2
View File
@@ -49,7 +49,7 @@ pub fn guess_from_position(
db: &impl HirDatabase,
position: FilePosition,
) -> Cancelable<Option<Module>> {
let file = db.file_syntax(position.file_id);
let file = db.source_file(position.file_id);
let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), position.offset)
{
Some(m) if !m.has_semi() => ModuleSource::new_inline(db, position.file_id, m),
@@ -346,7 +346,7 @@ pub(crate) fn file_id(self) -> FileId {
pub(crate) fn resolve(self, db: &impl HirDatabase) -> ModuleSourceNode {
match self {
ModuleSource::SourceFile(file_id) => {
let syntax = db.file_syntax(file_id);
let syntax = db.source_file(file_id);
ModuleSourceNode::SourceFile(syntax.ast().owned())
}
ModuleSource::Module(item_id) => {
@@ -38,7 +38,7 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> {
}
pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<SourceFileItems> {
let source_file = db.file_syntax(file_id);
let source_file = db.source_file(file_id);
let source_file = source_file.borrowed();
let mut res = SourceFileItems::default();
source_file
+9 -9
View File
@@ -18,7 +18,7 @@
use crate::{
completion::{completions, CompletionItem},
db::{self, FileSyntaxQuery, SyntaxDatabase},
db::{self, SourceFileQuery, SyntaxDatabase},
hir::{
self,
FnSignatureInfo,
@@ -189,7 +189,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
impl AnalysisImpl {
pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode {
self.db.file_syntax(file_id)
self.db.source_file(file_id)
}
pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> {
self.db.file_lines(file_id)
@@ -220,7 +220,7 @@ fn clone(&self) -> Snap {
.collect()
};
self.db
.query(FileSyntaxQuery)
.query(SourceFileQuery)
.sweep(salsa::SweepStrategy::default().discard_values());
Ok(query.search(&buf))
}
@@ -270,7 +270,7 @@ pub fn approximately_resolve_symbol(
&self,
position: FilePosition,
) -> Cancelable<Vec<(FileId, FileSymbol)>> {
let file = self.db.file_syntax(position.file_id);
let file = self.db.source_file(position.file_id);
let syntax = file.syntax();
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) {
if let Some(fn_descr) =
@@ -322,7 +322,7 @@ pub fn approximately_resolve_symbol(
}
pub fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> {
let file = self.db.file_syntax(position.file_id);
let file = self.db.source_file(position.file_id);
// Find the binding associated with the offset
let (binding, descr) = match find_binding(&self.db, &file, position) {
None => return Vec::new(),
@@ -365,13 +365,13 @@ pub fn doc_comment_for(
file_id: FileId,
symbol: FileSymbol,
) -> Cancelable<Option<String>> {
let file = self.db.file_syntax(file_id);
let file = self.db.source_file(file_id);
Ok(symbol.docs(&file))
}
pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> {
let syntax = self.db.file_syntax(file_id);
let syntax = self.db.source_file(file_id);
let mut res = ra_editor::diagnostics(&syntax)
.into_iter()
@@ -459,7 +459,7 @@ pub fn resolve_callable(
&self,
position: FilePosition,
) -> Cancelable<Option<(FnSignatureInfo, Option<usize>)>> {
let file = self.db.file_syntax(position.file_id);
let file = self.db.source_file(position.file_id);
let syntax = file.syntax();
// Find the calling expression and it's NameRef
@@ -470,7 +470,7 @@ pub fn resolve_callable(
let file_symbols = self.index_resolve(name_ref)?;
for (fn_file_id, fs) in file_symbols {
if fs.kind == FN_DEF {
let fn_file = self.db.file_syntax(fn_file_id);
let fn_file = self.db.source_file(fn_file_id);
if let Some(fn_def) = find_node_at_offset(fn_file.syntax(), fs.node_range.start()) {
let descr = hir::Function::guess_from_source(&*self.db, fn_file_id, fn_def);
if let Some(descriptor) = descr.signature_info(&*self.db) {
+1 -1
View File
@@ -32,7 +32,7 @@ fn library_symbols(id: SourceRootId) -> Arc<SymbolIndex> {
fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> {
db.check_canceled()?;
let syntax = db.file_syntax(file_id);
let syntax = db.source_file(file_id);
Ok(Arc::new(SymbolIndex::for_file(file_id, syntax)))
}