mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Add ServoUrl as a parameter to report_error(...) of ParseErrorReporter
passes test-tidy removed match and used map added new test test_report_error_passing_correct_url(...) and modified old unit tests removed the option for servourl and tidied up removed the duplicate test. made a few more changes after @cbrewster suggestions. changed _url to url in few places fixed the indenting
This commit is contained in:
parent
c62973b77b
commit
f48f0567cf
7 changed files with 36 additions and 19 deletions
|
@ -7,6 +7,7 @@ use ipc_channel::ipc::IpcSender;
|
|||
use log;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use script_traits::ConstellationControlMsg;
|
||||
use servo_url::ServoUrl;
|
||||
use std::sync::{Mutex, Arc};
|
||||
use style::error_reporting::ParseErrorReporter;
|
||||
|
||||
|
@ -21,11 +22,13 @@ pub struct CSSErrorReporter {
|
|||
}
|
||||
|
||||
impl ParseErrorReporter for CSSErrorReporter {
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
||||
let location = input.source_location(position);
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
info!("{}:{} {}", location.line, location.column, message)
|
||||
}
|
||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str,
|
||||
url: &ServoUrl) {
|
||||
let location = input.source_location(position);
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
info!("Url:\t{}\n{}:{} {}", url.as_str(), location.line, location.column, message)
|
||||
}
|
||||
|
||||
//TODO: report a real filename
|
||||
let _ = self.script_chan.lock().unwrap().send(
|
||||
ConstellationControlMsg::ReportCSSError(self.pipelineid,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
use cssparser::{Parser, SourcePosition};
|
||||
use log;
|
||||
use servo_url::ServoUrl;
|
||||
|
||||
/// A generic trait for an error reporter.
|
||||
pub trait ParseErrorReporter {
|
||||
|
@ -15,7 +16,7 @@ pub trait ParseErrorReporter {
|
|||
///
|
||||
/// 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);
|
||||
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.
|
||||
|
@ -27,11 +28,12 @@ pub trait ParseErrorReporter {
|
|||
/// 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) {
|
||||
if log_enabled!(log::LogLevel::Info) {
|
||||
let location = input.source_location(position);
|
||||
info!("{}:{} {}", location.line, location.column, message)
|
||||
}
|
||||
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> {
|
||||
|
|
|
@ -90,7 +90,8 @@ impl<'a> ParserContext<'a> {
|
|||
/// Set a `RUST_LOG=style::errors` environment variable
|
||||
/// to log CSS parse errors to stderr.
|
||||
pub fn log_css_error(input: &mut Parser, position: SourcePosition, message: &str, parsercontext: &ParserContext) {
|
||||
parsercontext.error_reporter.report_error(input, position, message);
|
||||
let servo_url = parsercontext.base_url;
|
||||
parsercontext.error_reporter.report_error(input, position, message, servo_url);
|
||||
}
|
||||
|
||||
// XXXManishearth Replace all specified value parse impls with impls of this
|
||||
|
|
|
@ -252,7 +252,8 @@ impl ParseErrorReporter for MemoryHoleReporter {
|
|||
fn report_error(&self,
|
||||
_: &mut Parser,
|
||||
_: SourcePosition,
|
||||
_: &str) {
|
||||
_: &str,
|
||||
_: &ServoUrl) {
|
||||
// do nothing
|
||||
}
|
||||
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue