Uh oh!
There was an error while loading. Please reload this page.
Rust: extract source files of dependencies - #19506
Conversation
69eed04 to
e4ee4a9CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
f7f434b to
af440c3Compareaf440c3 to
b5a0317Compare4865293 to
4313513Compareed28076 to
fd5e4a4Comparefd5e4a4 to
7e5f652Compare| }) | ||
| } | ||
| pub(crate) fn should_be_excluded(&self, item: &impl ast::AstNode) -> bool { |
There was a problem hiding this comment.
I cannot shake the feeling this is a bit a roundabout way of doing it: what I mean, is reconstructing the context around the AstNode by visiting the parent, when the emission was requested by emitting the parent already.
I wonder if we shouldn't do this by generating a new exclusion point where the emission of the body takes place. What about having this in the template for ast node emission:
pub(crate) fn emit_{{snake_case_name}}(&mut self, node: &ast::{{ast_name}}) -> Option<Label<generated::{{name}}>> {
pre_emit!({{name}}, self, node);
{{#has_attrs}}
if self.should_be_excluded(node) { return None; }
{{/has_attrs}}
{{#fields}}
let {{name}} =
{{#is_body}}
if self.should_skip_bodies() { None } else {
{{/is_body}}
{{#predicate}}
node.{{method}}().is_some()
{{/predicate}}
{{#string}}
node.try_get_text()
{{/string}}
{{#list}}
node.{{method}}().filter_map(|x| self.emit_{{snake_case_ty}}(&x)).collect()
{{/list}}
{{#optional}}
node.{{method}}().and_then(|x| self.emit_{{snake_case_ty}}(&x))
{{/optional}}
{{#is_body}}
}
{{/is_body}}
;
{{/fields}}
...
(and adding is_body: field.name == "body", to the FieldType::Optional(ty) => ExtractorNodeFieldInfo creation). This will cover all possible bodies, and avoid their emission at the sources without working up the AST. For example:
let body = ifself.should_skip_bodies(){None}else{
node.body().and_then(|x| self.emit_expr(&x))};There was a problem hiding this comment.
ah, the above does not also skip pat, but something could be done there at generation level as well
There was a problem hiding this comment.
here's what I mean: #19559 shifts the logic from climbing up the AST in the base extractor to generating the property skipping at field emission level, with the logic in the ast-generator instead.
7df384b to
df99e06Compare…brary mode When analysing a repository with multiple separate but related sub-projects there is a risk that some source file are extracted in library mode as well as source mode. To prevent this we pre-fill 'processed_files' set with all source files, even though they have not be processed yet, but are known to be processed later.. This prevents source file to be
redsun82
left a comment
There was a problem hiding this comment.
Happy to merge this if we're satisfied by DCA
No description provided.