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


Java PsiTestUtil.addContentRoot方法代码示例

本文整理汇总了Java中com.intellij.testFramework.PsiTestUtil.addContentRoot方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTestUtil.addContentRoot方法的具体用法?Java PsiTestUtil.addContentRoot怎么用?Java PsiTestUtil.addContentRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.testFramework.PsiTestUtil的用法示例。


在下文中一共展示了PsiTestUtil.addContentRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFileModuleExcludeRootUnderFileRoot

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testFileModuleExcludeRootUnderFileRoot() throws IOException {
  VirtualFile fileRoot = createChildData(myRootVFile, "fileRoot.txt");
  PsiTestUtil.addContentRoot(myModule, fileRoot);
  checkInfo(fileRoot, myModule, false, false, "", null);
  assertTrue(myFileIndex.isInContent(fileRoot));
  assertIteratedContent(myFileIndex, Arrays.asList(fileRoot), null);
  
  PsiTestUtil.addExcludedRoot(myModule, fileRoot);
  assertFalse(myFileIndex.isInContent(fileRoot));
  assertExcluded(fileRoot, myModule);
  assertIteratedContent(myFileIndex, null, Arrays.asList(fileRoot));
 
  // removing file exclude root
  PsiTestUtil.removeExcludedRoot(myModule, fileRoot);
  checkInfo(fileRoot, myModule, false, false, "", null);
  assertTrue(myFileIndex.isInContent(fileRoot));
  assertIteratedContent(myFileIndex, Arrays.asList(fileRoot), null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DirectoryIndexTest.java

示例2: createModule

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
protected void createModule(VirtualFile module1Content, boolean addSource) throws IOException {
  Module module = createEmptyModule();
  if (addSource) {
    PsiTestUtil.addSourceRoot(module, module1Content, true);
  }
  else {
    PsiTestUtil.addContentRoot(module, module1Content);
  }

  VirtualFile mockJUnit = findFile(MOCK_JUNIT);
  ModuleRootModificationUtil.addModuleLibrary(module, mockJUnit.getUrl());
  ModuleRootModificationUtil.setModuleSdk(module, ModuleRootManager.getInstance(myModule).getSdk());
  GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  VirtualFile testCase = mockJUnit.findFileByRelativePath("junit/framework/TestCase.java");
  assertNotNull(testCase);
  assertTrue(scope.contains(testCase));
  Module missingModule = createTempModule();
  addDependency(module, missingModule);
  ModuleManager.getInstance(myProject).disposeModule(missingModule);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:BaseConfigurationTestCase.java

示例3: testWorkForNonMavenProjects

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testWorkForNonMavenProjects() throws Throwable {
  Module m = createModule("module");
  PsiTestUtil.addContentRoot(m, myProjectRoot);

  createProjectPom("<groupId>test</groupId>" +
                   "<artifactId>project</artifactId>" +
                   "<version>1</version>" +

                   "<modules>" +
                   "  <module>m1</module>" +
                   "  <module>m2</module>" +
                   "</modules>" +

                   "<dependencies>" +
                   "  <dependency>" +
                   "    <groupId>xxx</groupId>" +
                   "    <artifactId>yyy</artifactId>" +
                   "    <version>zzz</version>" +
                   "  </dependency>" +
                   "</dependencies>");

  checkHighlighting(); // should not fail nor highlight errors
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:MavenNotManagedProjectInspectionsTest.java

示例4: testModulesWithSameSourceContentRoot

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testModulesWithSameSourceContentRoot() {
  // now our API allows this (ReformatCodeActionTest), although UI doesn't. Maybe API shouldn't allow it as well?
  PsiTestUtil.addContentRoot(myModule2, myModule1Dir);
  PsiTestUtil.addSourceRoot(myModule2, mySrcDir1);

  checkInfo(myModule1Dir, myModule, false, false, null, null);
  checkInfo(mySrcDir1, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule3, myModule);
  checkInfo(myTestSrc1, myModule, false, false, "", JavaSourceRootType.TEST_SOURCE, myModule3, myModule);
  checkInfo(myResDir, myModule, false, false, "", JavaResourceRootType.RESOURCE, myModule);

  checkInfo(mySrcDir2, myModule2, false, false, "", JavaSourceRootType.SOURCE, myModule2, myModule3);
  assertEquals(myModule2Dir, myIndex.getInfoForFile(mySrcDir2).getContentRoot());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:DirectoryIndexTest.java

示例5: testEnablingInspectionForNonMavenProjectsAfterImport

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testEnablingInspectionForNonMavenProjectsAfterImport() throws Throwable {
  if (ignore()) return;
  // can not reproduce in tests because of StartupManager.runWhenProjectIsInitialized
  // relies on ProjectManager.isProjectOpen. In tests the project is never being opened.
  
  ProjectManagerEx.getInstanceEx().openProject(myProject);
  UIUtil.dispatchAllInvocationEvents(); // startup activities

  Module m = createModule("module");
  PsiTestUtil.addContentRoot(m, myProjectRoot);

  createProjectPom("<groupId>test</groupId>" +
                   "<artifactId>project</artifactId>" +
                   "<version>1</version>" +

                   "<modules>" +
                   "  <module>m1</module>" +
                   "  <module>m2</module>" +
                   "</modules>" +

                   "<dependencies>" +
                   "  <dependency>" +
                   "    <groupId>xxx</groupId>" +
                   "    <artifactId>yyy</artifactId>" +
                   "    <version>zzz</version>" +
                   "  </dependency>" +
                   "</dependencies>");

  checkHighlighting(); // should not fail nor highlight errors
  
  importProject();

  checkHighlighting(); // should not fail nor highlight errors
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:MavenNotManagedProjectInspectionsTest.java

示例6: initContentRoot

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
private void initContentRoot() {
  try {
    File dir = createTempDirectory();
    root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
    PsiTestUtil.addContentRoot(myModule, root);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ManagingContentRootFoldersTest.java

示例7: testTest1

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testTest1() {
  final String rootPath = PathManagerEx.getTestDataPath() + "/moduleRootManager/roots/" + "test1";
  final VirtualFile[] rootFileBox = new VirtualFile[1];
  ApplicationManager.getApplication().runWriteAction(() -> {
    rootFileBox[0] =
    LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath.replace(File.separatorChar, '/'));
  });
  final VirtualFile rootFile = rootFileBox[0];
  final VirtualFile classesFile = rootFile.findChild("classes");
  assertNotNull(classesFile);
  final VirtualFile childOfContent = rootFile.findChild("x.txt");
  assertNotNull(childOfContent);
  final VirtualFile childOfClasses = classesFile.findChild("y.txt");
  assertNotNull(childOfClasses);

  final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule);


  PsiTestUtil.addContentRoot(myModule, rootFile);
  PsiTestUtil.setCompilerOutputPath(myModule, classesFile.getUrl(), false);
  PsiTestUtil.setExcludeCompileOutput(myModule, false);
  assertTrue(rootManager.getFileIndex().isInContent(childOfContent));
  assertTrue(rootManager.getFileIndex().isInContent(childOfClasses));

  PsiTestUtil.setExcludeCompileOutput(myModule, true);
  assertTrue(rootManager.getFileIndex().isInContent(childOfContent));
  assertFalse(rootManager.getFileIndex().isInContent(childOfClasses));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:RootsTest.java

示例8: testNonSourceContent

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testNonSourceContent() throws Exception {
  VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTempDirectory());
  PsiTestUtil.addContentRoot(myModule, root);

  createFile(myModule, root, "A.txt", "goo doo");

  FindModel findModel = FindManagerTestUtils.configureFindModel("goo");
  findModel.setProjectScope(false);
  findModel.setModuleName(myModule.getName());

  assertSize(1, findUsages(findModel));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:FindManagerTest.java

示例9: prepareProject

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void prepareProject(VirtualFile rootDir) {
  VirtualFile src = rootDir.findChild("src");
  if (src == null) {
    super.prepareProject(rootDir);
  }
  else {
    PsiTestUtil.addContentRoot(myModule, rootDir);
    PsiTestUtil.addSourceRoot(myModule, src);
  }
  VirtualFile gen = rootDir.findChild("gen");
  if (gen != null) {
    PsiTestUtil.addSourceRoot(myModule, gen, JavaSourceRootType.SOURCE, JpsJavaExtensionService.getInstance().createSourceRootProperties("", true));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:SafeDeleteTest.java

示例10: prepareProject

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
@Override
protected void prepareProject(VirtualFile rootDir) {
  PsiTestUtil.addContentRoot(myModule, rootDir);
  final VirtualFile[] children = rootDir.getChildren();
  for (VirtualFile child : children) {
    if (child.getName().startsWith("src")) {
      PsiTestUtil.addSourceRoot(myModule, child);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MovePackageAsDirectoryTest.java

示例11: testShouldNotFailOnAddingNewContentRootWithAPomFile

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testShouldNotFailOnAddingNewContentRootWithAPomFile() throws Exception {
  File newRootDir = new File(myDir, "newRoot");
  newRootDir.mkdirs();

  File pomFile = new File(newRootDir, "pom.xml");
  pomFile.createNewFile();

  VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(newRootDir);

  PsiTestUtil.addContentRoot(getModule("project"), root);  // should not throw an exception
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:WorkingWithOpenProjectTest.java

示例12: testExcludeModuleConfiguration

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExcludeModuleConfiguration() {
  final DisabledAutodetectionInfo state = new DisabledAutodetectionInfo();
  final VirtualFile dir = myTempFiles.createTempVDir();
  PsiTestUtil.addContentRoot(myModule, dir);
  final VirtualFile file = myTempFiles.createVFile(dir, "my-file", ".xml");
  state.getElements().add(new DisabledAutodetectionByTypeElement(FRAMEWORK_ID, myModule.getName()));
  getOldConfiguration().loadState(state);

  assertTrue(isFileExcluded(file));
  assertNull(getNewConfiguration().getState());
  assertOneElement(getOldConfiguration().getState().getElements());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ConvertingOldDetectionExcludesTest.java

示例13: testModuleContentUnderSourceRoot

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testModuleContentUnderSourceRoot() {
  PsiTestUtil.addContentRoot(myModule2, myPack1Dir);
  checkInfo(myPack1Dir, myModule2, false, false, null, null);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:DirectoryIndexTest.java

示例14: 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

示例15: testContentWrite

import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testContentWrite() throws Exception {
  File content = getTestRoot();
  File source = new File(content, "source");
  File testSource = new File(content, "testSource");
  File exclude = new File(content, "exclude");
  File classes = new File(content, "classes");
  File testClasses = new File(content, "testClasses");
  final VirtualFile contentFile = LocalFileSystem.getInstance().findFileByIoFile(content);
  assertNotNull(contentFile);
  final VirtualFile sourceFile = LocalFileSystem.getInstance().findFileByIoFile(source);
  assertNotNull(sourceFile);
  final VirtualFile testSourceFile = LocalFileSystem.getInstance().findFileByIoFile(testSource);
  assertNotNull(testSourceFile);
  final VirtualFile excludeFile = LocalFileSystem.getInstance().findFileByIoFile(exclude);

  assertNotNull(excludeFile);
  final VirtualFile classesFile = LocalFileSystem.getInstance().findFileByIoFile(classes);

  assertNotNull(classesFile);
  final VirtualFile testClassesFile = LocalFileSystem.getInstance().findFileByIoFile(testClasses);

  assertNotNull(testClassesFile);

  final File moduleFile = new File(content, "test.iml");
  final Module module = createModule(moduleFile);
  final ModuleRootManagerImpl moduleRootManager =
    (ModuleRootManagerImpl)ModuleRootManager.getInstance(module);

  PsiTestUtil.addContentRoot(module, contentFile);
  PsiTestUtil.addSourceRoot(module, sourceFile);
  PsiTestUtil.addSourceRoot(module, testSourceFile, true);
  ModuleRootModificationUtil.setModuleSdk(module, IdeaTestUtil.getMockJdk17());
  PsiTestUtil.addExcludedRoot(module, excludeFile);
  PsiTestUtil.setCompilerOutputPath(module, classesFile.getUrl(), false);
  PsiTestUtil.setCompilerOutputPath(module, testClassesFile.getUrl(), true);

  final Element element = new Element("root");
  moduleRootManager.getState().writeExternal(element);
  assertElementEquals(element,
                      "<root inherit-compiler-output=\"false\">" +
                      "<output url=\"file://$MODULE_DIR$/classes\" />" +
                      "<output-test url=\"file://$MODULE_DIR$/testClasses\" />" +
                      "<exclude-output />" +
                      "<content url=\"file://$MODULE_DIR$\">" +
                      "<sourceFolder url=\"file://$MODULE_DIR$/source\" isTestSource=\"false\" />" +
                      "<sourceFolder url=\"file://$MODULE_DIR$/testSource\" isTestSource=\"true\" />" +
                      "<excludeFolder url=\"file://$MODULE_DIR$/exclude\" />" +
                      "</content>" +
                      "<orderEntry type=\"jdk\" jdkName=\"java 1.7\" jdkType=\"JavaSDK\" />" +
                      "<orderEntry type=\"sourceFolder\" forTests=\"false\" />" +
                      "</root>",
                      module);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:ModuleRootsExternalizationTest.java


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