From f17ace37b47a6ab02bae457851b950a7ec86faf0 Mon Sep 17 00:00:00 2001 From: l3ops Date: Mon, 21 Nov 2022 12:15:17 +0100 Subject: [PATCH] refactor(rome_diagnostics): remove the legacy Diagnostics API (#3811) --- crates/rome_analyze/src/context.rs | 2 +- crates/rome_analyze/src/lib.rs | 10 +- crates/rome_analyze/src/matcher.rs | 6 +- crates/rome_analyze/src/options.rs | 2 +- crates/rome_analyze/src/registry.rs | 2 +- crates/rome_analyze/src/rule.rs | 10 +- crates/rome_analyze/src/services.rs | 2 +- crates/rome_analyze/src/signals.rs | 5 +- crates/rome_analyze/src/syntax.rs | 2 +- crates/rome_analyze/src/visitor.rs | 2 +- crates/rome_cli/src/execute.rs | 2 +- crates/rome_cli/src/main.rs | 2 +- crates/rome_cli/src/reports/mod.rs | 2 +- crates/rome_cli/src/traversal.rs | 30 +- crates/rome_diagnostics/examples/cli.rs | 2 +- crates/rome_diagnostics/examples/fs.rs | 2 +- crates/rome_diagnostics/examples/lint.rs | 2 +- crates/rome_diagnostics/examples/serde.rs | 4 +- .../rome_diagnostics/src/{v2 => }/adapters.rs | 2 +- .../rome_diagnostics/src/{v2 => }/advice.rs | 4 +- .../rome_diagnostics/src/{v2 => }/context.rs | 4 +- crates/rome_diagnostics/src/diagnostic.rs | 393 ++++++++---------- .../rome_diagnostics/src/{v2 => }/display.rs | 11 +- .../src/{v2 => }/display/backtrace.rs | 4 +- .../src/{v2 => }/display/diff.rs | 0 .../src/{v2 => }/display/frame.rs | 2 +- .../src/{v2 => }/display/message.rs | 2 +- crates/rome_diagnostics/src/emit.rs | 335 --------------- crates/rome_diagnostics/src/{v2 => }/error.rs | 4 +- crates/rome_diagnostics/src/file.rs | 212 ---------- crates/rome_diagnostics/src/lib.rs | 63 ++- .../rome_diagnostics/src/{v2 => }/location.rs | 0 crates/rome_diagnostics/src/{v2 => }/serde.rs | 5 +- crates/rome_diagnostics/src/suggestion.rs | 25 +- crates/rome_diagnostics/src/v2/diagnostic.rs | 186 --------- crates/rome_diagnostics/src/v2/mod.rs | 37 -- .../tests/macros/category_ident.rs | 2 +- .../tests/macros/category_paren.rs | 2 +- .../tests/macros/description_ident.rs | 2 +- .../tests/macros/description_paren.rs | 2 +- .../tests/macros/description_syntax_error.rs | 2 +- .../tests/macros/error_enum.rs | 2 +- .../tests/macros/error_union.rs | 2 +- .../tests/macros/location_eq.rs | 2 +- .../tests/macros/severity_lit_str.rs | 2 +- .../tests/macros/severity_paren.rs | 2 +- .../tests/macros/tags_comma.rs | 2 +- .../rome_diagnostics/tests/macros/tags_eq.rs | 2 +- .../tests/macros/unknown_container_attr.rs | 2 +- .../tests/macros/unknown_field_attr.rs | 2 +- .../tests/macros/unknown_location_attr.rs | 2 +- .../tests/macros/unknown_message_attr.rs | 2 +- .../rome_diagnostics_macros/src/generate.rs | 44 +- crates/rome_formatter/src/comments/builder.rs | 2 +- crates/rome_fs/src/fs.rs | 6 +- crates/rome_fs/src/fs/memory.rs | 6 +- crates/rome_fs/src/fs/os.rs | 2 +- crates/rome_fs/src/interner.rs | 2 +- crates/rome_fs/src/path.rs | 2 +- crates/rome_js_analyze/src/lib.rs | 6 +- crates/rome_js_analyze/src/react/hooks.rs | 2 +- .../nursery/no_super_without_extends.rs | 2 +- crates/rome_js_analyze/src/utils/tests.rs | 2 +- crates/rome_js_analyze/tests/spec_tests.rs | 4 +- .../rome_js_formatter/src/check_reformat.rs | 8 +- crates/rome_js_formatter/src/comments.rs | 2 +- crates/rome_js_formatter/src/lib.rs | 2 +- crates/rome_js_formatter/src/parentheses.rs | 2 +- .../rome_js_formatter/src/syntax_rewriter.rs | 2 +- .../src/utils/binary_like_expression.rs | 2 +- crates/rome_js_formatter/src/utils/jsx.rs | 2 +- .../rome_js_formatter/src/utils/test_call.rs | 2 +- .../rome_js_formatter/tests/check_reformat.rs | 11 +- .../rome_js_formatter/tests/prettier_tests.rs | 10 +- crates/rome_js_formatter/tests/spec_test.rs | 2 +- .../src/lexer/buffered_lexer.rs | 2 +- crates/rome_js_parser/src/lexer/errors.rs | 2 +- crates/rome_js_parser/src/lexer/mod.rs | 2 +- crates/rome_js_parser/src/lexer/tests.rs | 4 +- crates/rome_js_parser/src/lib.rs | 11 +- crates/rome_js_parser/src/parse.rs | 6 +- crates/rome_js_parser/src/parser.rs | 4 +- .../rome_js_parser/src/parser/parse_error.rs | 2 +- .../src/parser/rewrite_parser.rs | 2 +- crates/rome_js_parser/src/span.rs | 107 +++++ crates/rome_js_parser/src/syntax/binding.rs | 2 +- .../src/syntax/js_parse_error.rs | 2 +- crates/rome_js_parser/src/syntax/stmt.rs | 2 +- .../src/syntax/typescript/ts_parse_error.rs | 2 +- .../src/syntax/typescript/types.rs | 2 +- crates/rome_js_parser/src/test_utils.rs | 4 +- crates/rome_js_parser/src/tests.rs | 11 +- crates/rome_js_parser/src/token_source.rs | 2 +- crates/rome_js_semantic/src/events.rs | 4 +- crates/rome_js_semantic/src/semantic_model.rs | 8 +- .../src/semantic_model/closure.rs | 2 +- .../src/semantic_model/is_constant.rs | 2 +- .../rome_js_semantic/src/tests/assertions.rs | 6 +- crates/rome_lsp/src/session.rs | 2 +- crates/rome_lsp/src/url_interner.rs | 2 +- crates/rome_lsp/src/utils.rs | 3 +- crates/rome_lsp/tests/server.rs | 2 +- .../src/configuration/linter/mod.rs | 2 +- .../src/configuration/linter/rules.rs | 2 +- .../src/file_handlers/javascript.rs | 12 +- crates/rome_service/src/file_handlers/mod.rs | 2 +- crates/rome_service/src/settings.rs | 4 +- crates/rome_service/src/workspace.rs | 4 +- crates/rome_service/src/workspace/server.rs | 2 +- crates/rome_wasm/src/utils.rs | 19 +- xtask/bench/src/features/analyzer.rs | 2 +- xtask/bench/src/features/parser.rs | 14 +- xtask/bench/src/lib.rs | 2 +- xtask/codegen/src/generate_configuration.rs | 2 +- xtask/coverage/src/js/test262.rs | 2 +- xtask/coverage/src/jsx/jsx_babel.rs | 2 +- xtask/coverage/src/reporters.rs | 2 +- xtask/coverage/src/runner.rs | 27 +- xtask/coverage/src/symbols/msts.rs | 2 +- xtask/coverage/src/ts/ts_babel.rs | 2 +- xtask/lintdoc/src/main.rs | 6 +- 121 files changed, 563 insertions(+), 1282 deletions(-) rename crates/rome_diagnostics/src/{v2 => }/adapters.rs (97%) rename crates/rome_diagnostics/src/{v2 => }/advice.rs (99%) rename crates/rome_diagnostics/src/{v2 => }/context.rs (99%) rename crates/rome_diagnostics/src/{v2 => }/display.rs (99%) rename crates/rome_diagnostics/src/{v2 => }/display/backtrace.rs (99%) rename crates/rome_diagnostics/src/{v2 => }/display/diff.rs (100%) rename crates/rome_diagnostics/src/{v2 => }/display/frame.rs (99%) rename crates/rome_diagnostics/src/{v2 => }/display/message.rs (97%) delete mode 100644 crates/rome_diagnostics/src/emit.rs rename crates/rome_diagnostics/src/{v2 => }/error.rs (99%) delete mode 100644 crates/rome_diagnostics/src/file.rs rename crates/rome_diagnostics/src/{v2 => }/location.rs (100%) rename crates/rome_diagnostics/src/{v2 => }/serde.rs (99%) delete mode 100644 crates/rome_diagnostics/src/v2/diagnostic.rs delete mode 100644 crates/rome_diagnostics/src/v2/mod.rs create mode 100644 crates/rome_js_parser/src/span.rs diff --git a/crates/rome_analyze/src/context.rs b/crates/rome_analyze/src/context.rs index 0537c28cf41..5a18cd4522a 100644 --- a/crates/rome_analyze/src/context.rs +++ b/crates/rome_analyze/src/context.rs @@ -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 = <::Query as Queryable>::Output; diff --git a/crates/rome_analyze/src/lib.rs b/crates/rome_analyze/src/lib.rs index 981caa3d480..b4a0e349c35 100644 --- a/crates/rome_analyze/src/lib.rs +++ b/crates/rome_analyze/src/lib.rs @@ -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, @@ -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, diff --git a/crates/rome_analyze/src/matcher.rs b/crates/rome_analyze/src/matcher.rs index 475e8cae15c..1241732f63d 100644 --- a/crates/rome_analyze/src/matcher.rs +++ b/crates/rome_analyze/src/matcher.rs @@ -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::{ @@ -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, diff --git a/crates/rome_analyze/src/options.rs b/crates/rome_analyze/src/options.rs index 543d4d0afe8..9dd3f791f24 100644 --- a/crates/rome_analyze/src/options.rs +++ b/crates/rome_analyze/src/options.rs @@ -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; diff --git a/crates/rome_analyze/src/registry.rs b/crates/rome_analyze/src/registry.rs index 2145285ae77..713ebe672da 100644 --- a/crates/rome_analyze/src/registry.rs +++ b/crates/rome_analyze/src/registry.rs @@ -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; diff --git a/crates/rome_analyze/src/rule.rs b/crates/rome_analyze/src/rule.rs index 83b0ca63d1a..4a7168ff4d1 100644 --- a/crates/rome_analyze/src/rule.rs +++ b/crates/rome_analyze/src/rule.rs @@ -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; diff --git a/crates/rome_analyze/src/services.rs b/crates/rome_analyze/src/services.rs index 7ac0ba87b32..19e075005ff 100644 --- a/crates/rome_analyze/src/services.rs +++ b/crates/rome_analyze/src/services.rs @@ -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, diff --git a/crates/rome_analyze/src/signals.rs b/crates/rome_analyze/src/signals.rs index 3c118029daf..a4fce7da4c5 100644 --- a/crates/rome_analyze/src/signals.rs +++ b/crates/rome_analyze/src/signals.rs @@ -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) diff --git a/crates/rome_analyze/src/syntax.rs b/crates/rome_analyze/src/syntax.rs index 6528e1968d2..be92f46bc62 100644 --- a/crates/rome_analyze/src/syntax.rs +++ b/crates/rome_analyze/src/syntax.rs @@ -49,7 +49,7 @@ impl Visitor for SyntaxVisitor { #[cfg(test)] mod tests { - use rome_diagnostics::file::FileId; + use rome_diagnostics::location::FileId; use rome_rowan::{ raw_language::{RawLanguage, RawLanguageKind, RawLanguageRoot, RawSyntaxTreeBuilder}, AstNode, diff --git a/crates/rome_analyze/src/visitor.rs b/crates/rome_analyze/src/visitor.rs index e4ac8927f1c..dbdaa3c67ab 100644 --- a/crates/rome_analyze/src/visitor.rs +++ b/crates/rome_analyze/src/visitor.rs @@ -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::{ diff --git a/crates/rome_cli/src/execute.rs b/crates/rome_cli/src/execute.rs index 7937557dfcf..828b9cc119b 100644 --- a/crates/rome_cli/src/execute.rs +++ b/crates/rome_cli/src/execute.rs @@ -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::{ diff --git a/crates/rome_cli/src/main.rs b/crates/rome_cli/src/main.rs index 53e5bcbe815..fead72a1361 100644 --- a/crates/rome_cli/src/main.rs +++ b/crates/rome_cli/src/main.rs @@ -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; diff --git a/crates/rome_cli/src/reports/mod.rs b/crates/rome_cli/src/reports/mod.rs index 42654459fd3..cfa97b90aee 100644 --- a/crates/rome_cli/src/reports/mod.rs +++ b/crates/rome_cli/src/reports/mod.rs @@ -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; diff --git a/crates/rome_cli/src/traversal.rs b/crates/rome_cli/src/traversal.rs index fd6fcb5ef90..74806957221 100644 --- a/crates/rome_cli/src/traversal.rs +++ b/crates/rome_cli/src/traversal.rs @@ -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}; @@ -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" @@ -278,7 +276,7 @@ struct CIDiffDiagnostic<'a> { diff: FormatDiffAdvice<'a>, } -#[derive(Debug, v2::Diagnostic)] +#[derive(Debug, Diagnostic)] #[diagnostic( severity = Information, category = "format", @@ -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] @@ -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) { @@ -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, }; @@ -944,7 +942,7 @@ where } } -#[derive(Debug, v2::Diagnostic)] +#[derive(Debug, Diagnostic)] #[diagnostic(category = "internalError/panic", tags(INTERNAL))] struct PanicDiagnostic { #[description] @@ -952,11 +950,11 @@ struct PanicDiagnostic { 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; diff --git a/crates/rome_diagnostics/examples/cli.rs b/crates/rome_diagnostics/examples/cli.rs index 8544986f19f..18014358c88 100644 --- a/crates/rome_diagnostics/examples/cli.rs +++ b/crates/rome_diagnostics/examples/cli.rs @@ -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)] diff --git a/crates/rome_diagnostics/examples/fs.rs b/crates/rome_diagnostics/examples/fs.rs index ca32be845d9..5ad3ec67fdf 100644 --- a/crates/rome_diagnostics/examples/fs.rs +++ b/crates/rome_diagnostics/examples/fs.rs @@ -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, }; diff --git a/crates/rome_diagnostics/examples/lint.rs b/crates/rome_diagnostics/examples/lint.rs index 16208a0da07..01d12d36a4d 100644 --- a/crates/rome_diagnostics/examples/lint.rs +++ b/crates/rome_diagnostics/examples/lint.rs @@ -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, }; diff --git a/crates/rome_diagnostics/examples/serde.rs b/crates/rome_diagnostics/examples/serde.rs index 6c1cbff4602..428bc17226c 100644 --- a/crates/rome_diagnostics/examples/serde.rs +++ b/crates/rome_diagnostics/examples/serde.rs @@ -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; diff --git a/crates/rome_diagnostics/src/v2/adapters.rs b/crates/rome_diagnostics/src/adapters.rs similarity index 97% rename from crates/rome_diagnostics/src/v2/adapters.rs rename to crates/rome_diagnostics/src/adapters.rs index 7d92c2b662b..7024ed54913 100644 --- a/crates/rome_diagnostics/src/v2/adapters.rs +++ b/crates/rome_diagnostics/src/adapters.rs @@ -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)] diff --git a/crates/rome_diagnostics/src/v2/advice.rs b/crates/rome_diagnostics/src/advice.rs similarity index 99% rename from crates/rome_diagnostics/src/v2/advice.rs rename to crates/rome_diagnostics/src/advice.rs index 2559627993e..4bd20e7ec0a 100644 --- a/crates/rome_diagnostics/src/v2/advice.rs +++ b/crates/rome_diagnostics/src/advice.rs @@ -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; diff --git a/crates/rome_diagnostics/src/v2/context.rs b/crates/rome_diagnostics/src/context.rs similarity index 99% rename from crates/rome_diagnostics/src/v2/context.rs rename to crates/rome_diagnostics/src/context.rs index 761969d24fa..8fb32efef99 100644 --- a/crates/rome_diagnostics/src/v2/context.rs +++ b/crates/rome_diagnostics/src/context.rs @@ -1,6 +1,6 @@ use rome_console::fmt; -use super::{ +use crate::{ diagnostic::internal::AsDiagnostic, location::{AsResource, AsSourceCode}, Category, Error, Resource, SourceCode, @@ -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, diff --git a/crates/rome_diagnostics/src/diagnostic.rs b/crates/rome_diagnostics/src/diagnostic.rs index 3401cb3b641..74b8807eb69 100644 --- a/crates/rome_diagnostics/src/diagnostic.rs +++ b/crates/rome_diagnostics/src/diagnostic.rs @@ -1,255 +1,186 @@ -use crate::{ - file::{FileId, FileSpan, Span}, - v2::Category, - Applicability, CodeSuggestion, DiagnosticTag, -}; -use rome_console::fmt::Display; -use rome_console::{markup, MarkupBuf}; -use rome_text_edit::TextEdit; -use serde::{Deserialize, Serialize}; - -/// A diagnostic message that can give information -/// like errors or warnings. -#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] -pub struct Diagnostic { - pub file_id: FileId, - - pub severity: Severity, - pub code: Option<&'static Category>, - pub title: MarkupBuf, - pub summary: Option, - pub tag: Option, - - pub primary: Option, - pub children: Vec, - pub suggestions: Vec, - pub footers: Vec