Allow look-behind for headless effect sections during init. #6556
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.
Description
When a Section
init
s, it is given a list of the preceding trigger items.This is how an
else:
block searches for theif..:
it belongs to.This list basically contains information about the lines before a syntax.
However, effect sections do not get given this information unless they are heading a section (i.e. if they're used as inline effects rather than sections with a
:
).This means that
gets the list of trigger items, whereas
does not, despite both being the same syntax.
Presumably, this was historically done when EffectSections were made to avoid changing the signature of the
parse
method they use.What I changed
This change gives the trigger items to effect sections whether-or-not they are starting a section. The
SectionNode
will still be null, of course, since they don't have a section, but they are now able to look behind at the previous syntax elements.This change is mainly targeted at providing API compatibility for future (or addon) effect sections and should have no effect on existing syntax.
Does this break anything?
It shouldn't do, since I duplicated the method with its original signature, in case something exists that uses it directly.
I don't expect this to be a breaking change for any addon, since it is inconceivable that syntax would be conditionally reliant on the
triggerItems
parameter being null without also being dependent on, for example, theisSection
method or theSectionNode
parameter.Target Minecraft Versions: any
Requirements: none
Related Issues: none