+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

refactor(rome_diagnostics): remove the legacy Diagnostics API #3811

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::options::OptionsDeserializationDiagnostic;
use crate::{
registry::RuleRoot, AnalyzerOptions, FromServices, Queryable, Rule, RuleKey, ServiceBag,
};
use rome_diagnostics::v2::{Error, Result};
use rome_diagnostics::{Error, Result};
use std::ops::Deref;

type RuleQueryResult<R> = <<R as Rule>::Query as Queryable>::Output;
Expand Down
10 changes: 5 additions & 5 deletions crates/rome_analyze/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod syntax;
mod visitor;

// Re-exported for use in the `declare_group` macro
pub use rome_diagnostics::v2::category_concat;
pub use rome_diagnostics::category_concat;

pub use crate::categories::{
ActionCategory, RefactorKind, RuleCategories, RuleCategory, SourceActionKind,
Expand All @@ -41,10 +41,10 @@ pub use crate::signals::{AnalyzerAction, AnalyzerSignal};
pub use crate::syntax::SyntaxVisitor;
pub use crate::visitor::{NodeVisitor, Visitor, VisitorContext, VisitorFinishContext};
use rome_console::{markup, MarkupBuf};
use rome_diagnostics::file::FileId;
use rome_diagnostics::v2::advice::CodeSuggestionAdvice;
use rome_diagnostics::v2::{
category, Advices, Category, Diagnostic, DiagnosticTags, Error, Location, Severity, Visit,
use rome_diagnostics::advice::CodeSuggestionAdvice;
use rome_diagnostics::{
category, Advices, Category, Diagnostic, DiagnosticTags, Error, FileId, Location, Severity,
Visit,
};
use rome_rowan::{
AstNode, Direction, Language, SyntaxElement, SyntaxToken, TextRange, TextSize, TriviaPieceKind,
Expand Down
6 changes: 3 additions & 3 deletions crates/rome_analyze/src/matcher.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{cmp::Ordering, collections::BinaryHeap};

use rome_diagnostics::file::FileId;
use rome_diagnostics::location::FileId;
use rome_rowan::{Language, TextRange};

use crate::{
Expand Down Expand Up @@ -153,8 +153,8 @@ where

#[cfg(test)]
mod tests {
use rome_diagnostics::v2::{Diagnostic, Error, Severity};
use rome_diagnostics::{file::FileId, v2::category};
use rome_diagnostics::{category, location::FileId};
use rome_diagnostics::{Diagnostic, Error, Severity};
use rome_rowan::{
raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder},
AstNode, TextRange, TextSize, TriviaPiece, TriviaPieceKind,
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/options.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{RuleKey, TextRange, TextSize};
use rome_diagnostics::v2::{Diagnostic, LineIndexBuf, Resource, SourceCode};
use rome_diagnostics::{Diagnostic, LineIndexBuf, Resource, SourceCode};
use serde::Deserialize;
use serde_json::Error;
use serde_json::Value;
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{borrow, collections::BTreeSet};

use rome_diagnostics::v2::Error;
use rome_diagnostics::Error;
use rome_rowan::{AstNode, Language, RawSyntaxKind, SyntaxKind, SyntaxNode};
use rustc_hash::FxHashSet;

Expand Down
10 changes: 5 additions & 5 deletions crates/rome_analyze/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::registry::{RegistryVisitor, RuleLanguage, RuleSuppressions};
use crate::{AnalyzerDiagnostic, Phase, Phases, Queryable};
use rome_console::fmt::Display;
use rome_console::{markup, MarkupBuf};
use rome_diagnostics::file::FileId;
use rome_diagnostics::v2::advice::CodeSuggestionAdvice;
use rome_diagnostics::v2::location::AsSpan;
use rome_diagnostics::v2::{
use rome_diagnostics::advice::CodeSuggestionAdvice;
use rome_diagnostics::location::AsSpan;
use rome_diagnostics::location::FileId;
use rome_diagnostics::Applicability;
use rome_diagnostics::{
Advices, Category, Diagnostic, DiagnosticTags, Location, LogCategory, MessageAndDescription,
Visit,
};
use rome_diagnostics::Applicability;
use rome_rowan::{BatchMutation, Language, TextRange};
use serde::de::DeserializeOwned;

Expand Down
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/services.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{RuleKey, TextRange};
use rome_diagnostics::v2::{Diagnostic, LineIndexBuf, Resource, Result, SourceCode};
use rome_diagnostics::{Diagnostic, LineIndexBuf, Resource, Result, SourceCode};
use std::{
any::{Any, TypeId},
collections::HashMap,
Expand Down
5 changes: 2 additions & 3 deletions crates/rome_analyze/src/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use crate::{
AnalyzerDiagnostic, AnalyzerOptions, Queryable, RuleGroup, ServiceBag,
};
use rome_console::MarkupBuf;
use rome_diagnostics::file::FileSpan;
use rome_diagnostics::v2::advice::CodeSuggestionAdvice;
use rome_diagnostics::{file::FileId, Applicability, CodeSuggestion};
use rome_diagnostics::advice::CodeSuggestionAdvice;
use rome_diagnostics::{location::FileId, Applicability, CodeSuggestion, FileSpan};
use rome_rowan::{BatchMutation, Language};

/// Event raised by the analyzer when a [Rule](crate::Rule)
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<L: Language> Visitor for SyntaxVisitor<L> {
#[cfg(test)]
mod tests {

use rome_diagnostics::file::FileId;
use rome_diagnostics::location::FileId;
use rome_rowan::{
raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder},
AstNode,
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_analyze/src/visitor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BinaryHeap;

use rome_diagnostics::file::FileId;
use rome_diagnostics::location::FileId;
use rome_rowan::{AstNode, Language, SyntaxNode, TextRange, WalkEvent};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_cli/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::traversal::traverse;
use crate::{CliSession, Termination};
use rome_console::{markup, ConsoleExt};
use rome_diagnostics::file::FileId;
use rome_diagnostics::location::FileId;
use rome_diagnostics::MAXIMUM_DISPLAYABLE_DIAGNOSTICS;
use rome_fs::RomePath;
use rome_service::workspace::{
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! [website]: https://rome.tools

use rome_cli::{open_transport, setup_panic_handler, Arguments, CliSession, Termination};
use rome_diagnostics::v2::set_bottom_frame;
use rome_diagnostics::set_bottom_frame;
use rome_service::workspace;
use tokio::runtime::Runtime;

Expand Down
2 changes: 1 addition & 1 deletion crates/rome_cli/src/reports/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod formatter;

use crate::reports::formatter::{FormatterReportFileDetail, FormatterReportSummary};
use formatter::FormatterReport;
use rome_diagnostics::v2::{Category, Severity};
use rome_diagnostics::{Category, Severity};
use rome_service::RomeError;
use serde::Serialize;
use std::collections::HashMap;
Expand Down
30 changes: 14 additions & 16 deletions crates/rome_cli/src/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ use crossbeam::{
};
use rome_console::{fmt, markup, Console, ConsoleExt};
use rome_diagnostics::{
file::FileId,
v2::{
self,
adapters::{IoError, StdError},
category, Advices, Category, DiagnosticExt, Error, FilePath, PrintDescription,
PrintDiagnostic, Severity, Visit,
},
adapters::{IoError, StdError},
category,
location::FileId,
Advices, Category, Diagnostic, DiagnosticExt, Error, FilePath, PrintDescription,
PrintDiagnostic, Resource, Severity, Visit,
};
use rome_fs::{FileSystem, OpenOptions, PathInterner, RomePath};
use rome_fs::{TraversalContext, TraversalScope};
Expand Down Expand Up @@ -266,7 +264,7 @@ struct ProcessMessagesOptions<'ctx> {
report: &'ctx mut Report,
}

#[derive(Debug, v2::Diagnostic)]
#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "format",
message = "File content differs from formatting output"
Expand All @@ -278,7 +276,7 @@ struct CIDiffDiagnostic<'a> {
diff: FormatDiffAdvice<'a>,
}

#[derive(Debug, v2::Diagnostic)]
#[derive(Debug, Diagnostic)]
#[diagnostic(
severity = Information,
category = "format",
Expand All @@ -304,12 +302,12 @@ impl Advices for FormatDiffAdvice<'_> {
}
}

#[derive(Debug, v2::Diagnostic)]
#[derive(Debug, Diagnostic)]
struct TraversalDiagnostic<'a> {
#[location(resource)]
file_name: Option<&'a str>,
#[severity]
severity: v2::Severity,
severity: Severity,
#[category]
category: &'static Category,
#[message]
Expand Down Expand Up @@ -371,7 +369,7 @@ fn process_messages(options: ProcessMessagesOptions) {

Message::Error(mut err) => {
if let Some(location) = err.location() {
if let v2::Resource::File(FilePath::FileId(file_id)) = location.resource {
if let Resource::File(FilePath::FileId(file_id)) = location.resource {
// Retrieves the file name from the file ID cache, if it's a miss
// flush entries from the interner channel until it's found
let file_name = match paths.get(&file_id) {
Expand Down Expand Up @@ -423,7 +421,7 @@ fn process_messages(options: ProcessMessagesOptions) {
.location()
.and_then(|location| {
let path = match &location.resource {
v2::Resource::File(file) => file,
Resource::File(file) => file,
_ => return None,
};

Expand Down Expand Up @@ -944,19 +942,19 @@ where
}
}

#[derive(Debug, v2::Diagnostic)]
#[derive(Debug, Diagnostic)]
#[diagnostic(category = "internalError/panic", tags(INTERNAL))]
struct PanicDiagnostic {
#[description]
#[message]
message: String,
}

#[derive(Debug, v2::Diagnostic)]
#[derive(Debug, Diagnostic)]
#[diagnostic(category = "files/missingHandler", message = "unhandled file type")]
struct UnhandledDiagnostic;

#[derive(Debug, v2::Diagnostic)]
#[derive(Debug, Diagnostic)]
#[diagnostic(category = "parse", message = "Skipped file with syntax errors")]
struct SkippedDiagnostic;

Expand Down
2 changes: 1 addition & 1 deletion crates/rome_diagnostics/examples/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io;

use rome_console::{markup, ConsoleExt, EnvConsole};
use rome_diagnostics::v2::{Advices, Diagnostic, LogCategory, PrintDiagnostic, Resource, Visit};
use rome_diagnostics::{Advices, Diagnostic, LogCategory, PrintDiagnostic, Resource, Visit};
use rome_rowan::{TextRange, TextSize};

#[derive(Debug, Diagnostic)]
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_diagnostics/examples/fs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io;

use rome_console::{fmt, markup, ConsoleExt, EnvConsole};
use rome_diagnostics::v2::{
use rome_diagnostics::{
Advices, Diagnostic, FilePath, Location, LogCategory, PrintDiagnostic, Resource, SourceCode,
Visit,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_diagnostics/examples/lint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io;

use rome_console::{markup, ConsoleExt, EnvConsole};
use rome_diagnostics::v2::{
use rome_diagnostics::{
Advices, Diagnostic, FilePath, Location, LogCategory, PrintDiagnostic, Resource, SourceCode,
Visit,
};
Expand Down
4 changes: 1 addition & 3 deletions crates/rome_diagnostics/examples/serde.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use rome_console::{markup, ConsoleExt, EnvConsole};
use rome_diagnostics::v2::{
Diagnostic, LineIndexBuf, PrintDiagnostic, Resource, Result, SourceCode,
};
use rome_diagnostics::{Diagnostic, LineIndexBuf, PrintDiagnostic, Resource, Result, SourceCode};
use rome_rowan::{TextRange, TextSize};
use serde_json::Error;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::io;

use rome_console::{fmt, markup};

use super::{category, Category, Diagnostic};
use crate::{category, Category, Diagnostic};

/// Implements [Diagnostic] over types implementing [std::error::Error].
#[derive(Debug)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::{
use crate::Applicability;
use crate::{
display::Backtrace,
location::{AsResource, AsSourceCode, AsSpan},
Location,
};
use crate::Applicability;
use rome_console::fmt::{self, Display};
use rome_console::markup;
use rome_text_edit::TextEdit;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rome_console::fmt;

use super::{
use crate::{
diagnostic::internal::AsDiagnostic,
location::{AsResource, AsSourceCode},
Category, Error, Resource, SourceCode,
Expand Down Expand Up @@ -156,7 +156,7 @@ mod internal {
use rome_console::{fmt, markup};
use rome_text_edit::TextEdit;

use crate::v2::{
use crate::{
diagnostic::internal::AsDiagnostic, Advices, Backtrace, Category, Diagnostic,
DiagnosticTags, LineIndex, LineIndexBuf, Location, LogCategory, Resource, Severity,
SourceCode, Visit,
Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载