Search in sources :

Example 1 with ParameterInfo

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

the class GroovyIntroduceParameterObjectDelegate method createMergedParameterInfo.

@Override
public GrParameterInfo createMergedParameterInfo(GroovyIntroduceObjectClassDescriptor descriptor, GrMethod method, List<GrParameterInfo> oldMethodParameters) {
    final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(method.getProject());
    PsiType classType = elementFactory.createTypeByFQClassName(StringUtil.getQualifiedName(descriptor.getPackageName(), descriptor.getClassName()));
    return new GrParameterInfo(descriptor.getClassName(), null, null, classType, -1, false) {

        @Nullable
        @Override
        public PsiElement getActualValue(PsiElement callExpression, Object substitutor) {
            final IntroduceParameterObjectDelegate<PsiNamedElement, ParameterInfo, IntroduceParameterObjectClassDescriptor<PsiNamedElement, ParameterInfo>> delegate = findDelegate(callExpression);
            return delegate != null ? delegate.createNewParameterInitializerAtCallSite(callExpression, descriptor, oldMethodParameters, substitutor) : null;
        }
    };
}
Also used : GroovyPsiElementFactory(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory) GrParameterInfo(org.jetbrains.plugins.groovy.refactoring.changeSignature.GrParameterInfo) PsiNamedElement(com.intellij.psi.PsiNamedElement) IntroduceParameterObjectClassDescriptor(com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectClassDescriptor) ParameterInfo(com.intellij.refactoring.changeSignature.ParameterInfo) GrParameterInfo(org.jetbrains.plugins.groovy.refactoring.changeSignature.GrParameterInfo) PsiElement(com.intellij.psi.PsiElement) PsiType(com.intellij.psi.PsiType)

Example 2 with ParameterInfo

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

the class IntroduceParameterObjectAction method getHandler.

protected RefactoringActionHandler getHandler(@NotNull DataContext context) {
    final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
    if (element == null) {
        return null;
    }
    final IntroduceParameterObjectDelegate<PsiNamedElement, ParameterInfo, IntroduceParameterObjectClassDescriptor<PsiNamedElement, ParameterInfo>> delegate = IntroduceParameterObjectDelegate.findDelegate(element);
    return delegate != null ? delegate.getHandler(element) : null;
}
Also used : PsiNamedElement(com.intellij.psi.PsiNamedElement) IntroduceParameterObjectClassDescriptor(com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectClassDescriptor) ParameterInfo(com.intellij.refactoring.changeSignature.ParameterInfo) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)2 PsiNamedElement (com.intellij.psi.PsiNamedElement)2 ParameterInfo (com.intellij.refactoring.changeSignature.ParameterInfo)2 IntroduceParameterObjectClassDescriptor (com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectClassDescriptor)2 PsiType (com.intellij.psi.PsiType)1 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)1 GrParameterInfo (org.jetbrains.plugins.groovy.refactoring.changeSignature.GrParameterInfo)1