mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] KTIJ-36028 Do not report package mismatch on the 1st declaration
(cherry picked from commit e901b4796921c7288d5766628ed7d4a83ff640cb) GitOrigin-RevId: 130058f0814f7976912805d4de7e4b2f6748a623
This commit is contained in:
committed by
intellij-monorepo-bot
parent
de81d39bc1
commit
ac85e72f4d
+1
-1
@@ -69,7 +69,7 @@ class PackageDirectoryMismatchInspection : AbstractKotlinInspection() {
|
||||
fixes += ChangePackageFix("'${fqNameWithImplicitPrefix.asString()}'", fqNameWithImplicitPrefix)
|
||||
}
|
||||
|
||||
val element = if (directive.textLength != 0) directive else (file.declarations.firstOrNull() ?: file)
|
||||
val element = if (directive.textLength != 0) directive else file
|
||||
holder.registerProblem(
|
||||
element,
|
||||
KotlinBundle.message("text.package.directive.dont.match.file.location"),
|
||||
|
||||
-19
@@ -94,23 +94,4 @@ public abstract class K2MultiFileInspectionTestGenerated extends AbstractK2Multi
|
||||
runTest("../../../idea/tests/testData/multiFileInspections/kotlinSealedInJavaTest/kotlinSealedInJavaTest.test");
|
||||
}
|
||||
}
|
||||
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../../../idea/tests/testData/multiFileInspections/mismatchedProjectAndDirectoryRoot")
|
||||
public static class MismatchedProjectAndDirectoryRoot extends AbstractK2MultiFileInspectionTest {
|
||||
@java.lang.Override
|
||||
@org.jetbrains.annotations.NotNull
|
||||
public final KotlinPluginMode getPluginMode() {
|
||||
return KotlinPluginMode.K2;
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("mismatchedProjectAndDirectoryRoot.test")
|
||||
public void testMismatchedProjectAndDirectoryRoot() throws Exception {
|
||||
runTest("../../../idea/tests/testData/multiFileInspections/mismatchedProjectAndDirectoryRoot/mismatchedProjectAndDirectoryRoot.test");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -615,6 +615,11 @@ public abstract class K2HighlightingMetaInfoTestGenerated extends AbstractK2High
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblem.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mismatchPackageDirectoryFileLevelProblemDeclarations.kt")
|
||||
public void testMismatchPackageDirectoryFileLevelProblemDeclarations() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblemDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NamedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/NamedArguments.kt");
|
||||
|
||||
+5
@@ -336,6 +336,11 @@ public abstract class CommonNativeJvmK2HighlightingMetaInfoTestGenerated extends
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblem.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mismatchPackageDirectoryFileLevelProblemDeclarations.kt")
|
||||
public void testMismatchPackageDirectoryFileLevelProblemDeclarations() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblemDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NamedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/NamedArguments.kt");
|
||||
|
||||
+5
@@ -336,6 +336,11 @@ public abstract class JsK2HighlightingMetaInfoTestGenerated extends AbstractK2Hi
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblem.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mismatchPackageDirectoryFileLevelProblemDeclarations.kt")
|
||||
public void testMismatchPackageDirectoryFileLevelProblemDeclarations() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblemDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NamedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/NamedArguments.kt");
|
||||
|
||||
+5
@@ -336,6 +336,11 @@ public abstract class NativeLinuxK2HighlightingMetaInfoTestGenerated extends Abs
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblem.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mismatchPackageDirectoryFileLevelProblemDeclarations.kt")
|
||||
public void testMismatchPackageDirectoryFileLevelProblemDeclarations() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblemDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NamedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("../../idea/tests/testData/highlighterMetaInfo/NamedArguments.kt");
|
||||
|
||||
+5
@@ -620,6 +620,11 @@ public abstract class K1HighlightingMetaInfoTestGenerated extends AbstractK1High
|
||||
runTest("testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblem.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mismatchPackageDirectoryFileLevelProblemDeclarations.kt")
|
||||
public void testMismatchPackageDirectoryFileLevelProblemDeclarations() throws Exception {
|
||||
runTest("testData/highlighterMetaInfo/mismatchPackageDirectoryFileLevelProblemDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NamedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("testData/highlighterMetaInfo/NamedArguments.kt");
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun foo() {
|
||||
// TODO
|
||||
// TODO
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
// TOOL: org.jetbrains.kotlin.idea.k2.codeinsight.inspections.PackageDirectoryMismatchInspection
|
||||
// IGNORE_K1
|
||||
// IMPLICIT_PACKAGE_PREFIX: "foo"
|
||||
// HIGHLIGHT_WARNINGS
|
||||
// ALLOW_ERRORS
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun foo() {
|
||||
// TODO
|
||||
// TODO
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
// TOOL: org.jetbrains.kotlin.idea.k2.codeinsight.inspections.PackageDirectoryMismatchInspection
|
||||
// IGNORE_K1
|
||||
// IMPLICIT_PACKAGE_PREFIX: "foo"
|
||||
// HIGHLIGHT_WARNINGS
|
||||
// ALLOW_ERRORS
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<!FILE_LEVEL_HIGHLIGHTING!>fun foo() {
|
||||
// <!HIGHLIGHTING("descr='TODO'")!>TODO<!>
|
||||
// <!HIGHLIGHTING("descr='TODO'")!>TODO<!>
|
||||
// <!HIGHLIGHTING("descr='TODO'")!>TODO<!>
|
||||
// <!HIGHLIGHTING("descr='TODO'")!>TODO<!>
|
||||
}
|
||||
// TOOL: org.jetbrains.kotlin.idea.k2.codeinsight.inspections.PackageDirectoryMismatchInspection
|
||||
// IGNORE_K1
|
||||
// IMPLICIT_PACKAGE_PREFIX: "foo"
|
||||
// HIGHLIGHT_WARNINGS
|
||||
// ALLOW_ERRORS<!>
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
{
|
||||
"inspectionClass": "org.jetbrains.kotlin.idea.refactoring.move.changePackage.PackageDirectoryMismatchInspection",
|
||||
"k2InspectionClass": "org.jetbrains.kotlin.idea.k2.codeinsight.inspections.PackageDirectoryMismatchInspection"
|
||||
"inspectionClass": "org.jetbrains.kotlin.idea.refactoring.move.changePackage.PackageDirectoryMismatchInspection"
|
||||
}
|
||||
+2
-1
@@ -193,7 +193,8 @@ internal fun MutableTWorkspace.generateK2InspectionTests() {
|
||||
model("${idea}/multiFileInspections/mismatchedPackageDirectory", pattern = Patterns.TEST)
|
||||
model("${idea}/multiFileInspections/mismatchedProjectAndDirectory", pattern = Patterns.TEST)
|
||||
model("${idea}/multiFileInspections/kotlinSealedInJavaTest", pattern = Patterns.TEST)
|
||||
model("${idea}/multiFileInspections/mismatchedProjectAndDirectoryRoot", pattern = Patterns.TEST)
|
||||
// K2 test data intentionally slightly differs from K1
|
||||
//model("${idea}/multiFileInspections/mismatchedProjectAndDirectoryRoot", pattern = Patterns.TEST)
|
||||
}
|
||||
|
||||
testClass<AbstractK2MultiFileLocalInspectionTest> {
|
||||
|
||||
Reference in New Issue
Block a user