Skip to content

Commit

Permalink
[ fix #27 ] Catch exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Sep 9, 2019
1 parent f3ba6e3 commit bca3e0b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/rs/pest/editing/pest-inspection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class DuplicateRuleInspection : LocalInspectionTool() {
override fun checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array<ProblemDescriptor> {
if (file !is PestFile) return emptyArray()
val problemsHolder = ProblemsHolder(manager, file, isOnTheFly)
val ruleSet = ContainerUtil.newHashMap<String, PestGrammarRuleMixin>()
val problematicRules = ContainerUtil.newLinkedHashSet<PestGrammarRuleMixin>()
val ruleSet = hashMapOf<String, PestGrammarRuleMixin>()
val problematicRules = hashSetOf<PestGrammarRuleMixin>()
file.rules().forEach {
val name = it.name
val tried = ruleSet[name]
Expand Down Expand Up @@ -59,12 +59,16 @@ fun reloadVM(dom: Document, element: PestFile) {
availableRules = messages
livePreviewFile().forEach(DaemonCodeAnalyzer.getInstance(element.project)::restart)
} else with(element) {
errors = messages.mapNotNull { errorMsgRegex.matchEntire(it)?.groupValues }.map {
errors = messages.mapNotNull { errorMsgRegex.matchEntire(it)?.groupValues }.mapNotNull {
val startLine = it[1].toInt() - 1
val startCol = it[2].toInt() - 1
val endLine = it[3].toInt() - 1
val endCol = it[4].toInt() - 1
val range = TextRange(dom.getLineStartOffset(startLine) + startCol, dom.getLineStartOffset(endLine) + endCol)
val range = try {
TextRange(dom.getLineStartOffset(startLine) + startCol, dom.getLineStartOffset(endLine) + endCol)
} catch (e: IndexOutOfBoundsException) {
return@mapNotNull null
}
Pair(range, it[5])
}
availableRules = emptySequence()
Expand Down

0 comments on commit bca3e0b

Please sign in to comment.