From 37614254d7f26a8de368289749eb2c2bc6b64f3f Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 9 Jan 2019 15:24:02 +0300 Subject: [PATCH] Fix test on unused import suppression Before the fix for KT-7185, the file looked like: package suppression @file:Suppress("UnusedImport") import java.io.* // unused And it was parsed incorrectly, because @file: annotations should come before package directive But after fix, import directives started being parsed that lead to wrong unused import (because suppression wasn't parsed still) --- idea/testData/inspections/unusedImport/suppression.kt | 3 ++- .../kotlin/idea/codeInsight/AbstractInspectionTest.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/idea/testData/inspections/unusedImport/suppression.kt b/idea/testData/inspections/unusedImport/suppression.kt index cd6684b02b0..4ccf8064b31 100644 --- a/idea/testData/inspections/unusedImport/suppression.kt +++ b/idea/testData/inspections/unusedImport/suppression.kt @@ -1,3 +1,4 @@ @file:Suppress("UnusedImport") +package suppression -import java.io.* // unused \ No newline at end of file +import java.io.* // unused diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt index 03e034eb022..ea61c50879a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt @@ -94,7 +94,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() file.extension == "kt" -> { val text = FileUtil.loadFile(file, true) val fileText = - if (text.startsWith("package")) + if (text.lines().any { it.startsWith("package") }) text else "package ${file.nameWithoutExtension};$text"