-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: extract source files of dependencies #19506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
69eed04
to
e4ee4a9
Compare
f7f434b
to
af440c3
Compare
af440c3
to
b5a0317
Compare
4865293
to
4313513
Compare
ed28076
to
fd5e4a4
Compare
fd5e4a4
to
7e5f652
Compare
@@ -621,6 +637,45 @@ impl<'a> Translator<'a> { | |||
}) | |||
} | |||
|
|||
pub(crate) fn should_be_excluded(&self, item: &impl ast::AstNode) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = if self.should_skip_bodies() {
None
} else {
node.body().and_then(|x| self.emit_expr(&x))
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but we do need a DCA run on this before merging. #19559 can be considered as separate follow-up.
7df384b
to
df99e06
Compare
…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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to merge this if we're satisfied by DCA
No description provided.