Skip to content

Commit 3cff9ea

Browse files
committed
Retain logs from parse attempts.
1 parent 9c138a9 commit 3cff9ea

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

src/main/java/ch/njol/skript/ScriptLoader.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,7 @@
5454
import java.io.InputStream;
5555
import java.nio.file.Files;
5656
import java.nio.file.Path;
57-
import java.util.ArrayList;
58-
import java.util.Arrays;
59-
import java.util.Collections;
60-
import java.util.Comparator;
61-
import java.util.HashMap;
62-
import java.util.HashSet;
63-
import java.util.List;
64-
import java.util.Map;
65-
import java.util.Set;
66-
import java.util.TreeSet;
57+
import java.util.*;
6758
import java.util.concurrent.BlockingQueue;
6859
import java.util.concurrent.Callable;
6960
import java.util.concurrent.CompletableFuture;
@@ -983,22 +974,28 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
983974
TypeHints.enterScope(); // Begin conditional type hints
984975

985976
TriggerItem section;
977+
RetainingLogHandler handler = SkriptLogger.startRetainingLog();
986978
find_section:
987-
try (ParseLogHandler handler = SkriptLogger.startParseLogHandler()) {
979+
try {
988980
section = Section.parse(expr, "Can't understand this section: " + expr, (SectionNode) subNode, items);
989981
if (section != null)
990982
break find_section;
991-
ParseLogHandler copy = handler.backup();
983+
984+
// back up the failure log
985+
RetainingLogHandler backup = handler.backup();
992986
handler.clear();
993987

994988
section = Statement.parse(expr, "Can't understand this effect: " + expr, (SectionNode) subNode, items);
995989

996990
if (section != null)
997991
break find_section;
998992

999-
handler.restore(copy);
1000-
handler.printLog();
993+
// restore the failure log
994+
handler.restore(backup);
1001995
continue;
996+
} finally {
997+
handler.printLog();
998+
handler.close();
1002999
}
10031000

10041001
if (Skript.debug() || subNode.debug())

0 commit comments

Comments
 (0)