Reconstruct nested interpretation variables in string representation#1088
Merged
jasmith-hs merged 5 commits intomasterfrom Jul 13, 2023
Merged
Reconstruct nested interpretation variables in string representation#1088jasmith-hs merged 5 commits intomasterfrom
jasmith-hs merged 5 commits intomasterfrom
Conversation
jasmith-hs
commented
Jun 28, 2023
Comment on lines
+393
to
+416
| String pyishStringRepresentation = PyishObjectMapper.getAsPyishString(value); | ||
|
|
||
| if ( | ||
| depth < interpreter.getConfig().getMaxRenderDepth() && | ||
| interpreter.getConfig().isNestedInterpretationEnabled() | ||
| ) { | ||
| Set<String> dependentWords = EagerExpressionResolver.findDeferredWords( | ||
| pyishStringRepresentation, | ||
| interpreter | ||
| ); | ||
| if (!dependentWords.isEmpty()) { | ||
| hydrateReconstructionFromContextBeforeDeferring( | ||
| prefixToPreserveState, | ||
| dependentWords, | ||
| interpreter, | ||
| depth + 1 | ||
| ); | ||
| } | ||
| } | ||
| prefixToPreserveState.put( | ||
| name, | ||
| buildSetTag(ImmutableMap.of(name, pyishStringRepresentation), interpreter, false) | ||
| ); | ||
| return prefixToPreserveState; |
Contributor
Author
There was a problem hiding this comment.
Here's the recursion part
998d4b7 to
8d879ea
Compare
jasmith-hs
added a commit
that referenced
this pull request
Jul 24, 2023
(This test was not set up properly in #1088)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a variable is reconstructed, but it implicitly depends on another variable due to the use of nested interpretation, we'll need to reconstruct the dependent variable if nested interpretation is enabled.
This is well demonstrated through the new test:
fooandbarare not used explicitly anywhere, but due to nested interpretation, they are implicitly referenced. We can determine these references using a recursive approach with the same depth limit as the depth limit for nested interpretation.Essentially, when reconstructing a set tag for a variable which may have a string representation which uses nested interpretation, we can use
EagerExpressionResolver#findDeferredWordsto find words which are hidden inside of nested interpretation and also reconstruct them. So, with the above example, when trying to reconstructfoo, we realise that there's also a dependency oni_am, so we'll reconstructi_ambefore the reconstruction offoo. It would look something like this: