use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.
the class ChangeSignatureTest method testPropagateParameter.
public void testPropagateParameter() {
String basePath = getRelativePath() + getTestName(false);
configureByFile(basePath + ".java");
final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue("<caret> is not on method name", targetElement instanceof PsiMethod);
PsiMethod method = (PsiMethod) targetElement;
final PsiClass containingClass = method.getContainingClass();
assertTrue(containingClass != null);
final PsiMethod[] callers = containingClass.findMethodsByName("caller", false);
assertTrue(callers.length > 0);
final PsiMethod caller = callers[0];
final HashSet<PsiMethod> propagateParametersMethods = new HashSet<>();
propagateParametersMethods.add(caller);
final PsiParameter[] parameters = method.getParameterList().getParameters();
new ChangeSignatureProcessor(getProject(), method, false, null, method.getName(), CanonicalTypes.createTypeWrapper(PsiType.VOID), new ParameterInfoImpl[] { new ParameterInfoImpl(0, parameters[0].getName(), parameters[0].getType()), new ParameterInfoImpl(-1, "b", PsiType.BOOLEAN) }, null, propagateParametersMethods, null).run();
checkResultByFile(basePath + "_after.java");
}
use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.
the class ChangeSignatureTest method testPropagateParameterWithOverrider.
public void testPropagateParameterWithOverrider() {
String basePath = getRelativePath() + getTestName(false);
configureByFile(basePath + ".java");
final PsiElement targetElement = TargetElementUtil.findTargetElement(getEditor(), TargetElementUtil.ELEMENT_NAME_ACCEPTED);
assertTrue("<caret> is not on method name", targetElement instanceof PsiMethod);
PsiMethod method = (PsiMethod) targetElement;
final PsiClass containingClass = method.getContainingClass();
assertTrue(containingClass != null);
final PsiMethod[] callers = containingClass.findMethodsByName("caller", false);
assertTrue(callers.length > 0);
final PsiMethod caller = callers[0];
final HashSet<PsiMethod> propagateParametersMethods = new HashSet<>();
propagateParametersMethods.add(caller);
final PsiParameter[] parameters = method.getParameterList().getParameters();
new ChangeSignatureProcessor(getProject(), method, false, null, method.getName(), CanonicalTypes.createTypeWrapper(PsiType.VOID), new ParameterInfoImpl[] { new ParameterInfoImpl(0, parameters[0].getName(), parameters[0].getType()), new ParameterInfoImpl(-1, "b", PsiType.BOOLEAN, "true") }, null, propagateParametersMethods, null).run();
checkResultByFile(basePath + "_after.java");
}
use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.
the class IntroduceParameterObjectTest method generateParams.
private static ParameterInfoImpl[] generateParams(final PsiMethod method) {
final PsiParameter[] parameters = method.getParameterList().getParameters();
final ParameterInfoImpl[] datas = new ParameterInfoImpl[parameters.length];
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
datas[i] = new ParameterInfoImpl(i, parameter.getName(), parameter.getType());
}
return datas;
}
use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.
the class IntroduceParameterObjectTest method testSameTypeAndVarargs.
public void testSameTypeAndVarargs() throws Exception {
doTest(false, false, method -> {
final PsiParameter[] parameters = method.getParameterList().getParameters();
final ParameterInfoImpl[] datas = new ParameterInfoImpl[parameters.length - 1];
for (int i = 0; i < parameters.length - 1; i++) {
PsiParameter parameter = parameters[i];
datas[i] = new ParameterInfoImpl(i, parameter.getName(), parameter.getType());
}
return datas;
});
}
Aggregations