MCPcopy Create free account
hub / github.com/KDE/kdevelop / highlighting

Method highlighting

plugins/quickopen/duchainitemquickopen.cpp:61–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61QList<QVariant> DUChainItemData::highlighting() const
62{
63 DUChainReadLocker lock;
64
65 Declaration* decl = m_item.m_item.data();
66 if (!decl) {
67 return QList<QVariant>();
68 }
69
70 if (auto* def = dynamic_cast<FunctionDefinition*>(decl)) {
71 if (def->declaration()) {
72 decl = def->declaration();
73 }
74 }
75
76 QTextCharFormat boldFormat;
77 boldFormat.setFontWeight(QFont::Bold);
78 QTextCharFormat normalFormat;
79
80 int prefixLength = 0;
81
82 QString signature;
83 TypePtr<FunctionType> function = decl->type<FunctionType>();
84 if (function) {
85 signature = function->partToString(FunctionType::SignatureArguments);
86 }
87
88 //Only highlight the last part of the qualified identifier, so the scope doesn't distract too much
89 QualifiedIdentifier id = decl->qualifiedIdentifier();
90 QString fullId = id.toString();
91 QString lastId;
92 if (!id.isEmpty()) {
93 lastId = id.last().toString();
94 }
95
96 prefixLength += fullId.length() - lastId.length();
97
98 QList<QVariant> ret{
99 0,
100 prefixLength,
101 QVariant(normalFormat),
102 prefixLength,
103 lastId.length(),
104 QVariant(boldFormat),
105 };
106 if (!signature.isEmpty()) {
107 ret << prefixLength + lastId.length();
108 ret << signature.length();
109 ret << QVariant(normalFormat);
110 }
111
112 return ret;
113}
114
115QString DUChainItemData::htmlDescription() const
116{

Callers

nothing calls this directly

Calls 9

partToStringMethod · 0.80
QVariantClass · 0.50
dataMethod · 0.45
declarationMethod · 0.45
qualifiedIdentifierMethod · 0.45
toStringMethod · 0.45
isEmptyMethod · 0.45
lastMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected