diff options
author | hjk <hjk121@nokiamail.com> | 2014-11-15 13:33:40 +0100 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-11-15 13:37:12 +0100 |
commit | 82268eb77c367981c77bbf34c3278ed81f9757db (patch) | |
tree | 9e3565611190480e9d5895532437a1dd7f5ad1a5 /src/plugins/debugger/sourceutils.cpp | |
parent | 9f6f2e7a0e38cdd2bd0f9abc6bba41e93c4db7cd (diff) | |
download | qt-creator-82268eb77c367981c77bbf34c3278ed81f9757db.tar.gz |
Debugger: Use line information to find matching scopes for tooltips
More robust to variations in tool chains than function names.
(e.g. GDB reports 'foo' and LLDB 'foo()')
Change-Id: I1e5a3273b571658b4dd4200c9b3a0e9542a16015
Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src/plugins/debugger/sourceutils.cpp')
-rw-r--r-- | src/plugins/debugger/sourceutils.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/plugins/debugger/sourceutils.cpp b/src/plugins/debugger/sourceutils.cpp index d3bf19ff6d..eec4b595cf 100644 --- a/src/plugins/debugger/sourceutils.cpp +++ b/src/plugins/debugger/sourceutils.cpp @@ -269,11 +269,7 @@ bool isCppEditor(TextEditorWidget *editorWidget) QString cppFunctionAt(const QString &fileName, int line, int column) { - CppModelManager *modelManager = CppModelManager::instance(); - if (!modelManager) - return QString(); - - const Snapshot snapshot = modelManager->snapshot(); + const Snapshot snapshot = CppModelManager::instance()->snapshot(); if (const Document::Ptr document = snapshot.document(fileName)) return document->functionAt(line, column); @@ -283,7 +279,8 @@ QString cppFunctionAt(const QString &fileName, int line, int column) // Return the Cpp expression, and, if desired, the function QString cppExpressionAt(TextEditorWidget *editorWidget, int pos, - int *line, int *column, QString *function /* = 0 */) + int *line, int *column, QString *function, + int *scopeFromLine, int *scopeToLine) { *line = *column = 0; if (function) @@ -291,8 +288,7 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos, QTextCursor tc = editorWidget->textCursor(); QString expr = tc.selectedText(); - CppModelManager *modelManager = CppModelManager::instance(); - if (expr.isEmpty() && modelManager) { + if (expr.isEmpty()) { tc.setPosition(pos); const QChar ch = editorWidget->characterAt(pos); if (ch.isLetterOrNumber() || ch == QLatin1Char('_')) @@ -308,8 +304,15 @@ QString cppExpressionAt(TextEditorWidget *editorWidget, int pos, *line = tc.blockNumber(); } - if (function && !expr.isEmpty()) - *function = cppFunctionAt(editorWidget->textDocument()->filePath(), *line, *column); + if (!expr.isEmpty()) { + QString fileName = editorWidget->textDocument()->filePath(); + const Snapshot snapshot = CppModelManager::instance()->snapshot(); + if (const Document::Ptr document = snapshot.document(fileName)) { + QString func = document->functionAt(*line, *column, scopeFromLine, scopeToLine); + if (function) + *function = func; + } + } return expr; } |