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:
@@ -1157,11 +1157,10 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
|
||||
|
||||
case LocalsIndividualFormatRole: {
|
||||
const int format = value.toInt();
|
||||
if (format == -1) {
|
||||
if (format == -1)
|
||||
theIndividualFormats.remove(data.iname);
|
||||
} else {
|
||||
else
|
||||
theIndividualFormats[data.iname] = format;
|
||||
}
|
||||
engine()->updateWatchData(data);
|
||||
break;
|
||||
}
|
||||
@@ -1277,17 +1276,15 @@ static bool watchDataLessThan(const QByteArray &iname1, int sortId1,
|
||||
return sortId1 < sortId2;
|
||||
// Get positions of last part of iname 'local.this.i1" -> "i1"
|
||||
int cmpPos1 = iname1.lastIndexOf('.');
|
||||
if (cmpPos1 == -1) {
|
||||
if (cmpPos1 == -1)
|
||||
cmpPos1 = 0;
|
||||
} else {
|
||||
else
|
||||
cmpPos1++;
|
||||
}
|
||||
int cmpPos2 = iname2.lastIndexOf('.');
|
||||
if (cmpPos2 == -1) {
|
||||
if (cmpPos2 == -1)
|
||||
cmpPos2 = 0;
|
||||
} else {
|
||||
else
|
||||
cmpPos2++;
|
||||
}
|
||||
// Are we looking at an array with numerical inames 'local.this.i1.0" ->
|
||||
// Go by sort id.
|
||||
if (cmpPos1 < iname1.size() && cmpPos2 < iname2.size()
|
||||
@@ -1612,11 +1609,10 @@ void WatchHandler::watchExpression(const QString &exp, const QString &name)
|
||||
// (address) if it can be found. Default to watchExpression().
|
||||
void WatchHandler::watchVariable(const QString &exp)
|
||||
{
|
||||
if (const WatchData *localVariable = findCppLocalVariable(exp)) {
|
||||
if (const WatchData *localVariable = findCppLocalVariable(exp))
|
||||
watchExpression(QLatin1String(localVariable->exp), exp);
|
||||
} else {
|
||||
else
|
||||
watchExpression(exp);
|
||||
}
|
||||
}
|
||||
|
||||
static void swapEndian(char *d, int nchar)
|
||||
@@ -1657,11 +1653,10 @@ void WatchHandler::showSeparateWidget(QWidget *w)
|
||||
m_separateWindow = new SeparateViewWidget(debuggerCore()->mainWindow());
|
||||
|
||||
int index = indexOf(m_separateWindow, w);
|
||||
if (index != -1) {
|
||||
if (index != -1)
|
||||
m_separateWindow->setTabText(index, w->windowTitle());
|
||||
} else {
|
||||
else
|
||||
index = m_separateWindow->addTab(w, w->windowTitle());
|
||||
}
|
||||
m_separateWindow->setCurrentIndex(index);
|
||||
m_separateWindow->show();
|
||||
m_separateWindow->raise();
|
||||
|
||||
Reference in New Issue
Block a user