use super::external_sif::{
OmenaQueryExternalSifResolutionContext, promote_sif_backed_external_edges,
};
use super::shared::*;
#[derive(Clone, PartialEq, Eq)]
pub(in crate::style) struct OmenaQueryWorkspaceDiagnosticsSubstrateV0 {
pub(in crate::style) style_fact_entries: Vec<OmenaQueryStyleFactEntry>,
pub(in crate::style) sass_resolution: OmenaQuerySassModuleCrossFileResolutionV0,
pub(in crate::style) sass_resolution_without_manifests:
OmenaQuerySassModuleCrossFileResolutionV0,
pub(in crate::style) sass_resolution_without_path_mappings:
OmenaQuerySassModuleCrossFileResolutionV0,
pub(in crate::style) sass_resolution_with_external_sifs:
OmenaQuerySassModuleCrossFileResolutionV0,
#[cfg(feature = "hypergraph-ifds")]
pub(in crate::style) css_modules_resolution: OmenaQueryCssModulesCrossFileResolutionV0,
}
pub(in crate::style) fn collect_omena_query_workspace_diagnostics_substrate(
style_sources: &[OmenaQueryStyleSourceInputV0],
package_manifests: &[OmenaQueryStylePackageManifestV0],
external_sifs: &[OmenaQueryExternalSifInputV0],
bundler_path_mappings: &[OmenaResolverBundlerPathAliasMappingV0],
tsconfig_path_mappings: &[OmenaResolverTsconfigPathMappingV0],
) -> OmenaQueryWorkspaceDiagnosticsSubstrateV0 {
let style_source_refs = style_sources
.iter()
.map(|source| (source.style_path.as_str(), source.style_source.as_str()))
.collect::<Vec<_>>();
let style_fact_entries = collect_omena_query_style_fact_entries(style_source_refs.as_slice());
collect_omena_query_workspace_diagnostics_substrate_from_entries(
style_fact_entries,
package_manifests,
external_sifs,
bundler_path_mappings,
tsconfig_path_mappings,
)
}
pub(in crate::style) fn collect_omena_query_workspace_diagnostics_substrate_from_entries(
style_fact_entries: Vec<OmenaQueryStyleFactEntry>,
package_manifests: &[OmenaQueryStylePackageManifestV0],
external_sifs: &[OmenaQueryExternalSifInputV0],
bundler_path_mappings: &[OmenaResolverBundlerPathAliasMappingV0],
tsconfig_path_mappings: &[OmenaResolverTsconfigPathMappingV0],
) -> OmenaQueryWorkspaceDiagnosticsSubstrateV0 {
let sass_resolution = summarize_sass_module_cross_file_resolution(
&style_fact_entries,
package_manifests,
bundler_path_mappings,
tsconfig_path_mappings,
);
let mut sass_resolution_with_external_sifs = sass_resolution.clone();
promote_sif_backed_external_edges(
&mut sass_resolution_with_external_sifs,
OmenaQueryExternalSifResolutionContext {
package_manifests,
bundler_path_mappings,
tsconfig_path_mappings,
external_sifs,
},
);
let sass_resolution_without_manifests = summarize_sass_module_cross_file_resolution(
&style_fact_entries,
&[],
bundler_path_mappings,
tsconfig_path_mappings,
);
let sass_resolution_without_path_mappings = summarize_sass_module_cross_file_resolution(
&style_fact_entries,
package_manifests,
&[],
&[],
);
#[cfg(feature = "hypergraph-ifds")]
let css_modules_resolution =
summarize_css_modules_cross_file_resolution(&style_fact_entries, package_manifests);
OmenaQueryWorkspaceDiagnosticsSubstrateV0 {
style_fact_entries,
sass_resolution,
sass_resolution_without_manifests,
sass_resolution_without_path_mappings,
sass_resolution_with_external_sifs,
#[cfg(feature = "hypergraph-ifds")]
css_modules_resolution,
}
}
#[cfg(feature = "salsa-memo")]
pub(in crate::style) fn collect_omena_query_workspace_diagnostics_substrate_from_committed_graph(
style_fact_entries: Vec<OmenaQueryStyleFactEntry>,
css_modules_resolution: &OmenaQueryCssModulesCrossFileResolutionV0,
sass_resolution: &OmenaQuerySassModuleCrossFileResolutionV0,
sass_resolution_without_manifests: &OmenaQuerySassModuleCrossFileResolutionV0,
sass_resolution_without_path_mappings: &OmenaQuerySassModuleCrossFileResolutionV0,
sass_resolution_with_external_sifs: &OmenaQuerySassModuleCrossFileResolutionV0,
) -> OmenaQueryWorkspaceDiagnosticsSubstrateV0 {
#[cfg(not(feature = "hypergraph-ifds"))]
let _ = css_modules_resolution;
OmenaQueryWorkspaceDiagnosticsSubstrateV0 {
style_fact_entries,
sass_resolution: sass_resolution.clone(),
sass_resolution_without_manifests: sass_resolution_without_manifests.clone(),
sass_resolution_without_path_mappings: sass_resolution_without_path_mappings.clone(),
sass_resolution_with_external_sifs: sass_resolution_with_external_sifs.clone(),
#[cfg(feature = "hypergraph-ifds")]
css_modules_resolution: css_modules_resolution.clone(),
}
}
pub(in crate::style) fn collect_sass_module_graph_reachable_style_paths<'a>(
target_style_path: &'a str,
resolution: &'a OmenaQuerySassModuleCrossFileResolutionV0,
) -> BTreeSet<&'a str> {
let mut reachable = BTreeSet::new();
let mut stack = vec![target_style_path];
while let Some(current) = stack.pop() {
if !reachable.insert(current) {
continue;
}
for edge in resolution
.edges
.iter()
.filter(|edge| edge.from_style_path == current && edge.status == "resolved")
{
if let Some(next) = edge.resolved_style_path.as_deref() {
stack.push(next);
}
}
}
reachable
}
pub(in crate::style) struct OmenaQueryWorkspaceSharedPassProductsV0 {
pub(in crate::style) unused_selector:
Option<super::source_usage::OmenaQueryUnusedSelectorSharedV0>,
pub(in crate::style) inline_style_overrides_by_style: Option<
std::collections::BTreeMap<String, Vec<crate::OmenaQueryInlineStyleRuntimeOverrideV0>>,
>,
#[cfg(feature = "hypergraph-ifds")]
pub(in crate::style) cross_file_scc_report:
Option<crate::OmenaQueryUnifiedCrossFileSccReportV0>,
}