mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Proper TypeInfo getter for synthetic type members
This commit is contained in:
1 parent
55ae325458
commit
289c78f4de
5 files changed
+57
-15
No files matched your search
@@ -2677,10 +2677,10 @@ public class ScriptDocument {
|
||||
// Check for dynamic return type resolution (like Java.type("className"))
|
||||
SyntheticMethod synMethod = syntheticType.getMethod(methodName);
|
||||
TypeInfo dynamicReturnType = null;
|
||||
if (synMethod != null && synMethod.returnTypeResolver != null) {
|
||||
if (synMethod != null) {
|
||||
String argsText = text.substring(openParen + 1, closeParen);
|
||||
String[] strArgs = TypeResolver.parseStringArguments(argsText);
|
||||
dynamicReturnType = synMethod.returnTypeResolver.resolve(strArgs);
|
||||
dynamicReturnType = synMethod.resolveReturnType(strArgs);
|
||||
}
|
||||
|
||||
MethodCallInfo callInfo = new MethodCallInfo(methodName, nameStart, nameEnd, openParen,
|
||||
@@ -3553,9 +3553,9 @@ public class ScriptDocument {
|
||||
if (method != null) {
|
||||
// For methods with dynamic return type resolvers (like Java.type),
|
||||
// extract string arguments and resolve
|
||||
if (method.returnTypeResolver != null && segment.arguments != null) {
|
||||
if (segment.arguments != null) {
|
||||
String[] args = TypeResolver.parseStringArguments(segment.arguments);
|
||||
TypeInfo resolved = method.returnTypeResolver.resolve(args);
|
||||
TypeInfo resolved = method.resolveReturnType(args);
|
||||
if (resolved != null) {
|
||||
return resolved;
|
||||
}
|
||||
|
||||
+12
@@ -19,6 +19,18 @@ public class SyntheticField {
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the field type as TypeInfo.
|
||||
* @return The resolved TypeInfo for the field type, or unresolved if not found
|
||||
*/
|
||||
public TypeInfo getTypeInfo() {
|
||||
TypeInfo type = TypeResolver.getInstance().resolve(typeName);
|
||||
if (type == null) {
|
||||
type = TypeInfo.unresolved(typeName, typeName);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public FieldInfo toFieldInfo() {
|
||||
TypeInfo type = TypeResolver.getInstance().resolve(typeName);
|
||||
if (type == null) {
|
||||
|
||||
+24
@@ -32,6 +32,30 @@ public class SyntheticMethod {
|
||||
this.returnTypeResolver = returnTypeResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the return type as TypeInfo.
|
||||
* @return The resolved TypeInfo for the return type, or unresolved if not found
|
||||
*/
|
||||
public TypeInfo getReturnTypeInfo() {
|
||||
TypeInfo returnTypeInfo = TypeResolver.getInstance().resolve(returnType);
|
||||
if (returnTypeInfo == null) {
|
||||
returnTypeInfo = TypeInfo.unresolved(returnType, returnType);
|
||||
}
|
||||
return returnTypeInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the return type with dynamic arguments (for methods like Java.type).
|
||||
* @param arguments The method call arguments
|
||||
* @return The dynamically resolved TypeInfo, or static return type if no resolver
|
||||
*/
|
||||
public TypeInfo resolveReturnType(String[] arguments) {
|
||||
if (returnTypeResolver != null) {
|
||||
return returnTypeResolver.resolve(arguments);
|
||||
}
|
||||
return getReturnTypeInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MethodInfo from this synthetic method.
|
||||
*/
|
||||
|
||||
+15
@@ -1,5 +1,8 @@
|
||||
package noppes.npcs.client.gui.util.script.interpreter.type.synthetic;
|
||||
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.TypeInfo;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.TypeResolver;
|
||||
|
||||
public class SyntheticParameter {
|
||||
public final String name;
|
||||
public final String typeName;
|
||||
@@ -10,4 +13,16 @@ public class SyntheticParameter {
|
||||
this.typeName = typeName;
|
||||
this.documentation = documentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parameter type as TypeInfo.
|
||||
* @return The resolved TypeInfo for the parameter type, or unresolved if not found
|
||||
*/
|
||||
public TypeInfo getTypeInfo() {
|
||||
TypeInfo type = TypeResolver.getInstance().resolve(typeName);
|
||||
if (type == null) {
|
||||
type = TypeInfo.unresolved(typeName, typeName);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
+2
-11
@@ -2,12 +2,8 @@ package noppes.npcs.client.gui.util.script.interpreter.type.synthetic;
|
||||
|
||||
import noppes.npcs.client.gui.util.script.interpreter.method.MethodInfo;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.TypeInfo;
|
||||
import noppes.npcs.client.gui.util.script.interpreter.type.TypeResolver;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Represents a fully-built synthetic type.
|
||||
@@ -94,11 +90,6 @@ public class SyntheticType {
|
||||
if (method == null)
|
||||
return null;
|
||||
|
||||
if (method.returnTypeResolver != null) {
|
||||
return method.returnTypeResolver.resolve(arguments);
|
||||
}
|
||||
|
||||
// Fall back to static return type
|
||||
return TypeResolver.getInstance().resolve(method.returnType);
|
||||
return method.resolveReturnType(arguments);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user