use of com.intellij.codeInsight.intention.impl.ParameterClassMember in project intellij-community by JetBrains.
the class DefineParamsDefaultValueAction method getParams.
@Nullable
protected PsiParameter[] getParams(PsiElement element) {
final PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
assert method != null;
final PsiParameter[] parameters = method.getParameterList().getParameters();
if (parameters.length == 1) {
return parameters;
}
final ParameterClassMember[] members = new ParameterClassMember[parameters.length];
for (int i = 0; i < members.length; i++) {
members[i] = new ParameterClassMember(parameters[i]);
}
final PsiParameter selectedParam = PsiTreeUtil.getParentOfType(element, PsiParameter.class);
final int idx = selectedParam != null ? ArrayUtil.find(parameters, selectedParam) : -1;
if (ApplicationManager.getApplication().isUnitTestMode()) {
return idx >= 0 ? new PsiParameter[] { selectedParam } : null;
}
final MemberChooser<ParameterClassMember> chooser = new MemberChooser<>(members, false, true, element.getProject());
if (idx >= 0) {
chooser.selectElements(new ClassMember[] { members[idx] });
} else {
chooser.selectElements(members);
}
chooser.setTitle("Choose Default Value Parameters");
chooser.setCopyJavadocVisible(false);
if (chooser.showAndGet()) {
final List<ParameterClassMember> elements = chooser.getSelectedElements();
if (elements != null) {
PsiParameter[] params = new PsiParameter[elements.size()];
for (int i = 0; i < params.length; i++) {
params[i] = elements.get(i).getParameter();
}
return params;
}
}
return null;
}
Aggregations