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

Method defaultMethods

plugins/clang/codegen/clangclasshelper.cpp:42–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42QList<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
83ClangTemplateNewClass::ClangTemplateNewClass(const QUrl& url)
84 : TemplateClassGenerator(url)

Callers

nothing calls this directly

Calls 10

waitForUpdateMethod · 0.80
childContextsMethod · 0.80
localDeclarationsMethod · 0.80
IndexedStringClass · 0.50
openMethod · 0.45
closeMethod · 0.45
fileNameMethod · 0.45
sizeMethod · 0.45
firstMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected