Search in sources :

Example 1 with IntroduceParameterObjectProcessor

use of com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectProcessor in project intellij-community by JetBrains.

the class IntroduceParameterObjectTest method doTest.

private void doTest(final boolean delegate, final boolean createInner, final Function<PsiMethod, ParameterInfoImpl[]> function) throws Exception {
    doTest((rootDir, rootAfter) -> {
        PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(getProject()));
        assertNotNull("Class Test not found", aClass);
        final PsiMethod method = aClass.findMethodsByName("foo", false)[0];
        final ParameterInfoImpl[] datas = function.fun(method);
        final JavaIntroduceParameterObjectClassDescriptor classDescriptor = new JavaIntroduceParameterObjectClassDescriptor("Param", "", null, false, createInner, null, datas, method, false);
        final List<ParameterInfoImpl> parameters = new JavaMethodDescriptor(method).getParameters();
        IntroduceParameterObjectProcessor processor = new IntroduceParameterObjectProcessor<>(method, classDescriptor, parameters, delegate);
        processor.run();
    });
}
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 2 with IntroduceParameterObjectProcessor

use of com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectProcessor 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)

Aggregations

JavaMethodDescriptor (com.intellij.refactoring.changeSignature.JavaMethodDescriptor)2 ParameterInfoImpl (com.intellij.refactoring.changeSignature.ParameterInfoImpl)2 IntroduceParameterObjectProcessor (com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectProcessor)2 JavaIntroduceParameterObjectClassDescriptor (com.intellij.refactoring.introduceparameterobject.JavaIntroduceParameterObjectClassDescriptor)2