Change file's package to match directory: add space after package keyword if needed
#KT-39604 Fixed
This commit is contained in:
committed by
Ilya Kirillov
parent
1ce39222e3
commit
1188f4617a
@@ -137,6 +137,7 @@ public class KtPackageDirective extends KtModifierListOwnerStub<KotlinPlaceHolde
|
||||
PsiElement keyword = getPackageKeyword();
|
||||
if (keyword != null) {
|
||||
addAfter(newExpression, keyword);
|
||||
addAfter(psiFactory.createWhiteSpace(), keyword);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com.example
|
||||
|
||||
class Foo
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<caret>package
|
||||
|
||||
class Foo
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "com/example/test.kt",
|
||||
"inspectionClass": "org.jetbrains.kotlin.idea.refactoring.move.changePackage.PackageDirectoryMismatchInspection",
|
||||
"fix": "Change file's package to 'com.example'"
|
||||
}
|
||||
Generated
+5
@@ -78,6 +78,11 @@ public class MultiFileLocalInspectionTestGenerated extends AbstractMultiFileLoca
|
||||
runTest("idea/testData/multiFileLocalInspections/reconcilePackageWithDirectory/changeToNonDefaultPackageFromRoot/changeToNonDefaultPackageFromRoot.test");
|
||||
}
|
||||
|
||||
@TestMetadata("reconcilePackageWithDirectory/changeToNonDefaultPackageFromRootWithPackageKeyword/changeToNonDefaultPackageFromRootWithPackageKeyword.test")
|
||||
public void testReconcilePackageWithDirectory_changeToNonDefaultPackageFromRootWithPackageKeyword_ChangeToNonDefaultPackageFromRootWithPackageKeyword() throws Exception {
|
||||
runTest("idea/testData/multiFileLocalInspections/reconcilePackageWithDirectory/changeToNonDefaultPackageFromRootWithPackageKeyword/changeToNonDefaultPackageFromRootWithPackageKeyword.test");
|
||||
}
|
||||
|
||||
@TestMetadata("reconcilePackageWithDirectory/innerClass/innerClass.test")
|
||||
public void testReconcilePackageWithDirectory_innerClass_InnerClass() throws Exception {
|
||||
runTest("idea/testData/multiFileLocalInspections/reconcilePackageWithDirectory/innerClass/innerClass.test");
|
||||
|
||||
Reference in New Issue
Block a user