Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/main/java/ch/njol/skript/lang/Section.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,18 @@ public static Section parse(String expr, @Nullable String defaultError, SectionN
ParserInstance.registerData(SectionContext.class, SectionContext::new);
}

@SuppressWarnings("NotNullFieldNotInitialized")
protected static class SectionContext extends ParserInstance.Data {
/**
* Data stored in the {@link ParserInstance} to keep track of the current section being parsed.
* <br>
* This is used to allow syntaxes to claim sections, and to provide the section node and trigger items
* to syntaxes that need them. Failure to correctly manage this context via {@link #modify(SectionNode, List, Supplier)}
* may result in sections being double claimed or infinite parsing loops.
* <br>
* Most users should never need to interact with this class, only those dealing with manual parsing of expressions
* and similar behavior. Context is automatically handled in normal behavior via {@link Statement#parse(String, String)}
* and other similar methods.
*/
public static class SectionContext extends ParserInstance.Data {

protected SectionNode sectionNode;
protected List<TriggerItem> triggerItems;
Expand All @@ -216,7 +226,7 @@ public SectionContext(ParserInstance parserInstance) {
* <br>
* See <a href="https://github.com/SkriptLang/Skript/pull/4353">Pull Request #4353</a> and <a href="https://github.com/SkriptLang/Skript/issues/4473">Issue #4473</a>.
*/
protected <T> T modify(SectionNode sectionNode, List<TriggerItem> triggerItems, Supplier<T> supplier) {
public <T> T modify(SectionNode sectionNode, List<TriggerItem> triggerItems, Supplier<T> supplier) {
SectionNode prevSectionNode = this.sectionNode;
List<TriggerItem> prevTriggerItems = this.triggerItems;
Debuggable owner = this.owner;
Expand Down