diff --git a/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/JSAutocompleteProvider.java b/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/JSAutocompleteProvider.java index c594ecd02..e9217a4d3 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/JSAutocompleteProvider.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/autocomplete/JSAutocompleteProvider.java @@ -101,19 +101,13 @@ public class JSAutocompleteProvider extends JavaAutocompleteProvider { * Recursively add methods from a type and its parents. */ protected void addMethodsFromType(JSTypeInfo type, List items, Set added) { - addMethodsFromType(type, items, added, 0, new HashSet<>()); + addMethodsFromType(type, items, added, 0); } /** - * Recursively add methods from a type and its parents with inheritance depth tracking and cycle detection. + * Recursively add methods from a type and its parents with inheritance depth tracking. */ - private void addMethodsFromType(JSTypeInfo type, List items, Set added, int depth, Set visited) { - // Prevent infinite recursion from circular inheritance - if (visited.contains(type.getFullName())) { - return; - } - visited.add(type.getFullName()); - + private void addMethodsFromType(JSTypeInfo type, List items, Set added, int depth) { for (JSMethodInfo method : type.getMethods().values()) { String name = method.getName(); // Skip overload markers (name$1, name$2, etc.) @@ -128,7 +122,7 @@ public class JSAutocompleteProvider extends JavaAutocompleteProvider { // Add from parent type with incremented depth if (type.getResolvedParent() != null) { - addMethodsFromType(type.getResolvedParent(), items, added, depth + 1, visited); + addMethodsFromType(type.getResolvedParent(), items, added, depth + 1); } } @@ -136,19 +130,13 @@ public class JSAutocompleteProvider extends JavaAutocompleteProvider { * Recursively add fields from a type and its parents. */ protected void addFieldsFromType(JSTypeInfo type, List items, Set added) { - addFieldsFromType(type, items, added, 0, new HashSet<>()); + addFieldsFromType(type, items, added, 0); } /** - * Recursively add fields from a type and its parents with inheritance depth tracking and cycle detection. + * Recursively add fields from a type and its parents with inheritance depth tracking. */ - private void addFieldsFromType(JSTypeInfo type, List items, Set added, int depth, Set visited) { - // Prevent infinite recursion from circular inheritance - if (visited.contains(type.getFullName())) { - return; - } - visited.add(type.getFullName()); - + private void addFieldsFromType(JSTypeInfo type, List items, Set added, int depth) { for (JSFieldInfo field : type.getFields().values()) { if (!added.contains(field.getName())) { added.add(field.getName()); @@ -158,7 +146,7 @@ public class JSAutocompleteProvider extends JavaAutocompleteProvider { // Add from parent type with incremented depth if (type.getResolvedParent() != null) { - addFieldsFromType(type.getResolvedParent(), items, added, depth + 1, visited); + addFieldsFromType(type.getResolvedParent(), items, added, depth + 1); } } diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeInfo.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeInfo.java index 416720f37..7efdd8481 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeInfo.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeInfo.java @@ -89,25 +89,12 @@ public class JSTypeInfo { * Get a method by name, including inherited methods. */ public JSMethodInfo getMethod(String name) { - return getMethod(name, new HashSet<>()); - } - - /** - * Internal method to get method with cycle detection. - */ - private JSMethodInfo getMethod(String name, Set visited) { - // Prevent infinite recursion from circular inheritance - if (visited.contains(this.fullName)) { - return null; - } - visited.add(this.fullName); - JSMethodInfo method = methods.get(name); if (method != null) return method; // Check parent if (resolvedParent != null) { - return resolvedParent.getMethod(name, visited); + return resolvedParent.getMethod(name); } return null; } @@ -116,21 +103,8 @@ public class JSTypeInfo { * Get all methods with a given name (for overloads). */ public List getMethodOverloads(String name) { - return getMethodOverloads(name, new HashSet<>()); - } - - /** - * Internal method to get method overloads with cycle detection. - */ - private List getMethodOverloads(String name, Set visited) { List overloads = new ArrayList<>(); - // Prevent infinite recursion from circular inheritance - if (visited.contains(this.fullName)) { - return overloads; - } - visited.add(this.fullName); - // Get from this type if (methods.containsKey(name)) { overloads.add(methods.get(name)); @@ -144,7 +118,7 @@ public class JSTypeInfo { // Get from parent if (resolvedParent != null) { - overloads.addAll(resolvedParent.getMethodOverloads(name, visited)); + overloads.addAll(resolvedParent.getMethodOverloads(name)); } return overloads; @@ -161,25 +135,12 @@ public class JSTypeInfo { * Get a field by name, including inherited fields. */ public JSFieldInfo getField(String name) { - return getField(name, new HashSet<>()); - } - - /** - * Internal method to get field with cycle detection. - */ - private JSFieldInfo getField(String name, Set visited) { - // Prevent infinite recursion from circular inheritance - if (visited.contains(this.fullName)) { - return null; - } - visited.add(this.fullName); - JSFieldInfo field = fields.get(name); if (field != null) return field; // Check parent if (resolvedParent != null) { - return resolvedParent.getField(name, visited); + return resolvedParent.getField(name); } return null; } diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeRegistry.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeRegistry.java index dd497e465..8dfec22cf 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeRegistry.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/js_parser/JSTypeRegistry.java @@ -368,16 +368,7 @@ public class JSTypeRegistry { public void resolveInheritance() { for (JSTypeInfo type : types.values()) { JSTypeInfo child = type; - Set visited = new HashSet<>(); while (child != null && child.getExtendsType() != null && child.getResolvedParent() == null) { - // Prevent circular inheritance - if (visited.contains(child.getFullName())) { - System.out.println("WARNING: Circular inheritance detected: " + child.getFullName() + - " extends " + child.getExtendsType()); - break; - } - visited.add(child.getFullName()); - JSTypeInfo parent = getType(child.getExtendsType()); if (parent != null) { child.setResolvedParent(parent);