Search in sources :

Example 6 with ParameterInfoImpl

use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.

the class IntroduceParameterObjectTest method doTestExistingClass.

private void doTestExistingClass(final String existingClassName, final String existingClassPackage, final boolean generateAccessors, final String newVisibility, final Function<PsiMethod, ParameterInfoImpl[]> function) throws Exception {
    doTest((rootDir, rootAfter) -> {
        PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(getProject()));
        if (aClass == null) {
            aClass = myJavaFacade.findClass("p2.Test", GlobalSearchScope.projectScope(getProject()));
        }
        assertNotNull("Class Test not found", aClass);
        final PsiMethod method = aClass.findMethodsByName("foo", false)[0];
        final ParameterInfoImpl[] mergedParams = function.fun(method);
        final JavaIntroduceParameterObjectClassDescriptor classDescriptor = new JavaIntroduceParameterObjectClassDescriptor(existingClassName, existingClassPackage, null, true, false, newVisibility, mergedParams, method, generateAccessors);
        final List<ParameterInfoImpl> parameters = new JavaMethodDescriptor(method).getParameters();
        IntroduceParameterObjectProcessor processor = new IntroduceParameterObjectProcessor<>(method, classDescriptor, parameters, false);
        processor.run();
        LocalFileSystem.getInstance().refresh(false);
        FileDocumentManager.getInstance().saveAllDocuments();
    });
}
Also used : JavaMethodDescriptor(com.intellij.refactoring.changeSignature.JavaMethodDescriptor) IntroduceParameterObjectProcessor(com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectProcessor) JavaIntroduceParameterObjectClassDescriptor(com.intellij.refactoring.introduceparameterobject.JavaIntroduceParameterObjectClassDescriptor) ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl)

Example 7 with ParameterInfoImpl

use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.

the class IntroduceParameterObjectTest method testCopyJavadoc1.

public void testCopyJavadoc1() throws Exception {
    doTest(false, true, 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)

Example 8 with ParameterInfoImpl

use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.

the class IntroduceParameterObjectTest method testTypeParametersWithChosenSubtype.

public void testTypeParametersWithChosenSubtype() throws Exception {
    doTest(false, true, psiMethod -> {
        final PsiParameter parameter = psiMethod.getParameterList().getParameters()[0];
        final PsiClass collectionClass = getJavaFacade().findClass(CommonClassNames.JAVA_UTIL_COLLECTION);
        final ParameterInfoImpl variableData = new ParameterInfoImpl(0, parameter.getName(), JavaPsiFacade.getElementFactory(getProject()).createType(collectionClass));
        return new ParameterInfoImpl[] { variableData };
    });
}
Also used : ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl)

Example 9 with ParameterInfoImpl

use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.

the class ChangeSignaturePropagationTest method generateParameterInfos.

private static ParameterInfoImpl[] generateParameterInfos(PsiMethod method, ParameterInfoImpl[] newParameters) {
    final PsiParameter[] parameters = method.getParameterList().getParameters();
    ParameterInfoImpl[] result = new ParameterInfoImpl[parameters.length + newParameters.length];
    for (int i = 0; i < parameters.length; i++) {
        result[i] = new ParameterInfoImpl(i);
    }
    System.arraycopy(newParameters, 0, result, parameters.length, newParameters.length);
    return result;
}
Also used : ParameterInfoImpl(com.intellij.refactoring.changeSignature.ParameterInfoImpl)

Example 10 with ParameterInfoImpl

use of com.intellij.refactoring.changeSignature.ParameterInfoImpl in project intellij-community by JetBrains.

the class ChangeSignatureTest method testDuplicatedSignatureInInheritor.

public void testDuplicatedSignatureInInheritor() throws Exception {
    try {
        doTest(null, new ParameterInfoImpl[] { new ParameterInfoImpl(-1, "i", PsiType.INT) }, true);
        fail("Conflict expected");
    } catch (BaseRefactoringProcessor.ConflictsInTestsException ignored) {
    }
}
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