--- a/crates/jrsonnet-evaluator/src/lib.rs +++ b/crates/jrsonnet-evaluator/src/lib.rs @@ -63,16 +63,15 @@ use std::{ any::Any, cell::{Ref, RefCell, RefMut}, - collections::HashMap, fmt::{self, Debug}, path::Path, }; pub use ctx::*; pub use dynamic::*; -use error::{Error::*, LocError, Result, ResultExt}; +pub use error::{Error::*, LocError, Result, ResultExt}; pub use evaluate::*; -use function::{CallLocation, TlaArg}; +use function::CallLocation; use gc::{GcHashMap, TraceBox}; use hashbrown::hash_map::RawEntryMut; pub use import::*; @@ -305,7 +304,7 @@ jrsonnet_parser::parse( code, &ParserSettings { - file_name: file_name.clone(), + source: file_name.clone(), }, ) .map_err(|e| ImportSyntaxError { @@ -411,7 +410,7 @@ let parsed = jrsonnet_parser::parse( &code, &ParserSettings { - file_name: source.clone(), + source: source.clone(), }, ) .map_err(|e| ImportSyntaxError { --- a/crates/jrsonnet-parser/src/lib.rs +++ b/crates/jrsonnet-parser/src/lib.rs @@ -14,7 +14,7 @@ pub use source::{Source, SourceDirectory, SourceFile, SourcePath, SourcePathT, SourceVirtual}; pub struct ParserSettings { - pub file_name: Source, + pub source: Source, } macro_rules! expr_bin { @@ -230,7 +230,7 @@ pub rule var_expr(s: &ParserSettings) -> Expr = n:id() { expr::Expr::Var(n) } pub rule id_loc(s: &ParserSettings) -> LocExpr - = a:position!() n:id() b:position!() { LocExpr(Rc::new(expr::Expr::Str(n)), ExprLocation(s.file_name.clone(), a as u32,b as u32)) } + = a:position!() n:id() b:position!() { LocExpr(Rc::new(expr::Expr::Str(n)), ExprLocation(s.source.clone(), a as u32,b as u32)) } pub rule if_then_else_expr(s: &ParserSettings) -> Expr = cond:ifspec(s) _ keyword("then") _ cond_then:expr(s) cond_else:(_ keyword("else") _ e:expr(s) {e})? {Expr::IfElse{ cond, @@ -293,7 +293,7 @@ use UnaryOpType::*; rule expr(s: &ParserSettings) -> LocExpr = precedence! { - start:position!() v:@ end:position!() { LocExpr(Rc::new(v), ExprLocation(s.file_name.clone(), start as u32, end as u32)) } + start:position!() v:@ end:position!() { LocExpr(Rc::new(v), ExprLocation(s.source.clone(), start as u32, end as u32)) } -- a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)} -- @@ -351,7 +351,7 @@ let len = str.len(); LocExpr( Rc::new(Expr::Str(str)), - ExprLocation(settings.file_name.clone(), 0, len as u32), + ExprLocation(settings.source.clone(), 0, len as u32), ) } @@ -368,7 +368,7 @@ parse( $s, &ParserSettings { - file_name: Source::new_virtual("".into(), IStr::empty()), + source: Source::new_virtual("".into(), IStr::empty()), }, ) .unwrap() @@ -719,7 +719,7 @@ let file_name = Source::new_virtual("".into(), IStr::empty()); let expr = parse( "{} { local x = 1, x: x } + {}", - &ParserSettings { file_name }, + &ParserSettings { source: file_name }, ) .unwrap(); assert_eq!( --- a/crates/jrsonnet-stdlib/build.rs +++ b/crates/jrsonnet-stdlib/build.rs @@ -7,10 +7,7 @@ let parsed = parse( include_str!("./src/std.jsonnet"), &ParserSettings { - file_name: Source::new_virtual( - "".into(), - include_str!("./src/std.jsonnet").into(), - ), + source: Source::new_virtual("".into(), include_str!("./src/std.jsonnet").into()), }, ) .expect("parse"); --- a/crates/jrsonnet-stdlib/src/lib.rs +++ b/crates/jrsonnet-stdlib/src/lib.rs @@ -215,7 +215,7 @@ pub path_resolver: PathResolver, } -pub fn extvar_source(name: &str, code: impl Into) -> Source { +fn extvar_source(name: &str, code: impl Into) -> Source { let source_name = format!("", name); Source::new_virtual(source_name.into(), code.into()) } @@ -277,7 +277,7 @@ let parsed = jrsonnet_parser::parse( &code, &jrsonnet_parser::ParserSettings { - file_name: source.clone(), + source: source.clone(), }, ) .map_err(|e| ImportSyntaxError {