| 40 | } |
| 41 | |
| 42 | QList<DeclarationPointer> ClangClassHelper::defaultMethods(const QString& name) const |
| 43 | { |
| 44 | // TODO: this is the oldcpp approach, perhaps clang provides this directly? |
| 45 | // TODO: default destructor misses info about virtualness, possible needs ICreateClassHelper change? |
| 46 | |
| 47 | QTemporaryFile file(QDir::tempPath() + QLatin1String("/class_") + name + QLatin1String("_XXXXXX.cpp")); |
| 48 | file.open(); |
| 49 | QTextStream stream(&file); |
| 50 | stream << "class " << name << " {\n" |
| 51 | << " public:\n" |
| 52 | // default ctor |
| 53 | << " " << name << "();\n" |
| 54 | // copy ctor |
| 55 | << " " << name << "(const " << name << "& other);\n" |
| 56 | // default dtor |
| 57 | << " ~" << name << "();\n" |
| 58 | // assignment operator |
| 59 | << " " << name << "& operator=(const " << name << "& other);\n" |
| 60 | // equality operators |
| 61 | << " bool operator==(const " << name << "& other) const;\n" |
| 62 | << " bool operator!=(const " << name << "& other) const;\n" |
| 63 | << "};\n"; |
| 64 | file.close(); |
| 65 | ReferencedTopDUContext context(DUChain::self()->waitForUpdate(IndexedString(file.fileName()), |
| 66 | TopDUContext::AllDeclarationsAndContexts)); |
| 67 | QList<DeclarationPointer> methods; |
| 68 | { |
| 69 | DUChainReadLocker lock; |
| 70 | |
| 71 | if (context && context->childContexts().size() == 1) { |
| 72 | const auto localDeclarations = context->childContexts().first()->localDeclarations(); |
| 73 | methods.reserve(localDeclarations.size()); |
| 74 | for (auto* declaration : localDeclarations) { |
| 75 | methods << DeclarationPointer(declaration); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return methods; |
| 81 | } |
| 82 | |
| 83 | ClangTemplateNewClass::ClangTemplateNewClass(const QUrl& url) |
| 84 | : TemplateClassGenerator(url) |
nothing calls this directly
no test coverage detected