Skip to content
Snippets Groups Projects
Commit f97c7e14 authored by Pawel Polanski's avatar Pawel Polanski
Browse files

Creator tries to find the correct project files while shadow-building

parent b756d30c
No related branches found
No related tags found
No related merge requests found
...@@ -80,6 +80,12 @@ QString FileInProjectFinder::projectDirectory() const ...@@ -80,6 +80,12 @@ QString FileInProjectFinder::projectDirectory() const
return m_projectDir; return m_projectDir;
} }
void FileInProjectFinder::setProjectFiles(const QStringList &projectFiles)
{
m_projectFiles = projectFiles;
m_cache.clear();
}
/** /**
Returns the best match for the given originalPath in the project directory. Returns the best match for the given originalPath in the project directory.
...@@ -87,6 +93,8 @@ QString FileInProjectFinder::projectDirectory() const ...@@ -87,6 +93,8 @@ QString FileInProjectFinder::projectDirectory() const
If not, the leading directory in the path is stripped, and the - now shorter - path is If not, the leading directory in the path is stripped, and the - now shorter - path is
checked for existence. This continues until either the file is found, or the relative path checked for existence. This continues until either the file is found, or the relative path
does not contain any directories any more: In this case the originalPath is returned. does not contain any directories any more: In this case the originalPath is returned.
Second, we walk the list of project files, and search for a file name match there.
*/ */
QString FileInProjectFinder::findFile(const QString &originalPath, bool *success) const QString FileInProjectFinder::findFile(const QString &originalPath, bool *success) const
{ {
...@@ -125,6 +133,16 @@ QString FileInProjectFinder::findFile(const QString &originalPath, bool *success ...@@ -125,6 +133,16 @@ QString FileInProjectFinder::findFile(const QString &originalPath, bool *success
} }
} }
const QString fileName = QFileInfo(originalPath).fileName();
foreach (const QString &f, m_projectFiles) {
if (QFileInfo(f).fileName() == fileName) {
m_cache.insert(originalPath, f);
if (success)
*success = true;
return f;
}
}
if (success) if (success)
*success = false; *success = false;
......
...@@ -49,10 +49,13 @@ public: ...@@ -49,10 +49,13 @@ public:
void setProjectDirectory(const QString &absoluteProjectPath); void setProjectDirectory(const QString &absoluteProjectPath);
QString projectDirectory() const; QString projectDirectory() const;
void setProjectFiles(const QStringList &projectFiles);
QString findFile(const QString &originalPath, bool *success = 0) const; QString findFile(const QString &originalPath, bool *success = 0) const;
private: private:
QString m_projectDir; QString m_projectDir;
QStringList m_projectFiles;
mutable QHash<QString,QString> m_cache; mutable QHash<QString,QString> m_cache;
}; };
......
...@@ -58,8 +58,13 @@ QtOutputFormatter::QtOutputFormatter(ProjectExplorer::Project *project) ...@@ -58,8 +58,13 @@ QtOutputFormatter::QtOutputFormatter(ProjectExplorer::Project *project)
, m_qtTestFail(QLatin1String("^ Loc: \\[(.*)\\]$")) , m_qtTestFail(QLatin1String("^ Loc: \\[(.*)\\]$"))
, m_project(project) , m_project(project)
{ {
if(project) if(project) {
m_projectFinder.setProjectFiles(project->files(Qt4Project::ExcludeGeneratedFiles));
m_projectFinder.setProjectDirectory(project->projectDirectory()); m_projectFinder.setProjectDirectory(project->projectDirectory());
connect(project, SIGNAL(fileListChanged()),
this, SLOT(updateProjectFileList()));
}
} }
LinkResult QtOutputFormatter::matchLine(const QString &line) const LinkResult QtOutputFormatter::matchLine(const QString &line) const
...@@ -196,6 +201,7 @@ void QtOutputFormatter::handleLink(const QString &href) ...@@ -196,6 +201,7 @@ void QtOutputFormatter::handleLink(const QString &href)
const QString fileName = QUrl(qmlLineColumnLink.cap(1)).toLocalFile(); const QString fileName = QUrl(qmlLineColumnLink.cap(1)).toLocalFile();
const int line = qmlLineColumnLink.cap(2).toInt(); const int line = qmlLineColumnLink.cap(2).toInt();
const int column = qmlLineColumnLink.cap(3).toInt(); const int column = qmlLineColumnLink.cap(3).toInt();
TextEditor::BaseTextEditorWidget::openEditorAt(m_projectFinder.findFile(fileName), line, column - 1); TextEditor::BaseTextEditorWidget::openEditorAt(m_projectFinder.findFile(fileName), line, column - 1);
return; return;
...@@ -256,3 +262,9 @@ void QtOutputFormatter::handleLink(const QString &href) ...@@ -256,3 +262,9 @@ void QtOutputFormatter::handleLink(const QString &href)
} }
} }
} }
void QtOutputFormatter::updateProjectFileList()
{
if (m_project)
m_projectFinder.setProjectFiles(m_project.data()->files(Qt4Project::ExcludeGeneratedFiles));
}
...@@ -60,6 +60,7 @@ struct LinkResult ...@@ -60,6 +60,7 @@ struct LinkResult
class QT4PROJECTMANAGER_EXPORT QtOutputFormatter class QT4PROJECTMANAGER_EXPORT QtOutputFormatter
: public ProjectExplorer::OutputFormatter : public ProjectExplorer::OutputFormatter
{ {
Q_OBJECT
public: public:
QtOutputFormatter(ProjectExplorer::Project *project); QtOutputFormatter(ProjectExplorer::Project *project);
...@@ -67,6 +68,9 @@ public: ...@@ -67,6 +68,9 @@ public:
ProjectExplorer::OutputFormat format); ProjectExplorer::OutputFormat format);
virtual void handleLink(const QString &href); virtual void handleLink(const QString &href);
private slots:
void updateProjectFileList();
private: private:
LinkResult matchLine(const QString &line) const; LinkResult matchLine(const QString &line) const;
void appendLine(QTextCursor & cursor, LinkResult lr, void appendLine(QTextCursor & cursor, LinkResult lr,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment