Skip to content

[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

Merged
merged 7 commits into from
Dec 11, 2021
Merged

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Dec 9, 2021

Add module aliasing option to swift-ide-test
Add module aliasing handling in code complete
Resolves rdar://86294338

Add module aliasing handling in code complete
Resolves rdar://86294338
@elsh
Copy link
Contributor Author

elsh commented Dec 10, 2021

@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
Copy link
Contributor

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?

Copy link
Contributor Author

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

@elsh
Copy link
Contributor Author

elsh commented Dec 11, 2021

@swift-ci smoke test

Copy link
Contributor

@benlangmuir benlangmuir left a 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.

Comment on lines +2207 to +2213
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);
Copy link
Member

@rintaro rintaro Dec 11, 2021

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

@elsh
Copy link
Contributor Author

elsh commented Dec 11, 2021

@swift-ci smoke test

@elsh elsh merged commit 2ab97ed into main Dec 11, 2021
@elsh elsh deleted the es-complete branch December 11, 2021 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants