| 66 | } |
| 67 | |
| 68 | void AStyleFormatter::updateFormatter() |
| 69 | { |
| 70 | qCDebug(KDEV_ASTYLE) << "Updating option with: " << ISourceFormatter::optionMapToString(m_options); |
| 71 | // fill |
| 72 | int wsCount = m_options[QStringLiteral("FillCount")].toInt(); |
| 73 | if(m_options[QStringLiteral("Fill")].toString() == QLatin1String("Tabs")) { |
| 74 | const bool forceTabs = m_options[AStyleOptionKey::forceTabs()].toBool(); |
| 75 | AStyleFormatter::setTabIndentation(wsCount, forceTabs); |
| 76 | } else { |
| 77 | const bool tabSpaceConversion = m_options[AStyleOptionKey::tabSpaceConversion()].toBool(); |
| 78 | AStyleFormatter::setSpaceIndentationAndTabSpaceConversion(wsCount, tabSpaceConversion); |
| 79 | } |
| 80 | |
| 81 | AStyleFormatter::setEmptyLineFill(m_options[AStyleOptionKey::fillEmptyLines()].toBool()); |
| 82 | |
| 83 | // indent |
| 84 | AStyleFormatter::setSwitchIndent(m_options[QStringLiteral("IndentSwitches")].toBool()); |
| 85 | AStyleFormatter::setClassIndent(m_options[QStringLiteral("IndentClasses")].toBool()); |
| 86 | AStyleFormatter::setCaseIndent(m_options[QStringLiteral("IndentCases")].toBool()); |
| 87 | AStyleFormatter::setBracketIndent(m_options[QStringLiteral("IndentBrackets")].toBool()); |
| 88 | AStyleFormatter::setNamespaceIndent(m_options[QStringLiteral("IndentNamespaces")].toBool()); |
| 89 | AStyleFormatter::setLabelIndent(m_options[QStringLiteral("IndentLabels")].toBool()); |
| 90 | AStyleFormatter::setBlockIndent(m_options[QStringLiteral("IndentBlocks")].toBool()); |
| 91 | AStyleFormatter::setPreprocessorIndent(m_options[QStringLiteral("IndentPreprocessors")].toBool()); |
| 92 | AStyleFormatter::setAfterParens(m_options[QStringLiteral("AfterParens")].toBool()); |
| 93 | AStyleFormatter::setContinuation(m_options[QStringLiteral("Continuation")].toInt()); |
| 94 | |
| 95 | // continuation |
| 96 | AStyleFormatter::setMaxInStatementIndentLength(m_options[QStringLiteral("MaxStatement")].toInt()); |
| 97 | if(m_options[QStringLiteral("MinConditional")].toInt() != -1) |
| 98 | AStyleFormatter::setMinConditionalIndentLength(m_options[QStringLiteral("MinConditional")].toInt()); |
| 99 | |
| 100 | // brackets |
| 101 | QString s = m_options[QStringLiteral("Brackets")].toString(); |
| 102 | if(s == QLatin1String("Break")) |
| 103 | AStyleFormatter::setBracketFormatMode(astyle::BREAK_MODE); |
| 104 | else if(s == QLatin1String("Attach")) |
| 105 | AStyleFormatter::setBracketFormatMode(astyle::ATTACH_MODE); |
| 106 | else if(s == QLatin1String("Linux")) |
| 107 | AStyleFormatter::setBracketFormatMode(astyle::LINUX_MODE); |
| 108 | else if(s == QLatin1String("Stroustrup")) |
| 109 | // In astyle 2.06 BracketMode STROUSTRUP_MODE was removed and LINUX_MODE is the replacement |
| 110 | AStyleFormatter::setBracketFormatMode(astyle::LINUX_MODE); |
| 111 | else if(s == QLatin1String("Horstmann") || s == QLatin1String("RunInMode")) |
| 112 | AStyleFormatter::setBracketFormatMode(astyle::RUN_IN_MODE); |
| 113 | else |
| 114 | AStyleFormatter::setBracketFormatMode(astyle::NONE_MODE); |
| 115 | |
| 116 | AStyleFormatter::setBreakClosingHeaderBracketsMode(m_options[QStringLiteral("BracketsCloseHeaders")].toBool()); |
| 117 | AStyleFormatter::setAddBracesMode(m_options[AStyleOptionKey::bracesAdd()].toBool()); |
| 118 | |
| 119 | // blocks |
| 120 | AStyleFormatter::setBreakBlocksMode(m_options[QStringLiteral("BlockBreak")].toBool()); |
| 121 | AStyleFormatter::setBreakClosingHeaderBlocksMode(m_options[QStringLiteral("BlockBreakAll")].toBool()); |
| 122 | AStyleFormatter::setBreakElseIfsMode(m_options[QStringLiteral("BlockIfElse")].toBool()); |
| 123 | |
| 124 | // padding |
| 125 | AStyleFormatter::setOperatorPaddingMode(m_options[QStringLiteral("PadOperators")].toBool()); |
nothing calls this directly
no test coverage detected