-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Module Aliasing] Add module aliasing option to swift-ide-test #40494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add module aliasing handling in code complete Resolves rdar://86294338
@swift-ci smoke test |
// RUN: %target-swift-ide-test -code-completion -code-completion-token=MODULE_NAME -source-filename %t/FileLib1.swift -module-alias XLogging=AppleLogging -I %t > %t/result1.txt | ||
// RUN: %FileCheck %s -check-prefix CHECK1 < %t/result1.txt | ||
|
||
// CHECK1-NOT: AppleLogging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only going to check for this string before the start of completion results. Maybe you want %FileCheck %s --implicit-check-not=AppleLogging
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved CHECK1-NOT after "Begin completion". Lmk if it's still preferable to use --implicit-check-not
@swift-ci smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of suggestions, but nothing blocking. Should probably wait for @rintaro to look at it before merging as he's the completion expert.
auto moduleName = MD->getName(); | ||
|
||
// This checks if module aliasing was used. For example, when editing | ||
// `import ...`, and `-module-alias Foo=Bar` was passed, we want to show | ||
// Foo as an option to import, instead of Bar (name of the binary), as | ||
// Foo is the name that should appear in source files. | ||
auto aliasedName = Ctx.getRealModuleName(moduleName, ASTContext::ModuleAliasLookupOption::aliasFromRealName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, MD->getName()
should return the aliased name in the first place. I guess this is needed because the names returned from ASTContext::getVisibleTopLevelModuleNames()
are "real" names, right? Is it possible to modify it (or *ModuleLoader::collectVisibleTopLevelModuleNames()
) to return aliased names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, the names here are the "real" names (binary names) that were searched through the search paths. Moving the logic to return aliases to those functions doesn't seem ideal as they are lower-level functions that should not have know about the input flag -module-alias.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per discussion, this is to be addressed in a separate PR if needed after merging this. cc @rintaro
Add batch-code-compelte test
@swift-ci smoke test |
Add module aliasing option to swift-ide-test
Add module aliasing handling in code complete
Resolves rdar://86294338