use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.
the class ProjectViewUpdatingTest method testShowClassMembers.
public void testShowClassMembers() throws Exception {
getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
final AbstractProjectViewPSIPane pane = myStructure.createPane();
final JTree tree = pane.getTree();
PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: showClassMembers\n" + getRootFiles() + " +External Libraries\n");
myStructure.setShowMembers(true);
PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
PsiClass aClass = classFile.getClasses()[0];
PsiFile containingFile = aClass.getContainingFile();
pane.select(aClass, containingFile.getVirtualFile(), true);
PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " -[Class1]\n" + " +InnerClass\n" + " getValue():int\n" + " myField1:boolean\n" + " myField2:boolean\n" + " +Class2\n" + getRootFiles() + " +External Libraries\n", true);
final Document document = FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile());
final int caretPosition = document.getText().indexOf("public class InnerClass") - 1;
ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(myProject, () -> document.insertString(caretPosition, "\n"), "typing", null));
PsiDocumentManager.getInstance(myProject).commitDocument(document);
PlatformTestUtil.waitForAlarm(600);
PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " -[Class1]\n" + " +InnerClass\n" + " getValue():int\n" + " myField1:boolean\n" + " myField2:boolean\n" + " +Class2\n" + getRootFiles() + " +External Libraries\n", true);
classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
aClass = classFile.getClasses()[0];
final PsiField lastField = aClass.getFields()[1];
pane.select(lastField, containingFile.getVirtualFile(), true);
PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " -Class1\n" + " +InnerClass\n" + " getValue():int\n" + " myField1:boolean\n" + " [myField2:boolean]\n" + " +Class2\n" + getRootFiles() + " +External Libraries\n", true);
CommandProcessor.getInstance().executeCommand(myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
try {
assertEquals("myField2", lastField.getName());
lastField.setName("_firstField");
} catch (IncorrectOperationException e) {
fail(e.getMessage());
}
}), null, null);
PlatformTestUtil.waitForAlarm(600);
PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " -Class1\n" + " +InnerClass\n" + " getValue():int\n" + " [_firstField:boolean]\n" + " myField1:boolean\n" + " +Class2\n" + getRootFiles() + " +External Libraries\n", true);
}
use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.
the class ProjectViewUpdatingTest method testAnnoyingScrolling.
public void testAnnoyingScrolling() throws Exception {
getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject));
final AbstractProjectViewPSIPane pane = myStructure.createPane();
final JTree tree = pane.getTree();
myStructure.setShowMembers(true);
PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Class1.java");
PsiClass aClass = classFile.getClasses()[0];
PsiFile containingFile = aClass.getContainingFile();
PsiDirectory directory = containingFile.getContainingDirectory();
pane.select(aClass, containingFile.getVirtualFile(), true);
Point viewPosition = ((JViewport) tree.getParent()).getViewPosition();
for (int i = 0; i < 100; i++) {
JavaDirectoryService.getInstance().createClass(directory, "A" + i);
}
PlatformTestUtil.waitForAlarm(600);
Point viewPositionAfter = ((JViewport) tree.getParent()).getViewPosition();
assertEquals(viewPosition, viewPositionAfter);
}
use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.
the class ProjectViewUpdatingTest method testUpdateProjectView.
public void testUpdateProjectView() throws Exception {
getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
final AbstractProjectViewPSIPane pane = myStructure.createPane();
final JTree tree = pane.getTree();
PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: updateProjectView\n" + getRootFiles() + " +External Libraries\n");
final PsiJavaFile classFile = (PsiJavaFile) getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1").findFile("Form1.java");
final PsiClass aClass = classFile.getClasses()[0];
final PsiFile containingFile = aClass.getContainingFile();
pane.select(aClass, containingFile.getVirtualFile(), true);
PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: updateProjectView\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " Class1\n" + " +Class2.java\n" + " Class4.java\n" + " Form2.form\n" + " -Form:Form1\n" + " [Form1]\n" + " Form1.form\n" + getRootFiles() + " +External Libraries\n", true);
CommandProcessor.getInstance().executeCommand(myProject, () -> new RenameProcessor(myProject, aClass, "Form1_renamed", false, false).run(), null, null);
PlatformTestUtil.waitForAlarm(600);
PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " -PsiDirectory: updateProjectView\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " Class1\n" + " +Class2.java\n" + " Class4.java\n" + " Form2.form\n" + " -Form:Form1_renamed\n" + " Form1.form\n" + " [Form1_renamed]\n" + getRootFiles() + " +External Libraries\n", true);
TreeUtil.collapseAll(pane.getTree(), -1);
PlatformTestUtil.assertTreeEqual(tree, "-Project\n" + " +PsiDirectory: updateProjectView\n" + getRootFiles() + " +External Libraries\n");
final PsiClass aClass2 = JavaDirectoryService.getInstance().createClass(getContentDirectory().findSubdirectory("src").findSubdirectory("com").findSubdirectory("package1"), "Class6");
PlatformTestUtil.waitForAlarm(600);
final PsiFile containingFile2 = aClass2.getContainingFile();
pane.select(aClass2, containingFile2.getVirtualFile(), true);
PlatformTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: updateProjectView\n" + " -PsiDirectory: src\n" + " -PsiDirectory: com\n" + " -PsiDirectory: package1\n" + " Class1\n" + " +Class2.java\n" + " Class4.java\n" + " [Class6]\n" + " Form2.form\n" + " +Form:Form1_renamed\n" + getRootFiles() + " +External Libraries\n", true);
}
use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.
the class FormMergerTreeStructureProviderTest method testStandardProvidersForm1.
public void testStandardProvidersForm1() {
final AbstractProjectViewPSIPane pane = myStructure.createPane();
getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" + " PsiClass:Class1\n" + " PsiJavaFile:Class2.java\n" + " PsiClass:Class2\n" + " PsiClass:Class3\n" + " PsiJavaFile:Class4.java\n" + " PsiFile(plain text):Form2.form\n" + " Form:Form1\n" + " PsiClass:Form1\n" + " PsiFile(plain text):Form1.form\n");
PsiFile psiFile = getPackageDirectory().findFile("Form1.form");
VirtualFile virtualFile = psiFile.getContainingFile().getVirtualFile();
myStructure.checkNavigateFromSourceBehaviour(psiFile, virtualFile, pane);
}
use of com.intellij.ide.projectView.impl.ClassesTreeStructureProvider in project intellij-community by JetBrains.
the class FormMergerTreeStructureProviderTest method testStandardProviders.
public void testStandardProviders() {
final AbstractProjectViewPSIPane pane = myStructure.createPane();
getProjectTreeStructure().setProviders(new ClassesTreeStructureProvider(myProject), new FormMergerTreeStructureProvider(myProject));
assertStructureEqual(getPackageDirectory(), "PsiDirectory: package1\n" + " PsiClass:Class1\n" + " PsiJavaFile:Class2.java\n" + " PsiClass:Class2\n" + " PsiClass:Class3\n" + " PsiJavaFile:Class4.java\n" + " PsiFile(plain text):Form2.form\n" + " Form:Form1\n" + " PsiClass:Form1\n" + " PsiFile(plain text):Form1.form\n");
PsiClass psiClass = ((PsiJavaFile) getPackageDirectory().findFile("Form1.java")).getClasses()[0];
myStructure.checkNavigateFromSourceBehaviour(psiClass, psiClass.getContainingFile().getVirtualFile(), pane);
}
Aggregations