forked from qt-creator/qt-creator
Clang: Reuse full type qualification from tooltips
Use qualification helper function from clangtooltipinfocollector.h instead of Unified Symbol Resolution (USR) not to deal with special symbols used in USR. Affects current document filter and symbol outline. Task-number: QTCREATORBUG-20917 Change-Id: I616ba1bf066e986e0ee75d47d30e45f94474c1cd Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -44,6 +44,20 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
|
Utf8String qualificationPrefix(const Cursor &cursor)
|
||||||
|
{
|
||||||
|
// TODO: Implement with qualificationPrefixAsVector()
|
||||||
|
Utf8String qualifiedName;
|
||||||
|
|
||||||
|
for (Cursor parent = cursor.semanticParent();
|
||||||
|
parent.isValid() && (parent.kind() == CXCursor_Namespace);
|
||||||
|
parent = parent.semanticParent()) {
|
||||||
|
qualifiedName = parent.spelling() + Utf8StringLiteral("::") + qualifiedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qualifiedName;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Utf8StringVector qualificationPrefixAsVector(const Cursor &cursor)
|
Utf8StringVector qualificationPrefixAsVector(const Cursor &cursor)
|
||||||
@@ -59,20 +73,6 @@ Utf8StringVector qualificationPrefixAsVector(const Cursor &cursor)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utf8String qualificationPrefix(const Cursor &cursor)
|
|
||||||
{
|
|
||||||
// TODO: Implement with qualificationPrefixAsVector()
|
|
||||||
Utf8String qualifiedName;
|
|
||||||
|
|
||||||
for (Cursor parent = cursor.semanticParent();
|
|
||||||
parent.isValid() && (parent.kind() == CXCursor_Namespace);
|
|
||||||
parent = parent.semanticParent()) {
|
|
||||||
qualifiedName = parent.spelling() + Utf8StringLiteral("::") + qualifiedName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return qualifiedName;
|
|
||||||
}
|
|
||||||
|
|
||||||
Utf8String displayName(const Cursor &cursor)
|
Utf8String displayName(const Cursor &cursor)
|
||||||
{
|
{
|
||||||
if (cursor.kind() == CXCursor_ClassTemplate) {
|
if (cursor.kind() == CXCursor_ClassTemplate) {
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
|
class Cursor;
|
||||||
class UnsavedFiles;
|
class UnsavedFiles;
|
||||||
|
|
||||||
ToolTipInfo collectToolTipInfo(UnsavedFiles &unsavedFiles,
|
ToolTipInfo collectToolTipInfo(UnsavedFiles &unsavedFiles,
|
||||||
@@ -42,4 +43,6 @@ ToolTipInfo collectToolTipInfo(UnsavedFiles &unsavedFiles,
|
|||||||
uint line,
|
uint line,
|
||||||
uint column);
|
uint column);
|
||||||
|
|
||||||
|
Utf8String qualificationPrefix(const Cursor &cursor);
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "clangstring.h"
|
#include "clangstring.h"
|
||||||
|
#include "clangtooltipinfocollector.h"
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "fulltokeninfo.h"
|
#include "fulltokeninfo.h"
|
||||||
#include "sourcerange.h"
|
#include "sourcerange.h"
|
||||||
@@ -46,29 +47,24 @@ FullTokenInfo::operator TokenInfoContainer() const
|
|||||||
return TokenInfoContainer(line(), column(), length(), m_types, m_extraInfo);
|
return TokenInfoContainer(line(), column(), length(), m_types, m_extraInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Utf8String fullyQualifiedType(const Cursor &cursor)
|
static Utf8String fullyQualifiedType(const Cursor &cursor) {
|
||||||
{
|
Utf8String prefix;
|
||||||
Utf8String typeSpelling = cursor.type().canonical().utf8Spelling();
|
if (cursor.kind() == CXCursor_ClassTemplate || cursor.kind() == CXCursor_Namespace)
|
||||||
if (typeSpelling.isEmpty()) {
|
return qualificationPrefix(cursor) + cursor.displayName();
|
||||||
// Only if it's the namespaces level.
|
return cursor.type().canonical().spelling();
|
||||||
typeSpelling = cursor.unifiedSymbolResolution();
|
|
||||||
typeSpelling.replace(Utf8StringLiteral("c:@N@"), Utf8StringLiteral(""));
|
|
||||||
typeSpelling.replace(Utf8StringLiteral("@N@"), Utf8StringLiteral("::"));
|
|
||||||
typeSpelling.replace(Utf8StringLiteral("c:@aN"), Utf8StringLiteral("(anonymous)"));
|
|
||||||
}
|
|
||||||
return typeSpelling;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullTokenInfo::updateTypeSpelling(const Cursor &cursor, bool functionLike)
|
void FullTokenInfo::updateTypeSpelling(const Cursor &cursor, bool functionLike)
|
||||||
{
|
{
|
||||||
m_extraInfo.typeSpelling = fullyQualifiedType(cursor);
|
|
||||||
m_extraInfo.semanticParentTypeSpelling = fullyQualifiedType(cursor.semanticParent());
|
m_extraInfo.semanticParentTypeSpelling = fullyQualifiedType(cursor.semanticParent());
|
||||||
if (!functionLike)
|
if (!functionLike) {
|
||||||
|
m_extraInfo.typeSpelling = fullyQualifiedType(cursor);
|
||||||
return;
|
return;
|
||||||
Type type = cursor.type().canonical();
|
}
|
||||||
|
|
||||||
m_extraInfo.token = cursor.displayName();
|
m_extraInfo.token = cursor.displayName();
|
||||||
// On the client side full type is typeSpelling + token.
|
// On the client side full type is typeSpelling + token.
|
||||||
m_extraInfo.typeSpelling = type.resultType().utf8Spelling();
|
m_extraInfo.typeSpelling = cursor.type().resultType().utf8Spelling();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Utf8String propertyParentSpelling(CXTranslationUnit cxTranslationUnit,
|
static Utf8String propertyParentSpelling(CXTranslationUnit cxTranslationUnit,
|
||||||
|
Reference in New Issue
Block a user