mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 20:07:32 +00:00
Added args to autocomplete methods and highlighted them in dark gray
This commit is contained in:
1 parent
82632d9131
commit
5163044494
2 files changed
+51
-5
No files matched your search
+21
-2
@@ -82,8 +82,23 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
|
||||
String signature = buildMethodSignature(method);
|
||||
|
||||
// Build display name with parameters like "read(byte[] b)"
|
||||
StringBuilder displayName = new StringBuilder(name);
|
||||
displayName.append("(");
|
||||
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() : "?";
|
||||
displayName.append(paramType);
|
||||
if (param.getName() != null && !param.getName().isEmpty()) {
|
||||
displayName.append(" ").append(param.getName());
|
||||
}
|
||||
}
|
||||
displayName.append(")");
|
||||
|
||||
return new AutocompleteItem(
|
||||
name,
|
||||
displayName.toString(),
|
||||
insertText.toString(),
|
||||
Kind.METHOD,
|
||||
returnType,
|
||||
@@ -165,8 +180,12 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
|
||||
insertText.append("(");
|
||||
insertText.append(")");
|
||||
|
||||
// Use signature for display name if available, otherwise just name
|
||||
String displayName = method.getSignature() != null && method.getSignature().contains("(") ?
|
||||
method.getSignature().substring(method.getSignature().indexOf(name)) : name + "()";
|
||||
|
||||
return new AutocompleteItem(
|
||||
name,
|
||||
displayName,
|
||||
insertText.toString(),
|
||||
Kind.METHOD,
|
||||
method.getReturnType(),
|
||||
|
||||
+30
-3
@@ -301,9 +301,14 @@ public class AutocompleteMenu extends Gui {
|
||||
font.drawString(icon, textX + (ICON_WIDTH - font.getStringWidth(icon)) / 2, textY, iconColor);
|
||||
textX += ICON_WIDTH;
|
||||
|
||||
// Draw name with match highlighting
|
||||
drawHighlightedText(item.getName(), item.getMatchIndices(), textX, textY,
|
||||
item.isDeprecated() ? DIM_TEXT_COLOR : TEXT_COLOR);
|
||||
// Draw name with match highlighting and parameter coloring for methods
|
||||
if (item.getKind() == AutocompleteItem.Kind.METHOD) {
|
||||
drawMethodName(item.getName(), item.getMatchIndices(), textX, textY,
|
||||
item.isDeprecated() ? DIM_TEXT_COLOR : TEXT_COLOR);
|
||||
} else {
|
||||
drawHighlightedText(item.getName(), item.getMatchIndices(), textX, textY,
|
||||
item.isDeprecated() ? DIM_TEXT_COLOR : TEXT_COLOR);
|
||||
}
|
||||
|
||||
// Draw type label on the right
|
||||
if (item.getTypeLabel() != null && !item.getTypeLabel().isEmpty()) {
|
||||
@@ -314,6 +319,28 @@ public class AutocompleteMenu extends Gui {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw method name with parameters colored gray.
|
||||
*/
|
||||
private void drawMethodName(String text, int[] matchIndices, int x, int y, int baseColor) {
|
||||
// Find the opening parenthesis
|
||||
int parenIndex = text.indexOf('(');
|
||||
if (parenIndex == -1) {
|
||||
// No parameters, just draw normally
|
||||
drawHighlightedText(text, matchIndices, x, y, baseColor);
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw method name part with highlighting
|
||||
String methodName = text.substring(0, parenIndex);
|
||||
drawHighlightedText(methodName, matchIndices, x, y, baseColor);
|
||||
|
||||
// Draw parameters part in gray (no highlighting)
|
||||
String params = text.substring(parenIndex);
|
||||
int paramX = x + font.getStringWidth(methodName);
|
||||
font.drawString(params, paramX, y, DIM_TEXT_COLOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text with specific characters highlighted.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user