* additional formatting for line of source code. * every line of source code in a source code file should be sent * one after the other to this function. * indents event tables * unindents the case blocks * * @param line the original formatted line will be updated if necessary. */
| 99 | * @param line the original formatted line will be updated if necessary. |
| 100 | */ |
| 101 | void ASEnhancer::enhance(string& line, bool isInNamespace, bool isInPreprocessor, bool isInSQL) |
| 102 | { |
| 103 | shouldUnindentLine = true; |
| 104 | shouldUnindentComment = false; |
| 105 | lineNumber++; |
| 106 | |
| 107 | // check for beginning of event table |
| 108 | if (nextLineIsEventIndent) |
| 109 | { |
| 110 | isInEventTable = true; |
| 111 | nextLineIsEventIndent = false; |
| 112 | } |
| 113 | |
| 114 | // check for beginning of SQL declare section |
| 115 | if (nextLineIsDeclareIndent) |
| 116 | { |
| 117 | isInDeclareSection = true; |
| 118 | nextLineIsDeclareIndent = false; |
| 119 | } |
| 120 | |
| 121 | if (line.length() == 0 |
| 122 | && !isInEventTable |
| 123 | && !isInDeclareSection |
| 124 | && !emptyLineFill) |
| 125 | return; |
| 126 | |
| 127 | // test for unindent on attached braces |
| 128 | if (unindentNextLine) |
| 129 | { |
| 130 | sw.unindentDepth++; |
| 131 | sw.unindentCase = true; |
| 132 | unindentNextLine = false; |
| 133 | } |
| 134 | |
| 135 | // parse characters in the current line |
| 136 | parseCurrentLine(line, isInPreprocessor, isInSQL); |
| 137 | |
| 138 | // check for SQL indentable lines |
| 139 | if (isInDeclareSection) |
| 140 | { |
| 141 | size_t firstText = line.find_first_not_of(" \t"); |
| 142 | if (firstText == string::npos || line[firstText] != '#') |
| 143 | indentLine(line, 1); |
| 144 | } |
| 145 | |
| 146 | // check for event table indentable lines |
| 147 | if (isInEventTable |
| 148 | && (eventPreprocDepth == 0 |
| 149 | || (namespaceIndent && isInNamespace))) |
| 150 | { |
| 151 | size_t firstText = line.find_first_not_of(" \t"); |
| 152 | if (firstText == string::npos || line[firstText] != '#') |
| 153 | indentLine(line, 1); |
| 154 | } |
| 155 | |
| 156 | if (shouldUnindentComment && sw.unindentDepth > 0) |
| 157 | unindentLine(line, sw.unindentDepth - 1); |
| 158 | else if (shouldUnindentLine && sw.unindentDepth > 0) |