Search in sources :

Example 31 with ParameterInfoImpl

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");
}
Also used : ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl) HashSet(java.util.HashSet) ChangeSignatureProcessor(com.intellij.refactoring.changeSignature.ChangeSignatureProcessor)

Example 32 with ParameterInfoImpl

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");
}
Also used : ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl) HashSet(java.util.HashSet) ChangeSignatureProcessor(com.intellij.refactoring.changeSignature.ChangeSignatureProcessor)

Example 33 with ParameterInfoImpl

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;
}
Also used : ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl)

Example 34 with ParameterInfoImpl

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;
    });
}
Also used : ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl)

Aggregations

ParameterInfoImpl (com.intellij.refactoring.changeSignature.ParameterInfoImpl)34 ArrayList (java.util.ArrayList)10 ChangeSignatureProcessor (com.intellij.refactoring.changeSignature.ChangeSignatureProcessor)6 NotNull (org.jetbrains.annotations.NotNull)5 Nullable (org.jetbrains.annotations.Nullable)5 JavaCodeStyleManager (com.intellij.psi.codeStyle.JavaCodeStyleManager)4 JavaChangeSignatureDialog (com.intellij.refactoring.changeSignature.JavaChangeSignatureDialog)4 HashSet (java.util.HashSet)3 JavaChangeInfoImpl (com.intellij.refactoring.changeSignature.JavaChangeInfoImpl)2 JavaMethodDescriptor (com.intellij.refactoring.changeSignature.JavaMethodDescriptor)2 ThrownExceptionInfo (com.intellij.refactoring.changeSignature.ThrownExceptionInfo)2 IntroduceParameterObjectProcessor (com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectProcessor)2 JavaIntroduceParameterObjectClassDescriptor (com.intellij.refactoring.introduceparameterobject.JavaIntroduceParameterObjectClassDescriptor)2 UsageInfo (com.intellij.usageView.UsageInfo)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 LocalQuickFixAndIntentionActionOnPsiElement (com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement)1 FindUsagesHandler (com.intellij.find.findUsages.FindUsagesHandler)1 FindUsagesManager (com.intellij.find.findUsages.FindUsagesManager)1 JavaMethodFindUsagesOptions (com.intellij.find.findUsages.JavaMethodFindUsagesOptions)1 FindManagerImpl (com.intellij.find.impl.FindManagerImpl)1