Skip to content

Commit

Permalink
remove unused import
Browse files Browse the repository at this point in the history
add space into  regex for  `package and import declaration` matcher
  • Loading branch information
sealkingking committed Dec 23, 2018
1 parent 9902bc6 commit 649d98b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/wu/seal/jsontokotlin/ImportClassWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ object ImportClassWriter : IImportClassWriter {
if (importClassLineString !in text) {

val packageIndex = try {
"^[\\s]*package".toRegex(RegexOption.MULTILINE).find(text)!!.range.endInclusive
"^[\\s]*package\\s.+\n$".toRegex(RegexOption.MULTILINE).find(text)!!.range.endInclusive
} catch (e: Exception) {
-1
}
val lastImportKeywordIndex = try {
"^[\\s]*import".toRegex(RegexOption.MULTILINE).findAll(text).last().range.endInclusive
"^[\\s]*import\\s.+\n$".toRegex(RegexOption.MULTILINE).findAll(text).last().range.endInclusive
} catch (e: Exception) {
-1
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/kotlin/wu/seal/jsontokotlin/MakeKotlinClassAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import wu.seal.jsontokotlin.feedback.sendActionInfo
import wu.seal.jsontokotlin.ui.JsonInputDialog
import wu.seal.jsontokotlin.utils.ClassCodeFilter
import wu.seal.jsontokotlin.utils.executeCouldRollBackAction
import java.awt.SystemColor.text
import java.net.URL
import java.util.*

Expand Down Expand Up @@ -146,12 +145,12 @@ class MakeKotlinClassAction : AnAction("MakeKotlinClass") {
offset = document.textLength
}
val lastPackageKeywordLineEndIndex = try {
"^[\\s]*package.+\n$".toRegex(RegexOption.MULTILINE).findAll(document.text).last().range.endInclusive
"^[\\s]*package\\s.+\n$".toRegex(RegexOption.MULTILINE).findAll(document.text).last().range.endInclusive
} catch (e: Exception) {
-1
}
val lastImportKeywordLineEndIndex = try {
"^[\\s]*import.+\n$".toRegex(RegexOption.MULTILINE).findAll(document.text).last().range.endInclusive
"^[\\s]*import\\s.+\n$".toRegex(RegexOption.MULTILINE).findAll(document.text).last().range.endInclusive
} catch (e: Exception) {
-1
}
Expand Down

0 comments on commit 649d98b

Please sign in to comment.