diff options
author | Jonas Schievink <[email protected]> | 2020-11-24 20:55:08 +0000 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-11-24 20:55:08 +0000 |
commit | f9d0d511011b7071c621ac3f7c64c4aaec7f2dfb (patch) | |
tree | 7953f600686d62785e08fe8dfa2753572770e213 | |
parent | 9a3bb19d3274824d6648117ab32ac59358ff1f14 (diff) |
hir_expand::db: reduce fn visibility
-rw-r--r-- | crates/hir_expand/src/db.rs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs index 3fd9a90a8..36d3307a1 100644 --- a/crates/hir_expand/src/db.rs +++ b/crates/hir_expand/src/db.rs | |||
@@ -138,16 +138,13 @@ pub fn expand_hypothetical( | |||
138 | Some((node.syntax_node(), token)) | 138 | Some((node.syntax_node(), token)) |
139 | } | 139 | } |
140 | 140 | ||
141 | pub(crate) fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> { | 141 | fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> { |
142 | let map = | 142 | let map = |
143 | db.parse_or_expand(file_id).map_or_else(AstIdMap::default, |it| AstIdMap::from_source(&it)); | 143 | db.parse_or_expand(file_id).map_or_else(AstIdMap::default, |it| AstIdMap::from_source(&it)); |
144 | Arc::new(map) | 144 | Arc::new(map) |
145 | } | 145 | } |
146 | 146 | ||
147 | pub(crate) fn macro_def( | 147 | fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { |
148 | db: &dyn AstDatabase, | ||
149 | id: MacroDefId, | ||
150 | ) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { | ||
151 | match id.kind { | 148 | match id.kind { |
152 | MacroDefKind::Declarative => { | 149 | MacroDefKind::Declarative => { |
153 | let macro_call = id.ast_id?.to_node(db); | 150 | let macro_call = id.ast_id?.to_node(db); |
@@ -178,7 +175,7 @@ pub(crate) fn macro_def( | |||
178 | } | 175 | } |
179 | } | 176 | } |
180 | 177 | ||
181 | pub(crate) fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> { | 178 | fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<GreenNode> { |
182 | let id = match id { | 179 | let id = match id { |
183 | MacroCallId::LazyMacro(id) => id, | 180 | MacroCallId::LazyMacro(id) => id, |
184 | MacroCallId::EagerMacro(_id) => { | 181 | MacroCallId::EagerMacro(_id) => { |
@@ -191,16 +188,13 @@ pub(crate) fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option<Gr | |||
191 | Some(arg.green().clone()) | 188 | Some(arg.green().clone()) |
192 | } | 189 | } |
193 | 190 | ||
194 | pub(crate) fn macro_arg( | 191 | fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>> { |
195 | db: &dyn AstDatabase, | ||
196 | id: MacroCallId, | ||
197 | ) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>> { | ||
198 | let arg = db.macro_arg_text(id)?; | 192 | let arg = db.macro_arg_text(id)?; |
199 | let (tt, tmap) = mbe::syntax_node_to_token_tree(&SyntaxNode::new_root(arg))?; | 193 | let (tt, tmap) = mbe::syntax_node_to_token_tree(&SyntaxNode::new_root(arg))?; |
200 | Some(Arc::new((tt, tmap))) | 194 | Some(Arc::new((tt, tmap))) |
201 | } | 195 | } |
202 | 196 | ||
203 | pub(crate) fn macro_expand(db: &dyn AstDatabase, id: MacroCallId) -> MacroResult<Arc<tt::Subtree>> { | 197 | fn macro_expand(db: &dyn AstDatabase, id: MacroCallId) -> MacroResult<Arc<tt::Subtree>> { |
204 | macro_expand_with_arg(db, id, None) | 198 | macro_expand_with_arg(db, id, None) |
205 | } | 199 | } |
206 | 200 | ||
@@ -258,7 +252,7 @@ fn macro_expand_with_arg( | |||
258 | MacroResult { value: Some(Arc::new(tt)), error: err.map(|e| format!("{:?}", e)) } | 252 | MacroResult { value: Some(Arc::new(tt)), error: err.map(|e| format!("{:?}", e)) } |
259 | } | 253 | } |
260 | 254 | ||
261 | pub(crate) fn expand_proc_macro( | 255 | fn expand_proc_macro( |
262 | db: &dyn AstDatabase, | 256 | db: &dyn AstDatabase, |
263 | id: MacroCallId, | 257 | id: MacroCallId, |
264 | ) -> Result<tt::Subtree, mbe::ExpandError> { | 258 | ) -> Result<tt::Subtree, mbe::ExpandError> { |
@@ -285,7 +279,7 @@ pub(crate) fn expand_proc_macro( | |||
285 | expander.expand(db, lazy_id, ¯o_arg.0) | 279 | expander.expand(db, lazy_id, ¯o_arg.0) |
286 | } | 280 | } |
287 | 281 | ||
288 | pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNode> { | 282 | fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNode> { |
289 | match file_id.0 { | 283 | match file_id.0 { |
290 | HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()), | 284 | HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()), |
291 | HirFileIdRepr::MacroFile(macro_file) => { | 285 | HirFileIdRepr::MacroFile(macro_file) => { |
@@ -294,14 +288,14 @@ pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Optio | |||
294 | } | 288 | } |
295 | } | 289 | } |
296 | 290 | ||
297 | pub(crate) fn parse_macro( | 291 | fn parse_macro( |
298 | db: &dyn AstDatabase, | 292 | db: &dyn AstDatabase, |
299 | macro_file: MacroFile, | 293 | macro_file: MacroFile, |
300 | ) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> { | 294 | ) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> { |
301 | parse_macro_with_arg(db, macro_file, None) | 295 | parse_macro_with_arg(db, macro_file, None) |
302 | } | 296 | } |
303 | 297 | ||
304 | pub fn parse_macro_with_arg( | 298 | fn parse_macro_with_arg( |
305 | db: &dyn AstDatabase, | 299 | db: &dyn AstDatabase, |
306 | macro_file: MacroFile, | 300 | macro_file: MacroFile, |
307 | arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>, | 301 | arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>, |