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

Method formatRunIn

astyle/src/ASFormatter.cpp:4294–4396  ·  view source on GitHub ↗

* determine if a run-in can be attached. * if it can insert the indents in formattedLine and reset the current line break. */

Source from the content-addressed store, hash-verified

4292 * if it can insert the indents in formattedLine and reset the current line break.
4293 */
4294void ASFormatter::formatRunIn()
4295{
4296 assert(bracketFormatMode == RUN_IN_MODE || bracketFormatMode == NONE_MODE);
4297
4298 // keep one line blocks returns true without indenting the run-in
4299 if (!isOkToBreakBlock(bracketTypeStack->back()))
4300 return; // true;
4301
4302 // make sure the line begins with a bracket
4303 size_t lastText = formattedLine.find_last_not_of(" \t");
4304 if (lastText == string::npos || formattedLine[lastText] != '{')
4305 return; // false;
4306
4307 // make sure the bracket is broken
4308 if (formattedLine.find_first_not_of(" \t{") != string::npos)
4309 return; // false;
4310
4311 if (isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE))
4312 return; // false;
4313
4314 bool extraIndent = false;
4315 isInLineBreak = true;
4316
4317 // cannot attach a class modifier without indent-classes
4318 if (isCStyle()
4319 && isCharPotentialHeader(currentLine, charNum)
4320 && (isBracketType(bracketTypeStack->back(), CLASS_TYPE)
4321 || (isBracketType(bracketTypeStack->back(), STRUCT_TYPE)
4322 && isInIndentableStruct)))
4323 {
4324 if (findKeyword(currentLine, charNum, AS_PUBLIC)
4325 || findKeyword(currentLine, charNum, AS_PRIVATE)
4326 || findKeyword(currentLine, charNum, AS_PROTECTED))
4327 {
4328 if (!getClassIndent())
4329 return; // false;
4330 }
4331 else if (getClassIndent())
4332 extraIndent = true;
4333 }
4334
4335 // cannot attach a 'case' statement without indent-switches
4336 if (!getSwitchIndent()
4337 && isCharPotentialHeader(currentLine, charNum)
4338 && (findKeyword(currentLine, charNum, AS_CASE)
4339 || findKeyword(currentLine, charNum, AS_DEFAULT)))
4340 return; // false;
4341
4342 // extra indent for switch statements
4343 if (getSwitchIndent()
4344 && !preBracketHeaderStack->empty()
4345 && preBracketHeaderStack->back() == &AS_SWITCH
4346 && ((isLegalNameChar(currentChar)
4347 && !findKeyword(currentLine, charNum, AS_CASE))))
4348 extraIndent = true;
4349
4350 isInLineBreak = false;
4351 // remove for extra whitespace

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected