Improved unimported autocomplete classes handling + colored gray

This commit is contained in:
bigguy345 committed 2026-03-11 14:08:28 +02:00
1 parent 09cbbe75c9
commit acaefbb68c
3 files changed
+28 -6

No files matched your search

@@ -61,7 +61,9 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
// Match scoring
private int matchScore = 0; // How well this matches the query
private int[] matchIndices; // Indices of matched characters for highlighting
private int color = -1;
private AutocompleteItem(String name, String searchName, String insertText, Kind kind, String typeLabel,
TypeInfo typeLabelTypeInfo, String signature, String documentation, Object sourceData,
boolean deprecated, boolean requiresImport, String importPath, int inheritanceDepth) {
@@ -597,7 +599,8 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
public String getImportPath() { return importPath; }
public int getMatchScore() { return matchScore; }
public int[] getMatchIndices() { return matchIndices; }
public int getColor() { return color; };
public AutocompleteItem setColor(int col){ this.color = col;return this; }
/**
* Get the display name for a type, including generic arguments.
* Uses the unified getDisplayName() method which handles:
@@ -757,12 +760,14 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
private String insertText;
private Kind kind = Kind.FIELD;
private String typeLabel = "";
private TypeInfo typeInfo;
private String signature;
private String documentation;
private Object sourceData;
private boolean deprecated = false;
private boolean requiresImport = false;
private String importPath = null;
private int color = -1;
public Builder name(String name) {
this.name = name;
@@ -788,6 +793,11 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
this.typeLabel = typeLabel;
return this;
}
public Builder typeInfo(TypeInfo typeInfo) {
this.typeInfo = typeInfo;
return this;
}
public Builder signature(String signature) {
this.signature = signature;
@@ -818,13 +828,18 @@ public class AutocompleteItem implements Comparable<AutocompleteItem> {
this.importPath = importPath;
return this;
}
public Builder color(int color) {
this.color = color;
return this;
}
public AutocompleteItem build() {
if (insertText == null) {
insertText = name;
}
return new AutocompleteItem(name, searchName, insertText, kind, typeLabel,
null, signature, documentation, sourceData, deprecated, requiresImport, importPath, -1);
typeInfo, signature, documentation, sourceData, deprecated, requiresImport, importPath, -1).setColor(color);
}
}
}
@@ -459,11 +459,15 @@ public class AutocompleteMenu extends Gui {
TypeInfo type = item.getTypeInfo();
int col = type != null ? type.getTokenType().getHexColor() : DIM_TEXT_COLOR;
drawTypeLabel(typeLabel, typeLabelX, textY, col, type);
drawTypeLabel(item, typeLabel, typeLabelX, textY, col, type);
}
}
public int getColor(AutocompleteItem item) {
int col = item.getColor();
if (col != -1)
return col;
if (item.isInheritedObjectMethod() || item.isDeprecated())
return DIM_TEXT_COLOR;
@@ -631,8 +635,8 @@ public class AutocompleteMenu extends Gui {
return text;
}
private void drawTypeLabel(String typeLabel, int x, int y, int typeColor, TypeInfo typeInfo) {
if (typeInfo == null) {
private void drawTypeLabel(AutocompleteItem item, String typeLabel, int x, int y, int typeColor, TypeInfo typeInfo) {
if (typeInfo == null || item.getKind() == AutocompleteItem.Kind.CLASS) { //draw package on right
drawSimpleTypeWithArraySuffix(typeLabel, x, y, typeColor);
return;
}
@@ -4,6 +4,7 @@ import noppes.npcs.client.gui.util.script.interpreter.ScriptDocument;
import noppes.npcs.client.gui.util.script.interpreter.field.EnumConstantInfo;
import noppes.npcs.client.gui.util.script.interpreter.field.FieldInfo;
import noppes.npcs.client.gui.util.script.interpreter.method.MethodInfo;
import noppes.npcs.client.gui.util.script.interpreter.token.TokenType;
import noppes.npcs.client.gui.util.script.interpreter.type.ScriptTypeInfo;
import noppes.npcs.client.gui.util.script.interpreter.type.TypeChecker;
import noppes.npcs.client.gui.util.script.interpreter.type.TypeInfo;
@@ -434,10 +435,12 @@ public class JavaAutocompleteProvider implements AutocompleteProvider {
.kind(type.getKind() == TypeInfo.Kind.ENUM ?
AutocompleteItem.Kind.ENUM : AutocompleteItem.Kind.CLASS)
.typeLabel(type.getPackageName())
.typeInfo(type)
.signature(type.getFullName())
.sourceData(type)
.requiresImport(true)
.importPath(fullName)
.color(TokenType.UNUSED_IMPORT.getHexColor())
.build();
items.add(item);
existingSimpleNames.add(type.getSimpleName());