Skip to content

Commit

Permalink
Close on lifetimes...
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshew committed Oct 28, 2024
1 parent f59db4f commit 4b09b75
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 102 deletions.
6 changes: 3 additions & 3 deletions crates/biome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub struct AnalyzerContext<'a, L: Language> {
pub root: LanguageRoot<L>,
pub services: ServiceBag,
pub range: Option<TextRange>,
pub options: &'a AnalyzerOptions,
pub options: &'a AnalyzerOptions<'a>,
}

impl<'analyzer, L, Matcher, Break, Diag> Analyzer<'analyzer, L, Matcher, Break, Diag>
Expand Down Expand Up @@ -224,7 +224,7 @@ struct PhaseRunner<'analyzer, 'phase, L: Language, Matcher, Break, Diag> {
/// Optional text range to restrict the analysis to
range: Option<TextRange>,
/// Analyzer options
options: &'phase AnalyzerOptions,
options: &'phase AnalyzerOptions<'phase>,
}

/// Single entry for a suppression comment in the `line_suppressions` buffer
Expand Down Expand Up @@ -787,7 +787,7 @@ pub struct SuppressionCommentEmitterPayload<'a, L: Language> {
/// The original range of the diagnostic where the rule was triggered
pub diagnostic_text_range: &'a TextRange,
/// Explanation for the suppression to be used with `--suppress` and `--reason`
pub suppression_reason: String,
pub suppression_reason: &'a str,
}

type SignalHandler<'a, L, Break> = &'a mut dyn FnMut(&dyn AnalyzerSignal<L>) -> ControlFlow<Break>;
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct MatchQueryParams<'phase, 'query, L: Language> {
pub services: &'phase ServiceBag,
pub signal_queue: &'query mut BinaryHeap<SignalEntry<'phase, L>>,
pub suppression_action: &'phase dyn SuppressionAction<Language = L>,
pub options: &'phase AnalyzerOptions,
pub options: &'phase AnalyzerOptions<'phase>,
}

/// Wrapper type for a [QueryMatch]
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_analyze/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ pub struct AnalyzerConfiguration {

/// A set of information useful to the analyzer infrastructure
#[derive(Debug, Default)]
pub struct AnalyzerOptions {
pub struct AnalyzerOptions<'a> {
/// A data structured derived from the [`biome.json`] file
pub configuration: AnalyzerConfiguration,

/// The file that is being analyzed
pub file_path: PathBuf,

/// Suppression reason to be used with `--suppress` and `--reason`
pub suppression_reason: Option<String>,
pub suppression_reason: Option<&'a str>,
}

impl AnalyzerOptions {
impl<'a> AnalyzerOptions<'a> {
pub fn globals(&self) -> Vec<&str> {
self.configuration
.globals
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ pub trait Rule: RuleMeta + Sized {
ctx: &RuleContext<Self>,
text_range: &TextRange,
suppression_action: &dyn SuppressionAction<Language = RuleLanguage<Self>>,
suppression_reason: Option<String>,
suppression_reason: Option<&str>,
) -> Option<SuppressAction<RuleLanguage<Self>>>
where
Self: 'static,
Expand All @@ -902,7 +902,7 @@ pub trait Rule: RuleMeta + Sized {
mutation: &mut mutation,
token_offset: token,
diagnostic_text_range: text_range,
suppression_reason: suppression_reason.unwrap_or("<explanation>".to_string()),
suppression_reason: suppression_reason.unwrap_or("<explanation>"),
});

Some(SuppressAction {
Expand Down
8 changes: 4 additions & 4 deletions crates/biome_analyze/src/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ pub(crate) struct RuleSignal<'phase, R: Rule> {
/// An optional action to suppress the rule.
suppression_action: &'phase dyn SuppressionAction<Language = RuleLanguage<R>>,
/// An optional explanation for the suppression to be used with `--suppress` and `--reason`
suppression_reason: Option<String>,
suppression_reason: Option<&'phase str>,
/// A list of strings that are considered "globals" inside the analyzer
options: &'phase AnalyzerOptions,
options: &'phase AnalyzerOptions<'phase>,
}

impl<'phase, R> RuleSignal<'phase, R>
Expand All @@ -328,7 +328,7 @@ where
suppression_action: &'phase dyn SuppressionAction<
Language = <<R as Rule>::Query as Queryable>::Language,
>,
suppression_reason: Option<String>,
suppression_reason: Option<&'phase str>,
options: &'phase AnalyzerOptions,
) -> Self {
Self {
Expand Down Expand Up @@ -409,7 +409,7 @@ where
&ctx,
&text_range,
self.suppression_action,
self.suppression_reason.clone(),
self.suppression_reason,
) {
let action = AnalyzerAction {
rule_name: Some((<R::Group as RuleGroup>::NAME, R::METADATA.name)),
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/suppression_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub trait SuppressionAction {
mutation: &mut BatchMutation<Self::Language>,
apply_suppression: ApplySuppression<Self::Language>,
suppression_text: &str,
suppression_reason: String,
suppression_reason: &str,
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/biome_analyze/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct VisitorContext<'phase, 'query, L: Language> {
pub range: Option<TextRange>,
pub(crate) query_matcher: &'query mut dyn QueryMatcher<L>,
pub(crate) signal_queue: &'query mut BinaryHeap<SignalEntry<'phase, L>>,
pub options: &'phase AnalyzerOptions,
pub options: &'phase AnalyzerOptions<'phase>,
}

impl<'phase, 'query, L: Language> VisitorContext<'phase, 'query, L> {
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/src/execute/process_file/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn lint<'ctx>(
ctx: &'ctx SharedTraversalOptions<'ctx, '_>,
path: &Path,
suppress: bool,
suppression_reason: &Option<String>,
suppression_reason: Option<&String>,
) -> FileResult {
let mut workspace_file = WorkspaceFile::new(ctx, path)?;
lint_with_guard(
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_css_analyze/src/suppression_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl SuppressionAction for CssSuppressionAction {
mutation: &mut BatchMutation<Self::Language>,
apply_suppression: ApplySuppression<Self::Language>,
suppression_text: &str,
suppression_reason: String,
suppression_reason: &str,
) {
let ApplySuppression {
token_to_apply_suppression,
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_graphql_analyze/src/suppression_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl SuppressionAction for GraphqlSuppressionAction {
mutation: &mut BatchMutation<Self::Language>,
apply_suppression: ApplySuppression<Self::Language>,
suppression_text: &str,
suppression_reason: String,
suppression_reason: &str,
) {
let ApplySuppression {
token_to_apply_suppression,
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/suppression_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl SuppressionAction for JsSuppressionAction {
mutation: &mut BatchMutation<Self::Language>,
apply_suppression: ApplySuppression<Self::Language>,
suppression_text: &str,
suppression_reason: String,
suppression_reason: &str,
) {
let ApplySuppression {
token_to_apply_suppression,
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where
_: &mut BatchMutation<Self::Language>,
_: ApplySuppression<Self::Language>,
_: &str,
_: String,
_: &str,
) {
unreachable!("")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_json_analyze/src/suppression_action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl SuppressionAction for JsonSuppressionAction {
_mutation: &mut BatchMutation<Self::Language>,
_apply_suppression: ApplySuppression<Self::Language>,
_suppression_text: &str,
_suppression_reason: String,
_suppression_reason: &str,
) {
unreachable!("find_token_to_apply_suppression return None")
}
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_migrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
_: &mut BatchMutation<Self::Language>,
_: ApplySuppression<Self::Language>,
_: &str,
_: String,
_: &str,
) {
unreachable!("")
}
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_service/src/file_handlers/css.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ impl ServiceLanguage for CssLanguage {
}
}

fn resolve_analyzer_options(
global: Option<&Settings>,
_linter: Option<&LinterSettings>,
_overrides: Option<&OverrideSettings>,
_language: Option<&Self::LinterSettings>,
file_path: &BiomePath,
_file_source: &DocumentFileSource,
suppression_reason: Option<String>,
) -> AnalyzerOptions {
fn resolve_analyzer_options<'a>(
global: Option<&'a Settings>,
_linter: Option<&'a LinterSettings>,
_overrides: Option<&'a OverrideSettings>,
_language: Option<&'a Self::LinterSettings>,
file_path: &'a BiomePath,
_file_source: &'a DocumentFileSource,
suppression_reason: Option<&'a str>,
) -> AnalyzerOptions<'a> {
let preferred_quote = global
.and_then(|global| {
global
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_service/src/file_handlers/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ impl ServiceLanguage for GraphqlLanguage {
}
}

fn resolve_analyzer_options(
_global: Option<&Settings>,
_linter: Option<&LinterSettings>,
_overrides: Option<&OverrideSettings>,
_language: Option<&Self::LinterSettings>,
path: &BiomePath,
_file_source: &DocumentFileSource,
suppression_reason: Option<String>,
) -> AnalyzerOptions {
fn resolve_analyzer_options<'a>(
_global: Option<&'a Settings>,
_linter: Option<&'a LinterSettings>,
_overrides: Option<&'a OverrideSettings>,
_language: Option<&'a Self::LinterSettings>,
path: &'a BiomePath,
_file_source: &'a DocumentFileSource,
suppression_reason: Option<&'a str>,
) -> AnalyzerOptions<'a> {
AnalyzerOptions {
configuration: AnalyzerConfiguration::default(),
file_path: path.to_path_buf(),
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_service/src/file_handlers/grit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ impl ServiceLanguage for GritLanguage {
}
}

fn resolve_analyzer_options(
_global: Option<&crate::settings::Settings>,
_linter: Option<&crate::settings::LinterSettings>,
_overrides: Option<&crate::settings::OverrideSettings>,
_language: Option<&Self::LinterSettings>,
path: &biome_fs::BiomePath,
_file_source: &super::DocumentFileSource,
suppression_reason: Option<String>,
) -> biome_analyze::AnalyzerOptions {
fn resolve_analyzer_options<'a>(
_global: Option<&'a crate::settings::Settings>,
_linter: Option<&'a crate::settings::LinterSettings>,
_overrides: Option<&'a crate::settings::OverrideSettings>,
_language: Option<&'a Self::LinterSettings>,
path: &'a biome_fs::BiomePath,
_file_source: &'a super::DocumentFileSource,
suppression_reason: Option<&'a str>,
) -> biome_analyze::AnalyzerOptions<'a> {
AnalyzerOptions {
configuration: AnalyzerConfiguration::default(),
file_path: path.to_path_buf(),
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_service/src/file_handlers/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ impl ServiceLanguage for HtmlLanguage {
}
}

fn resolve_analyzer_options(
_global: Option<&crate::settings::Settings>,
_linter: Option<&crate::settings::LinterSettings>,
_overrides: Option<&crate::settings::OverrideSettings>,
_language: Option<&Self::LinterSettings>,
path: &biome_fs::BiomePath,
_file_source: &super::DocumentFileSource,
suppression_reason: Option<String>,
) -> AnalyzerOptions {
fn resolve_analyzer_options<'a>(
_global: Option<&'a crate::settings::Settings>,
_linter: Option<&'a crate::settings::LinterSettings>,
_overrides: Option<&'a crate::settings::OverrideSettings>,
_language: Option<&'a Self::LinterSettings>,
path: &'a biome_fs::BiomePath,
_file_source: &'a super::DocumentFileSource,
suppression_reason: Option<&'a str>,
) -> AnalyzerOptions<'a> {
AnalyzerOptions {
configuration: AnalyzerConfiguration::default(),
file_path: path.to_path_buf(),
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_service/src/file_handlers/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ impl ServiceLanguage for JsLanguage {
}
}

fn resolve_analyzer_options(
global: Option<&Settings>,
_linter: Option<&LinterSettings>,
overrides: Option<&OverrideSettings>,
_language: Option<&Self::LinterSettings>,
path: &BiomePath,
_file_source: &DocumentFileSource,
suppression_reason: Option<String>,
) -> AnalyzerOptions {
fn resolve_analyzer_options<'a>(
global: Option<&'a Settings>,
_linter: Option<&'a LinterSettings>,
overrides: Option<&'a OverrideSettings>,
_language: Option<&'a Self::LinterSettings>,
path: &'a BiomePath,
_file_source: &'a DocumentFileSource,
suppression_reason: Option<&'a str>,
) -> AnalyzerOptions<'a> {
let preferred_quote =
global
.and_then(|global| {
Expand Down
18 changes: 9 additions & 9 deletions crates/biome_service/src/file_handlers/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ impl ServiceLanguage for JsonLanguage {
}
}

fn resolve_analyzer_options(
global: Option<&Settings>,
_linter: Option<&LinterSettings>,
_overrides: Option<&OverrideSettings>,
_language: Option<&Self::LinterSettings>,
path: &BiomePath,
_file_source: &DocumentFileSource,
suppression_reason: Option<String>,
) -> AnalyzerOptions {
fn resolve_analyzer_options<'a>(
global: Option<&'a Settings>,
_linter: Option<&'a LinterSettings>,
_overrides: Option<&'a OverrideSettings>,
_language: Option<&'a Self::LinterSettings>,
path: &'a BiomePath,
_file_source: &'a DocumentFileSource,
suppression_reason: Option<&'a str>,
) -> AnalyzerOptions<'a> {
let configuration = AnalyzerConfiguration {
rules: global
.map(|g| to_analyzer_rules(g, path.as_path()))
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_service/src/file_handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ pub struct FixAllParams<'a> {
pub(crate) only: Vec<RuleSelector>,
pub(crate) skip: Vec<RuleSelector>,
pub(crate) rule_categories: RuleCategories,
pub(crate) suppression_reason: Option<String>,
pub(crate) suppression_reason: Option<&'a str>,
}

#[derive(Default)]
Expand Down Expand Up @@ -460,7 +460,7 @@ pub(crate) struct LintParams<'a> {
pub(crate) skip: Vec<RuleSelector>,
pub(crate) categories: RuleCategories,
pub(crate) manifest: Option<PackageJson>,
pub(crate) suppression_reason: Option<String>,
pub(crate) suppression_reason: Option<&'a str>,
}

pub(crate) struct LintResults {
Expand All @@ -478,7 +478,7 @@ pub(crate) struct CodeActionsParams<'a> {
pub(crate) language: DocumentFileSource,
pub(crate) only: Vec<RuleSelector>,
pub(crate) skip: Vec<RuleSelector>,
pub(crate) suppression_reason: Option<String>,
pub(crate) suppression_reason: Option<&'a str>,
}

type Lint = fn(LintParams) -> LintResults;
Expand Down
Loading

0 comments on commit 4b09b75

Please sign in to comment.