Port away from deprecated ::endl

Using a helper constexp in the KDevelop namespace where lots of endl
are used, to limit #if#else#endifs in the code. Can be completely
ported once Qt >= 5.14 is min required version

GIT_SILENT
parent 23ed2286
......@@ -27,6 +27,16 @@
#include "serialization/itemrepository.h"
namespace KDevelop {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
DEFINE_LIST_MEMBER_HASH(DefinitionsItem, definitions, IndexedDeclaration)
class DefinitionsItem
......
......@@ -38,8 +38,6 @@
#include <editor/rangeinrevision.h>
#include <editor/documentrange.h>
using namespace KDevelop;
namespace {
QDebug fromTextStream(const QTextStream& out)
{
......@@ -51,6 +49,18 @@ QDebug fromTextStream(const QTextStream& out)
};
}
}
namespace KDevelop {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
QString typeToString(DUContext::ContextType type)
{
switch (type) {
......@@ -66,9 +76,8 @@ QString typeToString(DUContext::ContextType type)
Q_ASSERT(false);
return QString();
}
}
class KDevelop::DUChainDumperPrivate
class DUChainDumperPrivate
{
public:
DUChainDumperPrivate()
......@@ -224,3 +233,5 @@ void DUChainDumper::dump(DUContext* context, int allowedDepth)
QTextStream out(stdout);
dump(context, allowedDepth, out);
}
}
......@@ -47,6 +47,14 @@ QDebug fromTextStream(const QTextStream& out)
}
namespace KDevelop {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
Utils::BasicSetRepository* RecursiveImportCacheRepository::repository()
{
static Utils::BasicSetRepository recursiveImportCacheRepositoryObject(QStringLiteral(
......
......@@ -68,6 +68,13 @@ template <class SessionT, class TokenStreamT, class TokenT, class LexerT,
class StartAstT, class DebugVisitorT, TokenTextFunc TokenTextT>
class DebugLanguageParserHelper
{
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
static constexpr TextStreamFunction endl = Qt::endl;
#else
static constexpr TextStreamFunction endl = ::endl;
#endif
public:
DebugLanguageParserHelper(const bool printAst, const bool printTokens)
: m_printAst(printAst)
......@@ -227,7 +234,11 @@ int initAndRunParser(KAboutData& aboutData, int argc, char* argv[])
if (fileName == "-") {
#ifndef Q_OS_WIN
if (isatty(STDIN_FILENO)) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
qerr << "no STDIN given" << Qt::endl;
#else
qerr << "no STDIN given" << endl;
#endif
return 255;
}
#endif
......
......@@ -48,6 +48,13 @@ using namespace KDevelop;
namespace KDevelop {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
// wrap the ProjectController to make its addProject() method public
class ProjectControllerWrapper : public ProjectController
{
......@@ -150,7 +157,7 @@ int main(int argc, char** argv)
auto manager = new AbstractFileManagerPlugin({}, core);
const char *kdwMethod[] = {"FAM", "Inotify", "Stat", "QFSWatch"};
qout << "KDirWatch backend: " << kdwMethod[KDirWatch().internalMethod()] << endl;
qout << "KDirWatch backend: " << kdwMethod[KDirWatch().internalMethod()] << KDevelop::endl;
QList<AbstractFileManagerPluginImportBenchmark*> benchmarks;
......
......@@ -31,9 +31,7 @@
#include <QFile>
#include <QDir>
using namespace KDevelop;
namespace {
namespace KDevelop {
QString lockFileForSession( const QString& id )
{
......@@ -55,8 +53,6 @@ void forceRemoveLockfile(const QString& lockFilename)
}
}
}
TryLockSessionResult SessionLock::tryLockSession(const QString& sessionId, bool doLocking)
{
///FIXME: if this is hit, someone tried to lock a non-existing session
......@@ -222,3 +218,5 @@ QString SessionLock::handleLockedSession(const QString& sessionName, const QStri
return QString();
}
}
......@@ -73,6 +73,14 @@ QString UseDefault() { return QStringLiteral("UseDefault"); }
namespace KDevelop
{
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
class SourceFormatterControllerPrivate
{
public:
......
......@@ -34,6 +34,14 @@
namespace KDevelop {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
bool askUser(const QString& mainText,
const QString& ttyPrompt,
const QString& mboxTitle,
......
......@@ -98,7 +98,11 @@ CXChildVisitResult visitCursor(CXCursor cursor, CXCursor /*parent*/, CXClientDat
}
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
(*data->out) << Qt::endl;
#else
(*data->out) << endl;
#endif
ClientData childData{data->out, data->session, data->file, data->depth + 1};
clang_visitChildren(cursor, &visitCursor, &childData);
......
......@@ -32,6 +32,13 @@ using namespace KDevelop;
using namespace KDevelopUtils;
class ClangParser {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
static constexpr TextStreamFunction endl = Qt::endl;
#else
static constexpr TextStreamFunction endl = ::endl;
#endif
public:
ClangParser(const bool printAst, const bool printTokens)
: m_session({})
......
......@@ -169,6 +169,11 @@ void DebugVisitor::printNode(QmlJS::AST::Node* node, Position position)
qout << indent() << stringForAstKind(node->kind)
<< " [(" << start.startLine << ", " << start.startColumn << "), "
<< "(" << end.startLine << ", " << (end.startColumn + end.length) << ")]"
<< " \"" << m_session->symbolAt(location) << "\"" << endl;
<< " \"" << m_session->symbolAt(location) << "\""
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
<< Qt::endl;
#else
<< endl;
#endif
}
......@@ -29,6 +29,13 @@ using namespace KDevelop;
using namespace KDevelopUtils;
class QmlParser {
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
static constexpr TextStreamFunction endl = Qt::endl;
#else
static constexpr TextStreamFunction endl = ::endl;
#endif
public:
QmlParser(const bool printAst, const bool printTokens)
: m_printAst(printAst), m_printTokens(printTokens)
......
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