Commit 1312363d authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use QChar/QLatin1Char/char for single char strings where possible

parent f8bbbd02
......@@ -247,7 +247,7 @@ static bool nodeNeedsUpdate(uint index) {
QString ModificationRevisionSet::toString() const
{
QMutexLocker lock(&modificationRevisionSetMutex);
QString ret = QStringLiteral("["); // krazy:exclude=doublequote_chars
QString ret(QLatin1Char('['));
Utils::Set set(m_index, &FileModificationSetRepositoryRepresenter::repository());
Utils::Set::Iterator it = set.iterator();
bool first = true;
......
......@@ -306,7 +306,7 @@ void MainWindow::loadSettings()
QString group(QStringLiteral("Toolbar"));
// Give a number to the toolbar, but prefer a name if there is one,
// because there's no real guarantee on the ordering of toolbars
group += (toolbar->objectName().isEmpty() ? QString::number(n) : QStringLiteral(" ")+toolbar->objectName());
group += (toolbar->objectName().isEmpty() ? QString::number(n) : QLatin1Char(' ')+toolbar->objectName());
KConfigGroup toolbarGroup(&cg, group);
toolbar->applySettings(toolbarGroup);
......
......@@ -185,7 +185,7 @@ KDevelop::VcsEvent BazaarUtils::parseBzrLogPart(const QString& output)
}
} else if (atMessage && !afterMessage) {
if (!line.isEmpty() && line[0].isSpace()) {
message += line.trimmed() + "\n";
message += line.trimmed() + QLatin1Char('\n');
} else if (!line.isEmpty()) {
afterMessage = true;
// leave atMessage = true
......
......@@ -167,7 +167,7 @@ void BzrAnnotateJob::parseBzrLog(KDevelop::DVcsJob* job)
atMessage = true;
}
} else {
message += line.trimmed() + "\n";
message += line.trimmed() + QLatin1Char('\n');
}
}
if (atMessage)
......
......@@ -179,7 +179,7 @@ ClangSupport::ClangSupport(QObject* parent, const QVariantList& )
{
const auto builtinDir = ClangIntegration::DUChainUtils::clangBuiltinIncludePath();
const auto headerToCheck = QLatin1String("cpuid.h");
if (!QFile::exists(builtinDir + QLatin1String("/") + headerToCheck)) {
if (!QFile::exists(builtinDir + QLatin1Char('/') + headerToCheck)) {
setErrorDescription(i18n("The clang builtin include path \"%1\" is invalid (missing %2 header).\n"
"Try setting the KDEV_CLANG_BUILTIN_DIR environment variable manually to fix this.\n"
"See also: https://bugs.kde.org/show_bug.cgi?id=393779", builtinDir, headerToCheck));
......
......@@ -162,11 +162,11 @@ QString SourceCodeInsertion::applySubScope(const QString& decl) const
QString ret;
foreach (const QString& scope, m_scope.toStringList()) {
ret += scopeType + QStringLiteral(" ") + scope + QStringLiteral(" {\n");
ret += scopeType + QLatin1Char(' ') + scope + QStringLiteral(" {\n");
}
ret += decl;
ret += QStringLiteral("}") + scopeClose + QStringLiteral("\n").repeated(m_scope.count());
ret += QLatin1Char('}') + scopeClose + QStringLiteral("\n").repeated(m_scope.count());
return ret;
}
......@@ -240,10 +240,10 @@ bool SourceCodeInsertion::insertFunctionDeclaration(KDevelop::Declaration* decla
decl.replace(declaration->qualifiedIdentifier().toString(), id.toString());
if (body.isEmpty()) {
decl += QStringLiteral(";");
decl += QLatin1Char(';');
} else {
if (!body.startsWith(QLatin1Char(' ')) && !body.startsWith(QLatin1Char('\n'))) {
decl += QStringLiteral(" ");
decl += QLatin1Char(' ');
}
decl += zeroIndentation(body);
}
......
......@@ -56,21 +56,21 @@ CXChildVisitResult visitCursor(CXCursor cursor, CXCursor /*parent*/, CXClientDat
auto type = clang_getCursorType(cursor);
if (type.kind != CXType_Invalid) {
ClangString typeName(clang_getTypeSpelling(type));
(*data->out) << "| type: \"" << typeName << "\"" << " (" << type.kind << ") ";
(*data->out) << "| type: \"" << typeName << '\"' << " (" << type.kind << ") ";
}
auto canonicalType = clang_getCanonicalType(type);
if (canonicalType.kind != CXType_Invalid
&& !clang_equalTypes(type, canonicalType)) {
ClangString typeName(clang_getTypeSpelling(canonicalType));
(*data->out) << "| canonical type: \"" << typeName << "\"" << " (" << canonicalType.kind << ") ";
(*data->out) << "| canonical type: \"" << typeName << '\"' << " (" << canonicalType.kind << ") ";
}
auto typedefType = clang_getTypedefDeclUnderlyingType(cursor);
if (typedefType.kind != CXType_Invalid
&& !clang_equalTypes(type, typedefType)) {
ClangString typeName(clang_getTypeSpelling(typedefType));
(*data->out) << "| typedef type: \"" << typeName << "\"" << " (" << typedefType.kind << ") ";
(*data->out) << "| typedef type: \"" << typeName << '\"' << " (" << typedefType.kind << ") ";
}
ClangString displayName(clang_getCursorDisplayName(cursor));
......
......@@ -63,7 +63,7 @@ QString escapePath(QString path)
static const QString toBeEscaped = QStringLiteral("\"()#$^");
for(const QChar &ch : toBeEscaped) {
path.replace(ch, "\\" + ch);
path.replace(ch, QLatin1Char('\\') + ch);
}
return path;
}
......
......@@ -227,7 +227,7 @@ void ProjectPathsWidget::batchEdit()
auto defines = pathsModel->data(midx, ProjectPathsModel::DefinesDataRole).value<Defines>();
for (auto it = defines.constBegin(); it != defines.constEnd(); it++) {
be.textEdit->appendPlainText(it.key() + "=" + it.value());
be.textEdit->appendPlainText(it.key() + QLatin1Char('=') + it.value());
}
dialog->setWindowTitle(i18n("Edit defined macros"));
......
......@@ -272,7 +272,7 @@ PathResolutionResult MakeFileResolver::resolveIncludePath(const QString& file, c
QString localName = sourceDir.dirName();
if (sourceDir.cdUp() && !fileName.isAbsolute()) {
QString checkFor = localName + "/" + file;
const QString checkFor = localName + QLatin1Char('/') + file;
PathResolutionResult oneUp = resolveIncludePath(checkFor, sourceDir.path(), maxStepsUp-1);
if (oneUp.success) {
oneUp.mergeWith(resultOnFail);
......
......@@ -184,7 +184,7 @@ QString Utils::unquoteExpression(const QString& expr)
QString Utils::quote(const QString& str, char quoteCh)
{
QString res = str;
res.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(quoteCh, QStringLiteral("\\") + quoteCh);
res.replace(QLatin1Char('\\'), QLatin1String("\\\\")).replace(quoteCh, QLatin1Char('\\') + quoteCh);
return quoteCh + res + quoteCh;
}
......
......@@ -393,7 +393,7 @@ void DisassembleWidget::disassembleMemoryHandler(const ResultRecord& r)
//We use offset at the same column where function is.
if(currentFunction == fct){
if(!fct.isEmpty()){
fct = QStringLiteral("+") + offs;
fct = QLatin1Char('+') + offs;
}
}else { currentFunction = fct; }
......
......@@ -73,7 +73,7 @@ PlasmoidExecutionJob::PlasmoidExecutionJob(ExecutePlasmoidPlugin* iface, ILaunch
void PlasmoidExecutionJob::start()
{
startOutput();
model()->appendLine( m_process->workingDirectory() + "> " + m_process->command() + " " + m_process->arguments().join(QLatin1Char(' ')) );
model()->appendLine( m_process->workingDirectory() + "> " + m_process->command() + ' ' + m_process->arguments().join(QLatin1Char(' ')) );
m_process->start();
}
......
......@@ -100,7 +100,7 @@ KDevelop::VcsJob * ProviderWidget::createWorkingCopy(const QUrl &dest)
QString url = pos.data(ProviderModel::VcsLocationRole).toString();
if (m_account->validAccount())
url = "https://" + m_account->token() + "@" + url.mid(8);
url = QLatin1String("https://") + m_account->token() + QLatin1Char('@') + url.midRef(8);
QUrl real = QUrl(url);
VcsLocation loc(real);
......
......@@ -66,7 +66,7 @@ QString toRevisionName(const KDevelop::VcsRevision& rev, const QString& currentR
case VcsRevision::Previous:
Q_ASSERT(!currentRevision.isEmpty());
tmp.setNum(previous);
tmp.prepend("#");
tmp.prepend(QLatin1Char('#'));
return tmp;
case VcsRevision::Start:
return QString();
......
......@@ -60,16 +60,16 @@ QString descriptionFromProblem(IProblem::Ptr problem)
.adjusted(QUrl::NormalizePathSegments)
.toDisplayString(QUrl::PreferLocalFile);
if (location.start().line() >= 0) {
text += QStringLiteral(":") + QString::number(location.start().line() + 1);
text += QLatin1Char(':') + QString::number(location.start().line() + 1);
if (location.start().column() >= 0) {
text += QStringLiteral(":") + QString::number(location.start().column() + 1);
text += QLatin1Char(':') + QString::number(location.start().column() + 1);
}
}
text += QStringLiteral(": ");
}
text += problem->description();
if (!problem->explanation().isEmpty()) {
text += QStringLiteral("\n") + problem->explanation();
text += QLatin1Char('\n') + problem->explanation();
}
return text;
}
......
......@@ -209,11 +209,11 @@ void CompletionItem::execute(KTextEditor::View* view, const KTextEditor::Range&
break;
case QmlJS::CompletionItem::Quotes:
document->replaceText(word, "\"" + base + "\"");
document->replaceText(word, '\"' + base + '\"');
break;
case QmlJS::CompletionItem::QuotesAndBracket:
document->replaceText(word, "\"" + base + "\"]");
document->replaceText(word, '\"' + base + "\"]");
break;
case QmlJS::CompletionItem::ColonOrBracket:
......
......@@ -81,13 +81,13 @@ FunctionCalltipCompletionItem::FunctionCalltipCompletionItem(const DeclarationPo
// [type] functionName
if (func->returnType()) {
m_prefix = func->returnType()->toString() + QLatin1String(" ");
m_prefix = func->returnType()->toString() + QLatin1Char(' ');
}
m_prefix += decl->identifier().toString();
// (arg1, arg2, [currentArgument in m_currentArgument], arg4, arg5)
m_arguments = QStringLiteral("(");
m_arguments = QLatin1Char('(');
for (int i=0; i<arguments.count(); ++i) {
if (i > 0) {
......@@ -102,7 +102,7 @@ FunctionCalltipCompletionItem::FunctionCalltipCompletionItem(const DeclarationPo
m_arguments += arguments.at(i);
}
m_arguments += QLatin1String(")");
m_arguments += QLatin1Char(')');
}
AbstractType::Ptr FunctionCalltipCompletionItem::currentArgumentType() const
......
......@@ -201,8 +201,8 @@ QStringList QmlJS::Cache::getFileNames(const QFileInfoList& fileInfos)
if (dumpFile.open(QIODevice::WriteOnly)) {
qmlplugindump.readLine(); // Skip "import QtQuick.tooling 1.1"
dumpFile.write("// " + filePath.toUtf8() + "\n");
dumpFile.write("import QtQuick " + executable.quickVersion.toUtf8() + "\n");
dumpFile.write("// " + filePath.toUtf8() + '\n');
dumpFile.write("import QtQuick " + executable.quickVersion.toUtf8() + '\n');
dumpFile.write(qmlplugindump.readAllStandardOutput());
dumpFile.close();
......
......@@ -142,7 +142,7 @@ QString DUChainItemData::htmlDescription() const
if (function && function->returnType()) {
text = i18nc("%1: function signature", "Return: %1",
function->partToString(FunctionType::SignatureReturn)) + QLatin1String(" ");
function->partToString(FunctionType::SignatureReturn)) + QLatin1Char(' ');
}
text += i18nc("%1: file path", "File: %1", ICore::self()->projectController()->prettyFileName(decl->url().toUrl()));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment