@@ -0,0 +1,3073 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.%0Apackage com.intellij.codeInspection;%0A%0Aimport com.intellij.openapi.progress.ProgressManager;%0Aimport com.intellij.psi.PsiClass;%0Aimport com.intellij.psi.PsiClassType;%0Aimport com.intellij.psi.PsiElement;%0Aimport com.intellij.psi.PsiType;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;%0Aimport org.jetbrains.uast.*;%0A%0Apublic final class JvmAnalysisUastUtil %7B%0A  @Nullable%0A  public static UCallExpression getUCallExpression(@NotNull PsiElement element) %7B%0A    UCallExpression callExpression = UastContextKt.toUElement(element, UCallExpression.class);%0A    if (callExpression == null) %7B%0A      return null;%0A    %7D%0A    // workaround for duplicate warnings on the same element%0A    if (callExpression.getSourcePsi() != element) %7B%0A      return null;%0A    %7D%0A    return callExpression;%0A  %7D%0A%0A  @Nullable%0A  public static PsiElement getMethodIdentifierSourcePsi(@NotNull UCallExpression callExpression) %7B%0A    UIdentifier methodIdentifier = callExpression.getMethodIdentifier();%0A    if (methodIdentifier == null) %7B%0A      return null;%0A    %7D%0A    return methodIdentifier.getSourcePsi();%0A  %7D%0A%0A  @Nullable%0A  public static String getExpressionReturnTypePsiClassFqnName(@NotNull UCallExpression expression) %7B%0A    PsiClass psiClass = getTypePsiClass(expression.getReturnType());%0A    return psiClass == null ? null : psiClass.getQualifiedName();%0A  %7D%0A%0A  @Nullable%0A  public static PsiClass getTypePsiClass(@Nullable PsiType type) %7B%0A    if (!(type instanceof PsiClassType)) %7B%0A      return null;%0A    %7D%0A    return ((PsiClassType)type).rawType().resolve();%0A  %7D%0A%0A  //TODO use UastContext#isExpressionValueUsed ?%0A  public static boolean isExpressionResultValueUsed(@NotNull UCallExpression expression) %7B%0A    UElement currentParent = expression;%0A    while ((currentParent = currentParent.getUastParent()) != null) %7B%0A      ProgressManager.checkCanceled();%0A%0A      if (currentParent instanceof UReturnExpression %7C%7C%0A          currentParent instanceof ULocalVariable %7C%7C%0A          currentParent instanceof UField %7C%7C%0A          currentParent instanceof UBinaryExpression %7C%7C%0A          currentParent instanceof UCallExpression) %7B%0A        return true;%0A      %7D%0A%0A      // chain of calls%0A      if (currentParent instanceof UQualifiedReferenceExpression) %7B%0A        UExpression selector = ((UQualifiedReferenceExpression)currentParent).getSelector();%0A        if (selector instanceof UCallExpression && !selector.equals(expression)) %7B%0A          return true;%0A        %7D%0A      %7D%0A%0A      if (currentParent instanceof UMethod %7C%7C%0A          currentParent instanceof UClass %7C%7C%0A          currentParent instanceof UFile) %7B%0A        break; // no need to go further if we already on method/class/file level; result is not used.%0A      %7D%0A    %7D%0A%0A    //Kotlin expression-bodies (a workaround for KT-23557)%0A    if (currentParent instanceof UMethod && !(((UMethod)currentParent).getUastBody() instanceof UBlockExpression)) %7B%0A      return true;%0A    %7D%0A%0A    return false;%0A  %7D%0A%7D%0A

Introduce JvmAnalysisUastUtil, move everything from ReactorUastUtil here