From ccd1b0800a5de5e046e6e9a4b6f49030c1ce3639 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 28 Nov 2019 12:50:26 +0300 Subject: Rename Source -> InFile --- crates/ra_hir_expand/src/diagnostics.rs | 4 ++-- crates/ra_hir_expand/src/lib.rs | 42 ++++++++++++++++----------------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs index 3d37e9335..108c1e38c 100644 --- a/crates/ra_hir_expand/src/diagnostics.rs +++ b/crates/ra_hir_expand/src/diagnostics.rs @@ -18,11 +18,11 @@ use std::{any::Any, fmt}; use ra_syntax::{SyntaxNode, SyntaxNodePtr, TextRange}; -use crate::{db::AstDatabase, Source}; +use crate::{db::AstDatabase, InFile}; pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { fn message(&self) -> String; - fn source(&self) -> Source; + fn source(&self) -> InFile; fn highlight_range(&self) -> TextRange { self.source().value.range() } diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index b6a739cda..2c5b6b2bb 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -90,9 +90,9 @@ impl HirFileId { let macro_arg = db.macro_arg(macro_file.macro_call_id)?; Some(ExpansionInfo { - expanded: Source::new(self, parse.syntax_node()), - arg: Source::new(loc.ast_id.file_id, arg_tt), - def: Source::new(loc.ast_id.file_id, def_tt), + expanded: InFile::new(self, parse.syntax_node()), + arg: InFile::new(loc.ast_id.file_id, arg_tt), + def: InFile::new(loc.ast_id.file_id, def_tt), macro_arg, macro_def, exp_map, @@ -167,9 +167,9 @@ impl MacroCallId { /// ExpansionInfo mainly describes how to map text range between src and expanded macro #[derive(Debug, Clone, PartialEq, Eq)] pub struct ExpansionInfo { - expanded: Source, - arg: Source, - def: Source, + expanded: InFile, + arg: InFile, + def: InFile, macro_def: Arc<(db::TokenExpander, mbe::TokenMap)>, macro_arg: Arc<(tt::Subtree, mbe::TokenMap)>, @@ -177,7 +177,7 @@ pub struct ExpansionInfo { } impl ExpansionInfo { - pub fn map_token_down(&self, token: Source<&SyntaxToken>) -> Option> { + pub fn map_token_down(&self, token: InFile<&SyntaxToken>) -> Option> { assert_eq!(token.file_id, self.arg.file_id); let range = token.value.text_range().checked_sub(self.arg.value.syntax().text_range().start())?; @@ -191,7 +191,7 @@ impl ExpansionInfo { Some(self.expanded.with_value(token)) } - pub fn map_token_up(&self, token: Source<&SyntaxToken>) -> Option> { + pub fn map_token_up(&self, token: InFile<&SyntaxToken>) -> Option> { let token_id = self.exp_map.token_by_range(token.value.text_range())?; let (token_id, origin) = self.macro_def.0.map_id_up(token_id); @@ -254,33 +254,33 @@ impl AstId { } } -/// `Source` stores a value of `T` inside a particular file/syntax tree. +/// `InFile` stores a value of `T` inside a particular file/syntax tree. /// /// Typical usages are: /// -/// * `Source` -- syntax node in a file -/// * `Source` -- ast node in a file -/// * `Source` -- offset in a file +/// * `InFile` -- syntax node in a file +/// * `InFile` -- ast node in a file +/// * `InFile` -- offset in a file #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] -pub struct Source { +pub struct InFile { pub file_id: HirFileId, pub value: T, } -impl Source { - pub fn new(file_id: HirFileId, value: T) -> Source { - Source { file_id, value } +impl InFile { + pub fn new(file_id: HirFileId, value: T) -> InFile { + InFile { file_id, value } } // Similarly, naming here is stupid... - pub fn with_value(&self, value: U) -> Source { - Source::new(self.file_id, value) + pub fn with_value(&self, value: U) -> InFile { + InFile::new(self.file_id, value) } - pub fn map U, U>(self, f: F) -> Source { - Source::new(self.file_id, f(self.value)) + pub fn map U, U>(self, f: F) -> InFile { + InFile::new(self.file_id, f(self.value)) } - pub fn as_ref(&self) -> Source<&T> { + pub fn as_ref(&self) -> InFile<&T> { self.with_value(&self.value) } pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { -- cgit v1.2.3