git.delta.rocks / jrsonnet / refs/commits / 7c5655fe8943

difftreelog

feat lazily evaluate source field in mergePatch

unzkwlwzYaroslav Bolyukin2026-02-08parent: #46ef62a.patch.diff
in: master

5 files changed

modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
1183 let entry = receiver.0.new.this_entries.entry(name);1183 let entry = receiver.0.new.this_entries.entry(name);
1184 entry.insert_entry(member);1184 entry.insert_entry(member);
1185 }1185 }
1186 /// Inserts thunk, replacing if it is already defined
1187 pub fn thunk(self, value: impl Into<Thunk<Val>>) {
1188 let (receiver, name, member) = self.build_member(MaybeUnbound::Bound(value.into()));
1189 let entry = receiver.0.new.this_entries.entry(name);
1190 entry.insert_entry(member);
1191 }
11861192
1187 /// Tries to insert value, returns an error if it was already defined1193 /// Tries to insert value, returns an error if it was already defined
1188 pub fn try_value(self, value: impl Into<Val>) -> Result<()> {1194 pub fn try_value(self, value: impl Into<Val>) -> Result<()> {
modifiedcrates/jrsonnet-formatter/src/lib.rsdiffbeforeafterboth
5 condition_helpers::is_multiple_lines,5 condition_helpers::is_multiple_lines,
6 condition_resolvers::true_resolver,6 condition_resolvers::true_resolver,
7 ir_helpers::{new_line_group, with_indent},7 ir_helpers::{new_line_group, with_indent},
8 ConditionResolver, ConditionResolverContext, LineNumber, PrintItemPath, PrintItems,8 ConditionResolver, ConditionResolverContext, LineNumber, PrintItems, PrintOptions,
9 PrintOptions, Signal,
10};9};
11use hi_doc::{Formatting, SnippetBuilder};10use hi_doc::{Formatting, SnippetBuilder};
12use jrsonnet_rowan_parser::{11use jrsonnet_rowan_parser::{
13 nodes::{12 nodes::{
14 Arg, ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,13 Arg, ArgsDesc, Assertion, BinaryOperator, Bind, CompSpec, Destruct, DestructArrayPart,
15 DestructRest, Expr, ExprBase, FieldName, ForSpec, IfSpec, ImportKind, Literal, Member,14 DestructRest, Expr, ExprBase, FieldName, ForSpec, IfSpec, ImportKind, Literal, Member,
16 Name, Number, ObjBody, ObjLocal, ParamsDesc, SliceDesc, SourceFile, Stmt, Suffix, Text,15 Name, Number, ObjBody, ObjLocal, ParamsDesc, SliceDesc, SourceFile, Stmt, Suffix, Text,
17 Trivia, TriviaKind, UnaryOperator, Visibility,16 UnaryOperator, Visibility,
18 },17 },
19 AstNode, AstToken as _, SyntaxToken,18 AstNode, AstToken as _, SyntaxToken,
20};19};
modifiedcrates/jrsonnet-stdlib/src/misc.rsdiffbeforeafterboth
201 let mut out = ObjValueBuilder::new();201 let mut out = ObjValueBuilder::new();
202 for field in target_fields.union(&patch_fields) {202 for field in target_fields.union(&patch_fields) {
203 let Some(field_patch) = patch.get(field.clone())? else {203 let Some(field_patch) = patch.get(field.clone())? else {
204 // All lazy fields might be unified into a single filtered object core instead of creating a thunk per, but this implementation is good enough.
205 let target_field = target.get_lazy(field.clone()).expect("we're iterating over fields union, if field is missing in patch - it exists in target");
204 out.field(field.clone()).value(target.get(field.clone())?.expect("we're iterating over fields union, if field is missing in patch - it exists in target"));206 out.field(field.clone()).thunk(target_field);
205 continue;207 continue;
206 };208 };
207 if matches!(field_patch, Val::Null) {209 if matches!(field_patch, Val::Null) {
addedtests/golden/issue188.jsonnetdiffbeforeafterboth

no changes

addedtests/golden/issue188.jsonnet.goldendiffbeforeafterboth

no changes