本文整理汇总了Java中com.intellij.testFramework.PsiTestUtil.addSourceContentToRoots方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTestUtil.addSourceContentToRoots方法的具体用法?Java PsiTestUtil.addSourceContentToRoots怎么用?Java PsiTestUtil.addSourceContentToRoots使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.testFramework.PsiTestUtil
的用法示例。
在下文中一共展示了PsiTestUtil.addSourceContentToRoots方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testModuleTwiceInDependents
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testModuleTwiceInDependents() throws IOException {
Module m = createModule("m.iml", StdModuleTypes.JAVA);
Module a = createModule("a.iml", StdModuleTypes.JAVA);
Module b = createModule("b.iml", StdModuleTypes.JAVA);
Module c = createModule("c.iml", StdModuleTypes.JAVA);
ModuleRootModificationUtil.addDependency(a, m, DependencyScope.COMPILE, false);
ModuleRootModificationUtil.addDependency(b, m, DependencyScope.COMPILE, true);
ModuleRootModificationUtil.addDependency(a, b, DependencyScope.COMPILE, true);
ModuleRootModificationUtil.addDependency(c, a, DependencyScope.COMPILE, true);
VirtualFile root = myFixture.findOrCreateDir("c");
PsiTestUtil.addSourceContentToRoots(c, root);
VirtualFile file = root.createChildData(this, "x.txt");
GlobalSearchScope deps = m.getModuleWithDependentsScope();
assertTrue(deps.contains(file));
}
示例2: testLocalScopeSearchPerformance
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testLocalScopeSearchPerformance() throws Exception {
final int fileCount = 3000;
final int lineCount = 500;
TempDirTestFixture fixture = new LightTempDirTestFixtureImpl();
fixture.setUp();
try {
String sampleText = StringUtil.repeat("zoo TargetWord foo bar goo\n", lineCount);
for (int i = 0; i < fileCount; i++) {
fixture.createFile("a" + i + ".txt", sampleText);
}
PsiTestUtil.addSourceContentToRoots(myModule, fixture.getFile(""));
VirtualFile file = fixture.createFile("target.txt", sampleText);
PsiFile psiFile = PsiManager.getInstance(myProject).findFile(file);
assertNotNull(psiFile);
final FindModel findModel = new FindModel();
findModel.setStringToFind("TargetWord");
findModel.setWholeWordsOnly(true);
findModel.setFromCursor(false);
findModel.setGlobal(true);
findModel.setMultipleFiles(true);
findModel.setCustomScope(true);
ThrowableRunnable test = () -> assertSize(lineCount, findUsages(findModel));
findModel.setCustomScope(GlobalSearchScope.fileScope(psiFile));
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
findModel.setCustomScope(new LocalSearchScope(psiFile));
PlatformTestUtil.startPerformanceTest("slow", 400, test).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
}
finally {
fixture.tearDown();
}
}
示例3: doTest
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void doTest(final String targetDirName, final Computable<PsiElement> source, final boolean expected) throws Exception {
String testName = getTestName(true);
String root = getTestDataPath() + getTestRoot() + testName;
VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, root, myFilesToDelete, false);
PsiTestUtil.addSourceContentToRoots(myModule, rootDir);
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final VirtualFile child1 = rootDir.findChild(targetDirName);
assertNotNull("File " + targetDirName + " not found", child1);
final PsiDirectory targetDirectory = myPsiManager.findDirectory(child1);
assertEquals(expected, MoveHandler.isMoveRedundant(source.compute(), targetDirectory));
}
示例4: prepareProject
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
protected void prepareProject(VirtualFile rootDir) {
PsiTestUtil.addSourceContentToRoots(myModule, rootDir);
}
示例5: addSourceRoot
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
protected VirtualFile addSourceRoot(Module module, boolean testSource) throws IOException {
final VirtualFile root = getVirtualFile(createTempDir(module.getName() + (testSource ? "Test" : "Prod") + "Src"));
PsiTestUtil.addSourceContentToRoots(module, root, testSource);
return root;
}