Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala committed Mar 19, 2024
1 parent 69c708f commit 449d618
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 91 deletions.
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ val sharedJavacOptions = List(
Nil
else
Seq("--release", "8")
},
}
)

val sharedScalacOptions = List(
Expand Down Expand Up @@ -267,8 +267,8 @@ lazy val telemetryInterfaces = project
},
libraryDependencies := List(
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.27.7",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.27.7" % "compile-internal"
)
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.27.7" % "compile-internal",
),
)

lazy val mtagsShared = project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class TelemetryReportContext(
telemetryClientConfig: TelemetryClient.Config =
TelemetryClient.Config.default,
logger: LoggerAccess = LoggerAccess.system,
)(implicit ec: ExecutionContext) extends ReportContext {
)(implicit ec: ExecutionContext)
extends ReportContext {

// Don't send reports with fragile user data - sources etc
override lazy val unsanitized: Reporter = reporter("unsanitized")
Expand Down Expand Up @@ -86,7 +87,9 @@ private class TelemetryReporter(
override def getReports(): ju.List[TimestampedFile] =
ju.Collections.emptyList()

override def cleanUpOldReports(maxReportsNumber: Int): ju.List[TimestampedFile] =
override def cleanUpOldReports(
maxReportsNumber: Int
): ju.List[TimestampedFile] =
ju.Collections.emptyList()

override def deleteAll(): Unit = ()
Expand Down
3 changes: 2 additions & 1 deletion metals/src/main/scala/scala/meta/metals/ServerState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ sealed trait ServerState
object ServerState {
case object Started extends ServerState
final case class Initialized(service: WorkspaceLspService) extends ServerState
final case class ShuttingDown(service: WorkspaceLspService) extends ServerState
final case class ShuttingDown(service: WorkspaceLspService)
extends ServerState
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ object TelemetryLevel {
}
}
}

Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package scala.meta.internal.telemetry



case class Environment(java: JavaInfo, system: SystemInfo)
object Environment {
val java: JavaInfo = JavaInfo(
System.getProperty("java.version", "unknown"),
System.getProperty("java.vendor", "unknown")
System.getProperty("java.vendor", "unknown"),
)
val system: SystemInfo = SystemInfo(
System.getProperty("os.arch", "unknown"),
System.getProperty("os.arch", "unknown"),
System.getProperty("os.name", "unknown"),
System.getProperty("os.version", "unknown")
System.getProperty("os.version", "unknown"),
)

val instance: Environment = Environment(java, system)
}

case class JavaInfo(version: String, distribution: String)
case class SystemInfo(architecture: String, name: String, version: String)
case class SystemInfo(architecture: String, name: String, version: String)
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
package scala.meta.internal.telemetry

case class ExceptionSummary(
exception: String,
stacktrace: List[StackTraceElement],
)

case class ExceptionSummary(exception: String, stacktrace: List[StackTraceElement])

case class StackTraceElement(fullyQualifiedName: String, methodName: String, errorFile: String, errorLine: Int)
case class StackTraceElement(
fullyQualifiedName: String,
methodName: String,
errorFile: String,
errorLine: Int,
)

object ExceptionSummary {
def from(e: Throwable, sanitize: String => String): ExceptionSummary = {
val stackTraceElements = e.getStackTrace().toList.flatMap(element => {
for {
className <- Option(element.getClassName)
methodName <- Option(element.getMethodName)
errorLine <- Option(element.getLineNumber)
errorFile <- Option(element.getFileName)
} yield StackTraceElement(sanitize(className), sanitize(methodName), sanitize(errorFile), errorLine)
})
val stackTraceElements = e
.getStackTrace()
.toList
.flatMap(element => {
for {
className <- Option(element.getClassName)
methodName <- Option(element.getMethodName)
errorLine <- Option(element.getLineNumber)
errorFile <- Option(element.getFileName)
} yield StackTraceElement(
sanitize(className),
sanitize(methodName),
sanitize(errorFile),
errorLine,
)
})

ExceptionSummary(sanitize(e.getMessage), stackTraceElements)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package scala.meta.internal.telemetry


case class MetalsUserConfiguration(
symbolPrefixes: Map[String, String],
bloopSbtAlreadyInstalled: Boolean,
bloopVersion: Option[String],
bloopJvmProperties: List[String],
ammoniteJvmProperties: List[String],
superMethodLensesEnabled: Boolean,
showInferredType: Option[String],
showImplicitArguments: Boolean,
showImplicitConversionsAndClasses: Boolean,
enableStripMarginOnTypeFormatting: Boolean,
enableIndentOnPaste: Boolean,
enableSemanticHighlighting: Boolean,
excludedPackages: List[String],
fallbackScalaVersion: Option[String],
testUserInterface: String
symbolPrefixes: Map[String, String],
bloopSbtAlreadyInstalled: Boolean,
bloopVersion: Option[String],
bloopJvmProperties: List[String],
ammoniteJvmProperties: List[String],
superMethodLensesEnabled: Boolean,
showInferredType: Option[String],
showImplicitArguments: Boolean,
showImplicitConversionsAndClasses: Boolean,
enableStripMarginOnTypeFormatting: Boolean,
enableIndentOnPaste: Boolean,
enableSemanticHighlighting: Boolean,
excludedPackages: List[String],
fallbackScalaVersion: Option[String],
testUserInterface: String,
)

case class MetalsServerConfiguration(
executeClientCommand: String,
snippetAutoIndent: Boolean,
isHttpEnabled: Boolean,
isInputBoxEnabled: Boolean,
askToReconnect: Boolean,
allowMultilineStringFormatting: Boolean,
compilers: PresentationCompilerConfig
executeClientCommand: String,
snippetAutoIndent: Boolean,
isHttpEnabled: Boolean,
isInputBoxEnabled: Boolean,
askToReconnect: Boolean,
allowMultilineStringFormatting: Boolean,
compilers: PresentationCompilerConfig,
)

Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package scala.meta.internal.telemetry


case class PresentationCompilerConfig(
symbolPrefixes: Map[String, String],
completionCommand: Option[String],
parameterHintsCommand: Option[String],
overrideDefFormat: String,
isDefaultSymbolPrefixes: Boolean,
isCompletionItemDetailEnabled: Boolean,
isStripMarginOnTypeFormattingEnabled: Boolean,
isCompletionItemDocumentationEnabled: Boolean,
isHoverDocumentationEnabled: Boolean,
snippetAutoIndent: Boolean,
isSignatureHelpDocumentationEnabled: Boolean,
isCompletionSnippetsEnabled: Boolean,
semanticdbCompilerOptions: List[String]
symbolPrefixes: Map[String, String],
completionCommand: Option[String],
parameterHintsCommand: Option[String],
overrideDefFormat: String,
isDefaultSymbolPrefixes: Boolean,
isCompletionItemDetailEnabled: Boolean,
isStripMarginOnTypeFormattingEnabled: Boolean,
isCompletionItemDocumentationEnabled: Boolean,
isHoverDocumentationEnabled: Boolean,
snippetAutoIndent: Boolean,
isSignatureHelpDocumentationEnabled: Boolean,
isCompletionSnippetsEnabled: Boolean,
semanticdbCompilerOptions: List[String],
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ package scala.meta.internal.telemetry

sealed trait ReporterContext
case class ScalaPresentationCompilerContext(
scalaVersion: String,
options: List[String],
config: PresentationCompilerConfig
scalaVersion: String,
options: List[String],
config: PresentationCompilerConfig,
) extends ReporterContext

case class MetalsLspContext(
metalsVersion: String,
userConfig: MetalsUserConfiguration,
serverConfig: MetalsServerConfiguration,
clientInfo: MetalsClientInfo,
buildServerConnections: List[BuildServerConnection]
metalsVersion: String,
userConfig: MetalsUserConfiguration,
serverConfig: MetalsServerConfiguration,
clientInfo: MetalsClientInfo,
buildServerConnections: List[BuildServerConnection],
) extends ReporterContext

case class MetalsClientInfo(name: Option[String], version: Option[String])
case class BuildServerConnection(name: String, version: String, isMain: Boolean)
case class BuildServerConnection(name: String, version: String, isMain: Boolean)
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@ import com.github.plokhotnyuk.jsoniter_scala.core._
import com.github.plokhotnyuk.jsoniter_scala.macros._

case class CrashReport(
error: ExceptionSummary,
componentName: String,
env: Environment = Environment.instance,
componentVersion: Option[String] = None,
reporterContext: Option[ReporterContext] = None
error: ExceptionSummary,
componentName: String,
env: Environment = Environment.instance,
componentVersion: Option[String] = None,
reporterContext: Option[ReporterContext] = None,
)

object CrashReport {
implicit val codec: JsonValueCodec[CrashReport] = JsonCodecMaker.make
}

case class ErrorReport(
name: String,
reporterName: String,
reporterContext: ReporterContext,
env: Environment = Environment.instance,
id: Option[String] = None,
text: Option[String] = None,
error: Option[ExceptionSummary] = None,
name: String,
reporterName: String,
reporterContext: ReporterContext,
env: Environment = Environment.instance,
id: Option[String] = None,
text: Option[String] = None,
error: Option[ExceptionSummary] = None,
)

object ErrorReport {
implicit val codec: JsonValueCodec[ErrorReport] = JsonCodecMaker.make
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ package scala.meta.internal.telemetry
import com.github.plokhotnyuk.jsoniter_scala.core._
import scala.util.Try

class FireAndForgetEndpoint[In: JsonValueCodec](val method: String, val uri: String) {
class FireAndForgetEndpoint[In: JsonValueCodec](
val method: String,
val uri: String,
) {
def encodeInput(request: In): String = writeToString(request)
def decodeInput(request: String): Try[In] = Try { readFromString(request) }
}

// This will be migrated to tapir endpoints in the next Commit
object TelemetryService {
val sendErrorReportEndpoint = new FireAndForgetEndpoint[ErrorReport]("POST", "/v1/telemetry/sendErrorReport")
val sendCrashReportEndpoint = new FireAndForgetEndpoint[CrashReport]("POST", "/v1/telemetry/sendCrashReport")
val sendErrorReportEndpoint = new FireAndForgetEndpoint[ErrorReport](
"POST",
"/v1/telemetry/sendErrorReport",
)
val sendCrashReportEndpoint = new FireAndForgetEndpoint[CrashReport](
"POST",
"/v1/telemetry/sendCrashReport",
)
}

trait TelemetryService {
def sendErrorReport(errorReport: ErrorReport): Unit
def sendCrashReport(crashReport: CrashReport): Unit
}



Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ object SampleReports {
error = Some(
telemetry.ExceptionSummary(
"ExceptionType",
List(telemetry.StackTraceElement("fullyQualifiedName", "methodName", "fileName", 0)),
List(
telemetry.StackTraceElement(
"fullyQualifiedName",
"methodName",
"fileName",
0,
)
),
)
),
reporterName = "reporterName",
Expand Down

0 comments on commit 449d618

Please sign in to comment.