Commit 74fcf21f authored by Milian Wolff's avatar Milian Wolff
Browse files

Remove obsolete QT_VERSION checks

We depend on Qt 5.15 nowadays, so we can get rid of all existing
QT_VERSION checks in that area to reduce clutter.
parent a6390bf3
......@@ -186,14 +186,7 @@ private:
Q_DECLARE_PRIVATE(BreakpointModel)
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(BreakpointModel::ColumnFlags)
#endif
}
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::BreakpointModel::ColumnFlags)
#endif
#endif
......@@ -79,14 +79,7 @@ private:
Q_DECLARE_PRIVATE(IVariableController)
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(IVariableController::UpdateTypes)
#endif
} // namespace KDevelop
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::IVariableController::UpdateTypes)
#endif
#endif
......@@ -216,14 +216,7 @@ Q_SIGNALS:
friend class IDocument;
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(IDocumentController::DocumentActivationParams)
#endif
} // namespace KDevelop
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::IDocumentController::DocumentActivationParams)
#endif
#endif
......@@ -180,21 +180,13 @@ QString ISourceFormatter::optionMapToString(const QMap<QString, QVariant> &map)
QMap<QString, QVariant> ISourceFormatter::stringToOptionMap(const QString &options)
{
QMap<QString, QVariant> map;
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QMap<QString, QVariant> map;
const auto pairs = options.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
for (auto& pair : pairs) {
const int pos = pair.indexOf(QLatin1Char('='));
map.insert(pair.left(pos).toString(), pair.mid(pos+1).toString());
}
#else
const QStringList pairs = options.split(QLatin1Char(','), QString::SkipEmptyParts);
for (auto& pair : pairs) {
const QStringList bits = pair.split(QLatin1Char('='));
map[bits[0]] = bits[1];
}
#endif
return map;
}
return map;
}
SourceFormatterStyle::MimeList ISourceFormatter::mimeTypesSupportedByBuiltInStyles()
......
......@@ -223,11 +223,7 @@ ReferencedTopDUContext ParseJob::duChain() const
bool ParseJob::abortRequested() const
{
Q_D(const ParseJob);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return d->abortRequested.loadRelaxed() != 0;
#else
return d->abortRequested.load() != 0;
#endif
}
void ParseJob::requestAbort()
......
......@@ -231,14 +231,7 @@ private:
Q_DECLARE_PRIVATE(ParseJob)
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(ParseJob::SequentialProcessingFlags)
#endif
}
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::ParseJob::SequentialProcessingFlags)
#endif
#endif
......@@ -208,13 +208,8 @@ DocumentChangeSet::ChangeResult DocumentChangeSet::applyAllChanges()
}
QList<QUrl> allFiles;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const auto changedFiles =
QSet<KDevelop::IndexedString>(d->documentsRename.keyBegin(), d->documentsRename.keyEnd()) +
QSet<KDevelop::IndexedString>(d->changes.keyBegin(), d->changes.keyEnd());
#else
const auto changedFiles = d->documentsRename.keys().toSet() + d->changes.keys().toSet();
#endif
const auto changedFiles = QSet<KDevelop::IndexedString>(d->documentsRename.keyBegin(), d->documentsRename.keyEnd())
+ QSet<KDevelop::IndexedString>(d->changes.keyBegin(), d->changes.keyEnd());
allFiles.reserve(changedFiles.size());
for (const IndexedString& file : changedFiles) {
allFiles << file.toUrl();
......
......@@ -123,11 +123,7 @@ QString TemplateRenderer::render(const QString& content, const QString& name)
}
if (d->emptyLinesPolicy == TrimEmptyLines && output.contains(QLatin1Char('\n'))) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList lines = output.split(QLatin1Char('\n'), Qt::KeepEmptyParts);
#else
QStringList lines = output.split(QLatin1Char('\n'), QString::KeepEmptyParts);
#endif
QMutableStringListIterator it(lines);
// Remove empty lines from the start of the document
......@@ -182,11 +178,7 @@ QString TemplateRenderer::render(const QString& content, const QString& name)
output = lines.join(QLatin1Char('\n'));
} else if (d->emptyLinesPolicy == RemoveEmptyLines) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList lines = output.split(QLatin1Char('\n'), Qt::SkipEmptyParts);
#else
QStringList lines = output.split(QLatin1Char('\n'), QString::SkipEmptyParts);
#endif
QMutableStringListIterator it(lines);
while (it.hasNext()) {
if (it.next().trimmed().isEmpty()) {
......
......@@ -84,9 +84,7 @@ private:
virtual AbstractFunctionDeclarationData* dynamicData() = 0;
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractFunctionDeclaration::FunctionSpecifiers)
#endif
///Use this to merge AbstractFunctionDeclaration into the class hierarchy. Base must be the base-class
///in the hierarchy, and Data must be the Data class of the following Declaration, and must be based on AbstractFunctionDeclarationData
......@@ -123,8 +121,4 @@ private:
}
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::AbstractFunctionDeclaration::FunctionSpecifiers)
#endif
#endif // KDEVPLATFORM_ABSTRACTFUNCTIONDECLARATION_H
......@@ -94,14 +94,7 @@ private:
Declaration* clonePrivate() const override;
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(ClassMemberDeclaration::StorageSpecifiers)
#endif
}
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::ClassMemberDeclaration::StorageSpecifiers)
#endif
#endif // KDEVPLATFORM_CLASSMEMBERDECLARATION_H
......@@ -15,16 +15,6 @@
#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
......@@ -130,11 +120,11 @@ public:
auto id = item->declaration;
const auto allDefinitions = definitions->definitions(id);
qout << "Definitions for" << id.qualifiedIdentifier() << endl;
qout << "Definitions for" << id.qualifiedIdentifier() << Qt::endl;
for (const IndexedDeclaration& decl : allDefinitions) {
if (decl.data()) {
qout << " " << decl.data()->qualifiedIdentifier() << "in" << decl.data()->url().byteArray() << "at" <<
decl.data()->rangeInCurrentRevision() << endl;
qout << " " << decl.data()->qualifiedIdentifier() << "in" << decl.data()->url().byteArray() << "at"
<< decl.data()->rangeInCurrentRevision() << Qt::endl;
}
}
......
......@@ -20,9 +20,7 @@
#include <QMutexLocker>
#include <QRecursiveMutex>
#include <QTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include <interfaces/idocumentcontroller.h>
#include <interfaces/icore.h>
......@@ -950,11 +948,7 @@ unloadContexts:
it != m_fileEnvironmentInformations.end();) {
ParsingEnvironmentFile* f = it->data();
Q_ASSERT(f->d_func()->classId);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
if (f->ref.loadRelaxed() == 1) {
#else
if (f->ref.load() == 1) {
#endif
Q_ASSERT(!f->d_func()->isDynamic()); //It cannot be dynamic, since we have stored before
//The ParsingEnvironmentFilePointer is only referenced once. This means that it does not belong to any
//loaded top-context, so just remove it to save some memory and processing time.
......@@ -1101,12 +1095,8 @@ unloadContexts:
if (checkContextsCount < percentageOfContexts)
checkContextsCount = percentageOfContexts;
if (visitor.checkContexts.size() > ( int )checkContextsCount)
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (visitor.checkContexts.size() > (int)checkContextsCount)
startPos = QRandomGenerator::global()->bounded(visitor.checkContexts.size() - checkContextsCount);
#else
startPos = qrand() % (visitor.checkContexts.size() - checkContextsCount);
#endif
int endPos = startPos + maxFinalCleanupCheckContexts;
if (endPos > visitor.checkContexts.size())
......
......@@ -40,15 +40,6 @@ 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) {
......@@ -115,13 +106,13 @@ void DUChainDumperPrivate::dumpProblems(TopDUContext* top, QTextStream& out)
QDebug qout = fromTextStream(out);
if (!top->problems().isEmpty()) {
qout << top->problems().size() << "problems encountered:" << endl;
qout << top->problems().size() << "problems encountered:" << Qt::endl;
const auto problems = top->problems();
for (const ProblemPointer& p : problems) {
qout << Indent(m_indent * 2) << p->description() << p->explanation() << p->finalLocation() << endl;
qout << Indent(m_indent * 2) << p->description() << p->explanation() << p->finalLocation() << Qt::endl;
}
qout << endl;
qout << Qt::endl;
}
}
......@@ -131,15 +122,14 @@ void DUChainDumperPrivate::dump(DUContext* context, int allowedDepth, bool isFro
qout << Indent(m_indent * 2) << (isFromImport ? " ==import==>" : "")
<< (dynamic_cast<TopDUContext*>(context) ? "Top-Context" : "Context") << typeToString(context->type())
<< "(owner: " << context->owner() << ")"
<< context << context->localScopeIdentifier() << "[" << context->scopeIdentifier(true) << "]"
<< context->range().castToSimpleRange()
<< "(owner: " << context->owner() << ")" << context << context->localScopeIdentifier() << "["
<< context->scopeIdentifier(true) << "]" << context->range().castToSimpleRange()
<< (dynamic_cast<TopDUContext*>(context) ? static_cast<TopDUContext*>(context)->url().byteArray() : "")
<< endl;
<< Qt::endl;
if (m_visitedContexts.contains(context)) {
qout << Indent((m_indent + 2) * 2) << "(Skipping" << context->scopeIdentifier(true) <<
"because it was already printed)" << endl;
qout << Indent((m_indent + 2) * 2) << "(Skipping" << context->scopeIdentifier(true)
<< "because it was already printed)" << Qt::endl;
return;
}
......@@ -151,26 +141,26 @@ void DUChainDumperPrivate::dump(DUContext* context, int allowedDepth, bool isFro
for (Declaration* dec : localDeclarations) {
//IdentifiedType* idType = dynamic_cast<IdentifiedType*>(dec->abstractType().data());
qout << Indent((m_indent + 2) * 2) << "Declaration:" << dec->toString() << "[" <<
dec->qualifiedIdentifier() << "]"
<< dec << "(internal ctx:" << dec->internalContext() << ")" << dec->range().castToSimpleRange() << ","
qout << Indent((m_indent + 2) * 2) << "Declaration:" << dec->toString() << "[" << dec->qualifiedIdentifier()
<< "]" << dec << "(internal ctx:" << dec->internalContext() << ")" << dec->range().castToSimpleRange()
<< ","
<< (dec->isDefinition() ? "defined, " : (FunctionDefinition::definition(dec) ? "" : "no definition, "))
<< dec->uses().count() << "use(s)." << endl;
<< dec->uses().count() << "use(s)." << Qt::endl;
if (FunctionDefinition::definition(dec)) {
qout << Indent((m_indent + 2) * 2 + 1) << "Definition:" <<
FunctionDefinition::definition(dec)->range().castToSimpleRange() << endl;
qout << Indent((m_indent + 2) * 2 + 1)
<< "Definition:" << FunctionDefinition::definition(dec)->range().castToSimpleRange() << Qt::endl;
}
const auto uses = dec->uses();
for (auto it = uses.constBegin(); it != uses.constEnd(); ++it) {
qout << Indent((m_indent + 3) * 2) << "File:" << it.key().str() << endl;
qout << Indent((m_indent + 3) * 2) << "File:" << it.key().str() << Qt::endl;
for (const RangeInRevision range : qAsConst(*it)) {
qout << Indent((m_indent + 4) * 2) << "Use:" << range.castToSimpleRange() << endl;
qout << Indent((m_indent + 4) * 2) << "Use:" << range.castToSimpleRange() << Qt::endl;
}
}
}
} else {
qout << Indent((m_indent + 2) * 2) << context->localDeclarations(top).count()
<< "Declarations," << context->childContexts().size() << "child-contexts" << endl;
qout << Indent((m_indent + 2) * 2) << context->localDeclarations(top).count() << "Declarations,"
<< context->childContexts().size() << "child-contexts" << Qt::endl;
}
++m_indent;
......@@ -180,7 +170,7 @@ void DUChainDumperPrivate::dump(DUContext* context, int allowedDepth, bool isFro
for (const DUContext::Import& parent : importedParentContexts) {
DUContext* import = parent.context(top);
if(!import) {
qout << Indent((m_indent+2) * 2+1) << "Could not get parent, is it registered in the DUChain?" << endl;
qout << Indent((m_indent+2) * 2+1) << "Could not get parent, is it registered in the DUChain?" << Qt::endl;
continue;
}
......@@ -203,7 +193,7 @@ void DUChainDumper::dump(DUContext* context, int allowedDepth, QTextStream& out)
d->m_visitedContexts.clear();
if (!context) {
out << "Error: Null context" << endl;
out << "Error: Null context" << Qt::endl;
return;
}
......
......@@ -115,11 +115,7 @@ bool DUChainLock::lockForWrite(uint timeout)
Q_ASSERT(d->ownReaderRecursion() == 0);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
if (d->m_writer.loadRelaxed() == QThread::currentThread()) {
#else
if (d->m_writer.load() == QThread::currentThread()) {
#endif
//We already hold the write lock, just increase the recursion count and return
d->m_writerRecursion.fetchAndAddRelaxed(1);
return true;
......@@ -132,19 +128,10 @@ bool DUChainLock::lockForWrite(uint timeout)
while (1) {
//Try acquiring the write-lcok
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
if (d->m_totalReaderRecursion.loadRelaxed() == 0 &&
#else
if (d->m_totalReaderRecursion.load() == 0 &&
#endif
d->m_writerRecursion.testAndSetOrdered(0, 1)) {
if (d->m_totalReaderRecursion.loadRelaxed() == 0 && d->m_writerRecursion.testAndSetOrdered(0, 1)) {
//Now we can be sure that there is no other writer, as we have increased m_writerRecursion from 0 to 1
d->m_writer = QThread::currentThread();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
if (d->m_totalReaderRecursion.loadRelaxed() == 0) {
#else
if (d->m_totalReaderRecursion.load() == 0) {
#endif
//There is still no readers, we have successfully acquired a write-lock
return true;
} else {
......@@ -174,11 +161,7 @@ void DUChainLock::releaseWriteLock()
//The order is important here, m_writerRecursion protects m_writer
//TODO: could testAndSet here
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
if (d->m_writerRecursion.loadRelaxed() == 1) {
#else
if (d->m_writerRecursion.load() == 1) {
#endif
d->m_writer = nullptr;
d->m_writerRecursion = 0;
} else {
......@@ -190,11 +173,7 @@ bool DUChainLock::currentThreadHasWriteLock() const
{
Q_D(const DUChainLock);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
return d->m_writer.loadRelaxed() == QThread::currentThread();
#else
return d->m_writer.load() == QThread::currentThread();
#endif
}
DUChainReadLocker::DUChainReadLocker(DUChainLock* duChainLock, uint timeout)
......
......@@ -42,9 +42,7 @@ struct KDEVPLATFORMLANGUAGE_EXPORT Colorizer
Formatting m_formatting;
};
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(Colorizer::Formatting)
#endif
class AbstractNavigationContext;
using NavigationContextPointer = QExplicitlySharedDataPointer<AbstractNavigationContext>;
......@@ -164,8 +162,4 @@ private:
}
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::Colorizer::Formatting)
#endif
#endif
......@@ -29,14 +29,6 @@ namespace {
// For now, just _always_ use the cache
const uint MinimumCountForCache = 1;
using TextStreamFunction = QTextStream& (*)(QTextStream&);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
constexpr TextStreamFunction endl = Qt::endl;
#else
constexpr TextStreamFunction endl = ::endl;
#endif
QDebug fromTextStream(const QTextStream& out)
{
if (out.device())
......@@ -447,21 +439,21 @@ struct DebugVisitor
IndexedDeclaration decl(item->declarations()[a]);
if (!decl.isDummy()) {
if (declarations.contains(decl)) {
qout << "declaration found for multiple identifiers. Previous identifier:" <<
declarations[decl].toString() << "current identifier:" << id.toString() << endl;
qout << "declaration found for multiple identifiers. Previous identifier:"
<< declarations[decl].toString() << "current identifier:" << id.toString() << Qt::endl;
} else {
declarations.insert(decl, id);
}
}
if (decl.data() && decl.data()->qualifiedIdentifier() != item->id.identifier()) {
qout << decl.data()->url().str() << "declaration" << decl.data()->qualifiedIdentifier() <<
"is registered as" << item->id.identifier() << endl;
qout << decl.data()->url().str() << "declaration" << decl.data()->qualifiedIdentifier()
<< "is registered as" << item->id.identifier() << Qt::endl;
}
const QString url = IndexedTopDUContext(decl.topContextIndex()).url().str();
if (!decl.data() && !decl.isDummy()) {
qout << "Item in symbol-table is invalid:" << id.toString() << "- localIndex:" << decl.localIndex() <<
"- url:" << url << endl;
qout << "Item in symbol-table is invalid:" << id.toString() << "- localIndex:" << decl.localIndex()
<< "- url:" << url << Qt::endl;
} else {
qout << "Item in symbol-table:" << id.toString() << "- localIndex:" << decl.localIndex() << "- url:" <<
url;
......@@ -470,7 +462,7 @@ struct DebugVisitor
} else {
qout << "- null declaration";
}
qout << endl;
qout << Qt::endl;
}
}
......@@ -490,8 +482,8 @@ void PersistentSymbolTable::dump(const QTextStream& out)
LockedItemRepository::read<PersistentSymbolTable>([&](const PersistentSymbolTableRepo& repo) {
repo.visitAllItems(v);
qout << "Statistics:" << endl;
qout << repo.statistics() << endl;
qout << "Statistics:" << Qt::endl;
qout << repo.statistics() << Qt::endl;
});
}
......
......@@ -97,11 +97,7 @@ void TestIdentifier::testIdentifier_data()
void TestIdentifier::testQualifiedIdentifier()
{
QFETCH(QString, stringId);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
const QStringList list = stringId.split(QStringLiteral("::"), Qt::SkipEmptyParts);
#else
const QStringList list = stringId.split(QStringLiteral("::"), QString::SkipEmptyParts);
#endif
QualifiedIdentifier id(stringId);
QCOMPARE(id.isEmpty(), stringId.isEmpty());
QCOMPARE(id, QualifiedIdentifier(stringId));
......
......@@ -999,12 +999,8 @@ void TopDUContext::clearProblems()
QVector<DUContext*> TopDUContext::importers() const
{
ENSURE_CAN_READ
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
const QSet<DUContext*>& directImporters = m_local->m_directImporters;
return QVector<DUContext*>(directImporters.begin(), directImporters.end());
#else
return QVector<DUContext*>::fromList(m_local->m_directImporters.values());
#endif
}
QList<DUContext*> TopDUContext::loadedImporters() const
......
......@@ -380,16 +380,9 @@ inline uint qHash(const ReferencedTopDUContext& ctx)
return ctx.hash();
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(TopDUContext::Features)
#endif
}
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
Q_DECLARE_OPERATORS_FOR_FLAGS(KDevelop::TopDUContext::Features)
#endif
Q_DECLARE_TYPEINFO(KDevelop::ReferencedTopDUContext, Q_MOVABLE_TYPE);
Q_DECLARE_METATYPE(KDevelop::ReferencedTopDUContext)
......
......@@ -89,11 +89,7 @@ public:
m_filtered.clear();
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList typedFragments = text.split(QStringLiteral("::"), Qt::SkipEmptyParts);
#else
QStringList typedFragments = text.split(QStringLiteral("::"), QString::SkipEmptyParts);
#endif
if (typedFragments.isEmpty()) {
clearFilter();
return;
......
Supports Markdown
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