From 4973203f72bb3bde1e72c380fd3ee2331c39716e Mon Sep 17 00:00:00 2001 From: bigguy345 Date: Sat, 20 Dec 2025 14:21:53 +0200 Subject: [PATCH] Removed unused --- .../gui/util/script/JavaTextContainer.java | 90 +------------------ 1 file changed, 1 insertion(+), 89 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java b/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java index 8dae4b782..48b198db5 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java @@ -54,95 +54,7 @@ public class JavaTextContainer extends TextContainer { super(text); this.text = text == null ? "" : text.replaceAll("\\r?\\n|\\r", "\n"); } - - public synchronized List getBraceSpans() { - if (braceSpansCache != null) - return braceSpansCache; - List spans = new ArrayList<>(); - if (text == null || text.isEmpty() || lines == null || lines.isEmpty()) { - braceSpansCache = spans; - return spans; - } - - // Heuristics limits to avoid runaway spans when braces are unbalanced. - final int MAX_SPAN_LINES = 200; // cap span length to this many lines - final int MAX_STACK_DEPTH = 512; // avoid excessive stack growth - - List excluded = MethodBlock.getExcludedRanges(text); - int exIdx = 0; - java.util.ArrayList openStack = new java.util.ArrayList<>(); - int len = text.length(); - for (int p = 0; p < len; p++) { - while (exIdx < excluded.size() && p >= excluded.get(exIdx)[1]) - exIdx++; - if (exIdx < excluded.size()) { - int[] r = excluded.get(exIdx); - if (p >= r[0] && p < r[1]) { - p = r[1] - 1; - continue; - } - } - char c = text.charAt(p); - if (c == '{') { - if (openStack.size() < MAX_STACK_DEPTH) { - // Look ahead to see if this open has a plausible closing brace within limits. - int openLine = getLineIndex(p); - int lookaheadChars = Math.max(1000, MAX_SPAN_LINES * 120); - int searchEnd = Math.min(len, p + lookaheadChars); - boolean foundClose = false; - int exIdx2 = exIdx; // local index for scanning ahead - for (int q = p + 1; q < searchEnd; q++) { - while (exIdx2 < excluded.size() && q >= excluded.get(exIdx2)[1]) exIdx2++; - if (exIdx2 < excluded.size()) { - int[] r2 = excluded.get(exIdx2); - if (q >= r2[0] && q < r2[1]) { q = r2[1] - 1; continue; } - } - if (text.charAt(q) == '}') { - int closeLineCandidate = getLineIndex(q); - if (closeLineCandidate - openLine <= MAX_SPAN_LINES) { - foundClose = true; - break; - } - } - } - if (foundClose) openStack.add(p); - } - } else if (c == '}') { - if (!openStack.isEmpty()) { - int openPos = openStack.remove(openStack.size() - 1); - int level = openStack.size() + 1; - int openLine = getLineIndex(openPos); - int closeLine = getLineIndex(p); - // Cap spans to avoid drawing across the whole document when syntax is broken - if (closeLine - openLine > MAX_SPAN_LINES) { - closeLine = Math.min(openLine + MAX_SPAN_LINES, lines.size() - 1); - } - // Only add spans where closeLine > openLine (multi-line blocks) - if (closeLine > openLine) { - spans.add(new int[]{level, openLine, closeLine}); - } - } - } - } - - braceSpansCache = spans; - return spans; - } - - private int getLineIndex(int pos) { - if (lines == null || lines.isEmpty()) - return 0; - int length = text == null ? 0 : text.length(); - for (int i = 0; i < lines.size(); i++) { - LineData d = lines.get(i); - int s = Math.max(0, Math.min(d.start, length)); - int e = Math.max(0, Math.min(d.end, length)); - if (pos >= s && pos <= e) - return i; - } - return Math.max(0, lines.size() - 1); - } - + public void init(int width, int height) { // lineHeight = ClientProxy.Font.height(); // if (lineHeight == 0)