<commit_before>/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (<EMAIL>)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

#ifndef INDENTER_C
#define INDENTER_C

/*
  This file is a self-contained interactive indenter for C++ and Qt
  Script.

  The general problem of indenting a C++ program is ill posed. On the
  one hand, an indenter has to analyze programs written in a
  free-form formal language that is best described in terms of
  tokens, not characters, not lines. On the other hand, indentation
  applies to lines and white space characters matter, and otherwise
  the programs to indent are formally invalid in general, as they are
  being edited.

  The approach taken here works line by line. We receive a program
  consisting of N lines or more, and we want to compute the
  indentation appropriate for the Nth line. Lines beyond the Nth
  lines are of no concern to us, so for simplicity we pretend the
  program has exactly N lines and we call the Nth line the "bottom
  line". Typically, we have to indent the bottom line when it's still
  empty, so we concentrate our analysis on the N - 1 lines that
  precede.

  By inspecting the (N - 1)-th line, the (N - 2)-th line, ...
  backwards, we determine the kind of the bottom line and indent it
  accordingly.

    * The bottom line is a comment line. See
      bottomLineStartsInCComment() and
      indentWhenBottomLineStartsInCComment().
    * The bottom line is a continuation line. See isContinuationLine()
      and indentForContinuationLine().
    * The bottom line is a standalone line. See
      indentForStandaloneLine().

  Certain tokens that influence the indentation, notably braces, are
  looked for in the lines. This is done by simple string comparison,
  without a real tokenizer. Confusing constructs such as comments and
  string literals are removed beforehand.
*/

namespace SharedTools {

/* qmake ignore Q_OBJECT */

/*
  The indenter avoids getting stuck in almost infinite loops by
  imposing arbitrary limits on the number of lines it analyzes when
  looking for a construct.

  For example, the indenter never considers more than BigRoof lines
  backwards when looking for the start of a C-style comment.
*/
namespace {
    enum { SmallRoof = 40, BigRoof = 400 };

/*
  The indenter supports a few parameters:

    * ppHardwareTabSize is the size of a '\t' in your favorite editor.
    * ppIndentSize is the size of an indentation, or software tab
      size.
    * ppContinuationIndentSize is the extra indent for a continuation
      line, when there is nothing to align against on the previous
      line.
    * ppCommentOffset is the indentation within a C-style comment,
      when it cannot be picked up.
*/


    enum { ppCommentOffset = 2 };
}

template <class Iterator>
Indenter<Iterator>::Indenter() :
    ppHardwareTabSize(8),
    ppIndentSize(4),
    ppContinuationIndentSize(8),
    yyLinizerState(new LinizerState),<commit_msg>Fixed auto indent for c style coments<commit_after>/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (<EMAIL>)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/

#ifndef INDENTER_C
#define INDENTER_C

/*
  This file is a self-contained interactive indenter for C++ and Qt
  Script.

  The general problem of indenting a C++ program is ill posed. On the
  one hand, an indenter has to analyze programs written in a
  free-form formal language that is best described in terms of
  tokens, not characters, not lines. On the other hand, indentation
  applies to lines and white space characters matter, and otherwise
  the programs to indent are formally invalid in general, as they are
  being edited.

  The approach taken here works line by line. We receive a program
  consisting of N lines or more, and we want to compute the
  indentation appropriate for the Nth line. Lines beyond the Nth
  lines are of no concern to us, so for simplicity we pretend the
  program has exactly N lines and we call the Nth line the "bottom
  line". Typically, we have to indent the bottom line when it's still
  empty, so we concentrate our analysis on the N - 1 lines that
  precede.

  By inspecting the (N - 1)-th line, the (N - 2)-th line, ...
  backwards, we determine the kind of the bottom line and indent it
  accordingly.

    * The bottom line is a comment line. See
      bottomLineStartsInCComment() and
      indentWhenBottomLineStartsInCComment().
    * The bottom line is a continuation line. See isContinuationLine()
      and indentForContinuationLine().
    * The bottom line is a standalone line. See
      indentForStandaloneLine().

  Certain tokens that influence the indentation, notably braces, are
  looked for in the lines. This is done by simple string comparison,
  without a real tokenizer. Confusing constructs such as comments and
  string literals are removed beforehand.
*/

namespace SharedTools {

/* qmake ignore Q_OBJECT */

/*
  The indenter avoids getting stuck in almost infinite loops by
  imposing arbitrary limits on the number of lines it analyzes when
  looking for a construct.

  For example, the indenter never considers more than BigRoof lines
  backwards when looking for the start of a C-style comment.
*/
namespace {
    enum { SmallRoof = 40, BigRoof = 400 };

/*
  The indenter supports a few parameters:

    * ppHardwareTabSize is the size of a '\t' in your favorite editor.
    * ppIndentSize is the size of an indentation, or software tab
      size.
    * ppContinuationIndentSize is the extra indent for a continuation
      line, when there is nothing to align against on the previous
      line.
    * ppCommentOffset is the indentation within a C-style comment,
      when it cannot be picked up.
*/


    enum { ppCommentOffset = 1 };
}

template <class Iterator>
Indenter<Iterator>::Indenter() :
    ppHardwareTabSize(8),
    ppIndentSize(4),
    ppContinuationIndentSize(8),
    yyLinizerState(new LinizerState),
{'fraction_non_alphanumeric': 0.09541420118343195, 'fraction_numerical': 0.005424063116370809, 'mean_word_length': 3.8262938726948246, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6420921', 'n_tokens_mistral': 2122, 'n_tokens_neox': 2015, 'n_words': 1069}