Class CodeSection
java.lang.Object
io.github.syst3ms.skriptparser.lang.Statement
io.github.syst3ms.skriptparser.lang.CodeSection
- All Implemented Interfaces:
SyntaxElement
- Direct Known Subclasses:
ArgumentSection, SecAsync, SecCase, SecChance, SecConditional, SecSwitch, SecWhile, SimpleCodeSection, Trigger
Represents a section of runnable code.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckFinishing(Predicate<? super Statement> finishingTest, SkriptLogger logger, int currentSectionLine, boolean warnUnreachable) booleancheckFinishing(Predicate<? super Statement> finishingTest, SkriptLogger logger, int currentSectionLine, boolean warnUnreachable, String errorMessage) booleancheckReturns(SkriptLogger logger, int currentSectionLine, boolean warnUnreachable) protected Set<Class<? extends SyntaxElement>> A list of the classes of every syntax that is allowed to be used inside of this CodeSection.getFirst()getItems()The items returned by this method are not representative of the execution of the code, meaning that all items in the list may not be all executed.getLast()protected booleanWhether the syntax restrictions outlined ingetAllowedSyntaxes()should also apply to expressions.booleanloadSection(FileSection section, ParserState parserState, SkriptLogger logger) This methods determines the logic of what is being done to the elements inside of this section.booleanrun(TriggerContext ctx) Executes this Statementfinal voidSets the items inside this lists, and also modifies other fields, reflected through the outputs ofgetFirst(),getLast()andStatement.getParent().walk(TriggerContext ctx) By default, runsStatement.run(TriggerContext); returnsStatement.getNext()if it returns true, ornullotherwise.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SyntaxElement
init, toString
-
Field Details
-
items
-
first
-
last
-
-
Constructor Details
-
CodeSection
public CodeSection()
-
-
Method Details
-
loadSection
This methods determines the logic of what is being done to the elements inside of this section. By default, this simply parses all items inside it, but this can be overridden. In case an extending class just needs to do some additional operations on top of what the default implementation already does, then callsuper.loadSection(section)before any such operations.- Parameters:
section- theFileSectionrepresenting this CodeSectionlogger- the logger- Returns:
trueif the items inside of the section were loaded properly,falseif there was a problem
-
run
Description copied from class:StatementExecutes this Statement -
walk
Description copied from class:StatementBy default, runsStatement.run(TriggerContext); returnsStatement.getNext()if it returns true, ornullotherwise. Note that if this method is overridden, then the implementation of Statement.run(TriggerContext) doesn't matter. -
setItems
Sets the items inside this lists, and also modifies other fields, reflected through the outputs ofgetFirst(),getLast()andStatement.getParent().- Parameters:
items- the items to set
-
getItems
The items returned by this method are not representative of the execution of the code, meaning that all items in the list may not be all executed. The list should rather be considered as a flat view of all the lines inside the section. PreferStatement.runAll(Statement, TriggerContext)to run the contents of this section- Returns:
- all items inside this section
-
getFirst
-
getLast
-
getAllowedSyntaxes
A list of the classes of every syntax that is allowed to be used inside of this CodeSection. The default behavior is to return an empty list, which equates to no restrictions. If overridden, this allows the creation of specialized, DSL-like sections in which only select statements and other sections (and potentially, but not necessarily, expressions).- Returns:
- a list of the classes of each syntax allowed inside this CodeSection
- See Also:
-
isRestrictingExpressions
protected boolean isRestrictingExpressions()Whether the syntax restrictions outlined ingetAllowedSyntaxes()should also apply to expressions. This is usually undesirable, so it is false by default. This should return true if and only ifgetAllowedSyntaxes()contains an Expression class.- Returns:
- whether the use of expressions is also restricted by
getAllowedSyntaxes(). False by default.
-
checkFinishing
public boolean checkFinishing(Predicate<? super Statement> finishingTest, SkriptLogger logger, int currentSectionLine, boolean warnUnreachable, String errorMessage) -
checkFinishing
public boolean checkFinishing(Predicate<? super Statement> finishingTest, SkriptLogger logger, int currentSectionLine, boolean warnUnreachable) -
checkReturns
-