From bca3e0bd6cc3148057cedacf2f53b9fa8386cc9e Mon Sep 17 00:00:00 2001 From: ice1000 Date: Mon, 9 Sep 2019 17:29:03 -0400 Subject: [PATCH] [ fix #27 ] Catch exception --- src/rs/pest/editing/pest-inspection.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/rs/pest/editing/pest-inspection.kt b/src/rs/pest/editing/pest-inspection.kt index b476421..70e32f2 100644 --- a/src/rs/pest/editing/pest-inspection.kt +++ b/src/rs/pest/editing/pest-inspection.kt @@ -22,8 +22,8 @@ class DuplicateRuleInspection : LocalInspectionTool() { override fun checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array { if (file !is PestFile) return emptyArray() val problemsHolder = ProblemsHolder(manager, file, isOnTheFly) - val ruleSet = ContainerUtil.newHashMap() - val problematicRules = ContainerUtil.newLinkedHashSet() + val ruleSet = hashMapOf() + val problematicRules = hashSetOf() file.rules().forEach { val name = it.name val tried = ruleSet[name] @@ -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()