M
- method type parameter for which delegate would workP
- parameter info type, should correspond to the change signature's parameter info of the corresponding languageC
- IntroduceParameterObjectClassDescriptor's type which describes class of a new parameter to introduce:
parameters to merge, their order, names and types as well as new class location, etcpublic abstract class IntroduceParameterObjectDelegate<M extends PsiNamedElement,P extends ParameterInfo,C extends IntroduceParameterObjectClassDescriptor<M,P>>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static LanguageExtension<IntroduceParameterObjectDelegate> |
EP_NAME |
Constructor and Description |
---|
IntroduceParameterObjectDelegate() |
Modifier and Type | Method and Description |
---|---|
abstract void |
collectAdditionalFixes(java.util.Collection<? super FixableUsageInfo> usages,
M method,
C descriptor)
Collect in
usages necessary fixes to change visibility, javadocs, etc |
abstract void |
collectConflicts(MultiMap<PsiElement,java.lang.String> conflicts,
UsageInfo[] infos,
M method,
C classDescriptor)
Collect conflicts in
conflicts |
abstract <M1 extends PsiNamedElement,P1 extends ParameterInfo> |
collectInternalUsages(java.util.Collection<? super FixableUsageInfo> usages,
M overridingMethod,
IntroduceParameterObjectClassDescriptor<M1,P1> classDescriptor,
P1 parameterInfo,
java.lang.String mergedParamName)
Collect in usages reference to the parameter inside overridingMethod.
|
abstract void |
collectUsagesToGenerateMissedFieldAccessors(java.util.Collection<? super FixableUsageInfo> usages,
M method,
C descriptor,
ReadWriteAccessDetector.Access[] accessors)
Collect in
usages fixes to generate field's accessors. |
abstract ChangeInfo |
createChangeSignatureInfo(M method,
java.util.List<P> newParameterInfos,
boolean delegate)
Pass new parameter infos to the change info constructor which corresponds to the language of this delegate
|
abstract P |
createMergedParameterInfo(C descriptor,
M method,
java.util.List<? extends P> oldMethodParameters)
Resulted parameter info should implement
ParameterInfo.getActualValue(PsiElement, Object) so the call site would be updated with actual values. |
abstract PsiElement |
createNewParameterInitializerAtCallSite(PsiElement callExpression,
IntroduceParameterObjectClassDescriptor descriptor,
java.util.List<? extends ParameterInfo> oldMethodParameters,
java.lang.Object substitutor)
Call site should be updated according to the selected parameters, which correspond to the parameters to merge (
IntroduceParameterObjectClassDescriptor.getParamsToMerge() )
E.g. |
static <M extends PsiNamedElement,P extends ParameterInfo,C extends IntroduceParameterObjectClassDescriptor<M,P>> |
findDelegate(PsiElement element)
Find delegate by element language.
|
abstract java.util.List<P> |
getAllMethodParameters(M sourceMethod) |
abstract RefactoringActionHandler |
getHandler(PsiElement element)
Refactoring handler should choose which method to refactor based on element selected, e.g.
|
abstract boolean |
isEnabledOn(PsiElement element)
Used from
IntroduceParameterObjectAction
in order to detect if current element is inside method which is possible to refactor |
public static final LanguageExtension<IntroduceParameterObjectDelegate> EP_NAME
public static <M extends PsiNamedElement,P extends ParameterInfo,C extends IntroduceParameterObjectClassDescriptor<M,P>> IntroduceParameterObjectDelegate<M,P,C> findDelegate(PsiElement element)
public abstract boolean isEnabledOn(PsiElement element)
IntroduceParameterObjectAction
in order to detect if current element is inside method which is possible to refactorelement
- current element from DataContextpublic abstract RefactoringActionHandler getHandler(PsiElement element)
AbstractIntroduceParameterObjectDialog
should be implemented to start the refactoringpublic abstract java.util.List<P> getAllMethodParameters(M sourceMethod)
MethodDescriptor.getParameters()
public abstract P createMergedParameterInfo(C descriptor, M method, java.util.List<? extends P> oldMethodParameters)
ParameterInfo.getActualValue(PsiElement, Object)
so the call site would be updated with actual values.
At the same time, usages in another languages should be correctly proceed. In order to do that, usage's delegate should be found and
createNewParameterInitializerAtCallSite(PsiElement, IntroduceParameterObjectClassDescriptor, List, Object)
should be called to provide actual valuepublic abstract PsiElement createNewParameterInitializerAtCallSite(PsiElement callExpression, IntroduceParameterObjectClassDescriptor descriptor, java.util.List<? extends ParameterInfo> oldMethodParameters, java.lang.Object substitutor)
IntroduceParameterObjectClassDescriptor.getParamsToMerge()
)
E.g. for the call foo(a, b, c) and parameter class which corresponds to the first 2 parameters, actual value should represent foo(new P(a, b), c)substitutor
- should contain call substitutor before change signature replaced parameterspublic abstract ChangeInfo createChangeSignatureInfo(M method, java.util.List<P> newParameterInfos, boolean delegate)
public abstract <M1 extends PsiNamedElement,P1 extends ParameterInfo> ReadWriteAccessDetector.Access collectInternalUsages(java.util.Collection<? super FixableUsageInfo> usages, M overridingMethod, IntroduceParameterObjectClassDescriptor<M1,P1> classDescriptor, P1 parameterInfo, java.lang.String mergedParamName)
M1
- method type of the original delegateP1
- parameter info type of the original delegateusages
- collection to store usagesoverridingMethod
- method where usages would be searched.
As method could override method from another language,
overriding method defines the delegate to use though class descriptor could belong to another language.classDescriptor
- descriptor of the created classparameterInfo
- parameter which usages are collected.
parameterInfo#getOldIndex and overridingMethod should provide the real parameter to searchmergedParamName
- name for new parameter, chosen in createMergedParameterInfo(IntroduceParameterObjectClassDescriptor, PsiNamedElement, List)
ReadWriteAccessDetector.Access
. If write access is needed, both accessors are expected.public abstract void collectUsagesToGenerateMissedFieldAccessors(java.util.Collection<? super FixableUsageInfo> usages, M method, C descriptor, ReadWriteAccessDetector.Access[] accessors)
usages
fixes to generate field's accessors.
If collectInternalUsages(Collection, PsiNamedElement, IntroduceParameterObjectClassDescriptor, ParameterInfo, String)
returns @NotNull value, corresponding to the parameter field requires an accessor.
To detect what accessor is required, use accessors[descriptor.getParamsToMerge()[paramIdx].getOldIdx()]
public abstract void collectAdditionalFixes(java.util.Collection<? super FixableUsageInfo> usages, M method, C descriptor)
usages
necessary fixes to change visibility, javadocs, etcpublic abstract void collectConflicts(MultiMap<PsiElement,java.lang.String> conflicts, UsageInfo[] infos, M method, C classDescriptor)
conflicts