forked from qt-creator/qt-creator
ProWriter: Remove QLatin1(Char|String)
Change-Id: I84f564ec5b12e5a397040cd3a132995327526f7d Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
88d1d92728
commit
6eac37a7d9
@@ -178,7 +178,7 @@ QString ProWriter::compileScope(const QString &scope)
|
||||
if (scope.isEmpty())
|
||||
return QString();
|
||||
QMakeParser parser(nullptr, nullptr, nullptr);
|
||||
ProFile *includeFile = parser.parsedProBlock(QStringRef(&scope), 0, QLatin1String("no-file"), 1);
|
||||
ProFile *includeFile = parser.parsedProBlock(QStringRef(&scope), 0, "no-file", 1);
|
||||
if (!includeFile)
|
||||
return QString();
|
||||
const QString result = includeFile->items();
|
||||
@@ -321,13 +321,13 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, const QString
|
||||
lines->erase(lines->begin() + lineNo + 1, lines->begin() + contInfo.lineNo);
|
||||
// remove rest of the line
|
||||
QString &line = (*lines)[lineNo];
|
||||
int eqs = line.indexOf(QLatin1Char('='));
|
||||
int eqs = line.indexOf('=');
|
||||
if (eqs >= 0) // If this is not true, we mess up the file a bit.
|
||||
line.truncate(eqs + 1);
|
||||
// put new values
|
||||
for (const QString &v : values) {
|
||||
line += ((flags & MultiLine) ? QLatin1String(" \\\n") + effectiveContIndent(contInfo)
|
||||
: QString::fromLatin1(" ")) + v;
|
||||
line += ((flags & MultiLine) ? QString(" \\\n") + effectiveContIndent(contInfo)
|
||||
: QString(" ")) + v;
|
||||
}
|
||||
} else {
|
||||
const ContinuationInfo contInfo = skipContLines(lines, lineNo, false);
|
||||
@@ -354,15 +354,14 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, const QString
|
||||
ContinuationInfo contInfo;
|
||||
if (!scope.isEmpty()) {
|
||||
if (scopeStart < 0) {
|
||||
added = QLatin1Char('\n') + scope + QLatin1String(" {");
|
||||
added = '\n' + scope + " {";
|
||||
} else {
|
||||
// TODO use anchoredPattern() once Qt 5.12 is mandatory
|
||||
const QRegularExpression rx("\\A(\\s*" + scope + "\\s*:\\s*)[^\\s{].*\\z");
|
||||
const QRegularExpressionMatch match(rx.match(lines->at(scopeStart)));
|
||||
if (match.hasMatch()) {
|
||||
(*lines)[scopeStart].replace(0, match.captured(1).length(),
|
||||
QString(scope + QLatin1String(" {\n")
|
||||
+ continuationIndent));
|
||||
scope + " {\n" + continuationIndent);
|
||||
contInfo = skipContLines(lines, scopeStart, false);
|
||||
lNo = contInfo.lineNo;
|
||||
scopeStart = -1;
|
||||
@@ -376,26 +375,26 @@ void ProWriter::putVarValues(ProFile *profile, QStringList *lines, const QString
|
||||
const QString &line = (*lines).at(lNo);
|
||||
for (int i = 0; i < line.size(); i++)
|
||||
// This is pretty sick, but qmake does pretty much the same ...
|
||||
if (line.at(i) == QLatin1Char('{')) {
|
||||
if (line.at(i) == '{') {
|
||||
++braces;
|
||||
} else if (line.at(i) == QLatin1Char('}')) {
|
||||
} else if (line.at(i) == '}') {
|
||||
if (!--braces)
|
||||
break;
|
||||
} else if (line.at(i) == QLatin1Char('#')) {
|
||||
} else if (line.at(i) == '#') {
|
||||
break;
|
||||
}
|
||||
} while (braces && ++lNo < lines->size());
|
||||
}
|
||||
for (; lNo > scopeStart + 1 && lines->at(lNo - 1).isEmpty(); lNo--) ;
|
||||
if (lNo != scopeStart + 1)
|
||||
added += QLatin1Char('\n');
|
||||
added += indent + var + QLatin1String((flags & AppendOperator) ? " +=" : " =");
|
||||
added += '\n';
|
||||
added += indent + var + ((flags & AppendOperator) ? " +=" : " =");
|
||||
for (const QString &v : values) {
|
||||
added += ((flags & MultiLine) ? QLatin1String(" \\\n") + effectiveContIndent(contInfo)
|
||||
: QString::fromLatin1(" ")) + v;
|
||||
added += ((flags & MultiLine) ? QString(" \\\n") + effectiveContIndent(contInfo)
|
||||
: QString(" ")) + v;
|
||||
}
|
||||
if (!scope.isEmpty() && scopeStart < 0)
|
||||
added += QLatin1String("\n}");
|
||||
added += "\n}";
|
||||
lines->insert(lNo, added);
|
||||
}
|
||||
}
|
||||
@@ -406,8 +405,8 @@ void ProWriter::addFiles(ProFile *profile, QStringList *lines, const QStringList
|
||||
QStringList valuesToWrite;
|
||||
QString prefixPwd;
|
||||
QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
|
||||
if (profile->fileName().endsWith(QLatin1String(".pri")))
|
||||
prefixPwd = QLatin1String("$$PWD/");
|
||||
if (profile->fileName().endsWith(".pri"))
|
||||
prefixPwd = "$$PWD/";
|
||||
for (const QString &v : values)
|
||||
valuesToWrite << (prefixPwd + baseDir.relativeFilePath(v));
|
||||
|
||||
@@ -466,7 +465,7 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
|
||||
int lineLen = line.length();
|
||||
bool killed = false;
|
||||
bool saved = false;
|
||||
int idx = line.indexOf(QLatin1Char('#'));
|
||||
int idx = line.indexOf('#');
|
||||
if (idx >= 0)
|
||||
lineLen = idx;
|
||||
QChar *chars = line.data();
|
||||
@@ -477,30 +476,30 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
|
||||
goto nextVar;
|
||||
}
|
||||
QChar c = chars[lineLen - 1];
|
||||
if (c != QLatin1Char(' ') && c != QLatin1Char('\t'))
|
||||
if (c != ' ' && c != '\t')
|
||||
break;
|
||||
lineLen--;
|
||||
}
|
||||
{
|
||||
int contCol = -1;
|
||||
if (chars[lineLen - 1] == QLatin1Char('\\'))
|
||||
if (chars[lineLen - 1] == '\\')
|
||||
contCol = --lineLen;
|
||||
int colNo = 0;
|
||||
if (first) {
|
||||
colNo = line.indexOf(QLatin1Char('=')) + 1;
|
||||
colNo = line.indexOf('=') + 1;
|
||||
first = false;
|
||||
saved = true;
|
||||
}
|
||||
while (colNo < lineLen) {
|
||||
QChar c = chars[colNo];
|
||||
if (c == QLatin1Char(' ') || c == QLatin1Char('\t')) {
|
||||
if (c == ' ' || c == '\t') {
|
||||
colNo++;
|
||||
continue;
|
||||
}
|
||||
int varCol = colNo;
|
||||
while (colNo < lineLen) {
|
||||
QChar c = chars[colNo];
|
||||
if (c == QLatin1Char(' ') || c == QLatin1Char('\t'))
|
||||
if (c == (' ') || c == ('\t'))
|
||||
break;
|
||||
colNo++;
|
||||
}
|
||||
@@ -519,7 +518,7 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
|
||||
contCol -= len;
|
||||
idx -= len;
|
||||
if (idx >= 0)
|
||||
line.insert(idx, QLatin1String("# ") + fn + QLatin1Char(' '));
|
||||
line.insert(idx, "# " + fn + ' ');
|
||||
chars = line.data();
|
||||
killed = true;
|
||||
} else {
|
||||
@@ -537,8 +536,7 @@ QList<int> ProWriter::removeVarValues(ProFile *profile, QStringList *lines,
|
||||
QString &bline = (*lines)[pos.first];
|
||||
bline.remove(pos.second, 1);
|
||||
if (pos.second == bline.length())
|
||||
while (bline.endsWith(QLatin1Char(' '))
|
||||
|| bline.endsWith(QLatin1Char('\t')))
|
||||
while (bline.endsWith(' ') || bline.endsWith('\t'))
|
||||
bline.chop(1);
|
||||
}
|
||||
contPos.clear();
|
||||
@@ -574,7 +572,7 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
|
||||
Utils::transform(removeVarValues(profile, lines, valuesToFind, vars),
|
||||
[values](int i) { return values.at(i); });
|
||||
|
||||
if (!profile->fileName().endsWith(QLatin1String(".pri")))
|
||||
if (!profile->fileName().endsWith(".pri"))
|
||||
return notYetChanged;
|
||||
|
||||
// If we didn't find them with a relative path to the .pro file
|
||||
@@ -582,7 +580,7 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
|
||||
|
||||
valuesToFind.clear();
|
||||
const QDir baseDir = QFileInfo(profile->fileName()).absoluteDir();
|
||||
const QString prefixPwd = QLatin1String("$$PWD/");
|
||||
const QString prefixPwd = "$$PWD/";
|
||||
for (const QString &absoluteFilePath : notYetChanged)
|
||||
valuesToFind << (prefixPwd + baseDir.relativeFilePath(absoluteFilePath));
|
||||
|
||||
|
Reference in New Issue
Block a user