MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / appendCharInsideComments

Method appendCharInsideComments

astyle/src/ASFormatter.cpp:3157–3190  ·  view source on GitHub ↗

* append the current bracket inside the end of line comments * currentChar contains the bracket, it will be appended to formattedLine * formattedLineCommentNum is the comment location on formattedLine */

Source from the content-addressed store, hash-verified

3155 * formattedLineCommentNum is the comment location on formattedLine
3156 */
3157void ASFormatter::appendCharInsideComments(void)
3158{
3159 if (formattedLineCommentNum == string::npos) // does the comment start on the previous line?
3160 {
3161 appendCurrentChar(); // don't attach
3162 return;
3163 }
3164 assert(formattedLine.compare(formattedLineCommentNum, 2, "//") == 0
3165 || formattedLine.compare(formattedLineCommentNum, 2, "/*") == 0);
3166
3167 // find the previous non space char
3168 size_t end = formattedLineCommentNum;
3169 size_t beg = formattedLine.find_last_not_of(" \t", end - 1);
3170 if (beg == string::npos)
3171 {
3172 appendCurrentChar(); // don't attach
3173 return;
3174 }
3175 beg++;
3176
3177 // insert the bracket
3178 if (end - beg < 3) // is there room to insert?
3179 formattedLine.insert(beg, 3 - end + beg, ' ');
3180 if (formattedLine[beg] == '\t') // don't pad with a tab
3181 formattedLine.insert(beg, 1, ' ');
3182 formattedLine[beg + 1] = currentChar;
3183 testForTimeToSplitFormattedLine();
3184
3185 if (isBeforeComment())
3186 breakLine();
3187 else if (isCharImmediatelyPostLineComment)
3188 shouldBreakLineAtNextChar = true;
3189 return;
3190}
3191
3192/**
3193 * add or remove space padding to operators

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected