Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Jul 17, 2024
1 parent 6b8f0fe commit 8a0bde7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/biome_parser/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct ParseDiagnostic {
span: Option<TextRange>,
#[message]
#[description]
message: MessageAndDescription,
pub message: MessageAndDescription,
#[advice]
advice: ParserAdvice,
}
Expand Down
24 changes: 20 additions & 4 deletions crates/biome_service/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use biome_configuration::diagnostics::{ConfigurationDiagnostic, EditorConfigDiag
use biome_configuration::{BiomeDiagnostic, CantLoadExtendFile};
use biome_console::fmt::Bytes;
use biome_console::markup;
use biome_diagnostics::serde::Diagnostic as SerdeDiagnostic;
use biome_css_parser::ParseDiagnostic;
use biome_diagnostics::{
category, Advices, Category, Diagnostic, DiagnosticTags, Location, LogCategory, Severity, Visit,
category, Advices, Category, Diagnostic, DiagnosticTags, Location, LogCategory,
MessageAndDescription, Severity, Visit,
};
use biome_formatter::{FormatError, PrintError};
use biome_fs::{BiomePath, FileSystemDiagnostic};
Expand Down Expand Up @@ -327,13 +328,28 @@ impl Diagnostic for SourceFileNotSupported {
#[derive(Debug, Deserialize, Diagnostic, Serialize)]
pub enum SearchError {
/// An invalid pattern was given
PatternCompilationError(SerdeDiagnostic),
PatternCompilationError(PatternCompilationError),
/// No pattern with the given ID
InvalidPattern(InvalidPattern),
/// Error while executing the search query.
QueryError(QueryDiagnostic),
}

#[derive(Debug, Deserialize, Diagnostic, Serialize)]
pub struct PatternCompilationError {
#[message]
#[description]
message: MessageAndDescription,
}

impl From<ParseDiagnostic> for PatternCompilationError {
fn from(diagnostic: ParseDiagnostic) -> Self {
Self {
message: diagnostic.message,
}
}
}

#[derive(Debug, Serialize, Deserialize, Diagnostic)]
#[diagnostic(
category = "search",
Expand Down Expand Up @@ -460,7 +476,7 @@ impl From<CompileError> for WorkspaceError {
fn from(value: CompileError) -> Self {
match value {
CompileError::ParsePatternError(diagnostic) => Self::SearchError(
SearchError::PatternCompilationError(SerdeDiagnostic::new(diagnostic)),
SearchError::PatternCompilationError(PatternCompilationError::from(diagnostic)),
),
// FIXME: This really needs proper diagnostics
_ => Self::SearchError(SearchError::QueryError(QueryDiagnostic(format!(
Expand Down

0 comments on commit 8a0bde7

Please sign in to comment.