Apply quick-fix "Make visible" for INVISIBLE_FAKE #KT-16131 Fixed

This commit is contained in:
shiraji
2017-03-11 00:55:37 +09:00
committed by Mikhail Glukhikh
parent d4500878cb
commit 27e1462b00
11 changed files with 128 additions and 2 deletions
@@ -40,11 +40,11 @@ object MakeVisibleFactory : KotlinIntentionActionsFactory() {
@Suppress("UNCHECKED_CAST")
val factory = diagnostic.factory as DiagnosticFactory3<*, DeclarationDescriptor, *, DeclarationDescriptor>
val descriptor = factory.cast(diagnostic).c as? DeclarationDescriptorWithVisibility ?: return emptyList()
val declaration = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor) as? KtModifierListOwner ?: return emptyList()
val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) as? KtModifierListOwner ?: return emptyList()
val module = DescriptorUtils.getContainingModule(descriptor)
val targetVisibilities = when (descriptor.visibility) {
PRIVATE -> if (module != usageModule) listOf(PUBLIC) else listOf(PUBLIC, INTERNAL)
PRIVATE, INVISIBLE_FAKE -> if (module != usageModule) listOf(PUBLIC) else listOf(PUBLIC, INTERNAL)
else -> listOf(PUBLIC)
}
@@ -0,0 +1,12 @@
// "Make 'doSth' internal" "true"
open class A {
private fun doSth() {
}
}
class B : A() {
fun bar() {
<caret>doSth()
}
}
@@ -0,0 +1,12 @@
// "Make 'doSth' internal" "true"
open class A {
internal fun doSth() {
}
}
class B : A() {
fun bar() {
doSth()
}
}
@@ -0,0 +1,12 @@
// "Make 'doSth' public" "true"
open class A {
private fun doSth() {
}
}
class B : A() {
fun bar() {
<caret>doSth()
}
}
@@ -0,0 +1,12 @@
// "Make 'doSth' public" "true"
open class A {
fun doSth() {
}
}
class B : A() {
fun bar() {
doSth()
}
}
@@ -0,0 +1,11 @@
// "Make 'foo' internal" "true"
open class A {
private val foo = 1
}
class B : A() {
fun bar() {
<caret>foo
}
}
@@ -0,0 +1,11 @@
// "Make 'foo' internal" "true"
open class A {
internal val foo = 1
}
class B : A() {
fun bar() {
foo
}
}
@@ -0,0 +1,11 @@
// "Make 'foo' public" "true"
open class A {
private val foo = 1
}
class B : A() {
fun bar() {
<caret>foo
}
}
@@ -0,0 +1,11 @@
// "Make 'foo' public" "true"
open class A {
val foo = 1
}
class B : A() {
fun bar() {
foo
}
}
@@ -1663,6 +1663,7 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/increaseVisibility/privateTopLevelVarWithSetterInFile.before.Main.kt");
doTestWithExtraFile(fileName);
}
}
@TestMetadata("idea/testData/quickfix/migration")
@@ -5815,6 +5815,39 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/increaseVisibility/protectedMemberToPublicSingleFile.kt");
doTest(fileName);
}
@TestMetadata("idea/testData/quickfix/increaseVisibility/invisibleFake")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class InvisibleFake extends AbstractQuickFixTest {
public void testAllFilesPresentInInvisibleFake() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/increaseVisibility/invisibleFake"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("methodToInternal.kt")
public void testMethodToInternal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/increaseVisibility/invisibleFake/methodToInternal.kt");
doTest(fileName);
}
@TestMetadata("methodToPublic.kt")
public void testMethodToPublic() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/increaseVisibility/invisibleFake/methodToPublic.kt");
doTest(fileName);
}
@TestMetadata("propertyToInternal.kt")
public void testPropertyToInternal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/increaseVisibility/invisibleFake/propertyToInternal.kt");
doTest(fileName);
}
@TestMetadata("propertyToPublic.kt")
public void testPropertyToPublic() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/increaseVisibility/invisibleFake/propertyToPublic.kt");
doTest(fileName);
}
}
}
@TestMetadata("idea/testData/quickfix/initializeWithConstructorParameter")