mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
hir_expand::db: reduce fn visibility
This commit is contained in:
parent
9a3bb19d32
commit
f9d0d51101
1 changed files with 9 additions and 15 deletions
|
@ -138,16 +138,13 @@ pub fn expand_hypothetical(
|
|||
Some((node.syntax_node(), token))
|
||||
}
|
||||
|
||||
pub(crate) fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> {
|
||||
fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> {
|
||||
let map =
|
||||
db.parse_or_expand(file_id).map_or_else(AstIdMap::default, |it| AstIdMap::from_source(&it));
|
||||
Arc::new(map)
|
||||
}
|
||||
|
||||
pub(crate) fn macro_def(
|
||||
db: &dyn AstDatabase,
|
||||
id: MacroDefId,
|
||||
) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> {
|
||||
fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> {
|
||||
match id.kind {
|
||||
MacroDefKind::Declarative => {
|
||||
let macro_call = id.ast_id?.to_node(db);
|
||||
|
@ -178,7 +175,7 @@ pub(crate) fn macro_def(
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> {
|
||||
fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> {
|
||||
let id = match id {
|
||||
MacroCallId::LazyMacro(id) => id,
|
||||
MacroCallId::EagerMacro(_id) => {
|
||||
|
@ -191,16 +188,13 @@ pub(crate) fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<Gr
|
|||
Some(arg.green().clone())
|
||||
}
|
||||
|
||||
pub(crate) fn macro_arg(
|
||||
db: &dyn AstDatabase,
|
||||
id: MacroCallId,
|
||||
) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>> {
|
||||
fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>> {
|
||||
let arg = db.macro_arg_text(id)?;
|
||||
let (tt, tmap) = mbe::syntax_node_to_token_tree(&SyntaxNode::new_root(arg))?;
|
||||
Some(Arc::new((tt, tmap)))
|
||||
}
|
||||
|
||||
pub(crate) fn macro_expand(db: &dyn AstDatabase, id: MacroCallId) -> MacroResult<Arc<tt::Subtree>> {
|
||||
fn macro_expand(db: &dyn AstDatabase, id: MacroCallId) -> MacroResult<Arc<tt::Subtree>> {
|
||||
macro_expand_with_arg(db, id, None)
|
||||
}
|
||||
|
||||
|
@ -258,7 +252,7 @@ fn macro_expand_with_arg(
|
|||
MacroResult { value: Some(Arc::new(tt)), error: err.map(|e| format!("{:?}", e)) }
|
||||
}
|
||||
|
||||
pub(crate) fn expand_proc_macro(
|
||||
fn expand_proc_macro(
|
||||
db: &dyn AstDatabase,
|
||||
id: MacroCallId,
|
||||
) -> Result<tt::Subtree, mbe::ExpandError> {
|
||||
|
@ -285,7 +279,7 @@ pub(crate) fn expand_proc_macro(
|
|||
expander.expand(db, lazy_id, ¯o_arg.0)
|
||||
}
|
||||
|
||||
pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNode> {
|
||||
fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNode> {
|
||||
match file_id.0 {
|
||||
HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()),
|
||||
HirFileIdRepr::MacroFile(macro_file) => {
|
||||
|
@ -294,14 +288,14 @@ pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Optio
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_macro(
|
||||
fn parse_macro(
|
||||
db: &dyn AstDatabase,
|
||||
macro_file: MacroFile,
|
||||
) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> {
|
||||
parse_macro_with_arg(db, macro_file, None)
|
||||
}
|
||||
|
||||
pub fn parse_macro_with_arg(
|
||||
fn parse_macro_with_arg(
|
||||
db: &dyn AstDatabase,
|
||||
macro_file: MacroFile,
|
||||
arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>,
|
||||
|
|
Loading…
Reference in a new issue