Skip to content

Commit

Permalink
add in new DoctorTargetInfo class and address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ckipp01 committed Dec 31, 2019
1 parent e379560 commit 0598245
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
57 changes: 19 additions & 38 deletions metals/src/main/scala/scala/meta/internal/metals/Doctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ final class Doctor(
onServer: MetalsHttpServer => Unit
): Unit = {
if (config.executeClientCommand.isOn) {
val output = config.doctorFormat match {
case format if format.isHtml => buildTargetsHtml()
case format if format.isJson => buildTargetsJson()
case _ => "Unsupported format. Possible options are `html` or `json`"
}
val output =
if (config.doctorFormat.isHtml) buildTargetsHtml()
else buildTargetsJson()
val params = new ExecuteCommandParams(
clientCommand.id,
List(output: AnyRef).asJava
Expand Down Expand Up @@ -132,7 +130,7 @@ final class Doctor(
def hint() =
if (isMaven) {
val website =
if (config.doctorFormat.value == "html")
if (config.doctorFormat.isHtml)
"<a href=https://scalameta.org/metals/docs/build-tools/maven.html>Metals website</a>"
else
"Metals Website - https://scalameta.org/metals/docs/build-tools/maven.html"
Expand Down Expand Up @@ -238,23 +236,15 @@ final class Doctor(
} else {
val targetResults = targets.sortBy(_.info.getBaseDirectory).map {
target =>
val (
buildTarget,
scalaVersion,
definition,
completions,
isSemanticdbNeeded,
references,
recommenedFix
) = extractTargetInfo(target)
val targetInfo = extractTargetInfo(target)
ujson.Obj(
"Build Target" -> buildTarget,
"Scala" -> scalaVersion,
"Build Target" -> targetInfo.name,
"Scala" -> targetInfo.scalaVersion,
"Diagnostics" -> Icons.unicode.check,
"Goto definition" -> definition,
"Completions" -> completions,
"Find references" -> references,
"Recommendation" -> recommenedFix
"Goto definition" -> targetInfo.definitionStatus,
"Completions" -> targetInfo.completionsStatus,
"Find references" -> targetInfo.referencesStatus,
"Recommendation" -> targetInfo.recommenedFix
)
}

Expand Down Expand Up @@ -304,25 +294,17 @@ final class Doctor(
targets: List[ScalaTarget]
): Unit = {
targets.sortBy(_.info.getBaseDirectory).foreach { target =>
val (
_,
scalaVersion,
definition,
completions,
isSemanticdbNeeded,
references,
recommenedFix
) = extractTargetInfo(target)
val targetInfo = extractTargetInfo(target)
val center = "style='text-align: center'"
html.element("tr")(
_.element("td")(_.text(target.info.getDisplayName))
.element("td")(_.text(scalaVersion))
_.element("td")(_.text(targetInfo.name))
.element("td")(_.text(targetInfo.scalaVersion))
.element("td", center)(_.text(Icons.unicode.check))
.element("td", center)(_.text(definition))
.element("td", center)(_.text(completions))
.element("td", center)(_.text(references))
.element("td", center)(_.text(targetInfo.definitionStatus))
.element("td", center)(_.text(targetInfo.completionsStatus))
.element("td", center)(_.text(targetInfo.referencesStatus))
.element("td")(
_.raw(recommenedFix)
_.raw(targetInfo.recommenedFix)
)
)
}
Expand Down Expand Up @@ -350,12 +332,11 @@ final class Doctor(
if (target.isScalaTarget)
recommendation(scalaVersion, target.isSemanticdbEnabled, target)
else ""
(
DoctorTargetInfo(
target.info.getDisplayName(),
scalaVersion,
definition,
completions,
isSemanticdbNeeded,
references,
recommenedFix
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package scala.meta.internal.metals
final case class DoctorFormatConfig(value: String) {
def isHtml: Boolean = value == "html"
def isJson: Boolean = value == "json"
def isMarkdown: Boolean = value == "markdown"
}

object DoctorFormatConfig {
def html = new DoctorFormatConfig("html")
def json = new DoctorFormatConfig("json")
def markdown = new DoctorFormatConfig("markdown")
def default = new DoctorFormatConfig(
System.getProperty("metals.doctor-format", "html")
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package scala.meta.internal.metals

final case class DoctorTargetInfo(
name: String,
scalaVersion: String,
definitionStatus: String,
completionsStatus: String,
referencesStatus: String,
recommenedFix: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ object MetalsServerConfig {
case "coc.nvim" =>
base.copy(
statusBar = StatusBarConfig.showMessage,
isHttpEnabled = true,
compilers = base.compilers.copy(
_parameterHintsCommand = Some("editor.action.triggerParameterHints"),
_completionCommand = Some("editor.action.triggerSuggest"),
Expand Down

0 comments on commit 0598245

Please sign in to comment.