Skip to content

Commit 98739e0

Browse files
committed
Fix for #84
1 parent e28f7c7 commit 98739e0

File tree

4 files changed

+139
-1
lines changed

4 files changed

+139
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# vscode-theme Changelog
44

55
## Unreleased
6+
### Added
7+
- Rainbow Brackets plugin will now be bundled within VSCode theme
8+
- #84 - Functionality to report bug through IDE error reporting tool
9+
10+
### Fixed
11+
- Icon colors are messed up in VSCode light theme
12+
613

714
## 1.9.1 - 2023-08-13
815

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pluginGroup = com.github.dinbtechit.vscodetheme
44
pluginName = VSCode Theme
55
# SemVer format -> https://semver.org
6-
pluginVersion = 1.9.1
6+
pluginVersion = 1.10.0
77

88
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
99
pluginSinceBuild = 211
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.github.dinbtechit.vscodetheme.diagostic
2+
3+
import com.intellij.ide.BrowserUtil
4+
import com.intellij.ide.plugins.PluginManagerCore
5+
import com.intellij.openapi.application.ApplicationInfo
6+
import com.intellij.openapi.diagnostic.ErrorReportSubmitter
7+
import com.intellij.openapi.diagnostic.IdeaLoggingEvent
8+
import com.intellij.openapi.diagnostic.SubmittedReportInfo
9+
import com.intellij.openapi.extensions.PluginId
10+
import org.apache.commons.lang.StringUtils
11+
import org.apache.http.client.utils.URIBuilder
12+
import java.awt.Component
13+
import java.io.BufferedReader
14+
import java.io.StringReader
15+
import java.net.URI
16+
import java.util.stream.Collectors
17+
18+
class VSCodeErrorReportSubmitter: ErrorReportSubmitter() {
19+
20+
private val packageAbbreviation: Map<String, String>? = null
21+
22+
override fun getReportActionText(): String {
23+
return "Report to VSCode Theme"
24+
}
25+
26+
override fun submit(
27+
events: Array<out IdeaLoggingEvent>,
28+
additionalInfo: String?,
29+
parentComponent: Component,
30+
consumer: com.intellij.util.Consumer<in SubmittedReportInfo>
31+
): Boolean {
32+
getReportIssueUrl(
33+
getReportTitle(events),
34+
getReportBody(events, additionalInfo)
35+
)?.let {
36+
BrowserUtil.browse(it)
37+
}
38+
return true
39+
}
40+
41+
private fun getReportTitle(events: Array<out IdeaLoggingEvent>): String {
42+
val event = events.firstOrNull()
43+
return event?.throwableText?.lineSequence()?.first()
44+
?: event?.message
45+
?: "Report bug"
46+
}
47+
48+
private fun getReportBody(events: Array<out IdeaLoggingEvent>, additionalInfo: String?): String {
49+
val javaVendor = System.getProperty("java.vendor")
50+
val javaVersion = System.getProperty("java.version")
51+
52+
val osName = System.getProperty("os.name")
53+
val osArch = System.getProperty("os.arch")
54+
55+
val appName = ApplicationInfo.getInstance().fullApplicationName
56+
57+
val plugin = PluginManagerCore.getPlugin(PluginId.getId("com.github.dinbtechit.vscodetheme"))
58+
val pluginVersion = plugin?.version
59+
60+
var stackTrace = ""
61+
for (event in events) {
62+
val message = event.message
63+
if (!message.isNullOrBlank()) {
64+
stackTrace = stackTrace.plus(message).plus("\n")
65+
}
66+
val throwableText = event.throwableText
67+
if (!throwableText.isNullOrBlank()) {
68+
stackTrace = stackTrace.plus("\n```\n")
69+
stackTrace= stackTrace.plus(
70+
BufferedReader(StringReader(throwableText)).lines()
71+
.map { line ->
72+
var abbreviated = line
73+
packageAbbreviation?.entries?.forEach { entry ->
74+
abbreviated = StringUtils.replace(abbreviated, entry.key, entry.value)
75+
}
76+
abbreviated
77+
}.collect(Collectors.joining("\n"))
78+
)
79+
stackTrace= stackTrace.plus("\n```\n\n")
80+
}
81+
}
82+
var description = additionalInfo
83+
if (description.isNullOrBlank()) {
84+
description = "A clear and concise description of what the bug is."
85+
}
86+
87+
return """
88+
|#Describe the bug
89+
| $description
90+
|
91+
|#To Reproduce
92+
|Steps to reproduce the behavior:
93+
|1. Go to '...'
94+
|2. Click on '....'
95+
|3. Scroll down to '....'
96+
|4. See error
97+
|
98+
|#Expected behavior
99+
|A clear and concise description of what you expected to happen.
100+
|
101+
|#Screenshots
102+
|If applicable, add screenshots to help explain your problem.
103+
|
104+
|#Environment
105+
|* Java: $javaVendor $javaVersion
106+
|* OS: $osName $osArch
107+
|* IDE: $appName
108+
|* Version: $pluginVersion
109+
|
110+
|#Additional context
111+
|${additionalInfo ?: "Add any other context about the problem here."}
112+
|
113+
|#Stacktrace#
114+
| $stackTrace
115+
""".trimMargin()
116+
}
117+
118+
private fun getReportIssueUrl(title: String, body: String): URI? {
119+
val uriBuilder = URIBuilder("https://github.com/dinbtechit/vscode-theme/issues/new")
120+
uriBuilder.addParameter("title", "[Bug] $title")
121+
uriBuilder.addParameter("labels", "bug")
122+
if (body.isNotBlank()) {
123+
uriBuilder.addParameter("body", body)
124+
} else {
125+
uriBuilder.addParameter("template", "bug_report.md")
126+
}
127+
return uriBuilder.build()
128+
}
129+
130+
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<notificationGroup id="VSCode Theme Notification Group" displayType="STICKY_BALLOON"/>
3737
<!--https://github.com/dinbtechit/vscode-theme/issues/38 Default Annotator Issues-->
3838
<!--<annotator language="" order="last" implementationClass="com.github.dinbtechit.vscodetheme.annotators.DefaultAnnotator"/>-->
39+
<errorHandler implementation="com.github.dinbtechit.vscodetheme.diagostic.VSCodeErrorReportSubmitter"/>
3940
</extensions>
4041
<actions>
4142
<action id="AlwaysApplyThemeAction" class="com.github.dinbtechit.vscodetheme.actions.AlwaysApplyThemeAction"

0 commit comments

Comments
 (0)