Merge remote-tracking branch 'origin/3.5'

Change-Id: I7b3ef276d438ff0f184a649153e8aeec08a9f8c9
This commit is contained in:
Eike Ziller
2015-08-04 13:15:51 +02:00
203 changed files with 6590 additions and 12601 deletions

View File

@@ -126,7 +126,7 @@ ProjectPart::Ptr BaseEditorDocumentParser::determineProjectPart(const QString &f
CppModelManager *cmm = CppModelManager::instance();
QList<ProjectPart::Ptr> projectParts = cmm->projectPart(filePath);
if (projectParts.isEmpty()) {
if (projectPart)
if (projectPart && config.stickToPreviousProjectPart)
// File is not directly part of any project, but we got one before. We will re-use it,
// because re-calculating this can be expensive when the dependency table is big.
return projectPart;

View File

@@ -47,6 +47,7 @@ public:
static BaseEditorDocumentParser *get(const QString &filePath);
struct Configuration {
bool stickToPreviousProjectPart = true;
bool usePrecompiledHeaders = false;
QByteArray editorDefines;
ProjectPart::Ptr manuallySetProjectPart;

View File

@@ -491,7 +491,7 @@ void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
}
if (!part->projectConfigFile.isEmpty())
m_out << i3 << "Project Config File: " << part->projectConfigFile << "\n";
m_out << i2 << "Project Part \"" << part->projectFile << "\"{{{3\n";
m_out << i2 << "Project Part \"" << part->id() << "\"{{{3\n";
m_out << i3 << "Project Part Name : " << part->displayName << "\n";
m_out << i3 << "Project Name : " << projectName << "\n";
m_out << i3 << "Project File : " << projectFilePath << "\n";

View File

@@ -54,6 +54,7 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
@@ -137,7 +138,7 @@ public:
mutable QMutex m_projectMutex;
QMap<ProjectExplorer::Project *, ProjectInfo> m_projectToProjectsInfo;
QMap<Utils::FileName, QList<ProjectPart::Ptr> > m_fileToProjectParts;
QMap<QString, ProjectPart::Ptr> m_projectFileToProjectPart;
QMap<QString, ProjectPart::Ptr> m_projectPartIdToProjectProjectPart;
// The members below are cached/(re)calculated from the projects and/or their project parts
bool m_dirty;
QStringList m_projectFiles;
@@ -710,13 +711,11 @@ void CppModelManager::removeFilesFromSnapshot(const QSet<QString> &filesToRemove
d->m_snapshot.remove(i.next());
}
static QStringList projectFilePaths(const QSet<ProjectPart::Ptr> &projectParts)
static QSet<QString> projectPartIds(const QSet<ProjectPart::Ptr> &projectParts)
{
QStringList result;
QSetIterator<ProjectPart::Ptr> it(projectParts);
while (it.hasNext())
result << it.next()->projectFile;
return result;
return Utils::transform(projectParts, [](const ProjectPart::Ptr &projectPart) {
return projectPart->id();
});
}
class ProjectInfoComparer
@@ -750,9 +749,9 @@ public:
QStringList removedProjectParts()
{
QSet<ProjectPart::Ptr> removed = m_old.projectParts().toSet();
removed.subtract(m_new.projectParts().toSet());
return projectFilePaths(removed);
QSet<QString> removed = projectPartIds(m_old.projectParts().toSet());
removed.subtract(projectPartIds(m_new.projectParts().toSet()));
return removed.toList();
}
/// Returns a list of common files that have a changed timestamp.
@@ -781,13 +780,13 @@ private:
};
/// Make sure that m_projectMutex is locked when calling this.
void CppModelManager::recalculateFileToProjectParts()
void CppModelManager::recalculateProjectPartMappings()
{
d->m_projectFileToProjectPart.clear();
d->m_projectPartIdToProjectProjectPart.clear();
d->m_fileToProjectParts.clear();
foreach (const ProjectInfo &projectInfo, d->m_projectToProjectsInfo) {
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
d->m_projectFileToProjectPart[projectPart->projectFile] = projectPart;
d->m_projectPartIdToProjectProjectPart[projectPart->id()] = projectPart;
foreach (const ProjectFile &cxxFile, projectPart->files)
d->m_fileToProjectParts[Utils::FileName::fromString(cxxFile.path)].append(
projectPart);
@@ -883,7 +882,7 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
// Update Project/ProjectInfo and File/ProjectPart table
d->m_projectToProjectsInfo.insert(project, newProjectInfo);
recalculateFileToProjectParts();
recalculateProjectPartMappings();
} // Mutex scope
@@ -908,9 +907,9 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &newProjectIn
return updateSourceFiles(filesToReindex, ForcedProgressNotification);
}
ProjectPart::Ptr CppModelManager::projectPartForProjectFile(const QString &projectFile) const
ProjectPart::Ptr CppModelManager::projectPartForId(const QString &projectPartId) const
{
return d->m_projectFileToProjectPart.value(projectFile);
return d->m_projectPartIdToProjectProjectPart.value(projectPartId);
}
QList<ProjectPart::Ptr> CppModelManager::projectPart(const Utils::FileName &fileName) const
@@ -981,17 +980,17 @@ void CppModelManager::delayedGC()
d->m_delayedGcTimer.start(500);
}
static QStringList pathsOfAllProjectParts(const ProjectInfo &projectInfo)
static QStringList idsOfAllProjectParts(const ProjectInfo &projectInfo)
{
QStringList projectPaths;
foreach (const ProjectPart::Ptr &part, projectInfo.projectParts())
projectPaths << part->projectFile;
projectPaths << part->id();
return projectPaths;
}
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
{
QStringList projectFilePaths;
QStringList projectPartIds;
{
QMutexLocker locker(&d->m_projectMutex);
@@ -999,14 +998,14 @@ void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
// Save paths
const ProjectInfo projectInfo = d->m_projectToProjectsInfo.value(project, ProjectInfo());
projectFilePaths = pathsOfAllProjectParts(projectInfo);
projectPartIds = idsOfAllProjectParts(projectInfo);
d->m_projectToProjectsInfo.remove(project);
recalculateFileToProjectParts();
recalculateProjectPartMappings();
}
if (!projectFilePaths.isEmpty())
emit projectPartsRemoved(projectFilePaths);
if (!projectPartIds.isEmpty())
emit projectPartsRemoved(projectPartIds);
delayedGC();
}
@@ -1085,7 +1084,7 @@ void CppModelManager::onAboutToUnloadSession()
do {
QMutexLocker locker(&d->m_projectMutex);
d->m_projectToProjectsInfo.clear();
recalculateFileToProjectParts();
recalculateProjectPartMappings();
d->m_dirty = true;
} while (0);
}

View File

@@ -94,7 +94,7 @@ public:
QFuture<void> updateProjectInfo(const ProjectInfo &newProjectInfo);
/// \return The project part with the given project file
ProjectPart::Ptr projectPartForProjectFile(const QString &projectFile) const;
ProjectPart::Ptr projectPartForId(const QString &projectPartId) const;
/// \return All project parts that mention the given file name as one of the sources/headers.
QList<ProjectPart::Ptr> projectPart(const Utils::FileName &fileName) const;
QList<ProjectPart::Ptr> projectPart(const QString &fileName) const
@@ -170,7 +170,7 @@ signals:
void sourceFilesRefreshed(const QSet<QString> &files);
void projectPartsUpdated(ProjectExplorer::Project *project);
void projectPartsRemoved(const QStringList &projectFiles);
void projectPartsRemoved(const QStringList &projectPartIds);
void globalSnapshotChanged();
@@ -198,7 +198,7 @@ private slots:
private:
void delayedGC();
void recalculateFileToProjectParts();
void recalculateProjectPartMappings();
void updateCppEditorDocuments() const;
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);

View File

@@ -146,7 +146,10 @@ ProjectPart::Ptr ProjectPart::copy() const
QString ProjectPart::id() const
{
return QDir::fromNativeSeparators(projectFile) + QLatin1Char(' ') + displayName;
QString projectPartId = QDir::fromNativeSeparators(projectFile);
if (!displayName.isEmpty())
projectPartId.append(QLatin1Char(' ') + displayName);
return projectPartId;
}
QByteArray ProjectPart::readProjectConfigFile(const ProjectPart::Ptr &part)
@@ -669,13 +672,15 @@ void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtension
opts << (gnuExtensions ? QLatin1String("-std=gnu++98") : QLatin1String("-std=c++98"));
break;
case ProjectPart::CXX03:
// Clang 3.6 does not know -std=gnu++03.
opts << QLatin1String("-std=c++03");
break;
case ProjectPart::CXX14:
opts << QLatin1String("-std=c++1y"); // TODO: change to c++14 after 3.5
opts << (gnuExtensions ? QLatin1String("-std=gnu++14") : QLatin1String("-std=c++14"));
break;
case ProjectPart::CXX17:
opts << QLatin1String("-std=c++1z"); // TODO: change to c++17 at some point in the future
// TODO: Change to (probably) "gnu++17"/"c++17" at some point in the future.
opts << (gnuExtensions ? QLatin1String("-std=gnu++1z") : QLatin1String("-std=c++1z"));
break;
}