forked from qt-creator/qt-creator
Clang: Enable follow symbol for 'auto' keyword
It will follow to the Type which is deduced from auto or to the pointee type if auto is deduced to pointer. Task-number: QTCREATORBUG-17191 Change-Id: I57db3f9b68c3da861691ab148fe39774ad5fceec Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -135,8 +135,10 @@ static Utils::Link linkAtCursor(const QTextCursor &cursor,
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mark.extraInfo.identifier || mark.extraInfo.token == "operator")
|
if (mark.extraInfo.identifier || mark.extraInfo.token == "operator"
|
||||||
|
|| mark.extraInfo.token == "auto") {
|
||||||
return token;
|
return token;
|
||||||
|
}
|
||||||
return Link();
|
return Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,8 +151,17 @@ FollowSymbolResult FollowSymbol::followSymbol(CXTranslationUnit tu,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For definitions we can always find a declaration in current TU
|
// For definitions we can always find a declaration in current TU
|
||||||
if (cursor.isDefinition())
|
if (cursor.isDefinition()) {
|
||||||
|
if (tokenSpelling == "auto") {
|
||||||
|
Type type = cursor.type().pointeeType();
|
||||||
|
if (!type.isValid())
|
||||||
|
type = cursor.type();
|
||||||
|
const Cursor declCursor = type.declaration();
|
||||||
|
return extractMatchingTokenRange(declCursor, declCursor.spelling());
|
||||||
|
}
|
||||||
|
|
||||||
return extractMatchingTokenRange(cursor.canonical(), tokenSpelling);
|
return extractMatchingTokenRange(cursor.canonical(), tokenSpelling);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cursor.isDeclaration()) {
|
if (!cursor.isDeclaration()) {
|
||||||
// This is the symbol usage
|
// This is the symbol usage
|
||||||
|
|||||||
Reference in New Issue
Block a user