Merge #666
666: rename source_file -> parse r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
8b6dea348f
19 changed files with 41 additions and 47 deletions
|
@ -71,7 +71,7 @@ pub trait SourceDatabase: salsa::Database + CheckCanceled {
|
||||||
#[salsa::input]
|
#[salsa::input]
|
||||||
fn file_text(&self, file_id: FileId) -> Arc<String>;
|
fn file_text(&self, file_id: FileId) -> Arc<String>;
|
||||||
// Parses the file into the syntax tree.
|
// Parses the file into the syntax tree.
|
||||||
fn source_file(&self, file_id: FileId) -> TreeArc<SourceFile>;
|
fn parse(&self, file_id: FileId) -> TreeArc<SourceFile>;
|
||||||
/// Path to a file, relative to the root of its source root.
|
/// Path to a file, relative to the root of its source root.
|
||||||
#[salsa::input]
|
#[salsa::input]
|
||||||
fn file_relative_path(&self, file_id: FileId) -> RelativePathBuf;
|
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)
|
Arc::new(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn source_file(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> {
|
fn parse(db: &impl SourceDatabase, file_id: FileId) -> TreeArc<SourceFile> {
|
||||||
let text = db.file_text(file_id);
|
let text = db.file_text(file_id);
|
||||||
SourceFile::parse(&*text)
|
SourceFile::parse(&*text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ use crate::{
|
||||||
|
|
||||||
#[salsa::query_group(HirDatabaseStorage)]
|
#[salsa::query_group(HirDatabaseStorage)]
|
||||||
pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
|
pub trait HirDatabase: SourceDatabase + AsRef<HirInterner> {
|
||||||
#[salsa::invoke(HirFileId::hir_source_file)]
|
#[salsa::invoke(HirFileId::hir_parse)]
|
||||||
fn hir_source_file(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
fn hir_parse(&self, file_id: HirFileId) -> TreeArc<SourceFile>;
|
||||||
|
|
||||||
#[salsa::invoke(crate::macros::expand_macro_invocation)]
|
#[salsa::invoke(crate::macros::expand_macro_invocation)]
|
||||||
fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
|
fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>;
|
||||||
|
|
|
@ -86,12 +86,9 @@ impl HirFileId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn hir_source_file(
|
pub(crate) fn hir_parse(db: &impl HirDatabase, file_id: HirFileId) -> TreeArc<SourceFile> {
|
||||||
db: &impl HirDatabase,
|
|
||||||
file_id: HirFileId,
|
|
||||||
) -> TreeArc<SourceFile> {
|
|
||||||
match file_id.0 {
|
match file_id.0 {
|
||||||
HirFileIdRepr::File(file_id) => db.source_file(file_id),
|
HirFileIdRepr::File(file_id) => db.parse(file_id),
|
||||||
HirFileIdRepr::Macro(m) => {
|
HirFileIdRepr::Macro(m) => {
|
||||||
if let Some(exp) = db.expand_macro_invocation(m) {
|
if let Some(exp) = db.expand_macro_invocation(m) {
|
||||||
return exp.file();
|
return exp.file();
|
||||||
|
@ -370,7 +367,7 @@ impl SourceFileItems {
|
||||||
self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
|
self.arena.iter().map(|(_id, i)| i).collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub fn id_of_source_file(&self) -> SourceFileItemId {
|
pub fn id_of_parse(&self) -> SourceFileItemId {
|
||||||
let (id, _syntax) = self.arena.iter().next().unwrap();
|
let (id, _syntax) = self.arena.iter().next().unwrap();
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl LoweredModule {
|
||||||
let id = loc.id(db);
|
let id = loc.id(db);
|
||||||
let file_id = HirFileId::from(id);
|
let file_id = HirFileId::from(id);
|
||||||
//FIXME: expand recursively
|
//FIXME: expand recursively
|
||||||
for item in db.hir_source_file(file_id).items() {
|
for item in db.hir_parse(file_id).items() {
|
||||||
self.add_def_id(source_map, db, module, file_id, item);
|
self.add_def_id(source_map, db, module, file_id, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, func: Function) -> Arc<FnScopes>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {
|
pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> {
|
||||||
let source_file = db.hir_source_file(file_id);
|
let source_file = db.hir_parse(file_id);
|
||||||
let res = SourceFileItems::new(file_id, &source_file);
|
let res = SourceFileItems::new(file_id, &source_file);
|
||||||
Arc::new(res)
|
Arc::new(res)
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,7 @@ pub(super) fn file_item(
|
||||||
) -> TreeArc<SyntaxNode> {
|
) -> TreeArc<SyntaxNode> {
|
||||||
match source_item_id.item_id {
|
match source_item_id.item_id {
|
||||||
Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(),
|
Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(),
|
||||||
None => db
|
None => db.hir_parse(source_item_id.file_id).syntax().to_owned(),
|
||||||
.hir_source_file(source_item_id.file_id)
|
|
||||||
.syntax()
|
|
||||||
.to_owned(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub fn module_from_declaration(
|
||||||
|
|
||||||
/// Locates the module by position in the source code.
|
/// Locates the module by position in the source code.
|
||||||
pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> {
|
pub fn module_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Module> {
|
||||||
let file = db.source_file(position.file_id);
|
let file = db.parse(position.file_id);
|
||||||
match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) {
|
match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) {
|
||||||
Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m),
|
Some(m) if !m.has_semi() => module_from_inline(db, position.file_id.into(), m),
|
||||||
_ => module_from_file_id(db, position.file_id.into()),
|
_ => module_from_file_id(db, position.file_id.into()),
|
||||||
|
@ -95,7 +95,7 @@ fn module_from_source(db: &impl HirDatabase, source: SourceItemId) -> Option<Mod
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn function_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Function> {
|
pub fn function_from_position(db: &impl HirDatabase, position: FilePosition) -> Option<Function> {
|
||||||
let file = db.source_file(position.file_id);
|
let file = db.parse(position.file_id);
|
||||||
let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)?;
|
let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset)?;
|
||||||
function_from_source(db, position.file_id, fn_def)
|
function_from_source(db, position.file_id, fn_def)
|
||||||
}
|
}
|
||||||
|
|
|
@ -547,7 +547,7 @@ fn quux() {
|
||||||
|
|
||||||
fn infer(content: &str) -> String {
|
fn infer(content: &str) -> String {
|
||||||
let (db, _, file_id) = MockDatabase::with_single_file(content);
|
let (db, _, file_id) = MockDatabase::with_single_file(content);
|
||||||
let source_file = db.source_file(file_id);
|
let source_file = db.parse(file_id);
|
||||||
let mut acc = String::new();
|
let mut acc = String::new();
|
||||||
for fn_def in source_file
|
for fn_def in source_file
|
||||||
.syntax()
|
.syntax()
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{FilePosition, CallInfo, db::RootDatabase};
|
||||||
|
|
||||||
/// Computes parameter information for the given call expression.
|
/// Computes parameter information for the given call expression.
|
||||||
pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {
|
pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<CallInfo> {
|
||||||
let file = db.source_file(position.file_id);
|
let file = db.parse(position.file_id);
|
||||||
let syntax = file.syntax();
|
let syntax = file.syntax();
|
||||||
|
|
||||||
// Find the calling expression and it's NameRef
|
// Find the calling expression and it's NameRef
|
||||||
|
@ -22,7 +22,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
|
||||||
let symbol = file_symbols
|
let symbol = file_symbols
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find(|it| it.ptr.kind() == FN_DEF)?;
|
.find(|it| it.ptr.kind() == FN_DEF)?;
|
||||||
let fn_file = db.source_file(symbol.file_id);
|
let fn_file = db.parse(symbol.file_id);
|
||||||
let fn_def = symbol.ptr.to_node(&fn_file);
|
let fn_def = symbol.ptr.to_node(&fn_file);
|
||||||
let fn_def = ast::FnDef::cast(fn_def).unwrap();
|
let fn_def = ast::FnDef::cast(fn_def).unwrap();
|
||||||
let mut call_info = CallInfo::new(fn_def)?;
|
let mut call_info = CallInfo::new(fn_def)?;
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind,
|
||||||
/// identifier prefix/fuzzy match should be done higher in the stack, together
|
/// identifier prefix/fuzzy match should be done higher in the stack, together
|
||||||
/// with ordering of completions (currently this is done by the client).
|
/// with ordering of completions (currently this is done by the client).
|
||||||
pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Option<Completions> {
|
pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Option<Completions> {
|
||||||
let original_file = db.source_file(position.file_id);
|
let original_file = db.parse(position.file_id);
|
||||||
let ctx = CompletionContext::new(db, &original_file, position)?;
|
let ctx = CompletionContext::new(db, &original_file, position)?;
|
||||||
|
|
||||||
let mut acc = Completions::default();
|
let mut acc = Completions::default();
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
|
pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRange {
|
||||||
let source_file = db.source_file(frange.file_id);
|
let source_file = db.parse(frange.file_id);
|
||||||
if let Some(range) = extend_selection_in_macro(db, &source_file, frange) {
|
if let Some(range) = extend_selection_in_macro(db, &source_file, frange) {
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub(crate) fn goto_definition(
|
||||||
db: &RootDatabase,
|
db: &RootDatabase,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
) -> Option<RangeInfo<Vec<NavigationTarget>>> {
|
) -> Option<RangeInfo<Vec<NavigationTarget>>> {
|
||||||
let file = db.source_file(position.file_id);
|
let file = db.parse(position.file_id);
|
||||||
let syntax = file.syntax();
|
let syntax = file.syntax();
|
||||||
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) {
|
if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) {
|
||||||
let navs = reference_definition(db, position.file_id, name_ref).to_vec();
|
let navs = reference_definition(db, position.file_id, name_ref).to_vec();
|
||||||
|
|
|
@ -7,7 +7,7 @@ use ra_syntax::{
|
||||||
use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget};
|
use crate::{db::RootDatabase, RangeInfo, FilePosition, FileRange, NavigationTarget};
|
||||||
|
|
||||||
pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeInfo<String>> {
|
pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeInfo<String>> {
|
||||||
let file = db.source_file(position.file_id);
|
let file = db.parse(position.file_id);
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
|
|
||||||
let mut range = None;
|
let mut range = None;
|
||||||
|
@ -53,7 +53,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
|
pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
|
||||||
let file = db.source_file(frange.file_id);
|
let file = db.parse(frange.file_id);
|
||||||
let syntax = file.syntax();
|
let syntax = file.syntax();
|
||||||
let leaf_node = find_covering_node(syntax, frange.range);
|
let leaf_node = find_covering_node(syntax, frange.range);
|
||||||
// if we picked identifier, expand to pattern/expression
|
// if we picked identifier, expand to pattern/expression
|
||||||
|
@ -88,7 +88,7 @@ fn doc_text_for(db: &RootDatabase, nav: NavigationTarget) -> Option<String> {
|
||||||
|
|
||||||
impl NavigationTarget {
|
impl NavigationTarget {
|
||||||
fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> {
|
fn node(&self, db: &RootDatabase) -> Option<TreeArc<SyntaxNode>> {
|
||||||
let source_file = db.source_file(self.file_id());
|
let source_file = db.parse(self.file_id());
|
||||||
let source_file = source_file.syntax();
|
let source_file = source_file.syntax();
|
||||||
let node = source_file
|
let node = source_file
|
||||||
.descendants()
|
.descendants()
|
||||||
|
|
|
@ -76,9 +76,9 @@ impl db::RootDatabase {
|
||||||
/// syntax trees. However, if we actually do that, everything is recomputed
|
/// syntax trees. However, if we actually do that, everything is recomputed
|
||||||
/// for some reason. Needs investigation.
|
/// for some reason. Needs investigation.
|
||||||
pub(crate) fn collect_garbage(&mut self) {
|
pub(crate) fn collect_garbage(&mut self) {
|
||||||
self.query(ra_db::SourceFileQuery)
|
self.query(ra_db::ParseQuery)
|
||||||
.sweep(SweepStrategy::default().discard_values());
|
.sweep(SweepStrategy::default().discard_values());
|
||||||
self.query(hir::db::HirSourceFileQuery)
|
self.query(hir::db::HirParseQuery)
|
||||||
.sweep(SweepStrategy::default().discard_values());
|
.sweep(SweepStrategy::default().discard_values());
|
||||||
self.query(hir::db::FileItemsQuery)
|
self.query(hir::db::FileItemsQuery)
|
||||||
.sweep(SweepStrategy::default().discard_values());
|
.sweep(SweepStrategy::default().discard_values());
|
||||||
|
@ -102,7 +102,7 @@ impl db::RootDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> {
|
pub(crate) fn find_all_refs(&self, position: FilePosition) -> Vec<(FileId, TextRange)> {
|
||||||
let file = self.source_file(position.file_id);
|
let file = self.parse(position.file_id);
|
||||||
// Find the binding associated with the offset
|
// Find the binding associated with the offset
|
||||||
let (binding, descr) = match find_binding(self, &file, position) {
|
let (binding, descr) = match find_binding(self, &file, position) {
|
||||||
None => return Vec::new(),
|
None => return Vec::new(),
|
||||||
|
@ -150,7 +150,7 @@ impl db::RootDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> {
|
pub(crate) fn diagnostics(&self, file_id: FileId) -> Vec<Diagnostic> {
|
||||||
let syntax = self.source_file(file_id);
|
let syntax = self.parse(file_id);
|
||||||
|
|
||||||
let mut res = ra_ide_api_light::diagnostics(&syntax)
|
let mut res = ra_ide_api_light::diagnostics(&syntax)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -214,7 +214,7 @@ impl db::RootDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn assists(&self, frange: FileRange) -> Vec<SourceChange> {
|
pub(crate) fn assists(&self, frange: FileRange) -> Vec<SourceChange> {
|
||||||
let file = self.source_file(frange.file_id);
|
let file = self.parse(frange.file_id);
|
||||||
assists::assists(&file, frange.range)
|
assists::assists(&file, frange.range)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|local_edit| SourceChange::from_local_edit(frange.file_id, local_edit))
|
.map(|local_edit| SourceChange::from_local_edit(frange.file_id, local_edit))
|
||||||
|
|
|
@ -313,7 +313,7 @@ impl Analysis {
|
||||||
|
|
||||||
/// Gets the syntax tree of the file.
|
/// Gets the syntax tree of the file.
|
||||||
pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> {
|
pub fn parse(&self, file_id: FileId) -> TreeArc<SourceFile> {
|
||||||
self.db.source_file(file_id).clone()
|
self.db.parse(file_id).clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the file's `LineIndex`: data structure to convert between absolute
|
/// Gets the file's `LineIndex`: data structure to convert between absolute
|
||||||
|
@ -330,21 +330,21 @@ impl Analysis {
|
||||||
/// Returns position of the mathcing brace (all types of braces are
|
/// Returns position of the mathcing brace (all types of braces are
|
||||||
/// supported).
|
/// supported).
|
||||||
pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> {
|
pub fn matching_brace(&self, position: FilePosition) -> Option<TextUnit> {
|
||||||
let file = self.db.source_file(position.file_id);
|
let file = self.db.parse(position.file_id);
|
||||||
ra_ide_api_light::matching_brace(&file, position.offset)
|
ra_ide_api_light::matching_brace(&file, position.offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a syntax tree represented as `String`, for debug purposes.
|
/// Returns a syntax tree represented as `String`, for debug purposes.
|
||||||
// FIXME: use a better name here.
|
// FIXME: use a better name here.
|
||||||
pub fn syntax_tree(&self, file_id: FileId) -> String {
|
pub fn syntax_tree(&self, file_id: FileId) -> String {
|
||||||
let file = self.db.source_file(file_id);
|
let file = self.db.parse(file_id);
|
||||||
ra_ide_api_light::syntax_tree(&file)
|
ra_ide_api_light::syntax_tree(&file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an edit to remove all newlines in the range, cleaning up minor
|
/// Returns an edit to remove all newlines in the range, cleaning up minor
|
||||||
/// stuff like trailing commas.
|
/// stuff like trailing commas.
|
||||||
pub fn join_lines(&self, frange: FileRange) -> SourceChange {
|
pub fn join_lines(&self, frange: FileRange) -> SourceChange {
|
||||||
let file = self.db.source_file(frange.file_id);
|
let file = self.db.parse(frange.file_id);
|
||||||
SourceChange::from_local_edit(
|
SourceChange::from_local_edit(
|
||||||
frange.file_id,
|
frange.file_id,
|
||||||
ra_ide_api_light::join_lines(&file, frange.range),
|
ra_ide_api_light::join_lines(&file, frange.range),
|
||||||
|
@ -354,7 +354,7 @@ impl Analysis {
|
||||||
/// Returns an edit which should be applied when opening a new line, fixing
|
/// Returns an edit which should be applied when opening a new line, fixing
|
||||||
/// up minor stuff like continuing the comment.
|
/// up minor stuff like continuing the comment.
|
||||||
pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> {
|
pub fn on_enter(&self, position: FilePosition) -> Option<SourceChange> {
|
||||||
let file = self.db.source_file(position.file_id);
|
let file = self.db.parse(position.file_id);
|
||||||
let edit = ra_ide_api_light::on_enter(&file, position.offset)?;
|
let edit = ra_ide_api_light::on_enter(&file, position.offset)?;
|
||||||
Some(SourceChange::from_local_edit(position.file_id, edit))
|
Some(SourceChange::from_local_edit(position.file_id, edit))
|
||||||
}
|
}
|
||||||
|
@ -363,14 +363,14 @@ impl Analysis {
|
||||||
/// this works when adding `let =`.
|
/// this works when adding `let =`.
|
||||||
// FIXME: use a snippet completion instead of this hack here.
|
// FIXME: use a snippet completion instead of this hack here.
|
||||||
pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
pub fn on_eq_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
||||||
let file = self.db.source_file(position.file_id);
|
let file = self.db.parse(position.file_id);
|
||||||
let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?;
|
let edit = ra_ide_api_light::on_eq_typed(&file, position.offset)?;
|
||||||
Some(SourceChange::from_local_edit(position.file_id, edit))
|
Some(SourceChange::from_local_edit(position.file_id, edit))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
|
/// Returns an edit which should be applied when a dot ('.') is typed on a blank line, indenting the line appropriately.
|
||||||
pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
pub fn on_dot_typed(&self, position: FilePosition) -> Option<SourceChange> {
|
||||||
let file = self.db.source_file(position.file_id);
|
let file = self.db.parse(position.file_id);
|
||||||
let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?;
|
let edit = ra_ide_api_light::on_dot_typed(&file, position.offset)?;
|
||||||
Some(SourceChange::from_local_edit(position.file_id, edit))
|
Some(SourceChange::from_local_edit(position.file_id, edit))
|
||||||
}
|
}
|
||||||
|
@ -378,13 +378,13 @@ impl Analysis {
|
||||||
/// Returns a tree representation of symbols in the file. Useful to draw a
|
/// Returns a tree representation of symbols in the file. Useful to draw a
|
||||||
/// file outline.
|
/// file outline.
|
||||||
pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {
|
pub fn file_structure(&self, file_id: FileId) -> Vec<StructureNode> {
|
||||||
let file = self.db.source_file(file_id);
|
let file = self.db.parse(file_id);
|
||||||
ra_ide_api_light::file_structure(&file)
|
ra_ide_api_light::file_structure(&file)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the set of folding ranges.
|
/// Returns the set of folding ranges.
|
||||||
pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
|
pub fn folding_ranges(&self, file_id: FileId) -> Vec<Fold> {
|
||||||
let file = self.db.source_file(file_id);
|
let file = self.db.parse(file_id);
|
||||||
ra_ide_api_light::folding_ranges(&file)
|
ra_ide_api_light::folding_ranges(&file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub(crate) fn rename(
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
new_name: &str,
|
new_name: &str,
|
||||||
) -> Option<SourceChange> {
|
) -> Option<SourceChange> {
|
||||||
let source_file = db.source_file(position.file_id);
|
let source_file = db.parse(position.file_id);
|
||||||
let syntax = source_file.syntax();
|
let syntax = source_file.syntax();
|
||||||
|
|
||||||
if let Some((ast_name, ast_module)) = find_name_and_module_at_offset(syntax, position) {
|
if let Some((ast_name, ast_module)) = find_name_and_module_at_offset(syntax, position) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub enum RunnableKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
|
pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
|
||||||
let source_file = db.source_file(file_id);
|
let source_file = db.parse(file_id);
|
||||||
source_file
|
source_file
|
||||||
.syntax()
|
.syntax()
|
||||||
.descendants()
|
.descendants()
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
||||||
|
|
||||||
use ra_syntax::{AstNode, TreeArc, SourceFile};
|
use ra_syntax::{AstNode, TreeArc, SourceFile};
|
||||||
use ra_db::{
|
use ra_db::{
|
||||||
SourceFileQuery, FileTextQuery, SourceRootId,
|
ParseQuery, FileTextQuery, SourceRootId,
|
||||||
salsa::{Database, debug::{DebugQueryTable, TableEntry}},
|
salsa::{Database, debug::{DebugQueryTable, TableEntry}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
|
|
||||||
pub(crate) fn status(db: &RootDatabase) -> String {
|
pub(crate) fn status(db: &RootDatabase) -> String {
|
||||||
let files_stats = db.query(FileTextQuery).entries::<FilesStats>();
|
let files_stats = db.query(FileTextQuery).entries::<FilesStats>();
|
||||||
let syntax_tree_stats = db.query(SourceFileQuery).entries::<SyntaxTreeStats>();
|
let syntax_tree_stats = db.query(ParseQuery).entries::<SyntaxTreeStats>();
|
||||||
let symbols_stats = db
|
let symbols_stats = db
|
||||||
.query(LibrarySymbolsQuery)
|
.query(LibrarySymbolsQuery)
|
||||||
.entries::<LibrarySymbolsStats>();
|
.entries::<LibrarySymbolsStats>();
|
||||||
|
|
|
@ -61,7 +61,7 @@ pub(crate) trait SymbolsDatabase: hir::db::HirDatabase {
|
||||||
|
|
||||||
fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
|
fn file_symbols(db: &impl SymbolsDatabase, file_id: FileId) -> Arc<SymbolIndex> {
|
||||||
db.check_canceled();
|
db.check_canceled();
|
||||||
let source_file = db.source_file(file_id);
|
let source_file = db.parse(file_id);
|
||||||
let mut symbols = source_file
|
let mut symbols = source_file
|
||||||
.syntax()
|
.syntax()
|
||||||
.descendants()
|
.descendants()
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> {
|
pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> {
|
||||||
let source_file = db.source_file(file_id);
|
let source_file = db.parse(file_id);
|
||||||
let mut res = ra_ide_api_light::highlight(source_file.syntax());
|
let mut res = ra_ide_api_light::highlight(source_file.syntax());
|
||||||
for macro_call in source_file
|
for macro_call in source_file
|
||||||
.syntax()
|
.syntax()
|
||||||
|
|
Loading…
Reference in a new issue