Avoid conflicts when moving members wiith package-local visibility
Add tests for Java "Move members" refactoring #KT-4459 Fixed
This commit is contained in:
@@ -21,8 +21,11 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiClassOwner;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
@@ -33,7 +36,7 @@ import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class JetFile extends PsiFileBase implements JetDeclarationContainer, JetElement {
|
||||
public class JetFile extends PsiFileBase implements JetDeclarationContainer, JetElement, PsiClassOwner {
|
||||
|
||||
private final boolean isCompiled;
|
||||
|
||||
@@ -96,6 +99,7 @@ public class JetFile extends PsiFileBase implements JetDeclarationContainer, Jet
|
||||
return ast != null ? (JetPackageDirective) ast.getPsi() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getPackageName() {
|
||||
PsiJetFileStub stub = (PsiJetFileStub) getStub();
|
||||
@@ -107,6 +111,15 @@ public class JetFile extends PsiFileBase implements JetDeclarationContainer, Jet
|
||||
return directive != null ? directive.getQualifiedName() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiClass[] getClasses() {
|
||||
return PsiClass.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPackageName(String packageName) { }
|
||||
|
||||
@Nullable
|
||||
public JetScript getScript() {
|
||||
return PsiTreeUtil.getChildOfType(this, JetScript.class);
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class B {
|
||||
public static class C {
|
||||
|
||||
public static class X {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public class A {
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: B.C.X = B.C.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.C.X = B.C.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: C.X = C.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.C.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class B {
|
||||
public static class C {
|
||||
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class A {
|
||||
public static class <caret>X {
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "B.C"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
|
||||
public static class B {
|
||||
|
||||
public static class X {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.B.X = A.B.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
public static class <caret>X {
|
||||
|
||||
}
|
||||
|
||||
public static class B {
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "A.B"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
public static class X {
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
public static class <caret>X {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "B"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
static class X {
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
public static class <caret>X {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "B",
|
||||
"visibility": "packageLocal"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
public static class X {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class A {
|
||||
public static class <caret>X {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Class A.X is private and will not be accessible from file noImports.kt.
|
||||
Class A.X is private and will not be accessible from file noImports.kt.
|
||||
Class A.X is private and will not be accessible from file onDemandImport.kt.
|
||||
Class A.X is private and will not be accessible from file onDemandImport.kt.
|
||||
Class A.X is private and will not be accessible from file specificImport.kt.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "B",
|
||||
"visibility": "private"
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package j;
|
||||
|
||||
public class A {
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
public static class X {
|
||||
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.B
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package k
|
||||
|
||||
import j.A.*
|
||||
import j.B
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package k
|
||||
|
||||
import j.A
|
||||
import j.B
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: B.X = B.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package j;
|
||||
|
||||
public class A {
|
||||
public static class <caret>X {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package k
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: j.A.X = j.A.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: X = X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.*
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.A
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: A.X = A.X()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package k
|
||||
|
||||
import j.A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
val t: XX = XX()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "j/main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "j.B"
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
public class B {
|
||||
public static class C {
|
||||
|
||||
public static String X = "";
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public class A {
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
B.C.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
B.C.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.*
|
||||
|
||||
fun bar(s: String) {
|
||||
C.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.C.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class B {
|
||||
public static class C {
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
public class A {
|
||||
public static String <caret>X = "";
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
A.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.*
|
||||
|
||||
fun bar(s: String) {
|
||||
A.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "B.C"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
|
||||
public static class B {
|
||||
|
||||
public static String X = "";
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
A.B.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
B.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
public static String <caret>X = "";
|
||||
|
||||
public static class B {
|
||||
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
A.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "A.B"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
public static String X = "";
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
B.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
B.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
public static String <caret>X = "";
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
A.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"mainFile": "main.java",
|
||||
"type": "MOVE_MEMBERS",
|
||||
"targetClass": "B"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
static String X = "";
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun bar(s: String) {
|
||||
B.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import A.*
|
||||
|
||||
fun bar(s: String) {
|
||||
B.X = s
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import B.X as XX
|
||||
|
||||
fun bar(s: String) {
|
||||
XX = s
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
public static String <caret>X = "";
|
||||
}
|
||||
|
||||
public class B {
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user