Skip to content

Commit 745dff2

Browse files
committed
add config info to exception log content
1 parent 43c883c commit 745dff2

File tree

8 files changed

+44
-17
lines changed

8 files changed

+44
-17
lines changed

src/main/kotlin/wu/seal/jsontokotlin/IConfigManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ interface IConfigManager {
123123
PropertiesComponent.getInstance().setValue(USER_UUID_KEY, value)
124124
}
125125

126-
var customAnnotaionImportClassString: String
126+
var customAnnotationImportClassString: String
127127
get() = if (isTestModel) TestConfig.customAnnotaionImportClassString else PropertiesComponent.getInstance().getValue(
128128
USER_CUSTOM_JSON_LIB_ANNOTATION_IMPORT_CLASS, "import kotlinx.serialization.SerialName\n" +
129129
"import kotlinx.serialization.Serializable"+"\n"

src/main/kotlin/wu/seal/jsontokotlin/feedback/Datas.kt

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@ import java.util.*
99
* Created by Seal.Wu on 2017/9/27.
1010
*/
1111
data class ConfigInfo(
12-
val uuid: String = UUID,
13-
val pluginVersion: String = PLUGIN_VERSION,
14-
val isPropertiesVar: Boolean = ConfigManager.isPropertiesVar,
15-
val isCommentOff: Boolean = ConfigManager.isCommentOff,
16-
val isOrderByAlphabetical: Boolean = ConfigManager.isOrderByAlphabetical,
17-
val propertyTypeStrategy: String = ConfigManager.propertyTypeStrategy.name,
18-
val initWithDefaultValue: Boolean = ConfigManager.initWithDefaultValue,
19-
val targetJsonConverterLib: String = ConfigManager.targetJsonConverterLib.name,
20-
val isInnerClassMode: Boolean = ConfigManager.isInnerClassModel,
21-
val timeStamp: String = Date().time.toString(),
22-
val daytime: String = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).format(Date())
12+
val uuid: String = UUID,
13+
val pluginVersion: String = PLUGIN_VERSION,
14+
val isPropertiesVar: Boolean = ConfigManager.isPropertiesVar,
15+
val isCommentOff: Boolean = ConfigManager.isCommentOff,
16+
val isOrderByAlphabetical: Boolean = ConfigManager.isOrderByAlphabetical,
17+
val propertyTypeStrategy: String = ConfigManager.propertyTypeStrategy.name,
18+
val initWithDefaultValue: Boolean = ConfigManager.initWithDefaultValue,
19+
val targetJsonConverterLib: String = ConfigManager.targetJsonConverterLib.name,
20+
val isInnerClassMode: Boolean = ConfigManager.isInnerClassModel,
21+
val customAnnotationImportClassString: String = ConfigManager.customAnnotationImportClassString,
22+
val customClassAnnotationFormatString: String = ConfigManager.customClassAnnotationFormatString,
23+
val customPropertyAnnotationFormatString: String = ConfigManager.customPropertyAnnotationFormatString,
24+
val enableMapType: Boolean = ConfigManager.enableMapType,
25+
val enableAutoReformat: Boolean = ConfigManager.enableAutoReformat,
26+
val enableMinimalAnnotation: Boolean = ConfigManager.enableMinimalAnnotation,
27+
val parenClassTemplate: String = ConfigManager.parenClassTemplate,
28+
val keywordPropertyValid: Boolean = ConfigManager.keywordPropertyValid,
29+
val extensionsConfig: String = ConfigManager.extensionsConfig,
30+
val timeStamp: String = Date().time.toString(),
31+
val daytime: String = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA).format(Date())
2332

2433
)

src/main/kotlin/wu/seal/jsontokotlin/feedback/ExceptionHandler.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package wu.seal.jsontokotlin.feedback
22

3+
import com.google.gson.Gson
4+
import com.google.gson.GsonBuilder
35
import com.intellij.openapi.ui.Messages
46
import java.io.PrintWriter
57
import java.io.StringWriter
@@ -15,13 +17,18 @@ import java.util.*
1517
/**
1618
* handler the exception
1719
*/
20+
21+
val prettyPrintGson = GsonBuilder().setPrettyPrinting().create()
22+
1823
fun getUncaughtExceptionHandler(jsonString: String, callBack: () -> Unit): Thread.UncaughtExceptionHandler = Thread.UncaughtExceptionHandler { _, e ->
1924
val logBuilder = StringBuilder()
25+
logBuilder.append("\n\n")
2026
logBuilder.append("PluginVersion:$PLUGIN_VERSION\n")
2127
logBuilder.append("user: $UUID").append("\n")
2228
val time = SimpleDateFormat("yyyy-MM-dd HH:mm:ss E", Locale.CHINA).format(Date())
2329
logBuilder.append("createTime: $time").append("\n")
2430

31+
logBuilder.appendln().append(getConfigInfo()).appendln()
2532
val stringWriter = StringWriter()
2633
val printWriter = PrintWriter(stringWriter, true)
2734
e.printStackTrace(printWriter)
@@ -42,6 +49,11 @@ fun getUncaughtExceptionHandler(jsonString: String, callBack: () -> Unit): Threa
4249
callBack.invoke()
4350
}
4451

52+
53+
fun getConfigInfo(): String {
54+
return prettyPrintGson.toJson(ConfigInfo())
55+
}
56+
4557
fun dealWithException(jsonString: String, e: Throwable) {
4658
var jsonString1 = jsonString
4759
val yes = Messages.showYesNoDialog("Some thing execute wrong.\nAgree with publishing your JSON text to help us to solve the problem?", "Excuse me", Messages.getQuestionIcon())

src/main/kotlin/wu/seal/jsontokotlin/feedback/NetWork.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fun sendConfigInfo() {
8585

8686
val outputStream = connection.outputStream
8787
val writer = outputStream.writer()
88-
writer.write(Gson().toJson(ConfigInfo()))
88+
writer.write(getConfigInfo())
8989
writer.flush()
9090
if (connection.responseCode != 200) {
9191
println(connection.responseMessage + "\n" + connection.errorStream.reader().readText())

src/main/kotlin/wu/seal/jsontokotlin/supporter/CustomJsonLibSupporter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object CustomJsonLibSupporter : IJsonLibSupporter {
2323
get() = ConfigManager.customClassAnnotationFormatString
2424

2525
override val annotationImportClassString: String
26-
get() = ConfigManager.customAnnotaionImportClassString
26+
get() = ConfigManager.customAnnotationImportClassString
2727

2828

2929
override fun getClassAnnotationBlockString(rawClassName: String): String {

src/main/kotlin/wu/seal/jsontokotlin/ui/SettingsAnnotationTab.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ class SettingsAnnotationTab(layout: LayoutManager?, isDoubleBuffered: Boolean) :
8989
annotationImportClass.layout = BoxLayout(annotationImportClass, BoxLayout.PAGE_AXIS)
9090
val importClassLable = JBLabel("Annotation Import Class : ")
9191
annotationImportClass.addComponentIntoVerticalBoxAlignmentLeft(importClassLable)
92-
val annotationImportClassTextArea = JTextArea(ConfigManager.customAnnotaionImportClassString)
92+
val annotationImportClassTextArea = JTextArea(ConfigManager.customAnnotationImportClassString)
9393
annotationImportClassTextArea.minimumSize = JBDimension(460, 40)
9494
annotationImportClassTextArea.addFocusListener(object : FocusListener {
9595
override fun focusLost(e: FocusEvent?) {
96-
ConfigManager.customAnnotaionImportClassString = annotationImportClassTextArea.text
96+
ConfigManager.customAnnotationImportClassString = annotationImportClassTextArea.text
9797

9898
}
9999

src/test/kotlin/wu/seal/jsontokotlin/feedback/ConfigInfoTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,11 @@ class ConfigInfoTest {
2222
val info = ConfigInfo()
2323
val infoJson = Gson().toJson(info)
2424
infoJson.should.not.be.empty
25+
println(infoJson)
26+
}
27+
28+
@Test
29+
fun getConfigTest() {
30+
println(getConfigInfo())
2531
}
2632
}

src/test/kotlin/wu/seal/jsontokotlin/supporter/CustomJsonLibSupporterTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CustomJsonLibSupporterTest {
2020
@org.junit.Test
2121
fun testAnnotationImportClass() {
2222

23-
println(ConfigManager.customAnnotaionImportClassString)
23+
println(ConfigManager.customAnnotationImportClassString)
2424
}
2525

2626
@org.junit.Test

0 commit comments

Comments
 (0)