diff options
author | Eike Ziller <eike.ziller@qt.io> | 2016-05-09 16:37:41 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2016-05-09 16:37:41 +0200 |
commit | 9e66ce48e432765073dad411bae5d0ff9a093c19 (patch) | |
tree | 1af4f549a1bad6815b10c98ff0031e9304033d86 /src | |
parent | f63d64330ef8a26df23669e78a45b0655a773406 (diff) | |
parent | 605ea627cc4fdd1d64e7a1388ed442293ffd0981 (diff) | |
download | qt-creator-9e66ce48e432765073dad411bae5d0ff9a093c19.tar.gz |
Merge remote-tracking branch 'origin/4.0'
Conflicts:
src/plugins/autotest/testcodeparser.cpp
src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri
tests/unit/unittest/unittest.pro
Change-Id: I9db4fbea6ea7c9fdd0d8e1703735af20c92e754b
Diffstat (limited to 'src')
33 files changed, 510 insertions, 253 deletions
diff --git a/src/app/Info.plist b/src/app/Info.plist index d5c6918bd7..8772259386 100644 --- a/src/app/Info.plist +++ b/src/app/Info.plist @@ -2,238 +2,242 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>NSPrincipalClass</key> - <string>NSApplication</string> - <key>NSSupportsAutomaticGraphicsSwitching</key> - <true/> - <key>CFBundleDocumentTypes</key> + <key>UTExportedTypeDeclarations</key> <array> <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeIconFile</key> + <key>UTTypeIconFile</key> <string>profile.icns</string> - <key>CFBundleTypeExtensions</key> + <key>UTTypeDescription</key> + <string>Qt Creator Makefile Based Project File</string> + <key>UTTypeConformsTo</key> <array> - <string>pro</string> + <string>public.plain-text</string> </array> - <key>CFBundleTypeName</key> - <string>Qt Project File</string> - <key>LSHandlerRank</key> - <string>Default</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qtcreator-genericproject</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>creator</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeIconFile</key> - <string>prifile.icns</string> - <key>CFBundleTypeExtensions</key> + <key>UTTypeIconFile</key> + <string>profile.icns</string> + <key>UTTypeDescription</key> + <string>Quick Project File</string> + <key>UTTypeConformsTo</key> <array> - <string>pri</string> + <string>public.plain-text</string> + <string>org.qt-project.qml</string> </array> - <key>CFBundleTypeName</key> - <string>Qt Project Include File</string> - <key>LSHandlerRank</key> - <string>Default</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qtcreator-qmlproject</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qmlproject</string> + </array> + </dict> </dict> + </array> + <key>UTImportedTypeDeclarations</key> + <array> <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeIconFile</key> + <key>UTTypeIconFile</key> <string>profile.icns</string> - <key>CFBundleTypeExtensions</key> + <key>UTTypeDescription</key> + <string>Qt Project File</string> + <key>UTTypeConformsTo</key> <array> - <string>qbs</string> + <string>public.source-code</string> </array> - <key>CFBundleTypeName</key> - <string>Qbs Project File</string> - <key>LSHandlerRank</key> - <string>Default</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.pro</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>pro</string> + </array> + </dict> </dict> - <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeIconFile</key> - <string>profile.icns</string> - <key>CFBundleTypeExtensions</key> - <array> - <string>creator</string> - </array> - <key>CFBundleTypeName</key> - <string>Qt Creator Makefile Based Project File</string> - <key>LSHandlerRank</key> - <string>Default</string> - </dict> - <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeIconFile</key> - <string>profile.icns</string> - <key>CFBundleTypeExtensions</key> - <array> - <string>qmlproject</string> - </array> - <key>CFBundleTypeName</key> - <string>Quick Project File</string> - <key>LSHandlerRank</key> - <string>Default</string> - </dict> - <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeExtensions</key> + <dict> + <key>UTTypeIconFile</key> + <string>prifile.icns</string> + <key>UTTypeDescription</key> + <string>Qt Project Include File</string> + <key>UTTypeConformsTo</key> <array> - <string>qrc</string> + <string>public.source-code</string> </array> - <key>CFBundleTypeName</key> - <string>Qt Resource File</string> - <key>LSHandlerRank</key> - <string>Default</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.pri</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>pri</string> + <string>prf</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeRole</key> - <string>Editor</string> - <key>CFBundleTypeExtensions</key> + <key>UTTypeIconFile</key> + <string>profile.icns</string> + <key>UTTypeDescription</key> + <string>Qbs Project File</string> + <key>UTTypeConformsTo</key> <array> - <string>ui</string> + <string>public.source-code</string> </array> - <key>CFBundleTypeName</key> - <string>Qt UI File</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qbs</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qbs</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>qml</string> - </array> - <key>CFBundleTypeName</key> - <string>QML File</string> - <key>CFBundleTypeOSTypes</key> + <key>UTTypeDescription</key> + <string>Qt Resource File</string> + <key>UTTypeConformsTo</key> <array> - <string>TEXT</string> - <string>utxt</string> + <string>public.source-code</string> + <string>public.xml</string> </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qrc</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qrc</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>h</string> - <string>hpp</string> - </array> - <key>CFBundleTypeName</key> - <string>Header File</string> - <key>CFBundleTypeOSTypes</key> + <key>UTTypeDescription</key> + <string>Qt UI File</string> + <key>UTTypeConformsTo</key> <array> - <string>TEXT</string> - <string>utxt</string> + <string>public.source-code</string> + <string>public.xml</string> </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.ui</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>ui</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeExtensions</key> + <key>UTTypeDescription</key> + <string>Qt Markup Language</string> + <key>UTTypeConformsTo</key> <array> - <string>cc</string> - <string>CC</string> - <string>cp</string> - <string>CP</string> - <string>cpp</string> - <string>CPP</string> - <string>cxx</string> - <string>CXX</string> - <string>c++</string> - <string>C++</string> + <string>public.source-code</string> </array> - <key>CFBundleTypeName</key> - <string>C++ Source File</string> - <key>CFBundleTypeOSTypes</key> - <array> - <string>TEXT</string> - <string>utxt</string> - </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qml</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qml</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>mm</string> - <string>MM</string> - </array> - <key>CFBundleTypeName</key> - <string>Objective-C++ Source File</string> - <key>CFBundleTypeOSTypes</key> + <key>UTTypeDescription</key> + <string>Qt Documentation</string> + <key>UTTypeConformsTo</key> <array> - <string>TEXT</string> - <string>utxt</string> + <string>public.source-code</string> </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qdoc</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qdoc</string> + </array> + </dict> </dict> <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>m</string> - </array> - <key>CFBundleTypeName</key> - <string>Objective-C Source File</string> - <key>CFBundleTypeOSTypes</key> + <key>UTTypeDescription</key> + <string>Qt Documentation Configuration</string> + <key>UTTypeConformsTo</key> <array> - <string>TEXT</string> - <string>utxt</string> + <string>public.source-code</string> </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> + <key>UTTypeIdentifier</key> + <string>org.qt-project.qdocconf</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>qdocconf</string> + </array> + </dict> </dict> + </array> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSSupportsAutomaticGraphicsSwitching</key> + <true/> + <key>CFBundleDocumentTypes</key> + <array> <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>c</string> - <string>C</string> - </array> - <key>CFBundleTypeName</key> - <string>C Source File</string> - <key>CFBundleTypeOSTypes</key> - <array> - <string>TEXT</string> - <string>utxt</string> - </array> <key>CFBundleTypeRole</key> <string>Editor</string> - </dict> - <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>txt</string> - <string>text</string> - </array> - <key>CFBundleTypeName</key> - <string>Text File</string> - <key>CFBundleTypeOSTypes</key> + <key>LSHandlerRank</key> + <string>Default</string> + <key>LSItemContentTypes</key> <array> - <string>TEXT</string> + <string>org.qt-project.pro</string> + <string>org.qt-project.pri</string> + <string>org.qt-project.qbs</string> + <string>org.qt-project.qrc</string> + <string>org.qt-project.ui</string> + <string>org.qt-project.qml</string> + <string>org.qt-project.qdoc</string> + <string>org.qt-project.qdocconf</string> + <string>org.qt-project.qtcreator-genericproject</string> + <string>org.qt-project.qtcreator-qmlproject</string> </array> - <key>CFBundleTypeRole</key> - <string>Editor</string> </dict> <dict> - <key>CFBundleTypeExtensions</key> - <array> - <string>*</string> - </array> - <key>CFBundleTypeName</key> - <string>NSStringPboardType</string> - <key>CFBundleTypeOSTypes</key> - <array> - <string>****</string> - </array> <key>CFBundleTypeRole</key> <string>Editor</string> + <key>LSItemContentTypes</key> + <array> + <string>public.c-source</string> + <string>public.objective-c-source</string> + <string>public.c-plus-plus-source</string> + <string>public.objective-c-plus-plus-source</string> + <string>public.c-header</string> + <string>public.c-plus-plus-header</string> + <string>com.sun.java-source</string> + <string>com.netscape.javascript-source</string> + <string>public.python-script</string> + <string>public.plain-text</string> + <string>com.apple.nspboard-type</string> + </array> </dict> </array> - <key>NSHumanReadableCopyright</key> - <string>(C) 2016 The Qt Company Ltd</string> + <key>NSHumanReadableCopyright</key> + <string>(C) 2016 The Qt Company Ltd</string> <key>CFBundleIconFile</key> <string>qtcreator</string> <key>CFBundlePackageType</key> diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 32580b9e8b..af2d59edf8 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -833,6 +833,7 @@ void PluginManagerPrivate::nextDelayedInitialize() break; // do next delayedInitialize after a delay } if (delayedInitializeQueue.isEmpty()) { + m_isInitializationDone = true; delete delayedInitializeTimer; delayedInitializeTimer = 0; profilingSummary(); @@ -1673,6 +1674,11 @@ QString PluginManager::platformName() return result; } +bool PluginManager::isInitializationDone() +{ + return d->m_isInitializationDone; +} + /*! Retrieves one object with \a name from the object pool. \sa addObject() diff --git a/src/libs/extensionsystem/pluginmanager.h b/src/libs/extensionsystem/pluginmanager.h index c2be55551f..36c5c055fd 100644 --- a/src/libs/extensionsystem/pluginmanager.h +++ b/src/libs/extensionsystem/pluginmanager.h @@ -146,6 +146,8 @@ public: static QString platformName(); + static bool isInitializationDone(); + signals: void objectAdded(QObject *obj); void aboutToRemoveObject(QObject *obj); diff --git a/src/libs/extensionsystem/pluginmanager_p.h b/src/libs/extensionsystem/pluginmanager_p.h index e0342d401c..bb7563b0ae 100644 --- a/src/libs/extensionsystem/pluginmanager_p.h +++ b/src/libs/extensionsystem/pluginmanager_p.h @@ -131,6 +131,8 @@ public: mutable QReadWriteLock m_lock; + bool m_isInitializationDone = false; + private slots: void nextDelayedInitialize(); void asyncShutdownFinished(); diff --git a/src/libs/utils/tooltip/tooltip.h b/src/libs/utils/tooltip/tooltip.h index 2d6d197528..03d4452773 100644 --- a/src/libs/utils/tooltip/tooltip.h +++ b/src/libs/utils/tooltip/tooltip.h @@ -29,6 +29,7 @@ #include <QSharedPointer> #include <QObject> +#include <QPointer> #include <QTimer> #include <QRect> @@ -106,7 +107,7 @@ private: void showTip(); void hideTipWithDelay(); - Internal::QTipLabel *m_tip; + QPointer<Internal::QTipLabel> m_tip; QWidget *m_widget; QRect m_rect; QTimer m_showTimer; diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index fbbb31c1c9..7597ced6f6 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -713,9 +713,21 @@ void TreeItem::removeChildren() void TreeItem::sortChildren(const std::function<bool(const TreeItem *, const TreeItem *)> &cmp) { if (m_model) { - m_model->layoutAboutToBeChanged(); - std::sort(m_children.begin(), m_children.end(), cmp); - m_model->layoutChanged(); + if (const int n = rowCount()) { + QVector<TreeItem *> tmp = m_children; + std::sort(tmp.begin(), tmp.end(), cmp); + if (tmp == m_children) { + // Nothing changed. + } else { + QModelIndex idx = index(); + m_model->beginRemoveRows(idx, 0, n - 1); + m_children.clear(); + m_model->endRemoveRows(); + m_model->beginInsertRows(idx, 0, n - 1); + tmp.swap(m_children); + m_model->endInsertRows(); + } + } } else { std::sort(m_children.begin(), m_children.end(), cmp); } diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 35e8068324..06ace3cb36 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -588,8 +588,11 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const QString &adbToo else dev.state = AndroidDeviceInfo::OkState; - if (dev.type == AndroidDeviceInfo::Emulator) + if (dev.type == AndroidDeviceInfo::Emulator) { dev.avdname = getAvdName(dev.serialNumber); + if (dev.avdname.isEmpty()) + dev.avdname = serialNo; + } devices.push_back(dev); } @@ -921,9 +924,11 @@ QString AndroidConfig::getAvdName(const QString &serialnumber) QTcpSocket tcpSocket; tcpSocket.connectToHost(QHostAddress(QHostAddress::LocalHost), port); - tcpSocket.waitForConnected(); + if (!tcpSocket.waitForConnected(100)) // Don't wait more than 100ms for a local connection + return QString{}; + tcpSocket.write(avdName + "exit\n"); - tcpSocket.waitForDisconnected(); + tcpSocket.waitForDisconnected(500); QByteArray name; const QByteArrayList response = tcpSocket.readAll().split('\n'); diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index 1a2fd4e78a..bac2556c83 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -42,6 +42,8 @@ #include <qtsupport/qtkitinformation.h> +#include <utils/hostosinfo.h> + #include <QDirIterator> #include <QTcpServer> @@ -93,6 +95,8 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration * params.displayName = AndroidManager::packageName(target); params.remoteSetupNeeded = true; params.useContinueInsteadOfRun = true; + if (!Utils::HostOsInfo::isWindowsHost()) // Workaround for NDK 11c(b?) + params.useTargetAsync = true; auto aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>(); if (aspect->useCppDebugger()) { diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 32ef9bfae3..5fbb8067f8 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -177,20 +177,21 @@ static QByteArray getFileContent(QString filePath) static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { - static QString expectedHeaderPrefix + static QStringList expectedHeaderPrefixes = Utils::HostOsInfo::isMacHost() - ? QLatin1String("QtTest.framework/Headers") - : QLatin1String("QtTest"); + ? QStringList({ QLatin1String("QtTest.framework/Headers"), QLatin1String("QtTest") }) + : QStringList({ QLatin1String("QtTest") }); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); foreach (const CPlusPlus::Document::Include &inc, includes) { // TODO this short cut works only for #include <QtTest> // bad, as there could be much more different approaches - if (inc.unresolvedFileName() == QLatin1String("QtTest") - && inc.resolvedFileName().endsWith( - QString::fromLatin1("%1/QtTest").arg(expectedHeaderPrefix))) { - return true; + if (inc.unresolvedFileName() == QLatin1String("QtTest")) { + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (inc.resolvedFileName().endsWith(QString::fromLatin1("%1/QtTest").arg(prefix))) + return true; + } } } @@ -198,9 +199,9 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, CPlusPlus::Snapshot snapshot = cppMM->snapshot(); const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName()); foreach (const QString &include, allIncludes) { - - if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(expectedHeaderPrefix))) { - return true; + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(prefix))) + return true; } } } @@ -210,25 +211,31 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { - static QString expectedHeaderPrefix + static QStringList expectedHeaderPrefixes = Utils::HostOsInfo::isMacHost() - ? QLatin1String("QtQuickTest.framework/Headers") - : QLatin1String("QtQuickTest"); + ? QStringList({ QLatin1String("QtQuickTest.framework/Headers"), + QLatin1String("QtQuickTest") }) + : QStringList({ QLatin1String("QtQuickTest") }); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); foreach (const CPlusPlus::Document::Include &inc, includes) { - if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h") - && inc.resolvedFileName().endsWith( - QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) { - return true; + if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h")) { + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (inc.resolvedFileName().endsWith( + QString::fromLatin1("%1/quicktest.h").arg(prefix))) { + return true; + } + } } } if (cppMM) { foreach (const QString &include, cppMM->snapshot().allIncludesForDocument(doc->fileName())) { - if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) - return true; + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(prefix))) + return true; + } } } return false; @@ -404,31 +411,31 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc, return declaringDoc; } -static bool hasFunctionWithDataTagUsage(const QMap<QString, TestCodeLocationAndType> &testFunctions) +static QSet<QString> filesWithDataFunctionDefinitions( + const QMap<QString, TestCodeLocationAndType> &testFunctions) { - foreach (const QString &functionName, testFunctions.keys()) { - if (functionName.endsWith(QLatin1String("_data")) && - testFunctions.contains(functionName.left(functionName.size() - 5))) { - return true; - } + QSet<QString> result; + QMap<QString, TestCodeLocationAndType>::ConstIterator it = testFunctions.begin(); + const QMap<QString, TestCodeLocationAndType>::ConstIterator end = testFunctions.end(); + + for ( ; it != end; ++it) { + const QString &key = it.key(); + if (key.endsWith(QLatin1String("_data")) && testFunctions.contains(key.left(key.size() - 5))) + result.insert(it.value().m_name); } - return false; + return result; } -static QMap<QString, TestCodeLocationList> checkForDataTags(const QString &fileName, - const QMap<QString, TestCodeLocationAndType> &testFunctions) +static QMap<QString, TestCodeLocationList> checkForDataTags(const QString &fileName) { - if (hasFunctionWithDataTagUsage(testFunctions)) { - const CPlusPlus::Snapshot snapshot = CPlusPlus::CppModelManagerBase::instance()->snapshot(); - const QByteArray fileContent = getFileContent(fileName); - CPlusPlus::Document::Ptr document = snapshot.preprocessedDocument(fileContent, fileName); - document->check(); - CPlusPlus::AST *ast = document->translationUnit()->ast(); - TestDataFunctionVisitor visitor(document); - visitor.accept(ast); - return visitor.dataTags(); - } - return QMap<QString, TestCodeLocationList>(); + const CPlusPlus::Snapshot snapshot = CPlusPlus::CppModelManagerBase::instance()->snapshot(); + const QByteArray fileContent = getFileContent(fileName); + CPlusPlus::Document::Ptr document = snapshot.preprocessedDocument(fileContent, fileName); + document->check(); + CPlusPlus::AST *ast = document->translationUnit()->ast(); + TestDataFunctionVisitor visitor(document); + visitor.accept(ast); + return visitor.dataTags(); } /****** end of helpers ******/ @@ -484,12 +491,11 @@ static bool handleQtTest(QFutureInterface<TestParseResult> futureInterface, return false; const QMap<QString, TestCodeLocationAndType> testFunctions = visitor.privateSlots(); + const QSet<QString> &files = filesWithDataFunctionDefinitions(testFunctions); - QMap<QString, TestCodeLocationList> dataTags = - checkForDataTags(declaringDoc->fileName(), testFunctions); - - if (declaringDoc->fileName() != fileName) - dataTags.unite(checkForDataTags(fileName, testFunctions)); + QMap<QString, TestCodeLocationList> dataTags; + foreach (const QString &file, files) + dataTags.unite(checkForDataTags(file)); TestParseResult parseResult(TestTreeModel::AutoTest); parseResult.fileName = declaringDoc->fileName(); diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp index f9058f42fb..a33a5d935d 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrolfactory.cpp @@ -70,10 +70,6 @@ bool ClangStaticAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigura Project *project = runConfiguration->target()->project(); QTC_ASSERT(project, return false); - - if (project->id() != "Qt4ProjectManager.Qt4Project" && project->id() != "Qbs.QbsProject") - return false; - const Core::Context context = project->projectLanguages(); if (!context.contains(ProjectExplorer::Constants::LANG_CXX)) return false; @@ -83,10 +79,7 @@ bool ClangStaticAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigura Kit *kit = target->kit(); QTC_ASSERT(kit, return false); ToolChain *toolChain = ToolChainKitInformation::toolChain(kit); - return toolChain && (toolChain->typeId() == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID - || toolChain->typeId() == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID - || toolChain->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID - || toolChain->typeId() == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID); + return toolChain; } RunControl *ClangStaticAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index a170e4f487..75df422801 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -238,6 +238,13 @@ QObject *CorePlugin::remoteCommand(const QStringList & /* options */, const QString &workingDirectory, const QStringList &args) { + if (!ExtensionSystem::PluginManager::isInitializationDone()) { + connect(ExtensionSystem::PluginManager::instance(), &ExtensionSystem::PluginManager::initializationDone, + this, [this, workingDirectory, args]() { + remoteCommand(QStringList(), workingDirectory, args); + }); + return nullptr; + } IDocument *res = m_mainWindow->openFiles( args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineAndColumnNumbers), workingDirectory); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 72cbd2b660..de79d03df1 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -559,6 +559,14 @@ public: { if (!(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain)) return false; + + Runnable runnable = runConfig->runnable(); + if (runnable.is<StandardRunnable>()) { + IDevice::ConstPtr device = runnable.as<StandardRunnable>().device; + if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + return true; + } + return DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE || isDebuggableScript(runConfig); diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index cd9b7d1019..376cfe258d 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -97,6 +97,7 @@ public: // Used by Android to avoid false positives on warnOnRelease bool skipExecutableValidation = false; + bool useTargetAsync = false; QStringList additionalSearchDirectories; // Used by iOS. diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 5b99bcd2c8..e369940cfe 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4436,7 +4436,12 @@ bool GdbEngine::usesExecInterrupt() const { DebuggerStartMode mode = runParameters().startMode; return (mode == AttachToRemoteServer || mode == AttachToRemoteProcess) - && boolSetting(TargetAsync); + && usesTargetAsync(); +} + +bool GdbEngine::usesTargetAsync() const +{ + return runParameters().useTargetAsync || boolSetting(TargetAsync); } void GdbEngine::scheduleTestResponse(int testCase, const QByteArray &response) diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 2f67440fa1..f94d4d2eef 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -422,6 +422,7 @@ protected: bool m_terminalTrap; bool m_temporaryStopPending; bool usesExecInterrupt() const; + bool usesTargetAsync() const; QHash<int, QByteArray> m_scheduledTestResponses; QSet<int> m_testCases; diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index 739973fd70..6c4e962172 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -205,7 +205,7 @@ void GdbRemoteServerEngine::setupInferior() // gdb/mi/mi-main.c:1958: internal-error: // mi_execute_async_cli_command: Assertion `is_running (inferior_ptid)' // failed.\nA problem internal to GDB has been detected,[...] - if (boolSetting(TargetAsync)) + if (usesTargetAsync()) runCommand({"set target-async on", NoFlags, CB(handleSetTargetAsync)}); if (symbolFile.isEmpty()) { @@ -429,7 +429,7 @@ void GdbRemoteServerEngine::handleExecRun(const DebuggerResponse &response) void GdbRemoteServerEngine::interruptInferior2() { QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()); - if (boolSetting(TargetAsync)) { + if (usesTargetAsync()) { runCommand({"-exec-interrupt", NoFlags, CB(handleInterruptInferior)}); } else if (m_isQnxGdb && HostOsInfo::isWindowsHost()) { m_gdbProc.interrupt(); diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp index b13414a0b0..5299a5bec4 100644 --- a/src/plugins/git/gitgrep.cpp +++ b/src/plugins/git/gitgrep.cpp @@ -152,7 +152,7 @@ public: } arguments << QLatin1String("--") << m_parameters.nameFilters; QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory)); - command->addFlags(VcsCommand::SilentOutput); + command->addFlags(VcsCommand::SilentOutput | VcsCommand::SuppressFailMessage); command->setProgressiveOutput(true); QFutureWatcher<FileSearchResultList> watcher; watcher.setFuture(m_fi.future()); diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index 8ff9a9ab34..3d8bcc7656 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -138,9 +138,15 @@ static bool isLocal(RunConfiguration *runConfiguration) bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const { - return mode == Constants::NORMAL_RUN_MODE - && isLocal(runConfiguration) - && runConfiguration->runnable().is<StandardRunnable>(); + if (mode != Constants::NORMAL_RUN_MODE) + return false; + const Runnable runnable = runConfiguration->runnable(); + if (!runnable.is<StandardRunnable>()) + return false; + const IDevice::ConstPtr device = runnable.as<StandardRunnable>().device; + if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + return true; + return isLocal(runConfiguration); } RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) diff --git a/src/plugins/projectexplorer/runnables.h b/src/plugins/projectexplorer/runnables.h index 5e4c94774c..3949b80a0b 100644 --- a/src/plugins/projectexplorer/runnables.h +++ b/src/plugins/projectexplorer/runnables.h @@ -42,6 +42,7 @@ public: QString workingDirectory; Utils::Environment environment; ApplicationLauncher::Mode runMode = ApplicationLauncher::Gui; + IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. }; PROJECTEXPLORER_EXPORT bool operator==(const StandardRunnable &r1, const StandardRunnable &r2); diff --git a/src/plugins/qbsprojectmanager/qbsprojectparser.cpp b/src/plugins/qbsprojectmanager/qbsprojectparser.cpp index e4fc351edf..af53e1bce8 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectparser.cpp +++ b/src/plugins/qbsprojectmanager/qbsprojectparser.cpp @@ -206,8 +206,12 @@ QString QbsProjectParser::libExecDirectory() const QString QbsProjectParser::pluginsBaseDirectory() const { const QString qbsInstallDir = QLatin1String(QBS_INSTALL_DIR); + + // Note: We assume here that Qt Creator and qbs use the same name for their library dir. + const QString qbsLibDirName = QLatin1String(IDE_LIBRARY_BASENAME); + if (!qbsInstallDir.isEmpty()) - return qbsInstallDir + QLatin1String("/lib/"); + return qbsInstallDir + QLatin1Char('/') + qbsLibDirName; if (HostOsInfo::isMacHost()) return QDir::cleanPath(QCoreApplication::applicationDirPath() + QLatin1String("/../PlugIns")); diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index 4a5621c287..57158f3c67 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -71,7 +71,7 @@ static inline QStringList supportedVersionsList() QStringLiteral("2.0"), QStringLiteral("2.1"), QStringLiteral("2.2"), QStringLiteral("2.3"), QStringLiteral("2.4"), QStringLiteral("2.5"), - QStringLiteral("2.6") + QStringLiteral("2.6"), QStringLiteral("2.7") }; return list; } diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 4418c9cde7..89eb5f62e1 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -457,6 +457,13 @@ QSet<Id> BaseQtVersion::availableFeatures() const if (qtVersion().matches(5, 6)) return features; + features.unite(versionedIds(Constants::FEATURE_QT_QUICK_PREFIX, 2, 7)); + features.unite(versionedIds(Constants::FEATURE_QT_QUICK_CONTROLS_2_PREFIX, 2, 0)); + features.subtract(versionedIds(Constants::FEATURE_QT_LABS_CONTROLS_PREFIX, 1, 0)); + + if (qtVersion().matches(5, 7)) + return features; + return features; } diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp index c1c79f1e3d..a212866c32 100644 --- a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp +++ b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp @@ -33,6 +33,7 @@ #include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/target.h> #include <projectexplorer/abi.h> +#include <projectexplorer/devicesupport/devicemanager.h> #include <coreplugin/icore.h> @@ -253,6 +254,7 @@ Runnable CustomExecutableRunConfiguration::runnable() const r.workingDirectory = workingDirectory(); r.environment = extraAspect<LocalEnvironmentAspect>()->environment(); r.runMode = extraAspect<TerminalAspect>()->runMode(); + r.device = DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE); return r; } diff --git a/src/plugins/qtsupport/qtsupportconstants.h b/src/plugins/qtsupport/qtsupportconstants.h index e2c90d9803..342ae6ce22 100644 --- a/src/plugins/qtsupport/qtsupportconstants.h +++ b/src/plugins/qtsupport/qtsupportconstants.h @@ -49,6 +49,7 @@ const char FEATURE_QWIDGETS[] = "QtSupport.Wizards.FeatureQWidgets"; const char FEATURE_QT_QUICK_PREFIX[] = "QtSupport.Wizards.FeatureQtQuick"; const char FEATURE_QMLPROJECT[] = "QtSupport.Wizards.FeatureQtQuickProject"; const char FEATURE_QT_QUICK_CONTROLS_PREFIX[] = "QtSupport.Wizards.FeatureQtQuick.Controls"; +const char FEATURE_QT_QUICK_CONTROLS_2_PREFIX[] = "QtSupport.Wizards.FeatureQtQuick.Controls.2"; const char FEATURE_QT_LABS_CONTROLS_PREFIX[] = "QtSupport.Wizards.FeatureQt.labs.controls"; const char FEATURE_QT_QUICK_UI_FILES[] = "QtSupport.Wizards.FeatureQtQuick.UiFiles"; const char FEATURE_QT_WEBKIT[] = "QtSupport.Wizards.FeatureQtWebkit"; diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index 935bc1f243..dde2ae7fd0 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -85,8 +85,9 @@ void ValgrindRunControl::start() ValgrindRunner *run = runner(); run->setValgrindExecutable(m_settings->valgrindExecutable()); run->setValgrindArguments(genericToolArguments() + toolArguments()); - run->setDevice(device()); - run->setDebuggee(runnable().as<StandardRunnable>()); + const StandardRunnable r = runnable().as<StandardRunnable>(); + run->setDevice(r.device ? r.device : device()); + run->setDebuggee(r); connect(run, &ValgrindRunner::processOutputReceived, this, &ValgrindRunControl::receiveProcessOutput); diff --git a/src/shared/clang/clang_installation.pri b/src/shared/clang/clang_installation.pri index 55333e9569..d19bab68d8 100644 --- a/src/shared/clang/clang_installation.pri +++ b/src/shared/clang/clang_installation.pri @@ -101,6 +101,8 @@ unix { !contains(QMAKE_DEFAULT_LIBDIRS, $$LLVM_LIBDIR): LLVM_LIBS = -L$${LLVM_LIBDIR} LLVM_LIBS += -l$${clang_lib} + + contains(QMAKE_DEFAULT_INCDIRS, $$LLVM_INCLUDEPATH): LLVM_INCLUDEPATH = } isEmpty(LLVM_VERSION): error("Cannot determine clang version at $$LLVM_INSTALL_DIR") diff --git a/src/shared/qbs b/src/shared/qbs -Subproject c9073856137a733776d0123804805ef9bc68308 +Subproject b062bb5b3e58a883471752bb5222e2f337ea72c diff --git a/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri b/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri index 6308ca01e5..7186ec858d 100644 --- a/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri +++ b/src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri @@ -33,7 +33,8 @@ HEADERS += $$PWD/clangipcserver.h \ $$PWD/clangtype.h \ $$PWD/highlightingmark.h \ $$PWD/highlightingmarks.h \ - $$PWD/highlightingmarksiterator.h + $$PWD/highlightingmarksiterator.h \ + $$PWD/utf8positionfromlinecolumn.h SOURCES += $$PWD/clangipcserver.cpp \ $$PWD/codecompleter.cpp \ @@ -66,4 +67,5 @@ SOURCES += $$PWD/clangipcserver.cpp \ $$PWD/clangtranslationunit.cpp \ $$PWD/clangtype.cpp \ $$PWD/highlightingmark.cpp \ - $$PWD/highlightingmarks.cpp + $$PWD/highlightingmarks.cpp \ + $$PWD/utf8positionfromlinecolumn.cpp diff --git a/src/tools/clangbackend/ipcsource/codecompleter.cpp b/src/tools/clangbackend/ipcsource/codecompleter.cpp index 7381ac2d27..436c668052 100644 --- a/src/tools/clangbackend/ipcsource/codecompleter.cpp +++ b/src/tools/clangbackend/ipcsource/codecompleter.cpp @@ -96,9 +96,8 @@ ClangCodeCompleteResults CodeCompleter::complete(uint line, bool CodeCompleter::hasDotAt(uint line, uint column) const { const UnsavedFile &unsavedFile = translationUnit.unsavedFile(); - const SourceLocation location = translationUnit.sourceLocationAtWithoutReparsing(line, column); - return unsavedFile.hasCharacterAt(location.offset(), '.'); + return unsavedFile.hasCharacterAt(line, column, '.'); } uint CodeCompleter::defaultOptions() const diff --git a/src/tools/clangbackend/ipcsource/unsavedfile.cpp b/src/tools/clangbackend/ipcsource/unsavedfile.cpp index 2cb3419545..a4d6f0fb82 100644 --- a/src/tools/clangbackend/ipcsource/unsavedfile.cpp +++ b/src/tools/clangbackend/ipcsource/unsavedfile.cpp @@ -26,6 +26,7 @@ #include "unsavedfile.h" #include "utf8string.h" +#include "utf8positionfromlinecolumn.h" #include <cstring> #include <ostream> @@ -70,6 +71,17 @@ const char *UnsavedFile::filePath() const return cxUnsavedFile.Filename; } +bool UnsavedFile::hasCharacterAt(uint line, uint column, char character) const +{ + Utf8PositionFromLineColumn converter(cxUnsavedFile.Contents); + if (converter.find(line, column)) { + const uint utf8Position = converter.position(); + return hasCharacterAt(utf8Position, character); + } + + return false; +} + bool UnsavedFile::hasCharacterAt(uint position, char character) const { if (position < cxUnsavedFile.Length) diff --git a/src/tools/clangbackend/ipcsource/unsavedfile.h b/src/tools/clangbackend/ipcsource/unsavedfile.h index 51b66c1b39..3433093ae1 100644 --- a/src/tools/clangbackend/ipcsource/unsavedfile.h +++ b/src/tools/clangbackend/ipcsource/unsavedfile.h @@ -54,6 +54,8 @@ public: const char *filePath() const; + // 1-based line and column + bool hasCharacterAt(uint line, uint column, char character) const; bool hasCharacterAt(uint position, char character) const; bool replaceAt(uint position, uint length, const Utf8String &replacement); diff --git a/src/tools/clangbackend/ipcsource/utf8positionfromlinecolumn.cpp b/src/tools/clangbackend/ipcsource/utf8positionfromlinecolumn.cpp new file mode 100644 index 0000000000..1d7ea1a88f --- /dev/null +++ b/src/tools/clangbackend/ipcsource/utf8positionfromlinecolumn.cpp @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "utf8positionfromlinecolumn.h" + +#include <QtGlobal> + +namespace ClangBackEnd { + +Utf8PositionFromLineColumn::Utf8PositionFromLineColumn(const char *utf8Text) + : m_utf8Text(utf8Text) + , m_currentByte(utf8Text) +{ +} + +bool Utf8PositionFromLineColumn::find(uint line, uint column) +{ + if (!m_utf8Text || *m_utf8Text == '\0' || line == 0 || column == 0) + return false; + + return advanceToLine(line) + && advanceToColumn(column); +} + +uint Utf8PositionFromLineColumn::position() const +{ + return m_previousByte - m_utf8Text; +} + +bool Utf8PositionFromLineColumn::advanceToLine(uint line) +{ + if (line == 1) + return true; + + uint currentLine = 1; + do { + if (*m_currentByte == '\n' && ++currentLine == line) { + advanceCodePoint(); + return true; + } + } while (advanceCodePoint()); + + return false; +} + +bool Utf8PositionFromLineColumn::advanceToColumn(uint column) +{ + while (column) { + if (advanceCodePoint(/*stopOnNewLine=*/ true)) + --column; + else + break; + } + + return column == 0; +} + +static bool isByteOfMultiByteCodePoint(unsigned char byte) +{ + return byte & 0x80; // Check if most significant bit is set +} + +bool Utf8PositionFromLineColumn::advanceCodePoint(bool stopOnNewLine) +{ + if (Q_UNLIKELY(*m_currentByte == '\0') || (stopOnNewLine && *m_currentByte == '\n')) + return false; + + m_previousByte = m_currentByte; + + // Process multi-byte UTF-8 code point (non-latin1) + if (Q_UNLIKELY(isByteOfMultiByteCodePoint(*m_currentByte))) { + unsigned trailingBytesCurrentCodePoint = 1; + for (unsigned char c = (*m_currentByte) << 2; isByteOfMultiByteCodePoint(c); c <<= 1) + ++trailingBytesCurrentCodePoint; + m_currentByte += trailingBytesCurrentCodePoint + 1; + + // Process single-byte UTF-8 code point (latin1) + } else { + ++m_currentByte; + } + + return true; +} + +} // namespace ClangBackEnd diff --git a/src/tools/clangbackend/ipcsource/utf8positionfromlinecolumn.h b/src/tools/clangbackend/ipcsource/utf8positionfromlinecolumn.h new file mode 100644 index 0000000000..facb152772 --- /dev/null +++ b/src/tools/clangbackend/ipcsource/utf8positionfromlinecolumn.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +namespace ClangBackEnd { + +using uint = unsigned; + +class Utf8PositionFromLineColumn +{ +public: + Utf8PositionFromLineColumn(const char *utf8Text); + + // 1-based line and column + bool find(uint line, uint column); + + uint position() const; + +private: + bool advanceToLine(uint line); + bool advanceToColumn(uint column); + bool advanceCodePoint(bool stopOnNewLine = false); + +private: + const char * const m_utf8Text = 0; + + const char *m_previousByte = 0; + const char *m_currentByte = 0; +}; + +} // namespace ClangBackEnd |