| 219 | } |
| 220 | |
| 221 | QVariantHash ClangTemplateNewClass::extraVariables() const |
| 222 | { |
| 223 | QVariantHash variables; |
| 224 | |
| 225 | const QString publicAccess = QStringLiteral("public"); |
| 226 | |
| 227 | QHash<QString, VariableDescriptionList> variableDescriptions; |
| 228 | QHash<QString, FunctionDescriptionList> functionDescriptions; |
| 229 | QHash<QString, FunctionDescriptionList> slotDescriptions; |
| 230 | FunctionDescriptionList signalDescriptions; |
| 231 | |
| 232 | const auto desc = description(); |
| 233 | for (const auto& function : desc.methods) { |
| 234 | const QString& access = function.access.isEmpty() ? publicAccess : function.access; |
| 235 | |
| 236 | if (function.isSignal) { |
| 237 | signalDescriptions << function; |
| 238 | } else if (function.isSlot) { |
| 239 | slotDescriptions[access] << function; |
| 240 | } else { |
| 241 | functionDescriptions[access] << function; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | for (const auto& variable : desc.members) { |
| 246 | const QString& access = variable.access.isEmpty() ? publicAccess : variable.access; |
| 247 | |
| 248 | variableDescriptions[access] << variable; |
| 249 | } |
| 250 | |
| 251 | ::addVariables(&variables, QLatin1String("_members"), variableDescriptions); |
| 252 | ::addVariables(&variables, QLatin1String("_functions"), functionDescriptions); |
| 253 | ::addVariables(&variables, QLatin1String("_slots"), slotDescriptions); |
| 254 | |
| 255 | variables[QStringLiteral("signals")] = CodeDescription::toVariantList(signalDescriptions); |
| 256 | variables[QStringLiteral("needs_qobject_macro")] = !slotDescriptions.isEmpty() || !signalDescriptions.isEmpty(); |
| 257 | |
| 258 | QStringList includedFiles; |
| 259 | DUChainReadLocker locker(DUChain::lock()); |
| 260 | |
| 261 | QUrl sourceUrl; |
| 262 | const auto urls = fileUrls(); |
| 263 | if (!urls.isEmpty()) { |
| 264 | sourceUrl = urls.constBegin().value(); |
| 265 | } else { |
| 266 | // includeDirectiveArgumentFromPath() expects a path to the folder where includes are used from |
| 267 | sourceUrl = baseUrl(); |
| 268 | sourceUrl.setPath(sourceUrl.path() + QLatin1String("/.h")); |
| 269 | } |
| 270 | const Path sourcePath(sourceUrl); |
| 271 | |
| 272 | const auto& directBaseClasses = this->directBaseClasses(); |
| 273 | for (const auto& baseClass : directBaseClasses) { |
| 274 | if (!baseClass) { |
| 275 | continue; |
| 276 | } |
| 277 | |
| 278 | clangDebug() << "Looking for includes for class" << baseClass->identifier().toString(); |
nothing calls this directly
no test coverage detected