本文整理汇总了Java中com.intellij.testFramework.PsiTestUtil.createTestProjectStructure方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTestUtil.createTestProjectStructure方法的具体用法?Java PsiTestUtil.createTestProjectStructure怎么用?Java PsiTestUtil.createTestProjectStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.testFramework.PsiTestUtil
的用法示例。
在下文中一共展示了PsiTestUtil.createTestProjectStructure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpProject
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUpProject() throws Exception {
final String root = PathManagerEx.getTestDataPath() + BASE_PATH;
VirtualFile tempProjectRootDir =
PsiTestUtil.createTestProjectStructure(getTestName(true), null, FileUtil.toSystemIndependentName(root), myFilesToDelete, false);
VirtualFile projectFile = tempProjectRootDir.findChild("orderEntry.ipr");
myProject = ProjectManagerEx.getInstanceEx().loadProject(projectFile.getPath());
ProjectManagerEx.getInstanceEx().openTestProject(myProject);
UIUtil.dispatchAllInvocationEvents(); // startup activities
setUpJdk();
myModule = ModuleManager.getInstance(getProject()).getModules()[0];
}
示例2: testMultipleFiles
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testMultipleFiles() throws Exception {
String rootBefore = getRoot();
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
final VirtualFile first = root.findFileByRelativePath("from/1.txt");
assertNotNull(first);
final VirtualFile second = root.findFileByRelativePath("from/2.txt");
assertNotNull(second);
final PsiFile firstPsi = myPsiManager.findFile(first);
final PsiFile secondPsi = myPsiManager.findFile(second);
assertTrue(CopyHandler.canCopy(new PsiElement[]{firstPsi, secondPsi}));
final VirtualFile toDir = root.findChild("to");
assertNotNull(toDir);
final PsiDirectory targetDirectory = myPsiManager.findDirectory(toDir);
CopyHandler.doCopy(new PsiElement[]{firstPsi, secondPsi}, targetDirectory);
assertNotNull(root.findFileByRelativePath("to/1.txt"));
assertNotNull(root.findFileByRelativePath("to/2.txt"));
}
示例3: doTest
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void doTest(String className) throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass classToInline = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage(classToInline));
InlineToAnonymousClassProcessor processor = new InlineToAnonymousClassProcessor(myProject,
classToInline,
null, false, false, false);
UsageInfo[] usages = processor.findUsages();
MultiMap<PsiElement,String> conflicts = processor.getConflicts(usages);
assertEquals(0, conflicts.size());
processor.run();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
示例4: doPackageCopy
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void doPackageCopy() throws Exception {
String root = JavaTestUtil.getJavaTestDataPath() + "/refactoring/copyClass/multifile/" + getTestName(true);
String rootBefore = root + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
final VirtualFile targetVDir = rootDir.findChild("p2");
final PsiDirectory sourceP1Dir = myPsiManager.findDirectory(rootDir.findChild("p1"));
final PsiDirectory targetP2Dir = myPsiManager.findDirectory(targetVDir);
new CopyClassesHandler().doCopy(new PsiElement[]{sourceP1Dir}, targetP2Dir);
String rootAfter = root + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
示例5: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
String root = JavaTestUtil.getJavaTestDataPath() + "/dependencies/cycle/" + getTestName(true);
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例6: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
String root = PluginPathManager.getPluginHomePath("ui-designer") + "/testData/binding/" + getTestName(true);
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
myTestProjectRoot = PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例7: testAnonymClass
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testAnonymClass() throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk14());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass psiClass = myJavaFacade.findClass("Test", ProjectScope.getAllScope(myProject));
assertNotNull(psiClass);
final PsiField[] fields = psiClass.getFields();
assertTrue(fields.length == 1);
final PsiExpression initializer = fields[0].getInitializer();
assertNotNull(initializer);
assertInstanceOf(initializer, PsiNewExpression.class);
final PsiAnonymousClass anonymousClass = ((PsiNewExpression)initializer).getAnonymousClass();
assertNotNull(anonymousClass);
final ArrayList<MemberInfo> infos = new ArrayList<>();
MemberInfo.extractClassMembers(anonymousClass, infos, member -> true, false);
for (MemberInfo info : infos) {
info.setChecked(true);
}
new WriteCommandAction.Simple(myProject) {
@Override
protected void run() throws Throwable {
ExtractSuperClassUtil
.extractSuperClass(myProject, psiClass.getContainingFile().getContainingDirectory(), "TestSubclass", anonymousClass,
infos.toArray(new MemberInfo[infos.size()]), new DocCommentPolicy(DocCommentPolicy.ASIS));
}
}.execute();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
IdeaTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
示例8: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_5);
String root = PathManagerEx.getTestDataPath() + "/psi/repositoryUse/src";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例9: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_5);
String root = PathManagerEx.getTestDataPath() + "/psi/repositoryUse/src15";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17("mock 1.5"));
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例10: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
String root = JavaTestUtil.getJavaTestDataPath() + "/psi/search/findUsages/" + getTestName(true);
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例11: doTest
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void doTest(@NonNls final String className,
@NonNls final String newClassName,
String[] conflicts,
String targetPackageName,
RefactoringTestUtil.MemberDescriptor... membersToFind) throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk14());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass psiClass = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
assertNotNull(psiClass);
final MemberInfo[] members = RefactoringTestUtil.findMembers(psiClass, membersToFind);
doTest(members, newClassName, targetPackageName, rootDir, psiClass, conflicts);
}
示例12: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
String root = JavaTestUtil.getJavaTestDataPath() + "/psi/search/findUsages15/" + getTestName(true);
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17("java 1.5"));
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例13: doTest
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void doTest(@NonNls String testName, @NonNls String[] classNames, @NonNls String newPackageName) throws Exception{
String root = JavaTestUtil.getJavaTestDataPath() + "/refactoring/moveClass/" + testName;
String rootBefore = root + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
performAction(classNames, newPackageName);
String rootAfter = root + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
示例14: setUp
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
String root = JavaTestUtil.getJavaTestDataPath() + "/dependencies/search/" + getTestName(true);
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete);
}
示例15: test
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void test() throws Exception {
VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, myFilesToDelete);
PsiDirectory dir = myPsiManager.findDirectory(root);
assertNotNull(dir);
PsiFile file = dir.createFile("AAA.java");
PsiClass aClass = myJavaFacade.getElementFactory().createClass("AAA");
file.add(aClass);
PsiTestUtil.checkFileStructure(file);
}