mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NPE: process usages in non-java files (17195)
This commit is contained in:
+34
-1
@@ -9,13 +9,14 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.refactoring.memberPushDown.PushDownProcessor;
|
||||
import com.intellij.refactoring.util.DocCommentPolicy;
|
||||
import com.intellij.refactoring.util.classMembers.MemberInfo;
|
||||
|
||||
//push first method from class a.A to class b.B
|
||||
public class PushDownImportsTest extends MultiFileTestCase {
|
||||
public class PushDownMultifileTest extends MultiFileTestCase {
|
||||
protected String getTestRoot() {
|
||||
return "/refactoring/pushDown/";
|
||||
}
|
||||
@@ -79,4 +80,36 @@ public class PushDownImportsTest extends MultiFileTestCase {
|
||||
public void testStaticImportOfPushedMethod() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUsagesInXml() throws Exception {
|
||||
try {
|
||||
doTest(new PerformAction() {
|
||||
public void performAction(final VirtualFile rootDir, final VirtualFile rootAfter) throws Exception {
|
||||
final PsiClass srcClass = myJavaFacade.findClass("a.A");
|
||||
assertTrue("Source class not found", srcClass != null);
|
||||
|
||||
final PsiClass targetClass = myJavaFacade.findClass("b.B");
|
||||
assertTrue("Target class not found", targetClass != null);
|
||||
|
||||
final PsiField[] fields = srcClass.getFields();
|
||||
assertTrue("No methods found", fields.length > 0);
|
||||
final MemberInfo[] membersToMove = new MemberInfo[1];
|
||||
final MemberInfo memberInfo = new MemberInfo(fields[0]);
|
||||
memberInfo.setChecked(true);
|
||||
membersToMove[0] = memberInfo;
|
||||
|
||||
new PushDownProcessor(getProject(), membersToMove, srcClass, new DocCommentPolicy(DocCommentPolicy.ASIS)).run();
|
||||
|
||||
|
||||
//LocalFileSystem.getInstance().refresh(false);
|
||||
//FileDocumentManager.getInstance().saveAllDocuments();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
assertEquals(e.getMessage(), "Class <b><code>b.B</code></b> is package local and will not be accessible from file <b><code>A.form</code></b>.");
|
||||
return;
|
||||
}
|
||||
fail("Conflict was not detected");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user