@@ -33,7 +33,7 @@ object ImportClassWriter : IImportClassWriter {
3333
3434 TargetJsonConverter .Gson -> insertGsonImportClass(project, editFile)
3535 TargetJsonConverter .FastJson -> insertFastJsonImportClass(project, editFile)
36- TargetJsonConverter .Jackson -> insertFastJsonImportClass (project, editFile)
36+ TargetJsonConverter .Jackson -> insertJackSonImportClass (project, editFile)
3737
3838 else -> {
3939 println (" No need to import any Class code" )
@@ -43,22 +43,31 @@ object ImportClassWriter : IImportClassWriter {
4343
4444
4545 override fun insertFastJsonImportClass (project : Project ? , editFile : Document ) {
46+
4647 }
4748
4849 override fun insertJackSonImportClass (project : Project ? , editFile : Document ) {
50+ val importClassString = JacksonSupporter .jacksonAnnotationImportClassString
51+ insertImportClassString(editFile, importClassString, project)
4952 }
5053
5154 override fun insertGsonImportClass (project : Project ? , editFile : Document ) {
55+
56+ val importClassString = GsonSupporter .gsonAnotationImportString
57+ insertImportClassString(editFile, importClassString, project)
58+ }
59+
60+ private fun insertImportClassString (editFile : Document , importClassString : String , project : Project ? ) {
5261 val text = editFile.text
53- if (GsonSupporter .gsonAnotationImportString !in text) {
62+ if (importClassString !in text) {
5463
5564 val packageIndex = text.indexOf(" package " )
5665 val importIndex = Math .max(text.lastIndexOf(" import" ), packageIndex)
5766 val insertIndex = if (importIndex == - 1 ) 0 else editFile.getLineEndOffset(editFile.getLineNumber(importIndex))
5867
5968
6069 executeCouldRollBackAction(project) {
61- editFile.insertString(insertIndex, " \n " + GsonSupporter .gsonAnotationImportString + " \n " )
70+ editFile.insertString(insertIndex, " \n " + importClassString + " \n " )
6271 }
6372
6473 }
0 commit comments