forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -202,7 +202,6 @@ void MakeStep::removeDirectory(const QString &dir)
|
||||
m_openDirectories.remove(dir);
|
||||
}
|
||||
|
||||
|
||||
CMakeProject *MakeStep::project() const
|
||||
{
|
||||
return m_pro;
|
||||
|
||||
@@ -143,7 +143,7 @@ QString GenericProject::includesFileName() const
|
||||
QString GenericProject::configFileName() const
|
||||
{ return m_configFileName; }
|
||||
|
||||
QStringList GenericProject::readLines(const QString &absoluteFileName) const
|
||||
static QStringList readLines(const QString &absoluteFileName)
|
||||
{
|
||||
QStringList lines;
|
||||
|
||||
@@ -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()));
|
||||
m_files.removeDuplicates();
|
||||
}
|
||||
|
||||
QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
||||
if (options & Configuration) {
|
||||
m_projectIncludePaths = readLines(includesFileName());
|
||||
m_projectIncludePaths.removeDuplicates();
|
||||
|
||||
m_files = convertToAbsoluteFiles(readLines(filesFileName()));
|
||||
m_files.removeDuplicates();
|
||||
QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
||||
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
|
||||
|
||||
m_projectIncludePaths = readLines(includesFileName());
|
||||
m_projectIncludePaths.removeDuplicates();
|
||||
m_defines.clear();
|
||||
|
||||
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
|
||||
QFile configFile(configFileName());
|
||||
if (configFile.open(QFile::ReadOnly))
|
||||
m_defines = configFile.readAll();
|
||||
}
|
||||
|
||||
m_defines.clear();
|
||||
|
||||
QFile configFile(configFileName());
|
||||
if (configFile.open(QFile::ReadOnly))
|
||||
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 =
|
||||
ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
|
||||
@@ -214,7 +221,6 @@ void GenericProject::refresh()
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, m_toolChain->systemHeaderPaths()) {
|
||||
if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
|
||||
allFrameworkPaths.append(headerPath.path());
|
||||
|
||||
else
|
||||
allIncludePaths.append(headerPath.path());
|
||||
}
|
||||
@@ -228,8 +234,17 @@ void GenericProject::refresh()
|
||||
pinfo.sourceFiles = files();
|
||||
pinfo.sourceFiles += generated();
|
||||
|
||||
QStringList filesToUpdate = pinfo.sourceFiles;
|
||||
filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
|
||||
QStringList filesToUpdate;
|
||||
|
||||
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->updateSourceFiles(filesToUpdate);
|
||||
@@ -450,8 +465,7 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
|
||||
|
||||
setIncludePaths(allIncludePaths());
|
||||
|
||||
parseProject();
|
||||
refresh();
|
||||
refresh(Everything);
|
||||
}
|
||||
|
||||
void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
|
||||
|
||||
@@ -94,6 +94,14 @@ public:
|
||||
QString buildParser(const QString &buildConfiguration) const;
|
||||
ProjectExplorer::ToolChain *toolChain() const;
|
||||
|
||||
enum RefreshOptions {
|
||||
Files = 0x01,
|
||||
Configuration = 0x02,
|
||||
Everything = Files | Configuration
|
||||
};
|
||||
|
||||
void refresh(RefreshOptions options);
|
||||
|
||||
QStringList includePaths() const;
|
||||
void setIncludePaths(const QStringList &includePaths);
|
||||
|
||||
@@ -106,18 +114,15 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void setToolChainId(const QString &toolChainId);
|
||||
void refresh();
|
||||
|
||||
protected:
|
||||
virtual void saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer);
|
||||
virtual void restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader &reader);
|
||||
|
||||
private:
|
||||
void parseProject();
|
||||
void parseProject(RefreshOptions options);
|
||||
QStringList convertToAbsoluteFiles(const QStringList &paths) const;
|
||||
|
||||
QStringList readLines(const QString &absoluteFileName) const;
|
||||
|
||||
Manager *m_manager;
|
||||
QString m_fileName;
|
||||
QString m_filesFileName;
|
||||
|
||||
@@ -79,10 +79,12 @@ void Manager::unregisterProject(GenericProject *project)
|
||||
void Manager::notifyChanged(const QString &fileName)
|
||||
{
|
||||
foreach (GenericProject *project, m_projects) {
|
||||
if (fileName == project->filesFileName() ||
|
||||
fileName == project->includesFileName() ||
|
||||
fileName == project->configFileName())
|
||||
project->refresh();
|
||||
if (fileName == project->filesFileName()) {
|
||||
project->refresh(GenericProject::Files);
|
||||
}
|
||||
else if (fileName == project->includesFileName() ||
|
||||
fileName == project->configFileName()) {
|
||||
project->refresh(GenericProject::Configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user