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
Node
s for information.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
A code location (line number and script name). -
Constructor Summary
ConstructorDescriptionErrorSource
(String syntaxType, String syntaxName, int lineNumber, String lineText, String script) Creates an instance of aErrorSource
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.static @NotNull ErrorSource
fromNodeAndElement
(@Nullable Node node, @NotNull SyntaxElement element) Creates an error source using information from a given node and syntax element.final int
hashCode()
Returns a hash code value for this object.int
Returns the value of thelineNumber
record component.lineText()
Returns the value of thelineText
record component.@NotNull ErrorSource.Location
location()
script()
Returns the value of thescript
record component.Returns the value of thesyntaxName
record component.Returns the value of thesyntaxType
record component.final String
toString()
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 aErrorSource
record class.- Parameters:
syntaxType
- the value for thesyntaxType
record componentsyntaxName
- the value for thesyntaxName
record componentlineNumber
- the value for thelineNumber
record componentlineText
- the value for thelineText
record componentscript
- the value for thescript
record 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 thesyntaxType
record component.- Returns:
- the value of the
syntaxType
record component
-
syntaxName
Returns the value of thesyntaxName
record component.- Returns:
- the value of the
syntaxName
record component
-
lineNumber
public int lineNumber()Returns the value of thelineNumber
record component.- Returns:
- the value of the
lineNumber
record component
-
lineText
Returns the value of thelineText
record component.- Returns:
- the value of the
lineText
record component
-
script
Returns the value of thescript
record component.- Returns:
- the value of the
script
record component
-