mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
de24a7dde7
@jdm @SimonSapin <!-- Please describe your changes on the following line: --> 1. Added ServoUrl as a parameter to report_error(...) of ParseErrorReporter trait. 2. I am not sure how to handle the case of impl ParseErrorReporter for CSSErrorReporter and MemoryHoleReporter, so have not made any changes (other than adding ServoUrl arg) to report_error implementations for these. 3. In StdoutErrorReporter i have added the ServoUrl arg to the info! function, 4. I would like to know if i am on the correct path and clarify what else needs to be done. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ X] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #15708 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because wanted to clarify before writing tests <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 0dbee36915abd926e61ca8571e11abf1f97ec830 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : f16f3faea6a37ab983ca26ec8637c698a581b9e5
43 lines
1.5 KiB
Rust
43 lines
1.5 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
//! Types used to report parsing errors.
|
|
|
|
#![deny(missing_docs)]
|
|
|
|
use cssparser::{Parser, SourcePosition};
|
|
use log;
|
|
use servo_url::ServoUrl;
|
|
|
|
/// A generic trait for an error reporter.
|
|
pub trait ParseErrorReporter {
|
|
/// Called the style engine detects an error.
|
|
///
|
|
/// Returns the current input being parsed, the source position it was
|
|
/// reported from, and a message.
|
|
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str, url: &ServoUrl);
|
|
/// Clone this error reporter.
|
|
///
|
|
/// TODO(emilio): I'm pretty sure all the box shenanigans can go away.
|
|
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync>;
|
|
}
|
|
|
|
/// An error reporter that reports the errors to the `info` log channel.
|
|
///
|
|
/// TODO(emilio): The name of this reporter is a lie, and should be renamed!
|
|
pub struct StdoutErrorReporter;
|
|
impl ParseErrorReporter for StdoutErrorReporter {
|
|
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str,
|
|
url: &ServoUrl) {
|
|
if log_enabled!(log::LogLevel::Info) {
|
|
let location = input.source_location(position);
|
|
info!("Url:\t{}\n{}:{} {}", url.as_str(), location.line, location.column, message)
|
|
}
|
|
}
|
|
|
|
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
|
Box::new(StdoutErrorReporter)
|
|
}
|
|
}
|