@@ -19,8 +19,8 @@ impl<'src> CompileError<'src> {
1919 }
2020}
2121
22- pub ( crate ) fn render_compile_error ( error : & CompileError ) {
23- use ariadne:: { Label , Report , ReportKind , Source } ;
22+ pub ( crate ) fn render_compile_error ( error : & CompileError , color : Color ) {
23+ use ariadne:: { Config , Label , Report , ReportKind , Source } ;
2424
2525 let token = error. token ;
2626 let source = Source :: from ( token. src ) ;
@@ -31,7 +31,8 @@ pub(crate) fn render_compile_error(error: &CompileError) {
3131 let path = format ! ( "{}" , token. path. display( ) ) ;
3232 let label = Label :: new ( ( & path, start..end) ) ;
3333
34- let report = Report :: build ( ReportKind :: Error , & path, start) ;
34+ let config = Config :: default ( ) . with_color ( color. stderr ( ) . active ( ) ) ;
35+ let report = Report :: build ( ReportKind :: Error , & path, start) . with_config ( config) ;
3536
3637 let report = match & * error. kind {
3738 CompileErrorKind :: AttributeArgumentCountMismatch {
@@ -49,27 +50,17 @@ pub(crate) fn render_compile_error(error: &CompileError) {
4950 } ;
5051
5152 report
52- . with_code ( "E01" )
5353 . with_message ( "Attribute argument count mismatch" )
5454 . with_label ( label. with_message ( label_msg) )
5555 . with_note ( note)
5656 . finish ( )
5757 }
58- /*
59- CompileErrorKind::BacktickShebang => todo!(),
60- CompileErrorKind::CircularRecipeDependency { recipe, circle } => todo!(),
61- CompileErrorKind::CircularVariableDependency { variable, circle } => todo!(),
62- CompileErrorKind::DependencyArgumentCountMismatch { dependency, found, min, max } => todo!(),
63- CompileErrorKind::Redefinition { first, first_type, name, second_type } => todo!(),
64- */
6558 CompileErrorKind :: DuplicateAttribute { attribute, first } => {
6659 let original_label = source
6760 . line ( * first)
6861 . map ( |line| Label :: new ( ( & path, line. span ( ) ) ) . with_message ( "original" ) ) ;
6962
70- let mut report = report
71- . with_code ( "E02" )
72- . with_message ( format ! ( "Duplicate attribute `{attribute}`" ) ) ;
63+ let mut report = report. with_message ( format ! ( "Duplicate attribute `{attribute}`" ) ) ;
7364 if let Some ( original) = original_label {
7465 report = report. with_label ( original) ;
7566 }
@@ -78,50 +69,7 @@ pub(crate) fn render_compile_error(error: &CompileError) {
7869 _ => {
7970 let message = format ! ( "{error}" ) ;
8071 report. with_message ( message) . with_label ( label) . finish ( )
81- } /*
82- CompileErrorKind::DuplicateParameter { recipe, parameter } => todo!(),
83- CompileErrorKind::DuplicateSet { setting, first } => todo!(),
84- CompileErrorKind::DuplicateVariable { variable } => todo!(),
85- CompileErrorKind::DuplicateUnexport { variable } => todo!(),
86- CompileErrorKind::ExpectedKeyword { expected, found } => todo!(),
87- CompileErrorKind::ExportUnexported { variable } => todo!(),
88- CompileErrorKind::ExtraLeadingWhitespace => todo!(),
89- CompileErrorKind::ExtraneousAttributes { count } => todo!(),
90- CompileErrorKind::FunctionArgumentCountMismatch { function, found, expected } => todo!(),
91- CompileErrorKind::Include => todo!(),
92- CompileErrorKind::InconsistentLeadingWhitespace { expected, found } => todo!(),
93- CompileErrorKind::Internal { message } => todo!(),
94- CompileErrorKind::InvalidAttribute { item_kind, item_name, attribute } => todo!(),
95- CompileErrorKind::InvalidEscapeSequence { character } => todo!(),
96- CompileErrorKind::MismatchedClosingDelimiter { close, open, open_line } => todo!(),
97- CompileErrorKind::MixedLeadingWhitespace { whitespace } => todo!(),
98- CompileErrorKind::ParameterFollowsVariadicParameter { parameter } => todo!(),
99- CompileErrorKind::ParsingRecursionDepthExceeded => todo!(),
100- CompileErrorKind::RequiredParameterFollowsDefaultParameter { parameter } => todo!(),
101- CompileErrorKind::ShebangAndScriptAttribute { recipe } => todo!(),
102- CompileErrorKind::ShellExpansion { err } => todo!(),
103- CompileErrorKind::UndefinedVariable { variable } => todo!(),
104- CompileErrorKind::UnexpectedCharacter { expected } => todo!(),
105- CompileErrorKind::UnexpectedClosingDelimiter { close } => todo!(),
106- CompileErrorKind::UnexpectedEndOfToken { expected } => todo!(),
107- CompileErrorKind::UnexpectedToken { expected, found } => todo!(),
108- CompileErrorKind::UnicodeEscapeCharacter { character } => todo!(),
109- CompileErrorKind::UnicodeEscapeDelimiter { character } => todo!(),
110- CompileErrorKind::UnicodeEscapeEmpty => todo!(),
111- CompileErrorKind::UnicodeEscapeLength { hex } => todo!(),
112- CompileErrorKind::UnicodeEscapeRange { hex } => todo!(),
113- CompileErrorKind::UnicodeEscapeUnterminated => todo!(),
114- CompileErrorKind::UnknownAliasTarget { alias, target } => todo!(),
115- CompileErrorKind::UnknownAttribute { attribute } => todo!(),
116- CompileErrorKind::UnknownDependency { recipe, unknown } => todo!(),
117- CompileErrorKind::UnknownFunction { function } => todo!(),
118- CompileErrorKind::UnknownSetting { setting } => todo!(),
119- CompileErrorKind::UnknownStartOfToken => todo!(),
120- CompileErrorKind::UnpairedCarriageReturn => todo!(),
121- CompileErrorKind::UnterminatedBacktick => todo!(),
122- CompileErrorKind::UnterminatedInterpolation => todo!(),
123- CompileErrorKind::UnterminatedString => todo!(),
124- */
72+ }
12573 } ;
12674
12775 report. eprint ( ( & path, source) ) . unwrap ( ) ;
0 commit comments