Errors in import list do not prevent from on-the-fly optimization - unresolved imports can be removed automatically

This commit is contained in:
Valentin Kipyatkov
2015-07-21 17:12:15 +03:00
parent 9c03661ce5
commit 2f438d0722
@@ -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)