use of com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectClassDescriptor 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;
}
};
}
use of com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectClassDescriptor 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;
}
use of com.intellij.refactoring.introduceParameterObject.IntroduceParameterObjectClassDescriptor in project intellij-community by JetBrains.
the class JavaIntroduceParameterObjectDelegate method createMergedParameterInfo.
@Override
public ParameterInfoImpl createMergedParameterInfo(JavaIntroduceParameterObjectClassDescriptor descriptor, PsiMethod method, List<ParameterInfoImpl> oldMethodParameters) {
final PsiCodeBlock body = method.getBody();
String baseParameterName = StringUtil.decapitalize(descriptor.getClassName());
final Project project = method.getProject();
if (!PsiNameHelper.getInstance(project).isIdentifier(baseParameterName, LanguageLevel.HIGHEST)) {
baseParameterName = StringUtil.fixVariableNameDerivedFromPropertyName(baseParameterName);
}
final String paramName = body != null ? JavaCodeStyleManager.getInstance(project).suggestUniqueVariableName(baseParameterName, body.getLBrace(), true) : JavaCodeStyleManager.getInstance(project).propertyNameToVariableName(baseParameterName, VariableKind.PARAMETER);
final String classTypeText = descriptor.createFakeClassTypeText();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
return new ParameterInfoImpl(-1, paramName, facade.getElementFactory().createTypeFromText(classTypeText, method), null) {
@Nullable
@Override
public PsiElement getActualValue(PsiElement exp, Object substitutor) {
final IntroduceParameterObjectDelegate<PsiNamedElement, ParameterInfo, IntroduceParameterObjectClassDescriptor<PsiNamedElement, ParameterInfo>> delegate = findDelegate(exp);
return delegate != null ? delegate.createNewParameterInitializerAtCallSite(exp, descriptor, oldMethodParameters, substitutor) : null;
}
};
}
Aggregations