Commit ad9e7cca authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Fix coding style for else statements

Change-Id: I1309db70e98d678e150388c76ce665e988fdf081
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent c67f7f63
......@@ -57,9 +57,9 @@ function build() {
if (nrButtons == 0)
return;
if (self.checkedButton)
if (self.checkedButton) {
self.checkedButton.checked = true;
else if (self.exclusive) {
} else if (self.exclusive) {
self.checkedButton = visibleButtons[0];
self.checkedButton.checked = true;
}
......
......@@ -3770,9 +3770,7 @@ void *qDumpObjectData440(
d.put(",namespace=\"" NS "\",");
d.put("dumperversion=\"1.3\",");
d.disarm();
}
else if (protocolVersion == 2 || protocolVersion == 3) {
} else if (protocolVersion == 2 || protocolVersion == 3) {
QDumper d;
d.protocolVersion = protocolVersion;
......@@ -3796,9 +3794,7 @@ void *qDumpObjectData440(
<< d.outerType << d.iname << d.exp << d.iname;
#endif
handleProtocolVersion2and3(d);
}
else {
} else {
#if USE_QT_CORE
# ifndef QT_BOOTSTRAPPED
qDebug() << "Unsupported protocol version" << protocolVersion;
......
......@@ -257,9 +257,7 @@ void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
{
if (m_singleSelectionManipulator.isActive()) {
m_singleSelectionManipulator.end(event->pos());
}
else if (m_rubberbandSelectionManipulator.isActive()) {
} else if (m_rubberbandSelectionManipulator.isActive()) {
QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) {
m_singleSelectionManipulator.begin(event->pos());
......
......@@ -84,8 +84,7 @@ QNetworkProxy ProxySettings::httpProxy ()
proxy.setUser (settings.value ("http_proxy/username", "").toString ());
proxy.setPassword (settings.value ("http_proxy/password", "").toString ());
//QNetworkProxy::setApplicationProxy (proxy);
}
else {
} else {
proxy.setType (QNetworkProxy::NoProxy);
}
return proxy;
......
......@@ -464,7 +464,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
else if (command.userType() == synchronizeCommandType) {
SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>();
m_synchronizeId = synchronizeCommand.synchronizeId();
} else
} else {
Q_ASSERT(false);
}
}
} // namespace QmlDesigner
......@@ -38,9 +38,9 @@ AnimatedToolButton {
hoverIconFromFile: "images/submenu.png";
function setIcon() {
if (backendValue == null)
if (backendValue == null) {
extendedFunctionButton.iconFromFile = "images/placeholder.png"
else if (backendValue.isBound ) {
} else if (backendValue.isBound ) {
if (backendValue.isTranslated) { //translations are a special case
extendedFunctionButton.iconFromFile = "images/placeholder.png"
} else {
......
......@@ -400,12 +400,11 @@ int main(int argc, char **argv)
QNetworkProxy proxy(QNetworkProxy::HttpProxy, proxyUrl.host(),
proxyUrl.port(), proxyUrl.userName(), proxyUrl.password());
QNetworkProxy::setApplicationProxy(proxy);
}
# if defined(Q_OS_MAC) // unix and mac
else {
} else {
QNetworkProxyFactory::setUseSystemConfiguration(true);
}
# endif
}
#else // windows
QNetworkProxyFactory::setUseSystemConfiguration(true);
#endif
......
......@@ -129,9 +129,9 @@ public:
virtual void visit(NamedType *type)
{
FullySpecifiedType ty = rewrite->env->apply(type->name(), rewrite);
if (! ty->isUndefinedType())
if (! ty->isUndefinedType()) {
temps.append(ty);
else {
} else {
const Name *name = rewrite->rewriteName(type->name());
temps.append(control()->namedType(name));
}
......
......@@ -264,7 +264,7 @@ private:
if (! name)
return name;
else if (const Identifier *nameId = name->asNameId()) {
if (const Identifier *nameId = name->asNameId()) {
const Identifier *id = control()->identifier(nameId->chars(), nameId->size());
return id;
......
......@@ -263,19 +263,20 @@ int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) const
forever {
const Token &tk = scanner[index - 1];
if (tk.is(T_EOF_SYMBOL))
if (tk.is(T_EOF_SYMBOL)) {
break;
else if (tk.is(T_LPAREN))
} else if (tk.is(T_LPAREN)) {
return scanner.startPosition() + tk.begin();
else if (tk.is(T_RPAREN)) {
} else if (tk.is(T_RPAREN)) {
int matchingBrace = scanner.startOfMatchingBrace(index);
if (matchingBrace == index) // If no matching brace found
return -1;
index = matchingBrace;
} else
} else {
--index;
}
}
return -1;
......
......@@ -57,7 +57,7 @@ static void addNames(const Name *name, QList<const Name *> *names, bool addAllNa
{
if (! name)
return;
else if (const QualifiedNameId *q = name->asQualifiedNameId()) {
if (const QualifiedNameId *q = name->asQualifiedNameId()) {
addNames(q->base(), names);
addNames(q->name(), names, addAllNames);
} else if (addAllNames || name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) {
......@@ -98,7 +98,7 @@ static inline bool compareName(const Name *name, const Name *other)
if (name == other)
return true;
else if (name && other) {
if (name && other) {
const Identifier *id = name->identifier();
const Identifier *otherId = other->identifier();
......@@ -599,10 +599,9 @@ QList<LookupItem> ClassOrNamespace::lookup_helper(const Name *name, bool searchI
if (name) {
if (const QualifiedNameId *q = name->asQualifiedNameId()) {
if (! q->base()) // e.g. ::std::string
if (! q->base()) { // e.g. ::std::string
result = globalNamespace()->find(q->name());
else if (ClassOrNamespace *binding = lookupType(q->base())) {
} else if (ClassOrNamespace *binding = lookupType(q->base())) {
result = binding->find(q->name());
QList<const Name *> fullName;
......@@ -864,7 +863,7 @@ ClassOrNamespace *ClassOrNamespace::lookupType_helper(const Name *name,
if (ClassOrNamespace *e = nestedType(name, origin))
return e;
else if (_templateId) {
if (_templateId) {
if (_usings.size() == 1) {
ClassOrNamespace *delegate = _usings.first();
......@@ -1265,8 +1264,7 @@ bool ClassOrNamespace::NestedClassInstantiator::isInstantiateNestedClassNeeded(c
if (Declaration *declaration = memberAsSymbol->asDeclaration()) {
if (containsTemplateType(declaration))
return true;
}
else if (Function *function = memberAsSymbol->asFunction()) {
} else if (Function *function = memberAsSymbol->asFunction()) {
if (containsTemplateType(function))
return true;
}
......@@ -1447,7 +1445,7 @@ void CreateBindings::process(Document::Ptr doc)
if (! doc)
return;
else if (Namespace *globalNamespace = doc->globalNamespace()) {
if (Namespace *globalNamespace = doc->globalNamespace()) {
if (! _processed.contains(globalNamespace)) {
_processed.insert(globalNamespace);
......
......@@ -244,7 +244,7 @@ QString MatchingText::insertParagraphSeparator(const QTextCursor &tc) const
if (current.is(T_EOF_SYMBOL))
break;
else if (current.is(T_CLASS) || current.is(T_STRUCT) || current.is(T_UNION) || current.is(T_ENUM)) {
if (current.is(T_CLASS) || current.is(T_STRUCT) || current.is(T_UNION) || current.is(T_ENUM)) {
// found a class key.
QString str = QLatin1String("};");
......
......@@ -170,8 +170,7 @@ bool Environment::isBuiltinMacro(const ByteArrayRef &s)
}
}
}
}
else if (s[2] == 'F') {
} else if (s[2] == 'F') {
if (s[3] == 'I') {
if (s[4] == 'L') {
if (s[5] == 'E') {
......@@ -183,8 +182,7 @@ bool Environment::isBuiltinMacro(const ByteArrayRef &s)
}
}
}
}
else if (s[2] == 'L') {
} else if (s[2] == 'L') {
if (s[3] == 'I') {
if (s[4] == 'N') {
if (s[5] == 'E') {
......@@ -196,8 +194,7 @@ bool Environment::isBuiltinMacro(const ByteArrayRef &s)
}
}
}
}
else if (s[2] == 'T') {
} else if (s[2] == 'T') {
if (s[3] == 'I') {
if (s[4] == 'M') {
if (s[5] == 'E') {
......
......@@ -576,16 +576,14 @@ bool ResolveExpression::visit(SimpleNameAST *ast)
if (n == 0) {
item.setType(newType);
item.setScope(typeItems[n].scope());
}
else {
} else {
LookupItem newItem(item);
newItem.setType(newType);
newItem.setScope(typeItems[n].scope());
newCandidates.push_back(newItem);
}
}
}
else {
} else {
item.setType(item.declaration()->type());
item.setScope(item.declaration()->enclosingScope());
}
......
......@@ -1862,12 +1862,11 @@ void Preprocessor::handleElseDirective(PPToken *tk, const PPToken &poundToken)
else if (m_client && !wasSkipping && startSkipping)
startSkippingBlocks(poundToken);
}
}
#ifndef NO_DEBUG
else {
} else {
std::cerr << "*** WARNING #else without #if" << std::endl;
}
#endif // NO_DEBUG
}
}
void Preprocessor::handleEndIfDirective(PPToken *tk, const PPToken &poundToken)
......@@ -1930,12 +1929,11 @@ void Preprocessor::handleIfDefDirective(bool checkUndefined, PPToken *tk)
startSkippingBlocks(*tk);
lex(tk); // consume the identifier
}
#ifndef NO_DEBUG
else {
} else {
std::cerr << "*** WARNING #ifdef without identifier" << std::endl;
}
#endif // NO_DEBUG
}
}
void Preprocessor::handleUndefDirective(PPToken *tk)
......@@ -1948,12 +1946,11 @@ void Preprocessor::handleUndefDirective(PPToken *tk)
if (m_client && macro)
m_client->macroAdded(*macro);
lex(tk); // consume macro name
}
#ifndef NO_DEBUG
else {
} else {
std::cerr << "*** WARNING #undef without identifier" << std::endl;
}
#endif // NO_DEBUG
}
}
PPToken Preprocessor::generateToken(enum Kind kind,
......
......@@ -259,13 +259,13 @@ const char *pp_skip_argument::operator () (const char *__first, const char *__la
lines = 0;
while (__first != __last) {
if (!depth && (*__first == ')' || *__first == ','))
if (!depth && (*__first == ')' || *__first == ',')) {
break;
else if (*__first == '(')
} else if (*__first == '(') {
++depth, ++__first;
else if (*__first == ')')
} else if (*__first == ')') {
--depth, ++__first;
else if (*__first == '\"') {
} else if (*__first == '\"') {
__first = skip_string_literal (__first, __last);
lines += skip_string_literal.lines;
} else if (*__first == '\'') {
......@@ -283,8 +283,9 @@ const char *pp_skip_argument::operator () (const char *__first, const char *__la
} else if (*__first == '\n') {
++__first;
++lines;
} else
} else {
++__first;
}
}
return __first;
......
......@@ -1183,9 +1183,9 @@ void PluginManagerPrivate::readPluginPaths()
PluginCollection *collection = 0;
// find correct plugin collection or create a new one
if (pluginCategories.contains(spec->category()))
if (pluginCategories.contains(spec->category())) {
collection = pluginCategories.value(spec->category());
else {
} else {
collection = new PluginCollection(spec->category());
pluginCategories.insert(spec->category(), collection);
}
......
......@@ -109,9 +109,9 @@ QList<Symbol *> Namespace::members() const
void Namespace::add(Symbol *symbol)
{
Symbol *&sym = _members[symbol->name()];
if (! sym)
if (! sym) {
sym = symbol;
else if (Function *fun = symbol->asFunction()) {
} else if (Function *fun = symbol->asFunction()) {
if (OverloadSet *o = sym->asOverloadSet()) {
o->addFunction(fun);
} else if (Function *firstFunction = sym->asFunction()) {
......@@ -121,8 +121,7 @@ void Namespace::add(Symbol *symbol)
o->addFunction(firstFunction);
o->addFunction(fun);
sym = o;
}
else {
} else {
// ### warning? return false?
}
} else {
......
......@@ -298,9 +298,9 @@ bool MatrixType::isLessThan(const Type *other) const
Q_ASSERT(other != 0);
const MatrixType *mat = other->asMatrixType();
Q_ASSERT(mat != 0);
if (_columns < mat->columns())
if (_columns < mat->columns()) {
return true;
else if (_columns == mat->columns()) {
} else if (_columns == mat->columns()) {
if (_rows < mat->rows())
return true;
else if (_rows == mat->rows() && _elementType < mat->elementType())
......
......@@ -228,9 +228,9 @@ void EasingContextPane::setGraphDisplayMode(GraphDisplayMode newMode)
void EasingContextPane::startAnimation()
{
if (m_simulation->running())
if (m_simulation->running()) {
m_simulation->stop();
else {
} else {
m_simulation->animate(ui->durationSpinBox->value(), m_easingGraph->easingCurve());
ui->playButton->setIcon(QIcon(QLatin1String(":/stopicon.png")));
}
......
......@@ -905,7 +905,7 @@ bool Lexer::scanRegExp(RegExpBodyPrefix prefix)
while (! _char.isNull() && ! isLineTerminator()) {
if (_char == QLatin1Char(']'))
break;
else if (_char == QLatin1Char('\\')) {
if (_char == QLatin1Char('\\')) {
// regular expression backslash sequence
_tokenText += _char;
scanChar();
......
......@@ -154,9 +154,9 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
parentObjectValue = switchObjectValue(objectValue);
if (parentObjectValue)
if (parentObjectValue) {
objectValue->setMember(QLatin1String("parent"), parentObjectValue);
else if (!_rootObjectValue) {
} else if (!_rootObjectValue) {
_rootObjectValue = objectValue;
_rootObjectValue->setClassName(_doc->componentName());
}
......
......@@ -255,14 +255,13 @@ protected:
qreal result = badnessFromSplits;
foreach (const QString &line, lines) {
// really long lines should be avoided at all cost
if (line.size() > strongMaxLineLength)
if (line.size() > strongMaxLineLength) {
result += 50 + (line.size() - strongMaxLineLength);
// having long lines is bad
else if (line.size() > maxLineLength) {
} else if (line.size() > maxLineLength) {
result += 3 + (line.size() - maxLineLength);
}
// and even ok-sized lines should have a cost
else {
} else {
result += 1;
}
......
......@@ -282,9 +282,8 @@ void Rewriter::changeBinding(UiObjectInitializer *ast,
}
break;
}
// for grouped properties:
else if (!prefix.isEmpty()) {
} else if (!prefix.isEmpty()) {
if (UiObjectDefinition *def = cast<UiObjectDefinition *>(member)) {
if (toString(def->qualifiedTypeNameId) == prefix)
changeBinding(def->initializer, suffix, newValue, binding);
......@@ -384,10 +383,10 @@ void Rewriter::removeBindingByName(UiObjectInitializer *ast, const QString &prop
UiObjectMember *member = it->member;
// run full name match (for ungrouped properties):
if (isMatchingPropertyMember(propertyName, member))
if (isMatchingPropertyMember(propertyName, member)) {
removeMember(member);
// check for grouped properties:
else if (!prefix.isEmpty()) {
} else if (!prefix.isEmpty()) {
if (UiObjectDefinition *def = cast<UiObjectDefinition *>(member)) {
if (toString(def->qualifiedTypeNameId) == prefix)
removeGroupedProperty(def, propertyName);
......
......@@ -80,10 +80,10 @@ void ScopeBuilder::push(AST::Node *node)
break;
}
// signals defined in QML
if (const ASTSignal *astsig = value_cast<ASTSignal>(value))
if (const ASTSignal *astsig = value_cast<ASTSignal>(value)) {
_scopeChain->appendJsScope(astsig->bodyScope());
// signals defined in C++
else if (const CppComponentValue *qmlObject = value_cast<CppComponentValue>(owner)) {
} else if (const CppComponentValue *qmlObject = value_cast<CppComponentValue>(owner)) {
if (const ObjectValue *scope = qmlObject->signalScope(name))
_scopeChain->appendJsScope(scope);
}
......
......@@ -860,9 +860,8 @@ QRect QStyleItem::subControlRect(const QString &subcontrolString)
subcontrol = QStyle::SC_SpinBoxDown;
else if (subcontrolString == QLatin1String("up"))
subcontrol = QStyle::SC_SpinBoxUp;
else if (subcontrolString == QLatin1String("edit")){
else if (subcontrolString == QLatin1String("edit"))
subcontrol = QStyle::SC_SpinBoxEditField;
}
return qApp->style()->subControlRect(control,
qstyleoption_cast<QStyleOptionComplex*>(m_styleoption),
subcontrol, widget());
......
......@@ -66,9 +66,9 @@ QtcLibrary {
}
property var botanDefines: {
var result = [];
if (useSystemBotan)
if (useSystemBotan) {
result.push("USE_SYSTEM_BOTAN")
else {
} else {
result.push("BOTAN_DLL=")
if (qbs.toolchain === "msvc")
result.push("BOTAN_BUILD_COMPILER_IS_MSVC", "BOTAN_TARGET_OS_HAS_GMTIME_S")
......
......@@ -124,9 +124,9 @@ void FancyMainWindow::updateDockWidget(QDockWidget *dockWidget)
: QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable;
if (dockWidget->property("managed_dockwidget").isNull()) { // for the debugger tool bar
QWidget *titleBarWidget = dockWidget->titleBarWidget();
if (d->m_locked && !titleBarWidget && !dockWidget->isFloating())
if (d->m_locked && !titleBarWidget && !dockWidget->isFloating()) {
titleBarWidget = new QWidget(dockWidget);
else if ((!d->m_locked || dockWidget->isFloating()) && titleBarWidget) {
} else if ((!d->m_locked || dockWidget->isFloating()) && titleBarWidget) {
delete titleBarWidget;
titleBarWidget = 0;
}
......
......@@ -162,9 +162,9 @@ bool ToolTip::tipChanged(const QPoint &pos, const TipContent &content, QWidget *
void ToolTip::setTipRect(QWidget *w, const QRect &rect)
{
if (!m_rect.isNull() && !w)
if (!m_rect.isNull() && !w) {
qWarning("ToolTip::show: Cannot pass null widget if rect is set");
else{
} else {
m_widget = w;
m_rect = rect;
}
......
......@@ -75,15 +75,15 @@ QString UnixUtils::substituteFileBrowserParameters(const QString &pre, const QSt
if (c == QLatin1Char('%') && i < pre.size()-1) {
c = pre.at(++i);
QString s;
if (c == QLatin1Char('d'))
if (c == QLatin1Char('d')) {
s = QLatin1Char('"') + QFileInfo(file).path() + QLatin1Char('"');
else if (c == QLatin1Char('f'))
} else if (c == QLatin1Char('f')) {
s = QLatin1Char('"') + file + QLatin1Char('"');
else if (c == QLatin1Char('n'))
} else if (c == QLatin1Char('n')) {
s = QLatin1Char('"') + QFileInfo(file).fileName() + QLatin1Char('"');
else if (c == QLatin1Char('%'))
} else if (c == QLatin1Char('%')) {
s = c;
else {
} else {
s = QLatin1Char('%');
s += c;
}
......
......@@ -94,8 +94,7 @@ void CMakeHighlighter::highlightBlock(const QString &text)
setFormat(i, 1, m_formats[CMakeStringFormat]);
}
inStringMode = !inStringMode;
}
else if (c == '\\') {
} else if (c == '\\') {
setFormat(i, 1, emptyFormat);
buf += c;
i++;
......
......@@ -172,9 +172,9 @@ MainWindow::MainWindow() :
if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost()) {
if (baseName == QLatin1String("windows")) {
// Sometimes we get the standard windows 95 style as a fallback
if (QStyleFactory::keys().contains(QLatin1String("Fusion")))
if (QStyleFactory::keys().contains(QLatin1String("Fusion"))) {
baseName = QLatin1String("fusion"); // Qt5
else { // Qt4
} else { // Qt4
// e.g. if we are running on a KDE4 desktop
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
if (desktopEnvironment == "kde")
......
......@@ -274,18 +274,16 @@ void ManhattanStyle::polish(QWidget *widget)
if (qobject_cast<QToolButton*>(widget)) {
widget->setAttribute(Qt::WA_Hover);
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
}
else if (qobject_cast<QLineEdit*>(widget)) {
} else if (qobject_cast<QLineEdit*>(widget)) {
widget->setAttribute(Qt::WA_Hover);