From 2f438d0722f6ac79a871fc1e3a3ab128cdaf31e4 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 21 Jul 2015 17:12:15 +0300 Subject: [PATCH] Errors in import list do not prevent from on-the-fly optimization - unresolved imports can be removed automatically --- .../kotlin/idea/inspections/UnusedImportInspection.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedImportInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedImportInspection.kt index 02aa5a128d7..cffc2a71f8d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedImportInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedImportInspection.kt @@ -146,7 +146,15 @@ class UnusedImportInspection : AbstractKotlinInspection() { val document = editor.document var hasErrors = false - DaemonCodeAnalyzerEx.processHighlights(document, project, HighlightSeverity.ERROR, 0, document.textLength, Processor { hasErrors = true; false }) + DaemonCodeAnalyzerEx.processHighlights(document, project, HighlightSeverity.ERROR, 0, document.textLength, Processor { highlightInfo -> + if (!importsRange.containsRange(highlightInfo.startOffset, highlightInfo.endOffset)) { + hasErrors = true + false + } + else { + true + } + }) if (hasErrors) return false return DaemonListeners.canChangeFileSilently(file)