Skip to content

Commit

Permalink
Make AnalysisQueryResult struct
Browse files Browse the repository at this point in the history
Summary: For code navigation. Clear now where `AnalysisQueryResult` is created for example.

Reviewed By: JakobDegen

Differential Revision: D51315032

fbshipit-source-id: 14cf33550ba56d5541a1be154cd2d6dca0106780
  • Loading branch information
stepancheg authored and facebook-github-bot committed Nov 15, 2023
1 parent 64be60b commit 8545fbf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/buck2_analysis/src/analysis/calculation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ async fn resolve_queries_impl(
))
}

anyhow::Ok((query.to_owned(), Arc::new(query_results)))
anyhow::Ok((
query.to_owned(),
Arc::new(AnalysisQueryResult {
result: query_results,
}),
))
}
}))
.await?;
Expand Down
2 changes: 1 addition & 1 deletion app/buck2_analysis/src/analysis/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn resolve_query<'v>(
match query_results.get(query) {
None => Err(anyhow::anyhow!(AnalysisError::MissingQuery(query.to_owned())).into()),
Some(x) => {
for (_, y) in x.iter() {
for (_, y) in x.result.iter() {
// IMPORTANT: Anything given back to the user must be kept alive
module.frozen_heap().add_reference(y.value().owner());
}
Expand Down
3 changes: 3 additions & 0 deletions app/buck2_analysis/src/attrs/resolve/attr_type/arg/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl ConfiguredQueryMacroBaseExt for QueryMacroBase<ConfiguredProvidersLabel> {
match &self.expansion_type {
QueryExpansion::Output => Ok(ResolvedQueryMacro::Outputs(
query_result
.result
.iter()
.map(|(_, providers)| {
providers
Expand All @@ -42,6 +43,7 @@ impl ConfiguredQueryMacroBaseExt for QueryMacroBase<ConfiguredProvidersLabel> {
)),
QueryExpansion::Target => Ok(ResolvedQueryMacro::Targets(
query_result
.result
.iter()
.map(|(target, _)| target.dupe())
.collect(),
Expand All @@ -54,6 +56,7 @@ impl ConfiguredQueryMacroBaseExt for QueryMacroBase<ConfiguredProvidersLabel> {
None => " ".to_owned().into_boxed_str(),
},
list: query_result
.result
.iter()
.map(|(target, providers)| {
(
Expand Down
2 changes: 1 addition & 1 deletion app/buck2_analysis/src/attrs/resolve/attr_type/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl ConfiguredQueryAttrExt for QueryAttr<ConfiguredProvidersLabel> {
let query_results = ctx.resolve_query(&self.query.query)?;
let mut dependencies = Vec::new();

for (target, providers) in &*query_results {
for (target, providers) in &query_results.result {
let providers_label =
ConfiguredProvidersLabel::new(target.dupe(), ProvidersName::Default);
if !self.providers.is_empty() {
Expand Down
4 changes: 3 additions & 1 deletion app/buck2_analysis/src/attrs/resolve/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use buck2_core::target::configured_target_label::ConfiguredTargetLabel;
use starlark::environment::Module;
use starlark::values::Heap;

pub type AnalysisQueryResult = Vec<(ConfiguredTargetLabel, FrozenProviderCollectionValue)>;
pub struct AnalysisQueryResult {
pub result: Vec<(ConfiguredTargetLabel, FrozenProviderCollectionValue)>,
}

/// The context for attribute resolution. Provides access to the providers from
/// dependents.
Expand Down
2 changes: 1 addition & 1 deletion app/buck2_audit_server/src/analysis_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl AuditSubcommand for AuditAnalysisQueriesCommand {
writeln!(stdout, "{}:", label)?;
for (query, result) in &query_results {
writeln!(stdout, " {}", query)?;
for (target, providers) in &**result {
for (target, providers) in &result.result {
writeln!(stdout, " {}", target.unconfigured())?;
if self.include_outputs {
let outputs = providers
Expand Down

0 comments on commit 8545fbf

Please sign in to comment.