Skip to content

Commit

Permalink
Improvement: adds details to github issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Feb 13, 2023
1 parent 6952110 commit 6e5d120
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package scala.meta.internal.metals

import java.net.URLEncoder

import scala.util.Properties

import org.eclipse.lsp4j.ClientInfo

object GithubNewIssue {
def buildUrl(clientInfo: ClientInfo): String = {
val clientVersion =
if (clientInfo.getVersion() == null) ""
else s" ${clientInfo.getVersion()}"
val body =
s"""|<!--
| Describe the bug ...
|
| Reproduction steps
| 1. Go to ...
| 2. Click on ...
| 3. Scroll down to ...
| 4. See error
|-->
|
|### Expected behaviour:
|
|<!-- A clear and concise description of what you expected to happen. -->
|
|**Operating system:**
|${Properties.osName}
|
|**Java version:**
|${Properties.javaVersion}
|
|**Editor/extension:**
|${clientInfo.getName()}$clientVersion
|
|**Metals version:**
|${BuildInfo.metalsVersion}
|
|### Extra context or search terms:
|<!--
| - Any other context about the problem
| - Search terms to help others discover this
|-->
|""".stripMargin
val encodedBody = URLEncoder.encode(body)
s"https://github.com/scalameta/metals/issues/new?body=$encodedBody"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import scala.meta.internal.implementation.ImplementationProvider
import scala.meta.internal.implementation.Supermethods
import scala.meta.internal.io.FileIO
import scala.meta.internal.metals.BuildInfo
import scala.meta.internal.metals.GithubNewIssue
import scala.meta.internal.metals.Messages.AmmoniteJvmParametersChange
import scala.meta.internal.metals.Messages.IncompatibleBloopVersion
import scala.meta.internal.metals.MetalsEnrichments._
Expand Down Expand Up @@ -1871,6 +1872,14 @@ class MetalsLspService(
else Future.successful(())
}
} yield ()).asJavaObject
case ServerCommands.OpenIssue() =>
Future
.successful(
Urls.openBrowser(
GithubNewIssue.buildUrl(initializeParams.getClientInfo())
)
)
.asJavaObject
case OpenBrowserCommand(url) =>
Future.successful(Urls.openBrowser(url)).asJavaObject
case ServerCommands.CascadeCompile() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,10 @@ object ServerCommands {
"Open the Metals logs to troubleshoot issues.",
)

val OpenIssue = new OpenBrowserCommand(
"https://github.com/scalameta/metals/issues/new/choose",
val OpenIssue = new Command(
"open-new-github-issue",
"Open issue on GitHub",
"Open the Metals repository on GitHub to ask a question, report a bug or request a new feature.",
"Open the Metals repository on GitHub to ask a question or report a bug.",
)

val MetalsGithub = new OpenBrowserCommand(
Expand Down

0 comments on commit 6e5d120

Please sign in to comment.