mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add module aliasing option to swift-ide-test
Add module aliasing handling in code complete Resolves rdar://86294338
This commit is contained in:
@@ -262,6 +262,33 @@ void CompilerInvocation::setSDKPath(const std::string &Path) {
|
||||
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts.Target);
|
||||
}
|
||||
|
||||
// This assumes the param args contains valid strings for module
|
||||
// aliasing. The full validation of input for aliasing is done at
|
||||
// ArgsToFrontendOptionsConverter::computeModulealiases.
|
||||
void CompilerInvocation::setModuleAliasMap(std::vector<std::string> args) {
|
||||
// ModuleAliasMap should initially be empty as setting
|
||||
// it should be called only once
|
||||
FrontendOpts.ModuleAliasMap.clear();
|
||||
for (auto item: args) {
|
||||
auto str = StringRef(item);
|
||||
// splits to an alias and the underlying name
|
||||
auto pair = str.split('=');
|
||||
auto lhs = pair.first;
|
||||
auto rhs = pair.second;
|
||||
if (rhs.empty()) // bad format, so skip to the next
|
||||
continue;
|
||||
if (!FrontendOpts.ModuleAliasMap.insert({rhs, StringRef()}).second) {
|
||||
// the underlying name was already added, so skip
|
||||
continue;
|
||||
}
|
||||
auto underlyingName = FrontendOpts.ModuleAliasMap.find(rhs)->first();
|
||||
if (!FrontendOpts.ModuleAliasMap.insert({lhs, underlyingName}).second) {
|
||||
// the alias was already added, so skip
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool ParseFrontendArgs(
|
||||
FrontendOptions &opts, ArgList &args, DiagnosticEngine &diags,
|
||||
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> *buffers) {
|
||||
|
||||
Reference in New Issue
Block a user