本文整理汇总了Java中com.intellij.testFramework.PsiTestUtil.removeSourceRoot方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTestUtil.removeSourceRoot方法的具体用法?Java PsiTestUtil.removeSourceRoot怎么用?Java PsiTestUtil.removeSourceRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.testFramework.PsiTestUtil
的用法示例。
在下文中一共展示了PsiTestUtil.removeSourceRoot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFileSourceRootsUnderDirContentRoot
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testFileSourceRootsUnderDirContentRoot() throws IOException {
VirtualFile fileSourceRoot = createChildData(myModule1Dir, "fileSourceRoot.txt");
assertTrue(myFileIndex.isInContent(fileSourceRoot));
assertFalse(myFileIndex.isInSource(fileSourceRoot));
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
assertTrue(myFileIndex.isInContent(fileSourceRoot));
assertTrue(myFileIndex.isInSource(fileSourceRoot));
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
// removing file source root
PsiTestUtil.removeSourceRoot(myModule, fileSourceRoot);
assertTrue(myFileIndex.isInContent(fileSourceRoot));
assertFalse(myFileIndex.isInSource(fileSourceRoot));
}
示例2: testRemoveSourceRoot
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testRemoveSourceRoot() {
final VirtualFile root = ModuleRootManager.getInstance(myModule).getContentRoots()[0];
PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to initialize caches
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
VirtualFile newFile = root.createChildData(null, "New.java");
VfsUtil.saveText(newFile, "class A{ Exception e;} //todo");
}
}.execute().throwException();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to update caches
VirtualFile[] sourceRoots = ModuleRootManager.getInstance(myModule).getSourceRoots();
LOG.assertTrue(sourceRoots.length == 1);
PsiTestUtil.removeSourceRoot(myModule, sourceRoots[0]);
PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
assertNotNull(exceptionClass);
// currently it actually finds usages by FQN due to Java PSI enabled for out-of-source java files
// so the following check is disabled
//checkUsages(exceptionClass, new String[]{});
checkTodos(new String[]{"2.java", "New.java"});
}
示例3: testFileContentAndSourceRoots
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testFileContentAndSourceRoots() throws IOException {
VirtualFile fileRoot = createChildData(myRootVFile, "fileRoot.txt");
VirtualFile fileSourceRoot = createChildData(myRootVFile, "fileSourceRoot.txt");
VirtualFile fileTestSourceRoot = createChildData(myRootVFile, "fileTestSourceRoot.txt");
assertNotInProject(fileRoot);
assertFalse(myFileIndex.isInContent(fileRoot));
assertIteratedContent(myFileIndex, null, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot));
ContentEntry contentEntry = PsiTestUtil.addContentRoot(myModule, fileRoot);
assertEquals(fileRoot, contentEntry.getFile());
checkInfo(fileRoot, myModule, false, false, "", null);
assertTrue(myFileIndex.isInContent(fileRoot));
assertFalse(myFileIndex.isInSource(fileRoot));
PsiTestUtil.addContentRoot(myModule, fileSourceRoot);
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
assertTrue(myFileIndex.isInContent(fileSourceRoot));
assertTrue(myFileIndex.isInSource(fileSourceRoot));
PsiTestUtil.addContentRoot(myModule, fileTestSourceRoot);
PsiTestUtil.addSourceRoot(myModule, fileTestSourceRoot, true);
checkInfo(fileTestSourceRoot, myModule, false, false, "", JavaSourceRootType.TEST_SOURCE, myModule);
assertTrue(myFileIndex.isInContent(fileTestSourceRoot));
assertTrue(myFileIndex.isInSource(fileTestSourceRoot));
assertIteratedContent(myFileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
// removing file source root
PsiTestUtil.removeSourceRoot(myModule, fileTestSourceRoot);
checkInfo(fileTestSourceRoot, myModule, false, false, "", null);
assertTrue(myFileIndex.isInContent(fileTestSourceRoot));
assertFalse(myFileIndex.isInSource(fileTestSourceRoot));
assertIteratedContent(myFileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
// removing file content root
PsiTestUtil.removeContentEntry(myModule, contentEntry.getFile());
assertNotInProject(fileRoot);
assertFalse(myFileIndex.isInContent(fileRoot));
assertFalse(myFileIndex.isInSource(fileRoot));
assertIteratedContent(myFileIndex, Arrays.asList(fileSourceRoot, fileTestSourceRoot), Arrays.asList(fileRoot));
}