Skip to content

Commit

Permalink
improvement: more granularity for showInferredType option
Browse files Browse the repository at this point in the history
  • Loading branch information
doofin committed Jun 6, 2023
1 parent cc5bab4 commit 08b1a47
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class SemanticdbTreePrinter(
* hello<<[String]>>("")
*/
case tree @ s.TypeApplyTree(_: s.OriginalTree | _: s.SelectTree, _)
if !ignoreTypesTrees && userConfig.showInferredType =>
if !ignoreTypesTrees && userConfig.showInferredType.nonEmpty =>
gatherSynthetics(tree)
/**
* implicit def implicitFun(object: T): R = ???
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ final class SyntheticsDecorationProvider(
}

private def areSyntheticsEnabled: Boolean = {
userConfig().showImplicitArguments || userConfig().showInferredType || userConfig().showImplicitConversionsAndClasses
userConfig().showImplicitArguments || userConfig().showInferredType.nonEmpty || userConfig().showImplicitConversionsAndClasses
}

private def createHoverAtPoint(
Expand Down Expand Up @@ -445,7 +445,7 @@ final class SyntheticsDecorationProvider(
} yield decorationOptions(lspRange, decoration)

val typDecorations =
if (userConfig().showInferredType)
if (userConfig().showInferredType.nonEmpty)
typeDecorations(path, textDocument, decorationPrinter)
else Nil
decorations ++ typDecorations
Expand Down Expand Up @@ -489,7 +489,9 @@ final class SyntheticsDecorationProvider(
if (param.decltpe.isEmpty) List(param.name.pos.toSemanticdb) else Nil
case cs: m.Case =>
// if the case is too long then it'll be too messy
visit(cs.body) // explorePatterns(List(cs.pat)) ++ visit(cs.body)
if (userConfig().showInferredType.contains("minimal"))
visit(cs.body) // don't show type hint for cases inside match
else explorePatterns(List(cs.pat)) ++ visit(cs.body)
case vl: m.Defn.Val =>
val values =
if (vl.decltpe.isEmpty) explorePatterns(vl.pats) else Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ case class UserConfiguration(
bloopJvmProperties: Option[List[String]] = None,
ammoniteJvmProperties: Option[List[String]] = None,
superMethodLensesEnabled: Boolean = false,
showInferredType: Boolean = false,
showInferredType: Option[String] = None,
showImplicitArguments: Boolean = false,
showImplicitConversionsAndClasses: Boolean = false,
remoteLanguageServer: Option[String] = None,
Expand Down Expand Up @@ -491,7 +491,7 @@ object UserConfiguration {
val superMethodLensesEnabled =
getBooleanKey("super-method-lenses-enabled").getOrElse(false)
val showInferredType =
getBooleanKey("show-inferred-type").getOrElse(false)
getStringKey("show-inferred-type")
val showImplicitArguments =
getBooleanKey("show-implicit-arguments").getOrElse(false)
val showImplicitConversionsAndClasses =
Expand Down

0 comments on commit 08b1a47

Please sign in to comment.