-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Draft: additional completions for using clause #23647
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,65 @@ class CompletionArgSuite extends BaseCompletionSuite: | |
"" | ||
) | ||
|
||
@Test def `using` = | ||
checkEdit( | ||
s"""|def hello(using String): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| hello(st@@) | ||
|""".stripMargin, | ||
s"""|def hello(using String): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| hello(using str) | ||
|""".stripMargin, | ||
assertSingleItem = false) | ||
|
||
@Test def `using2` = | ||
checkEdit( | ||
s"""|def hello(using String): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| hello(using st@@) | ||
|""".stripMargin, | ||
s"""|def hello(using String): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| hello(using str) | ||
|""".stripMargin, | ||
assertSingleItem = false) | ||
|
||
@Test def `using3` = | ||
checkEdit( | ||
s"""|def hello(using String, Int): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| val int = 4 | ||
| hello(str, in@@) | ||
|""".stripMargin, | ||
s"""|def hello(using String, Int): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| val int = 4 | ||
| hello(using str, int) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this check is actually failing because we check if arguments.size == 1 I would leave this test out or just document the current behaviour. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah the test was written this way as this was one of the proposed solutions to do nothing when we have 2 arguments. When I remove that guard the |
||
|""".stripMargin, | ||
assertSingleItem = false) | ||
|
||
@Test def `using4` = | ||
checkEdit( | ||
s"""|def hello(name: String)(using String): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| hello("name")(str@@) | ||
|""".stripMargin, | ||
s"""|def hello(name: String)(using String): Unit = ??? | ||
|@main def main1(): Unit = | ||
| val str = "hello" | ||
| hello("name")(using str) | ||
|""".stripMargin, | ||
assertSingleItem = false | ||
) | ||
|
||
@Test def `default-args` = | ||
check( | ||
s"""|object Main { | ||
|
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.
Looks like this one is adding two usings still, do you need help figuring this one out?
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.
yup some hints will be welcomed :). As far as I understand it the completion check is done from method invocation level, but I'm not sure how could I check the actual code or find out if there already i s'using' clause in any other way.