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

Method moduleExports

plugins/qmljs/duchain/frameworks/nodejs.cpp:74–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74DeclarationPointer NodeJS::moduleExports(const QString& moduleName, const IndexedString& url)
75{
76 QString urlStr = url.str();
77 QString fileName = moduleFileName(moduleName, urlStr);
78 DeclarationPointer exports;
79
80 if (fileName.isEmpty() || urlStr.contains(QLatin1String("__builtin_ecmascript.js")) || urlStr == fileName) {
81 return exports;
82 }
83
84 ReferencedTopDUContext topContext = ParseSession::contextOfFile(fileName, url, 0);
85 DUChainReadLocker lock;
86
87 if (topContext) {
88 static const QualifiedIdentifier idModule(QStringLiteral("module"));
89 static const QualifiedIdentifier idExports(QStringLiteral("exports"));
90
91 // Try "module.exports". If this declaration exists, it contains the
92 // module's exports
93 exports = getDeclaration(idModule, topContext.data());
94
95 if (exports && exports->internalContext()) {
96 exports = getDeclaration(idExports, exports->internalContext(), false);
97 }
98
99 // Try "exports", that always exist, has a structure type, and contains
100 // the exported symbols
101 if (!exports) {
102 exports = getDeclaration(idExports, topContext.data());
103 }
104 }
105
106 return exports;
107}
108
109DeclarationPointer NodeJS::moduleMember(const QString& moduleName,
110 const QString& memberName,

Callers 3

visitMethod · 0.80

Calls 6

getDeclarationFunction · 0.85
strMethod · 0.80
isEmptyMethod · 0.45
containsMethod · 0.45
dataMethod · 0.45
internalContextMethod · 0.45

Tested by

no test coverage detected