[SourceKit] Allow module references to be indexed (#19243)

Module references get indexed as a 'module' symbol; they get USRs similar to how clang would assign a USR for a module reference.

JIRA: https://bugs.swift.org/browse/SR-8677
This commit is contained in:
Bruno Rocha
2018-09-28 16:21:38 -03:00
committed by Argyrios Kyrtzidis
parent bb36ddfc17
commit bf84b297f8
19 changed files with 189 additions and 21 deletions

View File

@@ -365,6 +365,10 @@ ModuleDecl::ModuleDecl(Identifier name, ASTContext &ctx)
setAccess(AccessLevel::Public);
}
bool ModuleDecl::isClangModule() const {
return findUnderlyingClangModule() != nullptr;
}
void ModuleDecl::addFile(FileUnit &newFile) {
// Require Main and REPL files to be the first file added.
assert(Files.empty() ||
@@ -1636,6 +1640,13 @@ const ModuleDecl* ModuleEntity::getAsSwiftModule() const {
return nullptr;
}
const clang::Module* ModuleEntity::getAsClangModule() const {
assert(!Mod.isNull());
if (Mod.is<const ModuleDecl*>())
return nullptr;
return getClangModule(Mod);
}
// See swift/Basic/Statistic.h for declaration: this enables tracing SourceFiles, is
// defined here to avoid too much layering violation / circular linkage
// dependency.