From 2c6ab9ac1662ec4be854bfa32e3f21500e3c1cfc Mon Sep 17 00:00:00 2001 From: Ali Arslan Date: Fri, 29 Jul 2022 11:50:28 +0300 Subject: [PATCH] Revert "Parse more UnparsedLiterals, but only if they're actually meaningful (#4776)" This reverts commit c6bfd66fc3ba5c59a370d2c16cac7ce9a3cf4e91. --- .../ch/njol/skript/lang/SkriptParser.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/main/java/ch/njol/skript/lang/SkriptParser.java b/src/main/java/ch/njol/skript/lang/SkriptParser.java index c8efa14e459..bbb11af587f 100644 --- a/src/main/java/ch/njol/skript/lang/SkriptParser.java +++ b/src/main/java/ch/njol/skript/lang/SkriptParser.java @@ -367,20 +367,15 @@ private final Expression 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) new UnparsedLiteral(expr, e != null && (error == null || e.quality > error.quality) ? e : error); } for (final Class 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); @@ -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)); @@ -622,7 +611,7 @@ public final Expression parseExpression(final Class r = parseSingleExpr(true, null, types); + final Expression r = parseSingleExpr(false, null, types); if (r != null) { log.printLog(); return r; @@ -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;