diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 12:53:20 +0100 |
commit | 9f831dde07cb2411808534e76669b28a1b76e21d (patch) | |
tree | ed6252d64c9a3ab27aa93786272cda1b6008f3c7 /src/plugins/cpptools | |
parent | cdac81f896ef4b052d76f96485a08e6ec13696b8 (diff) | |
parent | ea1a92484ac99057b06130a012164bf9788650e9 (diff) | |
download | qt-creator-wip/clang.tar.gz |
Merge remote-tracking branch 'origin/master' into wip/clangwip/clang
Change-Id: I8a2c8068a3f2b15034fb1bf6304c9a0f3f0e3c8f
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r-- | src/plugins/cpptools/abstracteditorsupport.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/abstracteditorsupport.h | 2 | ||||
-rw-r--r-- | src/plugins/cpptools/completionsettingspage.ui | 12 | ||||
-rw-r--r-- | src/plugins/cpptools/cppfilesettingspage.cpp | 1 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager.cpp | 40 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager_test.cpp | 14 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanagerinterface.cpp | 11 | ||||
-rw-r--r-- | src/plugins/cpptools/cppmodelmanagerinterface.h | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/cppsnapshotupdater.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolseditorsupport.cpp | 8 |
10 files changed, 58 insertions, 39 deletions
diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp index cdbd86f342..ee48c39a33 100644 --- a/src/plugins/cpptools/abstracteditorsupport.cpp +++ b/src/plugins/cpptools/abstracteditorsupport.cpp @@ -38,7 +38,7 @@ namespace CppTools { AbstractEditorSupport::AbstractEditorSupport(CppModelManagerInterface *modelmanager) : - m_modelmanager(modelmanager) + m_modelmanager(modelmanager), m_revision(0) { } @@ -48,6 +48,7 @@ AbstractEditorSupport::~AbstractEditorSupport() void AbstractEditorSupport::updateDocument() { + ++m_revision; m_modelmanager->updateSourceFiles(QStringList(fileName())); } diff --git a/src/plugins/cpptools/abstracteditorsupport.h b/src/plugins/cpptools/abstracteditorsupport.h index e45a50e791..9b5616c690 100644 --- a/src/plugins/cpptools/abstracteditorsupport.h +++ b/src/plugins/cpptools/abstracteditorsupport.h @@ -50,6 +50,7 @@ public: virtual QString fileName() const = 0; void updateDocument(); + unsigned revision() const { return m_revision; } // TODO: find a better place for common utility functions static QString functionAt(const CppModelManagerInterface *mm, @@ -60,6 +61,7 @@ public: private: CppModelManagerInterface *m_modelmanager; + unsigned m_revision; }; } // namespace CppTools diff --git a/src/plugins/cpptools/completionsettingspage.ui b/src/plugins/cpptools/completionsettingspage.ui index e654cf804e..3ff7358375 100644 --- a/src/plugins/cpptools/completionsettingspage.ui +++ b/src/plugins/cpptools/completionsettingspage.ui @@ -107,7 +107,7 @@ <item row="2" column="0"> <widget class="QCheckBox" name="partiallyComplete"> <property name="toolTip"> - <string>Insert the common prefix of available completion items.</string> + <string>Inserts the common prefix of available completion items.</string> </property> <property name="text"> <string>Autocomplete common &prefix</string> @@ -120,7 +120,7 @@ <item row="3" column="0" colspan="2"> <widget class="QCheckBox" name="autoInsertBrackets"> <property name="toolTip"> - <string>Automatically insert semicolons and closing brackets, parentheses, curly braces, and quotes when appropriate.</string> + <string>Automatically inserts semicolons and closing brackets, parentheses, curly braces, and quotes when appropriate.</string> </property> <property name="text"> <string>&Automatically insert matching characters</string> @@ -151,7 +151,7 @@ <item> <widget class="QCheckBox" name="surroundSelectedText"> <property name="toolTip"> - <string>When typing a matching character and there is a text selection, instead of removing the selection, surround it with the corresponding characters.</string> + <string>When typing a matching character and there is a text selection, instead of removing the selection, surrounds it with the corresponding characters.</string> </property> <property name="text"> <string>Surround &text selections</string> @@ -205,7 +205,7 @@ <item> <widget class="QCheckBox" name="enableDoxygenCheckBox"> <property name="toolTip"> - <string>Automatically create a Doxygen comment upon pressing enter after a /**, /*!, //! or ///</string> + <string>Automatically creates a Doxygen comment upon pressing enter after a /**, /*!, //! or ///</string> </property> <property name="text"> <string>Enable Doxygen blocks</string> @@ -233,7 +233,7 @@ <item> <widget class="QCheckBox" name="generateBriefCheckBox"> <property name="toolTip"> - <string>Generate a <i>brief</i> command with an initial description for the corresponding declaration</string> + <string>Generates a <i>brief</i> command with an initial description for the corresponding declaration</string> </property> <property name="text"> <string>Generate brief description</string> @@ -245,7 +245,7 @@ <item> <widget class="QCheckBox" name="leadingAsterisksCheckBox"> <property name="toolTip"> - <string>Add leading asterisks when continuing Qt (/*!) and Java (/**) style comments on new lines</string> + <string>Adds leading asterisks when continuing Qt (/*!) and Java (/**) style comments on new lines</string> </property> <property name="text"> <string>Add leading asterisks</string> diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp index 9de31210d8..1571e7ac22 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -254,6 +254,7 @@ CppFileSettingsWidget::CppFileSettingsWidget(QWidget *parent) : foreach (const QString &suffix, headerMt.suffixes()) m_ui->headerSuffixComboBox->addItem(suffix); m_ui->licenseTemplatePathChooser->setExpectedKind(Utils::PathChooser::File); + m_ui->licenseTemplatePathChooser->setHistoryCompleter(QLatin1String("Cpp.LicenseTemplate.History")); m_ui->licenseTemplatePathChooser->addButton(tr("Edit..."), this, SLOT(slotEdit())); } diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 4d5e8a1d9d..7fdb9d0af0 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -64,7 +64,8 @@ namespace CppTools { uint qHash(const ProjectPart &p) { - uint h = qHash(p.defines) ^ p.cVersion ^ p.cxxVersion ^ p.cxxExtensions ^ p.qtVersion; + uint h = qHash(p.toolchainDefines) ^ qHash(p.projectDefines) ^ p.cVersion ^ p.cxxVersion + ^ p.cxxExtensions ^ p.qtVersion; foreach (const QString &i, p.includePaths) h ^= qHash(i); @@ -78,7 +79,9 @@ uint qHash(const ProjectPart &p) bool operator==(const ProjectPart &p1, const ProjectPart &p2) { - if (p1.defines != p2.defines) + if (p1.toolchainDefines != p2.toolchainDefines) + return false; + if (p1.projectDefines != p2.projectDefines) return false; if (p1.cVersion != p2.cVersion) return false; @@ -363,6 +366,22 @@ QStringList CppModelManager::internalFrameworkPaths() const return frameworkPaths; } +static void addUnique(const QList<QByteArray> &defs, QByteArray *macros, QSet<QByteArray> *alreadyIn) +{ + Q_ASSERT(macros); + Q_ASSERT(alreadyIn); + + foreach (const QByteArray &def, defs) { + if (def.trimmed().isEmpty()) + continue; + if (!alreadyIn->contains(def)) { + macros->append(def); + macros->append('\n'); + alreadyIn->insert(def); + } + } +} + QByteArray CppModelManager::internalDefinedMacros() const { QByteArray macros; @@ -372,14 +391,8 @@ QByteArray CppModelManager::internalDefinedMacros() const it.next(); const ProjectInfo pinfo = it.value(); foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { - const QList<QByteArray> defs = part->defines.split('\n'); - foreach (const QByteArray &def, defs) { - if (!alreadyIn.contains(def)) { - macros += def; - macros.append('\n'); - alreadyIn.insert(def); - } - } + addUnique(part->toolchainDefines.split('\n'), ¯os, &alreadyIn); + addUnique(part->projectDefines.split('\n'), ¯os, &alreadyIn); } } return macros; @@ -422,7 +435,8 @@ void CppModelManager::dumpModelManagerConfiguration() qDebug() << "cxxExtensions:" << cxxExtensions; qDebug() << "Qt version:" << part->qtVersion; qDebug() << "precompiled header:" << part->precompiledHeaders; - qDebug() << "defines:" << part->defines; + qDebug() << "toolchain defines:" << part->toolchainDefines; + qDebug() << "project defines:" << part->projectDefines; qDebug() << "includes:" << part->includePaths; qDebug() << "frameworkPaths:" << part->frameworkPaths; qDebug() << "files:" << part->files; @@ -550,7 +564,7 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList() QSetIterator<AbstractEditorSupport *> it(m_extraEditorSupports); while (it.hasNext()) { AbstractEditorSupport *es = it.next(); - workingCopy.insert(es->fileName(), es->contents()); + workingCopy.insert(es->fileName(), es->contents(), es->revision()); } // Add the project configuration file @@ -795,7 +809,7 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart() const { ProjectPart::Ptr part(new ProjectPart); - part->defines = m_definedMacros; + part->projectDefines = m_definedMacros; part->includePaths = m_includePaths; part->frameworkPaths = m_frameworkPaths; part->cVersion = ProjectPart::C11; diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp index a7a6aa222e..3325e1832d 100644 --- a/src/plugins/cpptools/cppmodelmanager_test.cpp +++ b/src/plugins/cpptools/cppmodelmanager_test.cpp @@ -217,7 +217,7 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean() ProjectPart::Ptr part(new ProjectPart); part->cxxVersion = ProjectPart::CXX98; part->qtVersion = ProjectPart::Qt5; - part->defines = QByteArray("#define OH_BEHAVE -1\n"); + part->projectDefines = QByteArray("#define OH_BEHAVE -1\n"); part->includePaths = QStringList() << testDataDir.includeDir(false); part->frameworkPaths = QStringList() << testDataDir.frameworksDir(false); pi.appendProjectPart(part); @@ -251,7 +251,7 @@ void CppToolsPlugin::test_modelmanager_framework_headers() ProjectPart::Ptr part(new ProjectPart); part->cxxVersion = ProjectPart::CXX98; part->qtVersion = ProjectPart::Qt5; - part->defines = QByteArray("#define OH_BEHAVE -1\n"); + part->projectDefines = QByteArray("#define OH_BEHAVE -1\n"); part->includePaths << testDataDir.includeDir(); part->frameworkPaths << testDataDir.frameworksDir(); const QString &source = testDataDir.fileFromSourcesDir( @@ -300,7 +300,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files() ProjectPart::Ptr part(new ProjectPart); part->cxxVersion = ProjectPart::CXX98; part->qtVersion = ProjectPart::Qt5; - part->defines = QByteArray("#define OH_BEHAVE -1\n"); + part->projectDefines = QByteArray("#define OH_BEHAVE -1\n"); part->includePaths = QStringList() << testDataDir.includeDir(false); part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource)); pi.appendProjectPart(part); @@ -320,7 +320,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files() QVERIFY(macrosInHeaderBefore.first().name() == "test_modelmanager_refresh_h"); // Introduce a define that will enable another define once the document is reparsed. - part->defines = QByteArray("#define TEST_DEFINE 1\n"); + part->projectDefines = QByteArray("#define TEST_DEFINE 1\n"); pi.clearProjectParts(); pi.appendProjectPart(part); mm->updateProjectInfo(pi); @@ -377,7 +377,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times() ProjectPart::Ptr part(new ProjectPart); // Simulate project configuration change by having different defines each time. defines += "\n#define ANOTHER_DEFINE"; - part->defines = defines; + part->projectDefines = defines; part->cxxVersion = ProjectPart::CXX98; part->qtVersion = ProjectPart::Qt5; part->files.append(ProjectFile(testHeader1, ProjectFile::CXXHeader)); @@ -810,7 +810,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project() part1->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part1->cxxVersion = ProjectPart::CXX11; part1->qtVersion = ProjectPart::NoQt; - part1->defines = QByteArray("#define SUB1\n"); + part1->projectDefines = QByteArray("#define SUB1\n"); part1->includePaths = QStringList() << testDataDirectory.includeDir(false); ProjectPart::Ptr part2(new ProjectPart); @@ -818,7 +818,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project() part2->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part2->cxxVersion = ProjectPart::CXX11; part2->qtVersion = ProjectPart::NoQt; - part2->defines = QByteArray("#define SUB2\n"); + part2->projectDefines = QByteArray("#define SUB2\n"); part2->includePaths = QStringList() << testDataDirectory.includeDir(false); ProjectInfo pi = mm->projectInfo(project); diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.cpp b/src/plugins/cpptools/cppmodelmanagerinterface.cpp index 31f1b55e18..3992c44bf5 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.cpp +++ b/src/plugins/cpptools/cppmodelmanagerinterface.cpp @@ -161,13 +161,7 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc, else includePaths << header.path(); - const QByteArray macros = tc->predefinedMacros(cxxflags); - if (!macros.isEmpty()) { - if (!defines.isEmpty()) - defines += '\n'; - defines += macros; - defines += '\n'; - } + toolchainDefines = tc->predefinedMacros(cxxflags); } static CppModelManagerInterface *g_instance = 0; @@ -235,5 +229,6 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart(const ProjectPart: // Update defines if (!m_defines.isEmpty()) m_defines.append('\n'); - m_defines.append(part->defines); + m_defines.append(part->toolchainDefines); + m_defines.append(part->projectDefines); } diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h index e1469efda0..fbb70f7f07 100644 --- a/src/plugins/cpptools/cppmodelmanagerinterface.h +++ b/src/plugins/cpptools/cppmodelmanagerinterface.h @@ -105,7 +105,8 @@ public: QString projectFile; ProjectExplorer::Project *project; QList<ProjectFile> files; - QByteArray defines; + QByteArray projectDefines; + QByteArray toolchainDefines; QStringList includePaths; QStringList frameworkPaths; QStringList precompiledHeaders; diff --git a/src/plugins/cpptools/cppsnapshotupdater.cpp b/src/plugins/cpptools/cppsnapshotupdater.cpp index 0a97a98fdf..fc97875c60 100644 --- a/src/plugins/cpptools/cppsnapshotupdater.cpp +++ b/src/plugins/cpptools/cppsnapshotupdater.cpp @@ -69,7 +69,8 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy) } if (m_projectPart) { - configFile += m_projectPart->defines; + configFile += m_projectPart->toolchainDefines; + configFile += m_projectPart->projectDefines; includePaths = m_projectPart->includePaths; frameworkPaths = m_projectPart->frameworkPaths; if (m_usePrecompiledHeaders) diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp index 85c304cad6..c2a3792c93 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.cpp +++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp @@ -186,7 +186,7 @@ QByteArray CppEditorSupport::contents() const const int editorRev = editorRevision(); if (m_cachedContentsEditorRevision != editorRev && !m_fileIsBeingReloaded) { m_cachedContentsEditorRevision = editorRev; - m_cachedContents = m_textEditor->textDocument()->contents().toUtf8(); + m_cachedContents = m_textEditor->textDocument()->plainText().toUtf8(); } return m_cachedContents; @@ -392,10 +392,14 @@ void CppEditorSupport::startHighlighting() m_lastHighlightRevision = revision; emit highlighterStarted(&m_highlighter, m_lastHighlightRevision); } else { + const unsigned revision = currentSource(false).revision; + if (m_lastHighlightRevision == revision) + return; + + m_lastHighlightRevision = revision; static const Document::Ptr dummyDoc; static const Snapshot dummySnapshot; m_highlighter = m_highlightingSupport->highlightingFuture(dummyDoc, dummySnapshot); - m_lastHighlightRevision = editorRevision(); emit highlighterStarted(&m_highlighter, m_lastHighlightRevision); } } |