forked from qt-creator/qt-creator
CppEditor: Fix "add definition" quickfix insertion string
... for the edge case of the insertion location being preceded by a function whose body is a try-catch clause. Fixes: QTCREATORBUG-14661 Change-Id: Icc7d5283ead81d644231479317214a8cc177493d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -3111,6 +3111,15 @@ public:
|
||||
// make target lookup context
|
||||
Document::Ptr targetDoc = targetFile->cppDocument();
|
||||
Scope *targetScope = targetDoc->scopeAt(loc.line(), loc.column());
|
||||
|
||||
// Correct scope in case of a function try-block. See QTCREATORBUG-14661.
|
||||
if (targetScope && targetScope->asBlock()) {
|
||||
if (Class * const enclosingClass = targetScope->enclosingClass())
|
||||
targetScope = enclosingClass;
|
||||
else
|
||||
targetScope = targetScope->enclosingNamespace();
|
||||
}
|
||||
|
||||
LookupContext targetContext(targetDoc, op->snapshot());
|
||||
ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope);
|
||||
if (!targetCoN)
|
||||
|
||||
Reference in New Issue
Block a user