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);
|
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
|
|||||||
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,18 +168,18 @@ QStringList GenericProject::readLines(const QString &absoluteFileName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenericProject::parseProject()
|
void GenericProject::parseProject(RefreshOptions options)
|
||||||
{
|
{
|
||||||
const QFileInfo projectFileInfo(m_fileName);
|
if (options & Files) {
|
||||||
|
|
||||||
QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
|
||||||
|
|
||||||
m_files = convertToAbsoluteFiles(readLines(filesFileName()));
|
m_files = convertToAbsoluteFiles(readLines(filesFileName()));
|
||||||
m_files.removeDuplicates();
|
m_files.removeDuplicates();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options & Configuration) {
|
||||||
m_projectIncludePaths = readLines(includesFileName());
|
m_projectIncludePaths = readLines(includesFileName());
|
||||||
m_projectIncludePaths.removeDuplicates();
|
m_projectIncludePaths.removeDuplicates();
|
||||||
|
|
||||||
|
QSettings projectInfo(m_fileName, QSettings::IniFormat);
|
||||||
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
|
m_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
|
||||||
|
|
||||||
m_defines.clear();
|
m_defines.clear();
|
||||||
@@ -187,14 +187,21 @@ void GenericProject::parseProject()
|
|||||||
QFile configFile(configFileName());
|
QFile configFile(configFileName());
|
||||||
if (configFile.open(QFile::ReadOnly))
|
if (configFile.open(QFile::ReadOnly))
|
||||||
m_defines = configFile.readAll();
|
m_defines = configFile.readAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options & Files)
|
||||||
emit fileListChanged();
|
emit fileListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericProject::refresh()
|
void GenericProject::refresh(RefreshOptions options)
|
||||||
{
|
{
|
||||||
parseProject();
|
QSet<QString> oldFileList;
|
||||||
|
if (!(options & Configuration))
|
||||||
|
oldFileList = m_files.toSet();
|
||||||
|
|
||||||
|
parseProject(options);
|
||||||
|
|
||||||
|
if (options & Files)
|
||||||
m_rootNode->refresh();
|
m_rootNode->refresh();
|
||||||
|
|
||||||
CppTools::CppModelManagerInterface *modelManager =
|
CppTools::CppModelManagerInterface *modelManager =
|
||||||
@@ -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()
|
|||||||
pinfo.sourceFiles = files();
|
pinfo.sourceFiles = files();
|
||||||
pinfo.sourceFiles += generated();
|
pinfo.sourceFiles += generated();
|
||||||
|
|
||||||
QStringList filesToUpdate = pinfo.sourceFiles;
|
QStringList filesToUpdate;
|
||||||
|
|
||||||
|
if (options & Configuration) {
|
||||||
|
filesToUpdate = pinfo.sourceFiles;
|
||||||
filesToUpdate.append(QLatin1String("<configuration>")); // XXX don't hardcode configuration file name
|
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
|
|||||||
|
|
||||||
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:
|
|||||||
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:
|
|||||||
|
|
||||||
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)
|
|||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user