Skip to content

Commit

Permalink
Fix for #84
Browse files Browse the repository at this point in the history
  • Loading branch information
dinbtechit committed Aug 18, 2023
1 parent e28f7c7 commit 98739e0
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
# vscode-theme Changelog

## Unreleased
### Added
- Rainbow Brackets plugin will now be bundled within VSCode theme
- #84 - Functionality to report bug through IDE error reporting tool

### Fixed
- Icon colors are messed up in VSCode light theme


## 1.9.1 - 2023-08-13

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pluginGroup = com.github.dinbtechit.vscodetheme
pluginName = VSCode Theme
# SemVer format -> https://semver.org
pluginVersion = 1.9.1
pluginVersion = 1.10.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 211
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package com.github.dinbtechit.vscodetheme.diagostic

import com.intellij.ide.BrowserUtil
import com.intellij.ide.plugins.PluginManagerCore
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.diagnostic.ErrorReportSubmitter
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
import com.intellij.openapi.diagnostic.SubmittedReportInfo
import com.intellij.openapi.extensions.PluginId
import org.apache.commons.lang.StringUtils
import org.apache.http.client.utils.URIBuilder
import java.awt.Component
import java.io.BufferedReader
import java.io.StringReader
import java.net.URI
import java.util.stream.Collectors

class VSCodeErrorReportSubmitter: ErrorReportSubmitter() {

private val packageAbbreviation: Map<String, String>? = null

override fun getReportActionText(): String {
return "Report to VSCode Theme"
}

override fun submit(
events: Array<out IdeaLoggingEvent>,
additionalInfo: String?,
parentComponent: Component,
consumer: com.intellij.util.Consumer<in SubmittedReportInfo>
): Boolean {
getReportIssueUrl(
getReportTitle(events),
getReportBody(events, additionalInfo)
)?.let {
BrowserUtil.browse(it)
}
return true
}

private fun getReportTitle(events: Array<out IdeaLoggingEvent>): String {
val event = events.firstOrNull()
return event?.throwableText?.lineSequence()?.first()
?: event?.message
?: "Report bug"
}

private fun getReportBody(events: Array<out IdeaLoggingEvent>, additionalInfo: String?): String {
val javaVendor = System.getProperty("java.vendor")
val javaVersion = System.getProperty("java.version")

val osName = System.getProperty("os.name")
val osArch = System.getProperty("os.arch")

val appName = ApplicationInfo.getInstance().fullApplicationName

val plugin = PluginManagerCore.getPlugin(PluginId.getId("com.github.dinbtechit.vscodetheme"))
val pluginVersion = plugin?.version

var stackTrace = ""
for (event in events) {
val message = event.message
if (!message.isNullOrBlank()) {
stackTrace = stackTrace.plus(message).plus("\n")
}
val throwableText = event.throwableText
if (!throwableText.isNullOrBlank()) {
stackTrace = stackTrace.plus("\n```\n")
stackTrace= stackTrace.plus(
BufferedReader(StringReader(throwableText)).lines()
.map { line ->
var abbreviated = line
packageAbbreviation?.entries?.forEach { entry ->
abbreviated = StringUtils.replace(abbreviated, entry.key, entry.value)
}
abbreviated
}.collect(Collectors.joining("\n"))
)
stackTrace= stackTrace.plus("\n```\n\n")
}
}
var description = additionalInfo
if (description.isNullOrBlank()) {
description = "A clear and concise description of what the bug is."
}

return """
|#Describe the bug
| $description
|
|#To Reproduce
|Steps to reproduce the behavior:
|1. Go to '...'
|2. Click on '....'
|3. Scroll down to '....'
|4. See error
|
|#Expected behavior
|A clear and concise description of what you expected to happen.
|
|#Screenshots
|If applicable, add screenshots to help explain your problem.
|
|#Environment
|* Java: $javaVendor $javaVersion
|* OS: $osName $osArch
|* IDE: $appName
|* Version: $pluginVersion
|
|#Additional context
|${additionalInfo ?: "Add any other context about the problem here."}
|
|#Stacktrace#
| $stackTrace
""".trimMargin()
}

private fun getReportIssueUrl(title: String, body: String): URI? {
val uriBuilder = URIBuilder("https://github.com/dinbtechit/vscode-theme/issues/new")
uriBuilder.addParameter("title", "[Bug] $title")
uriBuilder.addParameter("labels", "bug")
if (body.isNotBlank()) {
uriBuilder.addParameter("body", body)
} else {
uriBuilder.addParameter("template", "bug_report.md")
}
return uriBuilder.build()
}

}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<notificationGroup id="VSCode Theme Notification Group" displayType="STICKY_BALLOON"/>
<!--https://github.com/dinbtechit/vscode-theme/issues/38 Default Annotator Issues-->
<!--<annotator language="" order="last" implementationClass="com.github.dinbtechit.vscodetheme.annotators.DefaultAnnotator"/>-->
<errorHandler implementation="com.github.dinbtechit.vscodetheme.diagostic.VSCodeErrorReportSubmitter"/>
</extensions>
<actions>
<action id="AlwaysApplyThemeAction" class="com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction"
Expand Down

0 comments on commit 98739e0

Please sign in to comment.