diff --git a/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp b/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp index a5199491f61..3911920cc3d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdetailsrewriter.cpp @@ -42,53 +42,53 @@ namespace Internal { class PropertyVisitor: protected QmlJS::AST::Visitor { - QmlJS::AST::Node * _lastValidNode; - unsigned _line; - unsigned _col; public: - QmlJS::AST::Node * operator()(QmlJS::AST::Node *node, unsigned line, unsigned col) + QmlJS::AST::Node *operator()(QmlJS::AST::Node *node, int line, int column) { - _line = line; - _col = col; - _lastValidNode = 0; - accept(node); - return _lastValidNode; + QTC_ASSERT(line >= 0, return nullptr); + QTC_ASSERT(column >= 0, return nullptr); + QTC_ASSERT(node, return nullptr); + m_line = line; + m_column = column; + m_lastValidNode = nullptr; + node->accept(this); + return m_lastValidNode; } protected: using QmlJS::AST::Visitor::visit; - void accept(QmlJS::AST::Node *node) - { - if (node) - node->accept(this); - } - - bool containsLocation(QmlJS::AST::SourceLocation start, QmlJS::AST::SourceLocation end) - { - return (_line > start.startLine || (_line == start.startLine && _col >= start.startColumn)) - && (_line < end.startLine || (_line == end.startLine && _col <= end.startColumn)); - } - - - virtual bool preVisit(QmlJS::AST::Node *node) + bool preVisit(QmlJS::AST::Node *node) override { if (QmlJS::AST::cast(node)) return false; return containsLocation(node->firstSourceLocation(), node->lastSourceLocation()); } - virtual bool visit(QmlJS::AST::UiScriptBinding *ast) + bool visit(QmlJS::AST::UiScriptBinding *ast) override { - _lastValidNode = ast; + m_lastValidNode = ast; return true; } - virtual bool visit(QmlJS::AST::UiPublicMember *ast) + bool visit(QmlJS::AST::UiPublicMember *ast) override { - _lastValidNode = ast; + m_lastValidNode = ast; return true; } + +private: + QmlJS::AST::Node *m_lastValidNode = nullptr; + quint32 m_line = 0; + quint32 m_column = 0; + + bool containsLocation(QmlJS::AST::SourceLocation start, QmlJS::AST::SourceLocation end) + { + return (m_line > start.startLine + || (m_line == start.startLine && m_column >= start.startColumn)) + && (m_line < end.startLine + || (m_line == end.startLine && m_column <= end.startColumn)); + } }; QmlProfilerDetailsRewriter::QmlProfilerDetailsRewriter(QObject *parent) @@ -148,7 +148,6 @@ void QmlProfilerDetailsRewriter::rewriteDetailsForLocation( { PropertyVisitor propertyVisitor; QmlJS::AST::Node *node = propertyVisitor(doc->ast(), location.line(), location.column()); - if (!node) return;