use of com.intellij.codeInsight.daemon.impl.quickfix.CreateMethodQuickFix in project intellij-community by JetBrains.
the class ParameterizedParametersStaticCollectionInspection method buildFix.
@Override
protected InspectionGadgetsFix buildFix(final Object... infos) {
return new InspectionGadgetsFix() {
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
final PsiElement element = descriptor.getPsiElement();
final PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
if (method != null && infos[1] instanceof PsiType) {
PsiType type = (PsiType) infos[1];
final ChangeSignatureProcessor csp = new ChangeSignatureProcessor(project, method, false, PsiModifier.PUBLIC, method.getName(), type, new ParameterInfoImpl[0]);
csp.run();
} else {
final PsiClass psiClass = PsiTreeUtil.getParentOfType(element, PsiClass.class);
if (psiClass != null) {
final CreateMethodQuickFix fix = CreateMethodQuickFix.createFix(psiClass, "@" + PARAMETERS_FQN + " public static java.util.Collection parameters()", "");
if (fix != null) {
fix.applyFix(project, descriptor);
}
}
}
}
@Override
@NotNull
public String getName() {
return infos.length > 0 ? (String) infos[0] : "Create @Parameterized.Parameters data provider";
}
@NotNull
@Override
public String getFamilyName() {
return "Fix data provider signature";
}
};
}
Aggregations