forked from qt-creator/qt-creator
QmlProfiler: use project file finder in detailsRewriter
Change-Id: I838180820da54baf0f334de36a8297bc8b461ccc Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -104,17 +104,21 @@ protected:
|
||||
class QmlProfilerDetailsRewriter::QmlProfilerDetailsRewriterPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerDetailsRewriterPrivate(QmlProfilerDetailsRewriter *qq) : q(qq) {}
|
||||
QmlProfilerDetailsRewriterPrivate(QmlProfilerDetailsRewriter *qq,
|
||||
Utils::FileInProjectFinder *fileFinder)
|
||||
: m_projectFinder(fileFinder), q(qq) {}
|
||||
~QmlProfilerDetailsRewriterPrivate() {}
|
||||
|
||||
QList <PendingEvent> m_pendingEvents;
|
||||
QStringList m_pendingDocs;
|
||||
Utils::FileInProjectFinder *m_projectFinder;
|
||||
|
||||
QmlProfilerDetailsRewriter *q;
|
||||
};
|
||||
|
||||
QmlProfilerDetailsRewriter::QmlProfilerDetailsRewriter(QObject *parent) : QObject(parent),
|
||||
d(new QmlProfilerDetailsRewriterPrivate(this))
|
||||
QmlProfilerDetailsRewriter::QmlProfilerDetailsRewriter(
|
||||
QObject *parent, Utils::FileInProjectFinder *fileFinder)
|
||||
: QObject(parent), d(new QmlProfilerDetailsRewriterPrivate(this, fileFinder))
|
||||
{ }
|
||||
|
||||
QmlProfilerDetailsRewriter::~QmlProfilerDetailsRewriter()
|
||||
@@ -125,8 +129,10 @@ QmlProfilerDetailsRewriter::~QmlProfilerDetailsRewriter()
|
||||
void QmlProfilerDetailsRewriter::requestDetailsForLocation(int type,
|
||||
const QmlDebug::QmlEventLocation &location)
|
||||
{
|
||||
QString localFile = QUrl(location.filename).toLocalFile();
|
||||
|
||||
const QString localFile = d->m_projectFinder->findFile(location.filename);
|
||||
QFileInfo fileInfo(localFile);
|
||||
if (!fileInfo.exists() || !fileInfo.isReadable())
|
||||
return;
|
||||
if (QmlJSTools::languageOfFile(localFile) != QmlJS::Document::QmlLanguage)
|
||||
return;
|
||||
|
||||
@@ -157,7 +163,8 @@ void QmlProfilerDetailsRewriter::rewriteDetailsForLocation(QTextStream &textDoc,
|
||||
PropertyVisitor propertyVisitor;
|
||||
QmlJS::AST::Node *node = propertyVisitor(doc->ast(), location.line, location.column);
|
||||
|
||||
QTC_ASSERT(node, return);
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
qint64 startPos = node->firstSourceLocation().begin();
|
||||
qint64 len = node->lastSourceLocation().end() - startPos;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
#include <qmljs/qmljsdocument.h>
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
@@ -45,7 +46,7 @@ class QmlProfilerDetailsRewriter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlProfilerDetailsRewriter(QObject *parent);
|
||||
explicit QmlProfilerDetailsRewriter(QObject *parent, Utils::FileInProjectFinder *fileFinder);
|
||||
~QmlProfilerDetailsRewriter();
|
||||
|
||||
private:
|
||||
|
||||
@@ -167,7 +167,7 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
connect(d->m_profilerConnections, SIGNAL(dataReadyForProcessing()), d->m_profilerDataModel, SLOT(complete()));
|
||||
|
||||
|
||||
d->m_detailsRewriter = new QmlProfilerDetailsRewriter(this);
|
||||
d->m_detailsRewriter = new QmlProfilerDetailsRewriter(this, &d->m_projectFinder);
|
||||
connect(d->m_profilerDataModel, SIGNAL(requestDetailsForLocation(int,QmlDebug::QmlEventLocation)),
|
||||
d->m_detailsRewriter, SLOT(requestDetailsForLocation(int,QmlDebug::QmlEventLocation)));
|
||||
connect(d->m_detailsRewriter, SIGNAL(rewriteDetailsString(int,QmlDebug::QmlEventLocation,QString)),
|
||||
@@ -286,21 +286,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
|
||||
projectDirectory = project->projectDirectory();
|
||||
}
|
||||
|
||||
// get files from all the projects in the session
|
||||
QStringList sourceFiles;
|
||||
SessionManager *sessionManager = ProjectExplorerPlugin::instance()->session();
|
||||
QList<Project *> projects = sessionManager->projects();
|
||||
if (Project *startupProject = ProjectExplorerPlugin::instance()->startupProject()) {
|
||||
// startup project first
|
||||
projects.removeOne(ProjectExplorerPlugin::instance()->startupProject());
|
||||
projects.insert(0, startupProject);
|
||||
}
|
||||
foreach (Project *project, projects)
|
||||
sourceFiles << project->files(Project::ExcludeGeneratedFiles);
|
||||
|
||||
d->m_projectFinder.setProjectDirectory(projectDirectory);
|
||||
d->m_projectFinder.setProjectFiles(sourceFiles);
|
||||
d->m_projectFinder.setSysroot(sp.sysroot);
|
||||
populateFileFinder(projectDirectory, sp.sysroot);
|
||||
|
||||
connect(engine, SIGNAL(processRunning(quint16)), d->m_profilerConnections, SLOT(connectClient(quint16)));
|
||||
connect(d->m_profilerConnections, SIGNAL(connectionFailed()), engine, SLOT(cancelProcess()));
|
||||
@@ -431,9 +417,44 @@ QWidget *QmlProfilerTool::createWidgets()
|
||||
|
||||
toolbarWidget->setLayout(layout);
|
||||
|
||||
// When the widgets are requested we assume that the session data
|
||||
// is available, then we can populate the file finder
|
||||
populateFileFinder();
|
||||
|
||||
return toolbarWidget;
|
||||
}
|
||||
|
||||
void QmlProfilerTool::populateFileFinder(QString projectDirectory, QString activeSysroot)
|
||||
{
|
||||
// Initialize filefinder with some sensible default
|
||||
QStringList sourceFiles;
|
||||
SessionManager *sessionManager = ProjectExplorerPlugin::instance()->session();
|
||||
QList<Project *> projects = sessionManager->projects();
|
||||
if (Project *startupProject = ProjectExplorerPlugin::instance()->startupProject()) {
|
||||
// startup project first
|
||||
projects.removeOne(ProjectExplorerPlugin::instance()->startupProject());
|
||||
projects.insert(0, startupProject);
|
||||
}
|
||||
foreach (Project *project, projects)
|
||||
sourceFiles << project->files(Project::ExcludeGeneratedFiles);
|
||||
|
||||
if (!projects.isEmpty()) {
|
||||
if (projectDirectory.isEmpty()) {
|
||||
projectDirectory = projects.first()->projectDirectory();
|
||||
}
|
||||
|
||||
if (activeSysroot.isEmpty()) {
|
||||
if (Target *target = projects.first()->activeTarget())
|
||||
if (RunConfiguration *rc = target->activeRunConfiguration())
|
||||
activeSysroot = sysroot(rc);
|
||||
}
|
||||
}
|
||||
|
||||
d->m_projectFinder.setProjectDirectory(projectDirectory);
|
||||
d->m_projectFinder.setProjectFiles(sourceFiles);
|
||||
d->m_projectFinder.setSysroot(activeSysroot);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::recordingButtonChanged(bool recording)
|
||||
{
|
||||
d->m_profilerState->setClientRecording(recording);
|
||||
|
||||
@@ -104,6 +104,7 @@ private slots:
|
||||
|
||||
private:
|
||||
void clearDisplay();
|
||||
void populateFileFinder(QString projectDirectory = QString(), QString activeSysroot = QString());
|
||||
|
||||
class QmlProfilerToolPrivate;
|
||||
QmlProfilerToolPrivate *d;
|
||||
|
||||
Reference in New Issue
Block a user