Search in sources :

Example 1 with OverriderMethodUsageInfo

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

the class IntroduceParameterObjectProcessor method findUsages.

@Override
protected void findUsages(@NotNull List<FixableUsageInfo> usages) {
    if (myClassDescriptor.isUseExistingClass()) {
        myClassDescriptor.setExistingClassCompatibleConstructor(myClassDescriptor.findCompatibleConstructorInExistingClass(myMethod));
    }
    List<PsiNamedElement> methodHierarchy = new ArrayList<>();
    methodHierarchy.add(myMethod);
    for (UsageInfo info : ChangeSignatureProcessorBase.findUsages(myChangeInfo)) {
        if (info instanceof OverriderMethodUsageInfo) {
            methodHierarchy.add(((OverriderMethodUsageInfo) info).getOverridingMethod());
        }
        usages.add(new ChangeSignatureUsageWrapper(info));
    }
    final P[] paramsToMerge = myClassDescriptor.getParamsToMerge();
    for (PsiElement element : methodHierarchy) {
        final IntroduceParameterObjectDelegate delegate = IntroduceParameterObjectDelegate.findDelegate(element);
        if (delegate != null) {
            for (int i = 0; i < paramsToMerge.length; i++) {
                ReadWriteAccessDetector.Access access = delegate.collectInternalUsages(usages, (PsiNamedElement) element, myClassDescriptor, paramsToMerge[i], myMergedParameterInfo.getName());
                if (myAccessors[i] == null || access == ReadWriteAccessDetector.Access.Write) {
                    myAccessors[i] = access;
                }
            }
        }
    }
    myDelegate.collectUsagesToGenerateMissedFieldAccessors(usages, myMethod, myClassDescriptor, myAccessors);
    myDelegate.collectAdditionalFixes(usages, myMethod, myClassDescriptor);
}
Also used : PsiNamedElement(com.intellij.psi.PsiNamedElement) ArrayList(java.util.ArrayList) ReadWriteAccessDetector(com.intellij.codeInsight.highlighting.ReadWriteAccessDetector) UsageInfo(com.intellij.usageView.UsageInfo) OverriderMethodUsageInfo(com.intellij.refactoring.changeSignature.OverriderMethodUsageInfo) FixableUsageInfo(com.intellij.refactoring.util.FixableUsageInfo) OverriderMethodUsageInfo(com.intellij.refactoring.changeSignature.OverriderMethodUsageInfo) PsiElement(com.intellij.psi.PsiElement)

Aggregations

ReadWriteAccessDetector (com.intellij.codeInsight.highlighting.ReadWriteAccessDetector)1 PsiElement (com.intellij.psi.PsiElement)1 PsiNamedElement (com.intellij.psi.PsiNamedElement)1 OverriderMethodUsageInfo (com.intellij.refactoring.changeSignature.OverriderMethodUsageInfo)1 FixableUsageInfo (com.intellij.refactoring.util.FixableUsageInfo)1 UsageInfo (com.intellij.usageView.UsageInfo)1 ArrayList (java.util.ArrayList)1