Commit cc995d13 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Allow updating of configuration or file list separately

Now it will only update the list of files when you edit [project].files,
and only reparse all files when you edit [project].config or
[project].includes. When updating the file list it will only parse the
added files.
parent 9c8f4e30
...@@ -202,7 +202,6 @@ void MakeStep::removeDirectory(const QString &dir) ...@@ -202,7 +202,6 @@ void MakeStep::removeDirectory(const QString &dir)
m_openDirectories.remove(dir); m_openDirectories.remove(dir);
} }
CMakeProject *MakeStep::project() const CMakeProject *MakeStep::project() const
{ {
return m_pro; return m_pro;
......
...@@ -143,7 +143,7 @@ QString GenericProject::includesFileName() const ...@@ -143,7 +143,7 @@ QString GenericProject::includesFileName() const
QString GenericProject::configFileName() const QString GenericProject::configFileName() const
{ return m_configFileName; } { return m_configFileName; }
QStringList GenericProject::readLines(const QString &absoluteFileName) const static QStringList readLines(const QString &absoluteFileName)
{ {
QStringList lines; QStringList lines;
...@@ -168,34 +168,41 @@ QStringList GenericProject::readLines(const QString &absoluteFileName) const ...@@ -168,34 +168,41 @@ QStringList GenericProject::readLines(const QString &absoluteFileName) const
} }
void GenericProject::parseProject() void GenericProject::parseProject(RefreshOptions options)
{ {
const QFileInfo projectFileInfo(m_fileName); if (options & Files) {
m_files = convertToAbsoluteFiles(readLines(filesFileName()));
QSettings projectInfo(m_fileName, QSettings::IniFormat); m_files.removeDuplicates();
}
m_files = convertToAbsoluteFiles(readLines(filesFileName()));
m_files.removeDuplicates();
m_projectIncludePaths = readLines(includesFileName()); if (options & Configuration) {
m_projectIncludePaths.removeDuplicates(); m_projectIncludePaths = readLines(includesFileName());
m_projectIncludePaths.removeDuplicates();
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList()); QSettings projectInfo(m_fileName, QSettings::IniFormat);
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
m_defines.clear(); m_defines.clear();
QFile configFile(configFileName()); QFile configFile(configFileName());
if (configFile.open(QFile::ReadOnly)) if (configFile.open(QFile::ReadOnly))
m_defines = configFile.readAll(); m_defines = configFile.readAll();
}
emit fileListChanged(); if (options & Files)
emit fileListChanged();
} }
void GenericProject::refresh() void GenericProject::refresh(RefreshOptions options)
{ {
parseProject(); QSet<QString> oldFileList;
if (!(options & Configuration))
oldFileList = m_files.toSet();
m_rootNode->refresh(); parseProject(options);
if (options & Files)
m_rootNode->refresh();
CppTools::CppModelManagerInterface *modelManager = CppTools::CppModelManagerInterface *modelManager =
ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>(); ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
...@@ -214,7 +221,6 @@ void GenericProject::refresh() ...@@ -214,7 +221,6 @@ void GenericProject::refresh()
foreach (const ProjectExplorer::HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) { foreach (const ProjectExplorer::HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) {
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath) if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
allFrameworkPaths.append(headerPath.path()); allFrameworkPaths.append(headerPath.path());
else else
allIncludePaths.append(headerPath.path()); allIncludePaths.append(headerPath.path());
} }
...@@ -228,8 +234,17 @@ void GenericProject::refresh() ...@@ -228,8 +234,17 @@ void GenericProject::refresh()
pinfo.sourceFiles = files(); pinfo.sourceFiles = files();
pinfo.sourceFiles += generated(); pinfo.sourceFiles += generated();
QStringList filesToUpdate = pinfo.sourceFiles; QStringList filesToUpdate;
filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
if (options & Configuration) {
filesToUpdate = pinfo.sourceFiles;
filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
} else if (options & Files) {
// Only update files that got added to the list
QSet<QString> newFileList = m_files.toSet();
newFileList.subtract(oldFileList);
filesToUpdate.append(newFileList.toList());
}
modelManager->updateProjectInfo(pinfo); modelManager->updateProjectInfo(pinfo);
modelManager->updateSourceFiles(filesToUpdate); modelManager->updateSourceFiles(filesToUpdate);
...@@ -450,8 +465,7 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead ...@@ -450,8 +465,7 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
setIncludePaths(allIncludePaths()); setIncludePaths(allIncludePaths());
parseProject(); refresh(Everything);
refresh();
} }
void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer) void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
......
...@@ -94,6 +94,14 @@ public: ...@@ -94,6 +94,14 @@ public:
QString buildParser(const QString &buildConfiguration) const; QString buildParser(const QString &buildConfiguration) const;
ProjectExplorer::ToolChain *toolChain() const; ProjectExplorer::ToolChain *toolChain() const;
enum RefreshOptions {
Files = 0x01,
Configuration = 0x02,
Everything = Files | Configuration
};
void refresh(RefreshOptions options);
QStringList includePaths() const; QStringList includePaths() const;
void setIncludePaths(const QStringList &includePaths); void setIncludePaths(const QStringList &includePaths);
...@@ -106,18 +114,15 @@ public: ...@@ -106,18 +114,15 @@ public:
public Q_SLOTS: public Q_SLOTS:
void setToolChainId(const QString &toolChainId); void setToolChainId(const QString &toolChainId);
void refresh();
protected: protected:
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer); virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader); virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
private: private:
void parseProject(); void parseProject(RefreshOptions options);
QStringList convertToAbsoluteFiles(const QStringList &paths) const; QStringList convertToAbsoluteFiles(const QStringList &paths) const;
QStringList readLines(const QString &absoluteFileName) const;
Manager *m_manager; Manager *m_manager;
QString m_fileName; QString m_fileName;
QString m_filesFileName; QString m_filesFileName;
......
...@@ -79,10 +79,12 @@ void Manager::unregisterProject(GenericProject *project) ...@@ -79,10 +79,12 @@ void Manager::unregisterProject(GenericProject *project)
void Manager::notifyChanged(const QString &fileName) void Manager::notifyChanged(const QString &fileName)
{ {
foreach (GenericProject *project, m_projects) { foreach (GenericProject *project, m_projects) {
if (fileName == project->filesFileName() || if (fileName == project->filesFileName()) {
fileName == project->includesFileName() || project->refresh(GenericProject::Files);
fileName == project->configFileName()) }
project->refresh(); else if (fileName == project->includesFileName() ||
fileName == project->configFileName()) {
project->refresh(GenericProject::Configuration);
}
} }
} }
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