| 160 | } |
| 161 | |
| 162 | AbstractType::Ptr shortenTypeForViewing(const AbstractType::Ptr& type) |
| 163 | { |
| 164 | struct ShortenAliasExchanger |
| 165 | : public TypeExchanger |
| 166 | { |
| 167 | AbstractType::Ptr exchange(const AbstractType::Ptr& type) override { |
| 168 | if (!type) { |
| 169 | return type; |
| 170 | } |
| 171 | |
| 172 | AbstractType::Ptr newType(type->clone()); |
| 173 | |
| 174 | if (auto alias = type.dynamicCast<TypeAliasType>()) { |
| 175 | //If the aliased type has less involved template arguments, prefer it |
| 176 | AbstractType::Ptr shortenedTarget = exchange(alias->type()); |
| 177 | if (shortenedTarget && shortenedTarget->toString().count(QLatin1Char('<')) < alias->toString().count(QLatin1Char('<')) |
| 178 | && reservedIdentifierCount(shortenedTarget->toString()) <= reservedIdentifierCount(alias->toString())) |
| 179 | { |
| 180 | shortenedTarget->setModifiers(shortenedTarget->modifiers() | alias->modifiers()); |
| 181 | return shortenedTarget; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | newType->exchangeTypes(this); |
| 186 | |
| 187 | return newType; |
| 188 | } |
| 189 | }; |
| 190 | |
| 191 | ShortenAliasExchanger exchanger; |
| 192 | return exchanger.exchange(type); |
| 193 | } |
| 194 | |
| 195 | ///Returns a type that has all template types replaced with DelayedType's that have their template default parameters stripped away, |
| 196 | ///and all scope prefixes removed that are redundant within the given context |
no test coverage detected