forked from SkriptLang/Skript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to REConsumer, create RE and ErrorSource classes, use new config reload event.
- Loading branch information
Showing
11 changed files
with
287 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 0 additions & 145 deletions
145
src/main/java/org/skriptlang/skript/lang/errors/RuntimeErrorProducer.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
src/main/java/org/skriptlang/skript/log/runtime/ErrorSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.skriptlang.skript.log.runtime; | ||
|
||
import ch.njol.skript.config.Node; | ||
import ch.njol.skript.doc.Name; | ||
import ch.njol.skript.lang.SyntaxElement; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* A more versatile set of information about the source of an error. | ||
* Aims to avoid relying specifically on {@link Node}s for information. | ||
* <br> | ||
* Hashing is specifically based on line number and script name alone. | ||
* | ||
* @param syntaxType A string representing the type of syntax. See {@link SyntaxElement#getSyntaxTypeName()}. | ||
* @param syntaxName The name of the syntax emitting the error. | ||
* @param lineNumber The line number of the syntax emitting the error. | ||
* @param lineText The raw code of the line. | ||
* @param script The name of the script in which the line exists. | ||
*/ | ||
public record ErrorSource( | ||
String syntaxType, | ||
String syntaxName, | ||
int lineNumber, | ||
String lineText, | ||
String script | ||
) { | ||
|
||
/** | ||
* Creates an error source using information from a given node and syntax element. | ||
* @param node The node to use for line, line number, and script name. | ||
* @param element The element to use for the type and name. | ||
* @return A new error source. | ||
*/ | ||
public static @NotNull ErrorSource fromNodeAndElement(@Nullable Node node, @NotNull SyntaxElement element) { | ||
String elementName = element.getClass().getAnnotation(Name.class).value().trim().replaceAll("\n", ""); | ||
if (node == null) { | ||
return new ErrorSource(element.getSyntaxTypeName(), elementName, 0, "-unknown-", "-effect command-"); | ||
} | ||
String code = node.save().trim().replaceAll("§", "&"); | ||
return new ErrorSource(element.getSyntaxTypeName(), elementName, node.getLine(), code, node.getConfig().getFileName()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 13 * lineNumber + 17 * script.hashCode(); | ||
} | ||
|
||
} |
Oops, something went wrong.