aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cpptools/cppfollowsymbolundercursor.cpp')
-rw-r--r--src/plugins/cpptools/cppfollowsymbolundercursor.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/plugins/cpptools/cppfollowsymbolundercursor.cpp b/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
index ded069a96e..a21babf852 100644
--- a/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
+++ b/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
@@ -292,9 +292,9 @@ inline LookupItem skipForwardDeclarations(const QList<LookupItem> &resolvedSymbo
return result;
}
-Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
- const Document::Ptr &document,
- SymbolFinder *symbolFinder)
+Link attemptDeclDef(const QTextCursor &cursor, Snapshot snapshot,
+ const Document::Ptr &document,
+ SymbolFinder *symbolFinder)
{
Link result;
QTC_ASSERT(document, return result);
@@ -333,11 +333,6 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
}
if (!decl || !declParent)
return result;
- if (!decl->postfix_declarator_list || !decl->postfix_declarator_list->value)
- return result;
- FunctionDeclaratorAST *funcDecl = decl->postfix_declarator_list->value->asFunctionDeclarator();
- if (!funcDecl)
- return result;
Symbol *target = nullptr;
if (FunctionDefinitionAST *funDef = declParent->asFunctionDefinition()) {
@@ -346,8 +341,14 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
funDef->symbol);
if (!candidates.isEmpty()) // TODO: improve disambiguation
target = candidates.first();
- } else if (declParent->asSimpleDeclaration()) {
- target = symbolFinder->findMatchingDefinition(funcDecl->symbol, snapshot);
+ } else if (const SimpleDeclarationAST * const simpleDecl = declParent->asSimpleDeclaration()) {
+ FunctionDeclaratorAST *funcDecl = nullptr;
+ if (decl->postfix_declarator_list && decl->postfix_declarator_list->value)
+ funcDecl = decl->postfix_declarator_list->value->asFunctionDeclarator();
+ if (funcDecl)
+ target = symbolFinder->findMatchingDefinition(funcDecl->symbol, snapshot);
+ else
+ target = symbolFinder->findMatchingVarDefinition(simpleDecl->symbols->value, snapshot);
}
if (target) {
@@ -514,9 +515,9 @@ void FollowSymbolUnderCursor::findLink(
int pos = tc.position();
while (document->characterAt(pos).isSpace())
++pos;
- if (document->characterAt(pos) == QLatin1Char('(')) {
- link = attemptFuncDeclDef(cursor, snapshot, documentFromSemanticInfo,
- symbolFinder);
+ const QChar ch = document->characterAt(pos);
+ if (ch == '(' || ch == ';') {
+ link = attemptDeclDef(cursor, snapshot, documentFromSemanticInfo, symbolFinder);
if (link.hasValidLinkText())
return processLinkCallback(link);
}
@@ -585,16 +586,15 @@ void FollowSymbolUnderCursor::findLink(
if (positionInBlock >= tk.utf16charsBegin() && positionInBlock <= tk.utf16charsEnd()) {
cursorRegionReached = true;
if (tk.is(T_OPERATOR)) {
- link = attemptFuncDeclDef(cursor, theSnapshot,
- documentFromSemanticInfo, symbolFinder);
+ link = attemptDeclDef(cursor, theSnapshot,
+ documentFromSemanticInfo, symbolFinder);
if (link.hasValidLinkText())
return processLinkCallback(link);
} else if (tk.isPunctuationOrOperator() && i > 0 && tokens.at(i - 1).is(T_OPERATOR)) {
QTextCursor c = cursor;
c.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor,
positionInBlock - tokens.at(i - 1).utf16charsBegin());
- link = attemptFuncDeclDef(c, theSnapshot, documentFromSemanticInfo,
- symbolFinder);
+ link = attemptDeclDef(c, theSnapshot, documentFromSemanticInfo, symbolFinder);
if (link.hasValidLinkText())
return processLinkCallback(link);
}