Search in sources :

Example 1 with ReferencedElementsCollector

use of com.intellij.refactoring.inline.ReferencedElementsCollector in project intellij-community by JetBrains.

the class InlineSuperCallUsageInfo method getConflictMessage.

@Override
public String getConflictMessage() {
    final MultiMap<PsiElement, String> conflicts = new MultiMap<>();
    final PsiElement element = getElement();
    if (element instanceof PsiMethodCallExpression) {
        PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression) element;
        final PsiMethod superConstructor = methodCallExpression.resolveMethod();
        if (superConstructor != null) {
            InlineMethodProcessor.addInaccessibleMemberConflicts(superConstructor, new UsageInfo[] { new UsageInfo(methodCallExpression.getMethodExpression()) }, new ReferencedElementsCollector() {

                @Override
                protected void checkAddMember(@NotNull PsiMember member) {
                    if (!PsiTreeUtil.isAncestor(superConstructor.getContainingClass(), member, false)) {
                        super.checkAddMember(member);
                    }
                }
            }, conflicts);
            if (InlineMethodProcessor.checkBadReturns(superConstructor) && !InlineUtil.allUsagesAreTailCalls(superConstructor)) {
                conflicts.putValue(superConstructor, CommonRefactoringUtil.capitalize(RefactoringBundle.message("refactoring.is.not.supported.when.return.statement.interrupts.the.execution.flow", "") + " of super constructor"));
            }
        }
    }
    //todo
    return conflicts.isEmpty() ? null : conflicts.values().iterator().next();
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ReferencedElementsCollector(com.intellij.refactoring.inline.ReferencedElementsCollector) UsageInfo(com.intellij.usageView.UsageInfo) FixableUsageInfo(com.intellij.refactoring.util.FixableUsageInfo)

Aggregations

ReferencedElementsCollector (com.intellij.refactoring.inline.ReferencedElementsCollector)1 FixableUsageInfo (com.intellij.refactoring.util.FixableUsageInfo)1 UsageInfo (com.intellij.usageView.UsageInfo)1 MultiMap (com.intellij.util.containers.MultiMap)1