mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[NFC] Adopt new ImportPath types and terminology
# Conflicts: # lib/IDE/CodeCompletion.cpp
This commit is contained in:
@@ -167,7 +167,7 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
return error(Status::FailedToLoadBridgingHeader);
|
||||
}
|
||||
ModuleDecl *importedHeaderModule = clangImporter->getImportedHeaderModule();
|
||||
dependency.Import = ModuleDecl::ImportedModule{ModuleDecl::AccessPathTy(),
|
||||
dependency.Import = ModuleDecl::ImportedModule{ImportPath::Access(),
|
||||
importedHeaderModule};
|
||||
continue;
|
||||
}
|
||||
@@ -196,19 +196,19 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
modulePathStr = modulePathStr.slice(0, splitPoint);
|
||||
}
|
||||
|
||||
SmallVector<Identifier, 4> modulePath;
|
||||
ImportPath::Module::Builder modulePath;
|
||||
while (!modulePathStr.empty()) {
|
||||
StringRef nextComponent;
|
||||
std::tie(nextComponent, modulePathStr) = modulePathStr.split('\0');
|
||||
modulePath.push_back(ctx.getIdentifier(nextComponent));
|
||||
assert(!modulePath.back().empty() &&
|
||||
assert(!modulePath.back().Item.empty() &&
|
||||
"invalid module name (submodules not yet supported)");
|
||||
}
|
||||
auto module = getModule(modulePath, /*allowLoading*/true);
|
||||
auto module = getModule(modulePath.get(), /*allowLoading*/true);
|
||||
if (!module || module->failedToLoad()) {
|
||||
// If we're missing the module we're an overlay for, treat that specially.
|
||||
if (modulePath.size() == 1 &&
|
||||
modulePath.front() == file->getParentModule()->getName()) {
|
||||
modulePath.front().Item == file->getParentModule()->getName()) {
|
||||
return error(Status::MissingUnderlyingModule);
|
||||
}
|
||||
|
||||
@@ -221,14 +221,13 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
|
||||
if (scopePath.empty()) {
|
||||
dependency.Import =
|
||||
ModuleDecl::ImportedModule{ModuleDecl::AccessPathTy(), module};
|
||||
ModuleDecl::ImportedModule{ImportPath::Access(), module};
|
||||
} else {
|
||||
auto scopeID = ctx.getIdentifier(scopePath);
|
||||
assert(!scopeID.empty() &&
|
||||
"invalid decl name (non-top-level decls not supported)");
|
||||
Located<Identifier> accessPathElem = { scopeID, SourceLoc() };
|
||||
dependency.Import = ModuleDecl::ImportedModule{
|
||||
ctx.AllocateCopy(llvm::makeArrayRef(accessPathElem)), module};
|
||||
ImportPath::Access::Builder(scopeID).copyTo(ctx), module};
|
||||
}
|
||||
|
||||
// SPI
|
||||
@@ -475,26 +474,25 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
|
||||
if (Dep.isHeader())
|
||||
continue;
|
||||
|
||||
StringRef ModulePathStr = Dep.Core.RawPath;
|
||||
StringRef ScopePath;
|
||||
if (Dep.isScoped())
|
||||
std::tie(ModulePathStr, ScopePath) = ModulePathStr.rsplit('\0');
|
||||
ImportPath::Builder importPath;
|
||||
|
||||
SmallVector<Located<swift::Identifier>, 1> AccessPath;
|
||||
StringRef ModulePathStr = Dep.Core.RawPath;
|
||||
while (!ModulePathStr.empty()) {
|
||||
StringRef NextComponent;
|
||||
std::tie(NextComponent, ModulePathStr) = ModulePathStr.split('\0');
|
||||
AccessPath.push_back({Ctx.getIdentifier(NextComponent), SourceLoc()});
|
||||
importPath.push_back(Ctx.getIdentifier(NextComponent));
|
||||
}
|
||||
|
||||
if (AccessPath.size() == 1 && AccessPath[0].Item == Ctx.StdlibModuleName)
|
||||
if (importPath.size() == 1
|
||||
&& importPath.front().Item == Ctx.StdlibModuleName)
|
||||
continue;
|
||||
|
||||
ModuleDecl *M = Ctx.getLoadedModule(AccessPath);
|
||||
auto modulePath = importPath.get().getModulePath(Dep.isScoped());
|
||||
ModuleDecl *M = Ctx.getLoadedModule(modulePath);
|
||||
|
||||
auto Kind = ImportKind::Module;
|
||||
if (!ScopePath.empty()) {
|
||||
auto ScopeID = Ctx.getIdentifier(ScopePath);
|
||||
if (Dep.isScoped()) {
|
||||
auto ScopeID = importPath.get().getAccessPath(true).front().Item;
|
||||
assert(!ScopeID.empty() &&
|
||||
"invalid decl name (non-top-level decls not supported)");
|
||||
|
||||
@@ -505,8 +503,8 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
|
||||
} else {
|
||||
// Lookup the decl in the top-level module.
|
||||
ModuleDecl *TopLevelModule = M;
|
||||
if (AccessPath.size() > 1)
|
||||
TopLevelModule = Ctx.getLoadedModule(AccessPath.front().Item);
|
||||
if (importPath.size() > 1)
|
||||
TopLevelModule = Ctx.getLoadedModule(modulePath.getTopLevelPath());
|
||||
|
||||
SmallVector<ValueDecl *, 8> Decls;
|
||||
TopLevelModule->lookupQualified(
|
||||
@@ -517,12 +515,10 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
|
||||
"deserialized imports should not be ambiguous");
|
||||
Kind = *FoundKind;
|
||||
}
|
||||
|
||||
AccessPath.push_back({ ScopeID, SourceLoc() });
|
||||
}
|
||||
|
||||
auto *ID = ImportDecl::create(Ctx, FileContext, SourceLoc(), Kind,
|
||||
SourceLoc(), AccessPath);
|
||||
SourceLoc(), importPath.get());
|
||||
ID->setModule(M);
|
||||
if (Dep.isExported())
|
||||
ID->getAttrs().add(
|
||||
@@ -534,7 +530,7 @@ void ModuleFile::getImportDecls(SmallVectorImpl<Decl *> &Results) {
|
||||
Results.append(ImportDecls.begin(), ImportDecls.end());
|
||||
}
|
||||
|
||||
void ModuleFile::lookupVisibleDecls(ModuleDecl::AccessPathTy accessPath,
|
||||
void ModuleFile::lookupVisibleDecls(ImportPath::Access accessPath,
|
||||
VisibleDeclConsumer &consumer,
|
||||
NLKind lookupKind) {
|
||||
PrettyStackTraceModuleFile stackEntry(*this);
|
||||
@@ -732,7 +728,7 @@ ModuleFile::loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
|
||||
return results;
|
||||
}
|
||||
|
||||
void ModuleFile::lookupClassMember(ModuleDecl::AccessPathTy accessPath,
|
||||
void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
|
||||
DeclName name,
|
||||
SmallVectorImpl<ValueDecl*> &results) {
|
||||
PrettyStackTraceModuleFile stackEntry(*this);
|
||||
@@ -782,7 +778,7 @@ void ModuleFile::lookupClassMember(ModuleDecl::AccessPathTy accessPath,
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleFile::lookupClassMembers(ModuleDecl::AccessPathTy accessPath,
|
||||
void ModuleFile::lookupClassMembers(ImportPath::Access accessPath,
|
||||
VisibleDeclConsumer &consumer) {
|
||||
PrettyStackTraceModuleFile stackEntry(*this);
|
||||
assert(accessPath.size() <= 1 && "can only refer to top-level decls");
|
||||
|
||||
Reference in New Issue
Block a user