use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class AdvHighlightingTest method testSameClassesInSourceAndLib.
public void testSameClassesInSourceAndLib() throws Exception {
String path = PathManagerEx.getTestDataPath() + BASE_PATH + "/" + getTestName(true);
VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(new File(path));
assert root != null : path;
loadAllModulesUnder(root);
configureByExistingFile(root.findFileByRelativePath("src/ppp/SomeClass.java"));
PsiField field = ((PsiJavaFile) myFile).getClasses()[0].findFieldByName("f", false);
assert field != null;
PsiClass aClass = ((PsiClassType) field.getType()).resolve();
assert aClass != null;
assertEquals("ppp.BadClass", aClass.getQualifiedName());
//lies in source
VirtualFile vFile1 = myFile.getVirtualFile();
VirtualFile vFile2 = aClass.getContainingFile().getVirtualFile();
assert vFile1 != null;
assert vFile2 != null;
assertEquals(vFile1.getParent(), vFile2.getParent());
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class EncapsulateFieldsTest method testMoveJavadocToGetter.
public void testMoveJavadocToGetter() throws Exception {
doTest((rootDir, rootAfter) -> {
final PsiClass aClass = myJavaFacade.findClass("A", GlobalSearchScope.projectScope(myProject));
assertNotNull("Tested class not found", aClass);
final PsiField field = aClass.findFieldByName("i", false);
assertNotNull(field);
doTest(aClass, null, true, true, field);
});
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class ExtractClassTest method testPublicVisibility.
public void testPublicVisibility() throws Exception {
doTest((rootDir, rootAfter) -> {
PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));
assertNotNull("Class Test not found", aClass);
final ArrayList<PsiMethod> methods = new ArrayList<>();
methods.add(aClass.findMethodsByName("foos", false)[0]);
final ArrayList<PsiField> fields = new ArrayList<>();
fields.add(aClass.findFieldByName("myT", false));
final ExtractClassProcessor processor = new ExtractClassProcessor(aClass, fields, methods, new ArrayList<>(), "", null, "Extracted", PsiModifier.PUBLIC, false, Collections.<MemberInfo>emptyList());
processor.run();
LocalFileSystem.getInstance().refresh(false);
FileDocumentManager.getInstance().saveAllDocuments();
});
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class ExtractClassTest method doTestField.
private void doTestField(final String conflicts, final boolean generateGettersSetters) throws Exception {
doTest((rootDir, rootAfter) -> {
PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));
assertNotNull("Class Test not found", aClass);
final ArrayList<PsiMethod> methods = new ArrayList<>();
final ArrayList<PsiField> fields = new ArrayList<>();
fields.add(aClass.findFieldByName("myT", false));
doTest(aClass, methods, fields, conflicts, generateGettersSetters);
});
}
use of com.intellij.psi.PsiField in project intellij-community by JetBrains.
the class ExtractClassTest method testPublicFieldDelegation.
public void testPublicFieldDelegation() throws Exception {
doTest((rootDir, rootAfter) -> {
PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(myProject));
assertNotNull("Class Test not found", aClass);
final ArrayList<PsiField> fields = new ArrayList<>();
fields.add(aClass.findFieldByName("myT", false));
ExtractClassProcessor processor = new ExtractClassProcessor(aClass, fields, new ArrayList<>(), new ArrayList<>(), "", "Extracted");
processor.run();
LocalFileSystem.getInstance().refresh(false);
FileDocumentManager.getInstance().saveAllDocuments();
});
}
Aggregations