Skip to content

Commit

Permalink
fix: scala 2 additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Dec 17, 2024
1 parent 1ce512a commit 22f0c44
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ final class InferredTypeProvider(
* turns into
* `val a: Int = 1` or `var b: Int = 2`
*/
case vl @ ValDef(_, name, tpt, rhs) if !vl.symbol.isParameter =>
case vl @ ValDef(_, name, tpt, rhs)
if !vl.symbol.isParameter && tpt.pos.isDefined =>
val nameEnd = findNameEnd(tpt.pos.start, name)
val nameEndPos = tpt.pos.withEnd(nameEnd).withStart(nameEnd).toLsp
adjustOpt.foreach(adjust => nameEndPos.setEnd(adjust.adjustedEndPos))
Expand All @@ -124,7 +125,8 @@ final class InferredTypeProvider(
* turns into
* `.map((a: Int) => a + a)`
*/
case vl @ ValDef(_, name, tpt, _) if vl.symbol.isParameter =>
case vl @ ValDef(_, name, tpt, _)
if vl.symbol.isParameter && tpt.pos.isDefined =>
val nameEnd = findNameEnd(vl.pos.start, name)
val namePos = tpt.pos.withEnd(nameEnd).withStart(nameEnd).toLsp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,18 +478,21 @@ class SignatureHelpProvider(val compiler: MetalsGlobal) {
if (activeSignature == null) {
activeSignature = 0
}
val mainSignature = infos(activeSignature)
val deduplicated = infos
.filter { sig =>
sig != mainSignature && sig.getLabel() != mainSignature.getLabel()
}
.distinctBy(_.getLabel())
if (infos.isEmpty) new SignatureHelp()
else {
val mainSignature = infos(activeSignature)
val deduplicated = infos
.filter { sig =>
sig != mainSignature && sig.getLabel() != mainSignature.getLabel()
}
.distinctBy(_.getLabel())

new SignatureHelp(
(mainSignature :: deduplicated).asJava,
0,
activeParameter
)
new SignatureHelp(
(mainSignature :: deduplicated).asJava,
0,
activeParameter
)
}
}

def mparamss(
Expand Down

0 comments on commit 22f0c44

Please sign in to comment.