| 72 | } |
| 73 | |
| 74 | DeclarationPointer 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 | |
| 109 | DeclarationPointer NodeJS::moduleMember(const QString& moduleName, |
| 110 | const QString& memberName, |
no test coverage detected