@Nullable
  private static SourcePosition getSourcePositionForField(@NotNull FieldDescriptor descriptor,
                                                          @NotNull Project project,
                                                          @NotNull DebuggerContextImpl context,
                                                          boolean nearest) {
    final ReferenceType type = descriptor.getField().declaringType();
    final String fieldName = descriptor.getField().name();
    if (fieldName.startsWith(FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) {
      // this field actually mirrors a local variable in the outer class
      String varName = fieldName.substring(fieldName.lastIndexOf('$') + 1);
      PsiElement element = PositionUtil.getContextElement(context);
      if (element == null) {
        return null;
      }
      PsiClass aClass = PsiTreeUtil.getParentOfType(element, PsiClass.class, false);
      if (aClass == null) {
        return null;
      }
      PsiElement navigationElement = aClass.getNavigationElement();
      if (!(navigationElement instanceof PsiClass)) {
        return null;
      }
      aClass = (PsiClass)navigationElement;
      PsiVariable psiVariable = JavaPsiFacade.getInstance(project).getResolveHelper().resolveReferencedVariable(varName, aClass);
      if (psiVariable == null) {
        return null;
      }
      if (nearest) {
        return DebuggerContextUtil.findNearest(context, psiVariable, aClass.getContainingFile());
      }
      return SourcePosition.createFromElement(psiVariable);
    }
    else {
      PsiClass aClass = null;
      DebugProcessImpl debugProcess = context.getDebugProcess();
      if (debugProcess != null) {
        try {
          // important: use the last location to be sure the position will be within the anonymous class
          // and do not use type.allLineLocations as it fetches line tables for all methods
          List<Method> methods = type.methods();
          for (int i = methods.size() - 1; i >= 0; i--) {
            List<Location> locations = methods.get(i).allLineLocations();
            if (!locations.isEmpty()) {
              aClass = JVMNameUtil.getClassAt(debugProcess.getPositionManager().getSourcePosition(ContainerUtil.getLastItem(locations)));
              break;
            }
          }
        }
        catch (AbsentInformationException | ClassNotPreparedException ignored) {
        }
      }

      if (aClass == null) { // fallback
        DebuggerSession session = context.getDebuggerSession();
        GlobalSearchScope scope = session != null ? session.getSearchScope() : GlobalSearchScope.allScope(project);
        aClass = DebuggerUtils.findClass(type.name(), project, scope);
      }

      if (aClass != null) {
        PsiField field = aClass.findFieldByName(fieldName, false);
        if (field == null) return null;
        if (nearest) {
          return DebuggerContextUtil.findNearest(context, field.getNavigationElement(), aClass.getContainingFile());
        }
        return SourcePosition.createFromElement(field);
      }
      return null;
    }
  }
@Nullable
  private static SourcePosition getSourcePositionForField(@NotNull FieldDescriptor descriptor,
                                                          @NotNull Project project,
                                                          @NotNull DebuggerContextImpl context,
                                                          boolean nearest)