Commit 6dbc975f authored by Roberto Raggi's avatar Roberto Raggi
Browse files

re-enable the indexer.

parent 6ea4990b
...@@ -111,9 +111,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) ...@@ -111,9 +111,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
_file = new GenericProjectFile(this, fileName); _file = new GenericProjectFile(this, fileName);
_rootNode = new GenericProjectNode(_file); _rootNode = new GenericProjectNode(this, _file);
refresh();
} }
GenericProject::~GenericProject() GenericProject::~GenericProject()
...@@ -124,6 +122,15 @@ GenericProject::~GenericProject() ...@@ -124,6 +122,15 @@ GenericProject::~GenericProject()
delete _toolChain; delete _toolChain;
} }
void GenericProject::parseProject()
{
QSettings projectInfo(_fileName, QSettings::IniFormat);
_files = convertToAbsoluteFiles(projectInfo.value(QLatin1String("files")).toStringList());
_generated = convertToAbsoluteFiles(projectInfo.value(QLatin1String("generated")).toStringList());
_defines = projectInfo.value(QLatin1String("defines")).toStringList();
}
void GenericProject::refresh() void GenericProject::refresh()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
...@@ -150,21 +157,48 @@ void GenericProject::refresh() ...@@ -150,21 +157,48 @@ void GenericProject::refresh()
allIncludePaths.append(headerPath.path()); allIncludePaths.append(headerPath.path());
} }
allIncludePaths += _rootNode->includePaths(); allIncludePaths += includePaths();
pinfo.frameworkPaths = allFrameworkPaths; pinfo.frameworkPaths = allFrameworkPaths;
pinfo.includePaths = allIncludePaths; pinfo.includePaths = allIncludePaths;
// ### add _defines. // ### add _defines.
pinfo.sourceFiles = _rootNode->files(); pinfo.sourceFiles = files();
pinfo.sourceFiles += _rootNode->generated(); pinfo.sourceFiles += generated();
modelManager->updateProjectInfo(pinfo); modelManager->updateProjectInfo(pinfo);
modelManager->updateSourceFiles(pinfo.sourceFiles); modelManager->updateSourceFiles(pinfo.sourceFiles);
} }
} }
void GenericProject::setToolChain(const QString &toolChainId) QStringList GenericProject::convertToAbsoluteFiles(const QStringList &paths) const
{
const QDir projectDir(QFileInfo(_fileName).dir());
QStringList absolutePaths;
foreach (const QString &file, paths) {
QFileInfo fileInfo(projectDir, file);
absolutePaths.append(fileInfo.absoluteFilePath());
}
absolutePaths.removeDuplicates();
return absolutePaths;
}
QStringList GenericProject::files() const
{ return _files; }
QStringList GenericProject::generated() const
{ return _generated; }
QStringList GenericProject::includePaths() const
{ return _includePaths; }
void GenericProject::setIncludePaths(const QStringList &includePaths)
{ _includePaths = convertToAbsoluteFiles(includePaths); }
QStringList GenericProject::defines() const
{ return _defines; }
void GenericProject::setToolChainId(const QString &toolChainId)
{ {
using namespace ProjectExplorer; using namespace ProjectExplorer;
...@@ -310,7 +344,7 @@ QStringList GenericProject::files(FilesMode fileMode) const ...@@ -310,7 +344,7 @@ QStringList GenericProject::files(FilesMode fileMode) const
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
return _rootNode->files(); return _files; // ### TODO: handle generated files here.
} }
QStringList GenericProject::targets() const QStringList GenericProject::targets() const
...@@ -357,10 +391,11 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead ...@@ -357,10 +391,11 @@ void GenericProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsRead
if (toolChainId.isEmpty()) if (toolChainId.isEmpty())
toolChainId = QLatin1String("gcc"); toolChainId = QLatin1String("gcc");
setToolChain(toolChainId.toLower()); // ### move setToolChainId(toolChainId.toLower()); // ### move
setIncludePaths(reader.restoreValue(QLatin1String("includePaths")).toStringList());
const QStringList includePaths = reader.restoreValue(QLatin1String("includePaths")).toStringList(); parseProject();
_rootNode->setIncludePaths(includePaths); refresh();
} }
void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer) void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter &writer)
...@@ -370,7 +405,7 @@ void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter ...@@ -370,7 +405,7 @@ void GenericProject::saveSettingsImpl(ProjectExplorer::PersistentSettingsWriter
Project::saveSettingsImpl(writer); Project::saveSettingsImpl(writer);
writer.saveValue("toolChain", _toolChainId); writer.saveValue("toolChain", _toolChainId);
writer.saveValue("includePaths", _rootNode->includePaths()); writer.saveValue("includePaths", _includePaths);
} }
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
...@@ -394,7 +429,7 @@ GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project) ...@@ -394,7 +429,7 @@ GenericBuildSettingsWidget::GenericBuildSettingsWidget(GenericProject *project)
toolChainChooser->addItems(ProjectExplorer::ToolChain::supportedToolChains()); toolChainChooser->addItems(ProjectExplorer::ToolChain::supportedToolChains());
toolChainChooser->setCurrentIndex(toolChainChooser->findText(_project->toolChainId())); toolChainChooser->setCurrentIndex(toolChainChooser->findText(_project->toolChainId()));
fl->addRow(tr("Tool chain:"), toolChainChooser); fl->addRow(tr("Tool chain:"), toolChainChooser);
connect(toolChainChooser, SIGNAL(activated(QString)), _project, SLOT(setToolChain(QString))); connect(toolChainChooser, SIGNAL(activated(QString)), _project, SLOT(setToolChainId(QString)));
// include paths // include paths
QListView *includePathsView = new QListView; QListView *includePathsView = new QListView;
......
...@@ -76,24 +76,38 @@ public: ...@@ -76,24 +76,38 @@ public:
MakeStep *makeStep() const; MakeStep *makeStep() const;
QString buildParser(const QString &buildConfiguration) const; QString buildParser(const QString &buildConfiguration) const;
QStringList convertToAbsoluteFiles(const QStringList &paths) const;
QStringList includePaths() const;
void setIncludePaths(const QStringList &includePaths);
QStringList files() const;
QStringList generated() const;
QStringList defines() const;
QString toolChainId() const; QString toolChainId() const;
public Q_SLOTS: public Q_SLOTS:
void setToolChain(const QString &toolChainId); void setToolChainId(const QString &toolChainId);
private:
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 refresh();
Manager *_manager; Manager *_manager;
QString _fileName; QString _fileName;
GenericProjectFile *_file; GenericProjectFile *_file;
QString _projectName; QString _projectName;
QStringList _files;
QStringList _generated;
QStringList _includePaths;
QStringList _defines;
GenericProjectNode* _rootNode; GenericProjectNode* _rootNode;
ProjectExplorer::ToolChain *_toolChain; ProjectExplorer::ToolChain *_toolChain;
QString _toolChainId; QString _toolChainId;
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
**************************************************************************/ **************************************************************************/
#include "genericprojectnodes.h" #include "genericprojectnodes.h"
#include "genericproject.h"
#include <QDir> #include <QDir>
#include <QFileInfo> #include <QFileInfo>
#include <QSettings> #include <QSettings>
...@@ -36,8 +38,9 @@ ...@@ -36,8 +38,9 @@
using namespace GenericProjectManager; using namespace GenericProjectManager;
using namespace GenericProjectManager::Internal; using namespace GenericProjectManager::Internal;
GenericProjectNode::GenericProjectNode(Core::IFile *projectFile) GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *projectFile)
: ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absolutePath()), : ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absolutePath()),
_project(project),
_projectFile(projectFile) _projectFile(projectFile)
{} {}
...@@ -50,17 +53,6 @@ Core::IFile *GenericProjectNode::projectFile() const ...@@ -50,17 +53,6 @@ Core::IFile *GenericProjectNode::projectFile() const
QString GenericProjectNode::projectFilePath() const QString GenericProjectNode::projectFilePath() const
{ return _projectFile->fileName(); } { return _projectFile->fileName(); }
static QStringList convertToAbsoluteFiles(const QDir &dir, const QStringList &paths)
{
QStringList absolutePaths;
foreach (const QString &file, paths) {
QFileInfo fileInfo(dir, file);
absolutePaths.append(fileInfo.absoluteFilePath());
}
absolutePaths.removeDuplicates();
return absolutePaths;
}
void GenericProjectNode::refresh() void GenericProjectNode::refresh()
{ {
using namespace ProjectExplorer; using namespace ProjectExplorer;
...@@ -69,13 +61,6 @@ void GenericProjectNode::refresh() ...@@ -69,13 +61,6 @@ void GenericProjectNode::refresh()
removeFileNodes(fileNodes(), this); removeFileNodes(fileNodes(), this);
removeFolderNodes(subFolderNodes(), this); removeFolderNodes(subFolderNodes(), this);
QDir projectPath(path());
QSettings projectInfo(projectFilePath(), QSettings::IniFormat);
_files = convertToAbsoluteFiles(projectPath, projectInfo.value(QLatin1String("files")).toStringList());
_generated = convertToAbsoluteFiles(projectPath, projectInfo.value(QLatin1String("generated")).toStringList());
_defines = projectInfo.value(QLatin1String("defines")).toStringList();
FileNode *projectFileNode = new FileNode(projectFilePath(), ProjectFileType, FileNode *projectFileNode = new FileNode(projectFilePath(), ProjectFileType,
/* generated = */ false); /* generated = */ false);
...@@ -84,7 +69,7 @@ void GenericProjectNode::refresh() ...@@ -84,7 +69,7 @@ void GenericProjectNode::refresh()
QStringList filePaths; QStringList filePaths;
QHash<QString, QStringList> filesInPath; QHash<QString, QStringList> filesInPath;
foreach (const QString &absoluteFileName, _files) { foreach (const QString &absoluteFileName, _project->files()) {
QFileInfo fileInfo(absoluteFileName); QFileInfo fileInfo(absoluteFileName);
const QString absoluteFilePath = fileInfo.path(); const QString absoluteFilePath = fileInfo.path();
...@@ -144,96 +129,6 @@ ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName(const ...@@ -144,96 +129,6 @@ ProjectExplorer::FolderNode *GenericProjectNode::findOrCreateFolderByName(const
return findOrCreateFolderByName(components, components.length()); return findOrCreateFolderByName(components, components.length());
} }
#if 0
void GenericProjectNode::refresh()
{
using namespace ProjectExplorer;
removeFileNodes(fileNodes(), this);
removeFolderNodes(subFolderNodes(), this);
QDir projectPath(path());
QSettings projectInfo(projectFilePath(), QSettings::IniFormat);
_files = convertToAbsoluteFiles(projectPath, projectInfo.value(QLatin1String("files")).toStringList());
_generated = convertToAbsoluteFiles(projectPath, projectInfo.value(QLatin1String("generated")).toStringList());
_includePaths = convertToAbsoluteFiles(projectPath, projectInfo.value(QLatin1String("includes")).toStringList());
_defines = projectInfo.value(QLatin1String("defines")).toStringList();
_toolChainId = projectInfo.value(QLatin1String("toolchain"), QLatin1String("gcc")).toString().toLower();
FileNode *projectFileNode = new FileNode(projectFilePath(), ProjectFileType,
/* generated = */ false);
addFileNodes(QList<FileNode *>() << projectFileNode, this);
QHash<QString, FolderNode *> folders;
QHash<FolderNode *, QStringList> filesInFolder;
QList<FolderNode *> folderNodes;
foreach (const QString &file, _files) {
QFileInfo fileInfo(projectPath, file);
if (! fileInfo.isFile())
continue; // not a file.
QString folderPath = fileInfo.canonicalPath();
if (! folderPath.startsWith(path())) {
qDebug() << "*** skip:" << folderPath;
continue;
}
folderPath = folderPath.mid(path().length() + 1);
FolderNode *folder = folders.value(folderPath);
if (! folder) {
folder = new FolderNode(folderPath);
folders.insert(folderPath, folder);
folderNodes.append(folder);
}
filesInFolder[folder].append(fileInfo.canonicalFilePath());
}
addFolderNodes(folderNodes, this);
QHashIterator<FolderNode *, QStringList> it(filesInFolder);
while (it.hasNext()) {
it.next();
FolderNode *folder = it.key();
QStringList files = it.value();
QList<FileNode *> fileNodes;
foreach (const QString &filePath, files) {
QFileInfo fileInfo(projectPath, filePath);
FileNode *fileNode = new FileNode(fileInfo.absoluteFilePath(),
SourceType, /*generated = */ false);
fileNodes.append(fileNode);
}
addFileNodes(fileNodes, folder);
}
}
#endif
QStringList GenericProjectNode::files() const
{ return _files; }
QStringList GenericProjectNode::generated() const
{ return _generated; }
QStringList GenericProjectNode::includePaths() const
{ return _includePaths; }
void GenericProjectNode::setIncludePaths(const QStringList &includePaths)
{ _includePaths = convertToAbsoluteFiles(QDir(path()), includePaths); }
QStringList GenericProjectNode::defines() const
{ return _defines; }
bool GenericProjectNode::hasTargets() const bool GenericProjectNode::hasTargets() const
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
......
...@@ -38,10 +38,12 @@ ...@@ -38,10 +38,12 @@
namespace GenericProjectManager { namespace GenericProjectManager {
namespace Internal { namespace Internal {
class GenericProject;
class GenericProjectNode : public ProjectExplorer::ProjectNode class GenericProjectNode : public ProjectExplorer::ProjectNode
{ {
public: public:
GenericProjectNode(Core::IFile *projectFile); GenericProjectNode(GenericProject *project, Core::IFile *projectFile);
virtual ~GenericProjectNode(); virtual ~GenericProjectNode();
Core::IFile *projectFile() const; Core::IFile *projectFile() const;
...@@ -69,23 +71,13 @@ public: ...@@ -69,23 +71,13 @@ public:
void refresh(); void refresh();
QStringList includePaths() const;
void setIncludePaths(const QStringList &includePaths);
QStringList files() const;
QStringList generated() const;
QStringList defines() const;
private: private:
FolderNode *findOrCreateFolderByName(const QString &filePath); FolderNode *findOrCreateFolderByName(const QString &filePath);
FolderNode *findOrCreateFolderByName(const QStringList &components, int end); FolderNode *findOrCreateFolderByName(const QStringList &components, int end);
private: private:
GenericProject *_project;
Core::IFile *_projectFile; Core::IFile *_projectFile;
QStringList _files;
QStringList _generated;
QStringList _includePaths;
QStringList _defines;
QHash<QString, FolderNode *> _folderByName; QHash<QString, FolderNode *> _folderByName;
}; };
......
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