git.delta.rocks / jrsonnet / refs/commits / b9857aed17e5

difftreelog

style rename ast file_name to source

Yaroslav Bolyukin2022-11-09parent: #87a7e44.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
63use std::{63use std::{
64 any::Any,64 any::Any,
65 cell::{Ref, RefCell, RefMut},65 cell::{Ref, RefCell, RefMut},
66 collections::HashMap,
67 fmt::{self, Debug},66 fmt::{self, Debug},
68 path::Path,67 path::Path,
69};68};
7069
71pub use ctx::*;70pub use ctx::*;
72pub use dynamic::*;71pub use dynamic::*;
73use error::{Error::*, LocError, Result, ResultExt};72pub use error::{Error::*, LocError, Result, ResultExt};
74pub use evaluate::*;73pub use evaluate::*;
75use function::{CallLocation, TlaArg};74use function::CallLocation;
76use gc::{GcHashMap, TraceBox};75use gc::{GcHashMap, TraceBox};
77use hashbrown::hash_map::RawEntryMut;76use hashbrown::hash_map::RawEntryMut;
78pub use import::*;77pub use import::*;
305 jrsonnet_parser::parse(304 jrsonnet_parser::parse(
306 code,305 code,
307 &ParserSettings {306 &ParserSettings {
308 file_name: file_name.clone(),307 source: file_name.clone(),
309 },308 },
310 )309 )
311 .map_err(|e| ImportSyntaxError {310 .map_err(|e| ImportSyntaxError {
411 let parsed = jrsonnet_parser::parse(410 let parsed = jrsonnet_parser::parse(
412 &code,411 &code,
413 &ParserSettings {412 &ParserSettings {
414 file_name: source.clone(),413 source: source.clone(),
415 },414 },
416 )415 )
417 .map_err(|e| ImportSyntaxError {416 .map_err(|e| ImportSyntaxError {
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
--- 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("<test>".into(), IStr::empty()),
+					source: Source::new_virtual("<test>".into(), IStr::empty()),
 				},
 			)
 			.unwrap()
@@ -719,7 +719,7 @@
 		let file_name = Source::new_virtual("<test>".into(), IStr::empty());
 		let expr = parse(
 			"{} { local x = 1, x: x } + {}",
-			&ParserSettings { file_name },
+			&ParserSettings { source: file_name },
 		)
 		.unwrap();
 		assert_eq!(
modifiedcrates/jrsonnet-stdlib/build.rsdiffbeforeafterboth
--- 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(
-				"<std>".into(),
-				include_str!("./src/std.jsonnet").into(),
-			),
+			source: Source::new_virtual("<std>".into(), include_str!("./src/std.jsonnet").into()),
 		},
 	)
 	.expect("parse");
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- 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<IStr>) -> Source {
+fn extvar_source(name: &str, code: impl Into<IStr>) -> Source {
 	let source_name = format!("<extvar:{}>", 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 {