当前位置: 首页>>代码示例>>Java>>正文


Java PsiTestUtil.removeSourceRoot方法代码示例

本文整理汇总了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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DirectoryIndexTest.java

示例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"});
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:UpdateCacheTest.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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:DirectoryIndexTest.java


注:本文中的com.intellij.testFramework.PsiTestUtil.removeSourceRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。