Package edu.umd.cs.findbugs.gui2
Class ClassSearchAutoComplete
java.lang.Object
edu.umd.cs.findbugs.gui2.ClassSearchAutoComplete
Provides auto-completion functionality for the class name search filter in
the GUI.
Displays matching class names and simple names dynamically as the user types.
-
Constructor Summary
ConstructorsConstructorDescriptionClassSearchAutoComplete(JTextField textField, Supplier<Collection<String>> candidateSupplier) Creates and attaches auto-completion support to the given text field. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassSearchAutoCompleteattach(JTextField textField, MainFrame mainFrame) Attaches auto-completion support configured with the MainFrame's bug collection.computeSuggestions(String token, Collection<String> candidates, int maxResults) Computes suggestions for the given token from the candidate collection.static int[]findCurrentTokenRange(String text, int caretPos) Finds the start and end indices of the token surrounding the given caret position.getAvailableClassNames(MainFrame mainFrame) Extracts all unique class names (full qualified and simple names) from the bug collection.static StringreplaceTokenAtRange(String text, int start, int end, String replacement) Replaces the substring from start to end with the given replacement string.
-
Constructor Details
-
ClassSearchAutoComplete
public ClassSearchAutoComplete(JTextField textField, Supplier<Collection<String>> candidateSupplier) Creates and attaches auto-completion support to the given text field.- Parameters:
textField- the search text fieldcandidateSupplier- supplier providing available candidate class names
-
-
Method Details
-
attach
Attaches auto-completion support configured with the MainFrame's bug collection.- Parameters:
textField- the search text fieldmainFrame- the main frame instance- Returns:
- the initialized ClassSearchAutoComplete instance
-
getAvailableClassNames
Extracts all unique class names (full qualified and simple names) from the bug collection.- Parameters:
mainFrame- the main frame instance- Returns:
- set of available class names
-
findCurrentTokenRange
Finds the start and end indices of the token surrounding the given caret position. Tokens are separated by whitespace, comma, or colon.- Parameters:
text- the entire input stringcaretPos- current caret position- Returns:
- an int array of size 2 containing [startIndex, endIndex]
-
replaceTokenAtRange
Replaces the substring from start to end with the given replacement string.- Parameters:
text- original textstart- start indexend- end indexreplacement- replacement string- Returns:
- updated string
-
computeSuggestions
public static List<String> computeSuggestions(String token, Collection<String> candidates, int maxResults) Computes suggestions for the given token from the candidate collection. Suggestions are prioritized: prefix matches > substring matches > fuzzy matches.- Parameters:
token- current query tokencandidates- available class name candidatesmaxResults- maximum number of suggestions to return- Returns:
- ordered list of suggestions
-