forked from qt-creator/qt-creator
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -280,11 +280,10 @@ void StandardItemTreeModelBuilder::addItem(const QString &s)
|
||||
|
||||
void StandardItemTreeModelBuilder::pushRow()
|
||||
{
|
||||
if (m_rowParents.isEmpty()) {
|
||||
if (m_rowParents.isEmpty())
|
||||
m_model->appendRow(m_row);
|
||||
} else {
|
||||
else
|
||||
m_rowParents.top()->appendRow(m_row);
|
||||
}
|
||||
m_rowParents.push(m_row.front());
|
||||
m_row.clear();
|
||||
}
|
||||
@@ -379,11 +378,10 @@ void XmlWriterTreeModelVisitor::run()
|
||||
void XmlWriterTreeModelVisitor::handleItem(const QModelIndex &m)
|
||||
{
|
||||
const QString value = m.data(Qt::DisplayRole).toString();
|
||||
if (value.isEmpty()) {
|
||||
if (value.isEmpty())
|
||||
m_writer.writeEmptyElement(m_modelItemElement);
|
||||
} else {
|
||||
else
|
||||
m_writer.writeTextElement(m_modelItemElement, value);
|
||||
}
|
||||
}
|
||||
|
||||
// TreeModelVisitor for debugging/copying models
|
||||
@@ -1030,11 +1028,10 @@ void DebuggerToolTipWidget::restoreTreeModel(QXmlStreamReader &r, QStandardItemM
|
||||
case QXmlStreamReader::EndElement: {
|
||||
const QStringRef element = r.name();
|
||||
// Row closing: pop off parent.
|
||||
if (element == QLatin1String(modelRowElementC)) {
|
||||
if (element == QLatin1String(modelRowElementC))
|
||||
builder.endRow();
|
||||
} else if (element == QLatin1String(modelElementC)) {
|
||||
else if (element == QLatin1String(modelElementC))
|
||||
withinModel = false;
|
||||
}
|
||||
}
|
||||
break; // EndElement
|
||||
default:
|
||||
@@ -1145,11 +1142,10 @@ void DebuggerToolTipManager::registerToolTip(DebuggerToolTipWidget *toolTipWidge
|
||||
void DebuggerToolTipManager::purgeClosedToolTips()
|
||||
{
|
||||
for (DebuggerToolTipWidgetList::iterator it = m_tooltips.begin(); it != m_tooltips.end() ; ) {
|
||||
if (it->isNull()) {
|
||||
if (it->isNull())
|
||||
it = m_tooltips.erase(it);
|
||||
} else {
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1272,11 +1268,10 @@ void DebuggerToolTipManager::slotUpdateVisibleToolTips()
|
||||
// Reposition and show all tooltips of that file.
|
||||
const QString fileName = toolTipEditor.fileName();
|
||||
foreach (const QPointer<DebuggerToolTipWidget> &tw, m_tooltips) {
|
||||
if (tw->fileName() == fileName) {
|
||||
if (tw->fileName() == fileName)
|
||||
tw->positionShow(toolTipEditor);
|
||||
} else {
|
||||
else
|
||||
tw->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user