private static int checkOrRemoveScopeEndingAt(@NotNull Editor editor, int offset, boolean removeScope) {
    ApplicationManager.getApplication().assertReadAccessAllowed();

    if (!CodeInsightSettings.getInstance().TAB_EXITS_BRACKETS_AND_QUOTES) return 0;

    if (editor instanceof EditorWindow) {
      DocumentWindow documentWindow = ((EditorWindow)editor).getDocument();
      offset = documentWindow.injectedToHost(offset);
      editor = ((EditorWindow)editor).getDelegate();
    }
    if (!(editor instanceof EditorImpl)) return 0;

    Tracker tracker = Tracker.forEditor((EditorImpl)editor, false);
    if (tracker == null) return 0;

    return tracker.getCaretShiftForScopeEndingAt(offset, removeScope);
  }
private static int checkOrRemoveScopeEndingAt(@NotNull Editor editor, int offset, boolean removeScope)