-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
93132b8
Add module aliasing option to swift-ide-test
elsh 0ff4195
Add repl code complete tests
elsh 1e5160b
Update comments
elsh b5b285e
Reuse compute module aliases function
elsh 541c078
Update input description
elsh 0fc4fe2
Add batch-code-complete test
elsh 4ad3a55
Exit early args are invalid
elsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %{python} %utils/split_file.py -o %t %s | ||
|
||
// RUN: %empty-directory(%t/Modules) | ||
// RUN: %target-swift-frontend -emit-module -module-name AppleLogging -module-alias XLogging=AppleLogging -o %t/Modules %t/FileLogging.swift | ||
|
||
// BEGIN FileLogging.swift | ||
public struct Logger { | ||
public init() {} | ||
} | ||
|
||
public protocol Logging { | ||
var name: String { get } | ||
} | ||
|
||
public func setupLogger() -> XLogging.Logger? { | ||
return Logger() | ||
} | ||
|
||
// RUN: %empty-directory(%t/Out) | ||
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %t/FileLib1.swift -module-alias XLogging=AppleLogging -filecheck %raw-FileCheck -completion-output-dir %t/Out -I %t/Modules | ||
|
||
// BEGIN FileLib1.swift | ||
import XLogging | ||
|
||
func testModuleNameInBody() { | ||
#^EXPR^# | ||
} | ||
|
||
// EXPR: Begin completion | ||
// EXPR-NOT: AppleLogging | ||
// EXPR-DAG: Decl[Module]/None: XLogging[#Module#]; name=XLogging | ||
// EXPR-DAG: Decl[Protocol]/OtherModule[XLogging]/Flair[RareType]: Logging[#Logging#]; name=Logging | ||
// EXPR-DAG: Decl[Struct]/OtherModule[XLogging]: Logger[#Logger#]; name=Logger | ||
// EXPR-DAG: Decl[FreeFunction]/OtherModule[XLogging]: setupLogger()[#Logger?#]; name=setupLogger() | ||
// EXPR: End completions | ||
|
||
// RUN: %empty-directory(%t/Out) | ||
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %t/FileLib2.swift -module-alias XLogging=AppleLogging -filecheck %raw-FileCheck -completion-output-dir %t/Out -I %t/Modules | ||
|
||
// BEGIN FileLib2.swift | ||
import XLogging | ||
|
||
class ModuleNameInClause: #^MODULE^# { | ||
} | ||
|
||
// MODULE: Begin completion | ||
// MODULE-NOT: AppleLogging | ||
// MODULE-DAG: Decl[Module]/None: XLogging[#Module#]; name=XLogging | ||
|
||
// MODULE-DAG: Decl[Protocol]/OtherModule[XLogging]: Logging[#Logging#]; name=Logging | ||
// MODULE-DAG: Decl[Struct]/OtherModule[XLogging]: Logger[#Logger#]; name=Logger | ||
// MODULE: End completions | ||
|
||
// RUN: %empty-directory(%t/Out) | ||
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %t/FileLib3.swift -module-alias XLogging=AppleLogging -filecheck %raw-FileCheck -completion-output-dir %t/Out -I %t/Modules | ||
|
||
// BEGIN FileLib3.swift | ||
import XLogging | ||
|
||
func testModuleNameInDecl() -> #^TYPE^# { | ||
} | ||
|
||
// TYPE: Begin completion | ||
// TYPE-NOT: AppleLogging | ||
// TYPE-DAG: Decl[Module]/None: XLogging[#Module#]; name=XLogging | ||
// TYPE-DAG: Decl[Protocol]/OtherModule[XLogging]: Logging[#Logging#]; name=Logging | ||
// TYPE-DAG: Decl[Struct]/OtherModule[XLogging]: Logger[#Logger#]; name=Logger | ||
// TYPE: End completions | ||
|
||
// RUN: %empty-directory(%t/Out) | ||
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %t/FileLib4.swift -module-alias XLogging=AppleLogging -filecheck %raw-FileCheck -completion-output-dir %t/Out -I %t/Modules | ||
|
||
// BEGIN FileLib4.swift | ||
import #^IMPORT^# | ||
|
||
// IMPORT: Begin completion | ||
// IMPORT-NOT: AppleLogging | ||
// IMPORT: Decl[Module]/None: XLogging[#Module#]; name=XLogging | ||
// IMPORT: End completions |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 fromASTContext::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