Record Class ErrorSource
java.lang.Object
java.lang.Record
org.skriptlang.skript.log.runtime.ErrorSource
- Record Components:
syntaxType- A string representing the type of syntax. SeeSyntaxElement.getSyntaxTypeName().syntaxName- The name of the syntax emitting the error.lineNumber- The line number of the syntax emitting the error.lineText- The raw code of the line.script- The name of the script in which the line exists.
public record ErrorSource(String syntaxType, String syntaxName, int lineNumber, String lineText, String script)
extends Record
A more versatile set of information about the source of an error.
Aims to avoid relying specifically on
Nodes for information.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA code location (line number and script name). -
Constructor Summary
ConstructorsConstructorDescriptionErrorSource(String syntaxType, String syntaxName, int lineNumber, String lineText, String script) Creates an instance of aErrorSourcerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static @NotNull ErrorSourcefromNodeAndElement(@Nullable Node node, @NotNull SyntaxElement element) Creates an error source using information from a given node and syntax element.final inthashCode()Returns a hash code value for this object.intReturns the value of thelineNumberrecord component.lineText()Returns the value of thelineTextrecord component.@NotNull ErrorSource.Locationlocation()script()Returns the value of thescriptrecord component.Returns the value of thesyntaxNamerecord component.Returns the value of thesyntaxTyperecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ErrorSource
public ErrorSource(String syntaxType, String syntaxName, int lineNumber, String lineText, String script) Creates an instance of aErrorSourcerecord class.- Parameters:
syntaxType- the value for thesyntaxTyperecord componentsyntaxName- the value for thesyntaxNamerecord componentlineNumber- the value for thelineNumberrecord componentlineText- the value for thelineTextrecord componentscript- the value for thescriptrecord component
-
-
Method Details
-
fromNodeAndElement
@NotNull public static @NotNull ErrorSource fromNodeAndElement(@Nullable @Nullable Node node, @NotNull @NotNull SyntaxElement element) Creates an error source using information from a given node and syntax element.- Parameters:
node- The node to use for line, line number, and script name.element- The element to use for the type and name.- Returns:
- A new error source.
-
location
- Returns:
- The code location (line number and script name) of the source of the error. Used for hash maps.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
syntaxType
Returns the value of thesyntaxTyperecord component.- Returns:
- the value of the
syntaxTyperecord component
-
syntaxName
Returns the value of thesyntaxNamerecord component.- Returns:
- the value of the
syntaxNamerecord component
-
lineNumber
public int lineNumber()Returns the value of thelineNumberrecord component.- Returns:
- the value of the
lineNumberrecord component
-
lineText
Returns the value of thelineTextrecord component.- Returns:
- the value of the
lineTextrecord component
-
script
Returns the value of thescriptrecord component.- Returns:
- the value of the
scriptrecord component
-