mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AddMethodQualifierFix prevent IOOBE in getText()
This commit is contained in:
+9
-6
@@ -51,8 +51,11 @@ public class AddMethodQualifierFix implements IntentionAction {
|
||||
@Override
|
||||
public String getText() {
|
||||
final List<PsiVariable> candidates = getOrFindCandidates();
|
||||
if (candidates.isEmpty()) {
|
||||
return getFamilyName();
|
||||
}
|
||||
String text = QuickFixBundle.message("add.method.qualifier.fix.text", candidates.size() > 1 ? "" : candidates.get(0).getName());
|
||||
if (myCandidates.size() > 1) {
|
||||
if (candidates.size() > 1) {
|
||||
text += "...";
|
||||
}
|
||||
return text;
|
||||
@@ -61,7 +64,7 @@ public class AddMethodQualifierFix implements IntentionAction {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return getText();
|
||||
return QuickFixBundle.message("add.method.qualifier.fix.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +111,7 @@ public class AddMethodQualifierFix implements IntentionAction {
|
||||
|
||||
@TestOnly
|
||||
public List<PsiVariable> getCandidates() {
|
||||
return myCandidates;
|
||||
return getOrFindCandidates();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,8 +119,8 @@ public class AddMethodQualifierFix implements IntentionAction {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(file)) {
|
||||
return;
|
||||
}
|
||||
if (myCandidates.size() == 1 || UNIT_TEST_MODE) {
|
||||
qualify(myCandidates.get(0), editor);
|
||||
if (getOrFindCandidates().size() == 1 || UNIT_TEST_MODE) {
|
||||
qualify(getOrFindCandidates().get(0), editor);
|
||||
}
|
||||
else {
|
||||
chooseAndQualify(editor);
|
||||
@@ -126,7 +129,7 @@ public class AddMethodQualifierFix implements IntentionAction {
|
||||
|
||||
private void chooseAndQualify(final Editor editor) {
|
||||
final BaseListPopupStep<PsiVariable> step =
|
||||
new BaseListPopupStep<PsiVariable>(QuickFixBundle.message("add.qualifier"), myCandidates) {
|
||||
new BaseListPopupStep<PsiVariable>(QuickFixBundle.message("add.qualifier"), getOrFindCandidates()) {
|
||||
@Override
|
||||
public PopupStep onChosen(final PsiVariable selectedValue, final boolean finalChoice) {
|
||||
if (selectedValue != null && finalChoice) {
|
||||
|
||||
@@ -269,6 +269,7 @@ add.missing.annotation.parameters.fix=Add missing annotation parameters - {0}
|
||||
add.missing.annotation.single.parameter.fix=Add missing annotation parameter ''{0}''
|
||||
|
||||
add.method.qualifier.fix.text=Add qualifier {0} to method
|
||||
add.method.qualifier.fix.family=Add method qualifier
|
||||
|
||||
collection.addall.can.be.replaced.with.constructor.fix.options.title=Classes to check
|
||||
collection.addall.can.be.replaced.with.constructor.fix.description=''{0}()'' method can be replaced with parametrized constructor
|
||||
|
||||
Reference in New Issue
Block a user