use of com.intellij.codeInsight.lookup.LookupManager in project intellij-community by JetBrains.
the class ChangeTo method applyFix.
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement element = descriptor.getPsiElement();
if (element == null)
return;
Editor editor = PsiUtilBase.findEditor(element);
if (editor == null) {
return;
}
TextRange textRange = ((ProblemDescriptorBase) descriptor).getTextRange();
editor.getSelectionModel().setSelection(textRange.getStartOffset(), textRange.getEndOffset());
String word = editor.getSelectionModel().getSelectedText();
if (word == null || StringUtil.isEmpty(word)) {
return;
}
List<LookupElement> lookupItems = new ArrayList<>();
for (String variant : getSuggestions(project)) {
lookupItems.add(LookupElementBuilder.create(variant));
}
LookupElement[] items = new LookupElement[lookupItems.size()];
items = lookupItems.toArray(items);
LookupManager lookupManager = LookupManager.getInstance(project);
lookupManager.showLookup(editor, items);
}
Aggregations