Skip to content

Commit

Permalink
Revert "Parse more UnparsedLiterals, but only if they're actually mea…
Browse files Browse the repository at this point in the history
…ningful (SkriptLang#4776)"

This reverts commit c6bfd66.
  • Loading branch information
bilektugrul committed Jul 29, 2022
1 parent 5c41519 commit 2c6ab9a
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/main/java/ch/njol/skript/lang/SkriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,15 @@ private final <T> Expression<? extends T> parseSingleExpr(final boolean allowUnp
log.printError();
return null;
}
if (types[0] == Object.class) {
// Do check if a literal with this name actually exists before returning an UnparsedLiteral
if (!allowUnparsedLiteral || Classes.parseSimple(expr, Object.class, context) == null) {
log.printError();
return null;
}
if (allowUnparsedLiteral && types[0] == Object.class) {
log.clear();
final LogEntry e = log.getError();
LogEntry e = log.getError();
return (Literal<? extends T>) new UnparsedLiteral(expr, e != null && (error == null || e.quality > error.quality) ? e : error);
}
for (final Class<? extends T> c : types) {
log.clear();
assert c != null;
final T t = Classes.parse(expr, c, context);
T t = Classes.parse(expr, c, context);
if (t != null) {
log.printLog();
return new SimpleLiteral<>(t, false);
Expand Down Expand Up @@ -566,20 +561,14 @@ else if (!hasSingular && hasPlural)
log.printError();
return null;
}
if (vi.classes[0].getC() == Object.class) {
// Do check if a literal with this name actually exists before returning an UnparsedLiteral
if (!allowUnparsedLiteral || Classes.parseSimple(expr, Object.class, context) == null) {
log.printError();
return null;
}
if (allowUnparsedLiteral && vi.classes[0].getC() == Object.class) {
log.clear();
final LogEntry e = log.getError();
LogEntry e = log.getError();
return new UnparsedLiteral(expr, e != null && (error == null || e.quality > error.quality) ? e : error);
}
for (final ClassInfo<?> ci : vi.classes) {
for (ClassInfo<?> ci : vi.classes) {
log.clear();
assert ci.getC() != null;
final Object t = Classes.parse(expr, ci.getC(), context);
Object t = Classes.parse(expr, ci.getC(), context);
if (t != null) {
log.printLog();
return new SimpleLiteral<>(t, false, new UnparsedLiteral(expr));
Expand Down Expand Up @@ -622,7 +611,7 @@ public final <T> Expression<? extends T> parseExpression(final Class<? extends T
final boolean isObject = types.length == 1 && types[0] == Object.class;
final ParseLogHandler log = SkriptLogger.startParseLogHandler();
try {
final Expression<? extends T> r = parseSingleExpr(true, null, types);
final Expression<? extends T> r = parseSingleExpr(false, null, types);
if (r != null) {
log.printLog();
return r;
Expand Down Expand Up @@ -748,7 +737,7 @@ public final Expression<?> parseExpression(final ExprInfo vi) {
final ParseLogHandler log = SkriptLogger.startParseLogHandler();
try {
// Attempt to parse a single expression
final Expression<?> r = parseSingleExpr(true, null, vi);
final Expression<?> r = parseSingleExpr(false, null, vi);
if (r != null) {
log.printLog();
return r;
Expand Down

0 comments on commit 2c6ab9a

Please sign in to comment.