| 59 | } |
| 60 | |
| 61 | QList<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 | |
| 115 | QString DUChainItemData::htmlDescription() const |
| 116 | { |
nothing calls this directly
no test coverage detected