diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2013-01-08 03:32:53 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2013-01-08 10:48:18 +0100 |
commit | 29a93998df8405e8799ad23934a56cd99fb36403 (patch) | |
tree | c0e4a341efeef78fbe530a618caaa50254daad59 /src/plugins/qmljseditor/qmljshighlighter.cpp | |
parent | 73a2717bed511cffd0163195c314f7d919e5128b (diff) | |
download | qt-creator-29a93998df8405e8799ad23934a56cd99fb36403.tar.gz |
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>
Diffstat (limited to 'src/plugins/qmljseditor/qmljshighlighter.cpp')
-rw-r--r-- | src/plugins/qmljseditor/qmljshighlighter.cpp | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/plugins/qmljseditor/qmljshighlighter.cpp b/src/plugins/qmljseditor/qmljshighlighter.cpp index 836f2447c4..19281c358d 100644 --- a/src/plugins/qmljseditor/qmljshighlighter.cpp +++ b/src/plugins/qmljseditor/qmljshighlighter.cpp @@ -203,23 +203,22 @@ bool Highlighter::maybeQmlKeyword(const QStringRef &text) const return false; const QChar ch = text.at(0); - if (ch == QLatin1Char('p') && text == QLatin1String("property")) { + if (ch == QLatin1Char('p') && text == QLatin1String("property")) return true; - } else if (ch == QLatin1Char('a') && text == QLatin1String("alias")) { + else if (ch == QLatin1Char('a') && text == QLatin1String("alias")) return true; - } else if (ch == QLatin1Char('s') && text == QLatin1String("signal")) { + else if (ch == QLatin1Char('s') && text == QLatin1String("signal")) return true; - } else if (ch == QLatin1Char('p') && text == QLatin1String("property")) { + else if (ch == QLatin1Char('p') && text == QLatin1String("property")) return true; - } else if (ch == QLatin1Char('r') && text == QLatin1String("readonly")) { + else if (ch == QLatin1Char('r') && text == QLatin1String("readonly")) return true; - } else if (ch == QLatin1Char('i') && text == QLatin1String("import")) { + else if (ch == QLatin1Char('i') && text == QLatin1String("import")) return true; - } else if (ch == QLatin1Char('o') && text == QLatin1String("on")) { + else if (ch == QLatin1Char('o') && text == QLatin1String("on")) return true; - } else { + else return false; - } } bool Highlighter::maybeQmlBuiltinType(const QStringRef &text) const @@ -229,47 +228,46 @@ bool Highlighter::maybeQmlBuiltinType(const QStringRef &text) const const QChar ch = text.at(0); - if (ch == QLatin1Char('a') && text == QLatin1String("action")) { + if (ch == QLatin1Char('a') && text == QLatin1String("action")) return true; - } else if (ch == QLatin1Char('b') && text == QLatin1String("bool")) { + else if (ch == QLatin1Char('b') && text == QLatin1String("bool")) return true; - } else if (ch == QLatin1Char('c') && text == QLatin1String("color")) { + else if (ch == QLatin1Char('c') && text == QLatin1String("color")) return true; - } else if (ch == QLatin1Char('d') && text == QLatin1String("date")) { + else if (ch == QLatin1Char('d') && text == QLatin1String("date")) return true; - } else if (ch == QLatin1Char('d') && text == QLatin1String("double")) { + else if (ch == QLatin1Char('d') && text == QLatin1String("double")) return true; - } else if (ch == QLatin1Char('e') && text == QLatin1String("enumeration")) { + else if (ch == QLatin1Char('e') && text == QLatin1String("enumeration")) return true; - } else if (ch == QLatin1Char('f') && text == QLatin1String("font")) { + else if (ch == QLatin1Char('f') && text == QLatin1String("font")) return true; - } else if (ch == QLatin1Char('i') && text == QLatin1String("int")) { + else if (ch == QLatin1Char('i') && text == QLatin1String("int")) return true; - } else if (ch == QLatin1Char('l') && text == QLatin1String("list")) { + else if (ch == QLatin1Char('l') && text == QLatin1String("list")) return true; - } else if (ch == QLatin1Char('p') && text == QLatin1String("point")) { + else if (ch == QLatin1Char('p') && text == QLatin1String("point")) return true; - } else if (ch == QLatin1Char('r') && text == QLatin1String("real")) { + else if (ch == QLatin1Char('r') && text == QLatin1String("real")) return true; - } else if (ch == QLatin1Char('r') && text == QLatin1String("rect")) { + else if (ch == QLatin1Char('r') && text == QLatin1String("rect")) return true; - } else if (ch == QLatin1Char('s') && text == QLatin1String("size")) { + else if (ch == QLatin1Char('s') && text == QLatin1String("size")) return true; - } else if (ch == QLatin1Char('s') && text == QLatin1String("string")) { + else if (ch == QLatin1Char('s') && text == QLatin1String("string")) return true; - } else if (ch == QLatin1Char('t') && text == QLatin1String("time")) { + else if (ch == QLatin1Char('t') && text == QLatin1String("time")) return true; - } else if (ch == QLatin1Char('u') && text == QLatin1String("url")) { + else if (ch == QLatin1Char('u') && text == QLatin1String("url")) return true; - } else if (ch == QLatin1Char('v') && text == QLatin1String("variant")) { + else if (ch == QLatin1Char('v') && text == QLatin1String("variant")) return true; - } else if (ch == QLatin1Char('v') && text == QLatin1String("var")) { + else if (ch == QLatin1Char('v') && text == QLatin1String("var")) return true; - } else if (ch == QLatin1Char('v') && text == QLatin1String("vector3d")) { + else if (ch == QLatin1Char('v') && text == QLatin1String("vector3d")) return true; - } else { + else return false; - } } int Highlighter::onBlockStart() |