mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 23:37:32 +00:00
proper JS type names in HoverInfo/Autocomplete
instead of "InitEvent", now its "INpcEvent.InitEvent"
This commit is contained in:
1 parent
92a196d296
commit
9c222b89d4
2 files changed
+36
-28
No files matched your search
+18
-14
@@ -86,8 +86,8 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
}
|
||||
insertText.append(")");
|
||||
|
||||
String returnType = method.getReturnType() != null ?
|
||||
method.getReturnType().getSimpleName() : "void";
|
||||
String returnType = method.getReturnType() != null ?
|
||||
getName(method.getReturnType()) : "void";
|
||||
|
||||
String signature = buildMethodSignature(method);
|
||||
|
||||
@@ -97,8 +97,8 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
for (int i = 0; i < method.getParameterCount(); i++) {
|
||||
if (i > 0) displayName.append(", ");
|
||||
FieldInfo param = method.getParameters().get(i);
|
||||
String paramType = param.getTypeInfo() != null ?
|
||||
param.getTypeInfo().getSimpleName() : "?";
|
||||
String paramType = param.getTypeInfo() != null ?
|
||||
getName(param.getTypeInfo()) : "?";
|
||||
displayName.append(paramType);
|
||||
if (param.getName() != null && !param.getName().isEmpty()) {
|
||||
displayName.append(" ").append(param.getName());
|
||||
@@ -125,8 +125,8 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
* Create from a Java FieldInfo.
|
||||
*/
|
||||
public static AutocompleteItem fromField(FieldInfo field) {
|
||||
String typeLabel = field.getTypeInfo() != null ?
|
||||
field.getTypeInfo().getSimpleName() : "?";
|
||||
String typeLabel = field.getTypeInfo() != null ?
|
||||
getName(field.getTypeInfo()) : "?";
|
||||
|
||||
Kind kind;
|
||||
switch (field.getScope()) {
|
||||
@@ -173,11 +173,11 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
default:
|
||||
kind = Kind.CLASS;
|
||||
}
|
||||
|
||||
String name = getName(type);
|
||||
return new AutocompleteItem(
|
||||
type.getSimpleName(),
|
||||
type.getSimpleName(), // searchName same as display name for types
|
||||
type.getSimpleName(),
|
||||
name,
|
||||
name, // searchName same as display name for types
|
||||
name,
|
||||
kind,
|
||||
type.getPackageName(),
|
||||
type.getFullName(),
|
||||
@@ -259,15 +259,15 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
|
||||
private static String buildMethodSignature(MethodInfo method) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String returnType = method.getReturnType() != null ?
|
||||
method.getReturnType().getSimpleName() : "void";
|
||||
String returnType = method.getReturnType() != null ?
|
||||
getName(method.getReturnType()) : "void";
|
||||
sb.append(returnType).append(" ").append(method.getName()).append("(");
|
||||
|
||||
for (int i = 0; i < method.getParameterCount(); i++) {
|
||||
if (i > 0) sb.append(", ");
|
||||
FieldInfo param = method.getParameters().get(i);
|
||||
String paramType = param.getTypeInfo() != null ?
|
||||
param.getTypeInfo().getSimpleName() : "?";
|
||||
String paramType = param.getTypeInfo() != null ?
|
||||
getName(param.getTypeInfo()) : "?";
|
||||
sb.append(paramType).append(" ").append(param.getName());
|
||||
}
|
||||
|
||||
@@ -396,6 +396,10 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
public int getMatchScore() { return matchScore; }
|
||||
public int[] getMatchIndices() { return matchIndices; }
|
||||
|
||||
public static String getName(TypeInfo type) {
|
||||
return type.isJSType() ? type.getFullName() : type.getSimpleName();
|
||||
}
|
||||
|
||||
public int getParameterCount() {
|
||||
if (sourceData instanceof MethodInfo) {
|
||||
return ((MethodInfo) sourceData).getParameterCount();
|
||||
|
||||
+18
-14
@@ -509,7 +509,7 @@ public class TokenHoverInfo {
|
||||
int classColor = clazz.isInterface() ? TokenType.INTERFACE_DECL.getHexColor()
|
||||
: clazz.isEnum() ? TokenType.ENUM_DECL.getHexColor()
|
||||
: TokenType.IMPORTED_CLASS.getHexColor();
|
||||
addSegment(typeInfo.getSimpleName(), classColor);
|
||||
addSegment(getName(typeInfo), classColor);
|
||||
|
||||
// Extends
|
||||
Class<?> superclass = clazz.getSuperclass();
|
||||
@@ -568,7 +568,7 @@ public class TokenHoverInfo {
|
||||
int classColor = scriptType.getKind() == TypeInfo.Kind.INTERFACE ? TokenType.INTERFACE_DECL.getHexColor()
|
||||
: scriptType.getKind() == TypeInfo.Kind.ENUM ? TokenType.ENUM_DECL.getHexColor()
|
||||
: TokenType.IMPORTED_CLASS.getHexColor();
|
||||
addSegment(typeInfo.getSimpleName(), classColor);
|
||||
addSegment(getName(typeInfo), classColor);
|
||||
|
||||
// Extends clause for ScriptTypeInfo
|
||||
if (scriptType.hasSuperClass()) {
|
||||
@@ -576,7 +576,7 @@ public class TokenHoverInfo {
|
||||
TypeInfo superClass = scriptType.getSuperClass();
|
||||
if (superClass != null && superClass.isResolved()) {
|
||||
// Color based on resolved type
|
||||
addSegment(superClass.getSimpleName(), getColorForTypeInfo(superClass));
|
||||
addSegment(getName(superClass), getColorForTypeInfo(superClass));
|
||||
} else {
|
||||
// Unresolved - show the raw name in undefined color
|
||||
String superName = scriptType.getSuperClassName();
|
||||
@@ -603,7 +603,7 @@ public class TokenHoverInfo {
|
||||
if (i > 0) addSegment(", ", TokenType.DEFAULT.getHexColor());
|
||||
|
||||
TypeInfo ifaceType = implementedInterfaces.get(i);
|
||||
String ifaceName = (i < interfaceNames.size()) ? interfaceNames.get(i) : ifaceType.getSimpleName();
|
||||
String ifaceName = (i < interfaceNames.size()) ? interfaceNames.get(i) : getName(ifaceType);
|
||||
|
||||
if (ifaceType != null && ifaceType.isResolved()) {
|
||||
addSegment(ifaceName, getColorForTypeInfo(ifaceType));
|
||||
@@ -632,9 +632,9 @@ public class TokenHoverInfo {
|
||||
} else {
|
||||
// Unresolved type
|
||||
iconIndicator = "?";
|
||||
addSegment(typeInfo.getSimpleName(), TokenType.IMPORTED_CLASS.getHexColor());
|
||||
addSegment(getName(typeInfo), TokenType.IMPORTED_CLASS.getHexColor());
|
||||
if (!typeInfo.isResolved()) {
|
||||
errors.add("Cannot resolve class '" + typeInfo.getSimpleName() + "'");
|
||||
errors.add("Cannot resolve class '" + getName(typeInfo) + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,7 +759,7 @@ public class TokenHoverInfo {
|
||||
|
||||
// Type - check for actual type color
|
||||
int typeColor = getColorForTypeInfo(declaredType);
|
||||
addSegment(declaredType.getSimpleName(), typeColor);
|
||||
addSegment(getName(declaredType), typeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
}
|
||||
|
||||
@@ -800,7 +800,7 @@ public class TokenHoverInfo {
|
||||
|
||||
// Type (enum type name)
|
||||
int typeColor = getColorForTypeInfo(enumType);
|
||||
addSegment(enumType.getSimpleName(), typeColor);
|
||||
addSegment(getName(enumType), typeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ public class TokenHoverInfo {
|
||||
TypeInfo declaredType = fieldInfo.getDeclaredType();
|
||||
if (declaredType != null) {
|
||||
int typeColor = getColorForTypeInfo(declaredType);
|
||||
addSegment(declaredType.getSimpleName(), typeColor);
|
||||
addSegment(getName(declaredType), typeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
}
|
||||
|
||||
@@ -850,7 +850,7 @@ public class TokenHoverInfo {
|
||||
return fullName;
|
||||
} else {
|
||||
String pkg = type.getPackageName();
|
||||
String className = type.getSimpleName();
|
||||
String className = getName(type);
|
||||
if (pkg != null && !pkg.isEmpty()) {
|
||||
return pkg + "." + className;
|
||||
} else {
|
||||
@@ -876,7 +876,7 @@ public class TokenHoverInfo {
|
||||
TypeInfo declaredType = fieldInfo.getDeclaredType();
|
||||
if (declaredType != null) {
|
||||
int typeColor = getColorForTypeInfo(declaredType);
|
||||
addSegment(declaredType.getSimpleName(), typeColor);
|
||||
addSegment(getName(declaredType), typeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
}
|
||||
|
||||
@@ -889,6 +889,10 @@ public class TokenHoverInfo {
|
||||
iconIndicator = "?";
|
||||
//addSegment(token.getText(), TokenType.UNDEFINED_VAR.getHexColor());
|
||||
}
|
||||
|
||||
public String getName(TypeInfo type){
|
||||
return type.isJSType()? type.getFullName() : type.getSimpleName();
|
||||
}
|
||||
|
||||
private void extractFieldInfoGeneric(Token token) {
|
||||
FieldInfo fieldInfo = token.getFieldInfo();
|
||||
@@ -927,7 +931,7 @@ public class TokenHoverInfo {
|
||||
TypeInfo paramType = param.getDeclaredType();
|
||||
if (paramType != null) {
|
||||
int paramTypeColor = getColorForTypeInfo(paramType);
|
||||
addSegment(paramType.getSimpleName(), paramTypeColor);
|
||||
addSegment(getName(paramType), paramTypeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
}
|
||||
addSegment(param.getName(), TokenType.PARAMETER.getHexColor());
|
||||
@@ -1006,7 +1010,7 @@ public class TokenHoverInfo {
|
||||
TypeInfo returnType = methodInfo.getReturnType();
|
||||
if (returnType != null) {
|
||||
int returnTypeColor = getColorForTypeInfo(returnType);
|
||||
addSegment(returnType.getSimpleName(), returnTypeColor);
|
||||
addSegment(getName(returnType), returnTypeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
} else {
|
||||
addSegment("void ", TokenType.KEYWORD.getHexColor());
|
||||
@@ -1024,7 +1028,7 @@ public class TokenHoverInfo {
|
||||
TypeInfo paramType = param.getDeclaredType();
|
||||
if (paramType != null) {
|
||||
int paramTypeColor = getColorForTypeInfo(paramType);
|
||||
addSegment(paramType.getSimpleName(), paramTypeColor);
|
||||
addSegment(getName(paramType), paramTypeColor);
|
||||
addSegment(" ", TokenType.DEFAULT.getHexColor());
|
||||
}
|
||||
addSegment(param.getName(), TokenType.PARAMETER.getHexColor());
|
||||
|
||||
Reference in new issue
Block a user