Skip to content

Commit

Permalink
bugfix: Named args completions with default values
Browse files Browse the repository at this point in the history
  • Loading branch information
jkciesluk committed Sep 18, 2023
1 parent d7be734 commit 9783cde
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ object NamedArgCompletions:
.filterNot {
case (arg, _) if arg.symbol.denot.is(Flags.Synthetic) => true
case (Ident(name), _) => name.is(DefaultGetterName) // default args
case (Select(Ident(_), name), _) =>
name.is(DefaultGetterName) // default args for apply method
case (Select(_, name), _) =>
// default args for methods defined in object
name.is(DefaultGetterName)
case _ => false
}
.map {
Expand Down
34 changes: 34 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionArgSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,40 @@ class CompletionArgSuite extends BaseCompletionSuite {
"",
)

check(
"default-args",
"""|object Main {
| def foo() = {
| def deployment(
| arg1: String,
| arg2: Int = 1,
| ): Option[Int] = ???
| val abc = deployment(@@)
| }
|}
|""".stripMargin,
"""|arg1 = : String
|arg2 = : Int
|""".stripMargin,
topLines = Some(2),
)

check(
"default-args2",
"""|object Main {
| def deployment(
| arg1: String,
| arg2: Int = 1,
| ): Option[Int] = ???
| val abc = deployment(@@)
|}
|""".stripMargin,
"""|arg1 = : String
|arg2 = : Int
|""".stripMargin,
topLines = Some(2),
)

checkSnippet( // see: https://github.com/scalameta/metals/issues/2400
"explicit-dollar",
"""
Expand Down

0 comments on commit 9783cde

Please sign in to comment.