本文整理汇总了Java中com.intellij.testFramework.PsiTestUtil.addExcludedRoot方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTestUtil.addExcludedRoot方法的具体用法?Java PsiTestUtil.addExcludedRoot怎么用?Java PsiTestUtil.addExcludedRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.testFramework.PsiTestUtil
的用法示例。
在下文中一共展示了PsiTestUtil.addExcludedRoot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExcludesShouldBeRecognizedRightOnRefresh
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExcludesShouldBeRecognizedRightOnRefresh() throws Exception {
final VirtualFile dir = createChildDirectory(myModule1Dir, "dir");
final VirtualFile excluded = createChildDirectory(dir, "excluded");
PsiTestUtil.addExcludedRoot(myModule, excluded);
delete(dir);
boolean created = new File(myModule1Dir.getPath(), "dir/excluded/foo").mkdirs();
assertTrue(created);
VirtualFileListener l = new VirtualFileAdapter() {
@Override
public void fileCreated(@NotNull VirtualFileEvent e) {
assertEquals("dir", e.getFileName());
VirtualFile file = e.getFile();
assertInProject(file);
assertExcluded(file.findFileByRelativePath("excluded"), myModule);
assertExcluded(file.findFileByRelativePath("excluded/foo"), myModule);
}
};
VirtualFileManager.getInstance().addVirtualFileListener(l, getTestRootDisposable());
VirtualFileManager.getInstance().syncRefresh();
}
示例2: testFileModuleExcludeRootUnderDirectoryRoot
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testFileModuleExcludeRootUnderDirectoryRoot() throws IOException {
VirtualFile fileExcludeRoot = createChildData(mySrcDir1, "fileExcludeRoot.txt");
assertTrue(myFileIndex.isInContent(fileExcludeRoot));
assertTrue(myFileIndex.isInSource(fileExcludeRoot));
assertIteratedContent(myFileIndex, Arrays.asList(fileExcludeRoot), null);
PsiTestUtil.addExcludedRoot(myModule, fileExcludeRoot);
assertFalse(myFileIndex.isInContent(fileExcludeRoot));
assertFalse(myFileIndex.isInSource(fileExcludeRoot));
assertNull(myFileIndex.getContentRootForFile(fileExcludeRoot));
assertEquals(myModule1Dir, myFileIndex.getContentRootForFile(fileExcludeRoot, false));
assertNull(myFileIndex.getModuleForFile(fileExcludeRoot));
assertEquals(myModule, myFileIndex.getModuleForFile(fileExcludeRoot, false));
assertExcluded(fileExcludeRoot, myModule);
assertIteratedContent(myFileIndex, null, Arrays.asList(fileExcludeRoot));
// removing file exclude root
PsiTestUtil.removeExcludedRoot(myModule, fileExcludeRoot);
assertTrue(myFileIndex.isInContent(fileExcludeRoot));
assertTrue(myFileIndex.isInSource(fileExcludeRoot));
assertIteratedContent(myFileIndex, Arrays.asList(fileExcludeRoot), null);
}
示例3: 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);
}
示例4: testAddExcludeRoot
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testAddExcludeRoot() throws Exception{
PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to initialize caches
ProjectRootManagerEx rootManager = (ProjectRootManagerEx)ProjectRootManager.getInstance(myProject);
final VirtualFile root = rootManager.getContentRoots()[0];
final VirtualFile dir = root.findChild("aDir");
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
VirtualFile newFile = dir.createChildData(null, "New.java");
VfsUtil.saveText(newFile, "class A{ Exception e;} //todo");
}
}.execute().throwException();
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
PsiTestUtil.addExcludedRoot(myModule, dir);
PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception",GlobalSearchScope.allScope(getProject()));
assertNotNull(exceptionClass);
checkUsages(exceptionClass, new String[]{"1.java"});
checkTodos(new String[]{});
}
示例5: testSCR6066
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testSCR6066() throws Exception{
ProjectRootManagerEx rootManager = (ProjectRootManagerEx)ProjectRootManager.getInstance(myProject);
final VirtualFile root = rootManager.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
PsiTestUtil.addExcludedRoot(myModule, root);
PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
assertNotNull(exceptionClass);
checkUsages(exceptionClass, new String[]{});
checkTodos(new String[]{});
}
示例6: testRemoveExcludeRoot
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testRemoveExcludeRoot() throws Exception{
ProjectRootManagerEx rootManager = (ProjectRootManagerEx)ProjectRootManager.getInstance(myProject);
final VirtualFile root = rootManager.getContentRoots()[0];
final VirtualFile dir = root.findChild("aDir");
PsiTestUtil.addExcludedRoot(myModule, dir);
PsiTodoSearchHelper.SERVICE.getInstance(myProject).findFilesWithTodoItems(); // to initialize caches
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
VirtualFile newFile = dir.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
PsiTestUtil.removeExcludedRoot(myModule, dir);
PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject()));
assertNotNull(exceptionClass);
checkUsages(exceptionClass, new String[]{"1.java", "2.java", "New.java"});
checkTodos(new String[]{"2.java", "New.java"});
}
示例7: testFindInExcludedDirectory
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testFindInExcludedDirectory() throws Exception {
VirtualFile root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTempDirectory());
addSourceContentToRoots(myModule, root);
VirtualFile excluded = createChildDirectory(root, "excluded");
createFile(myModule, excluded, "a.txt", "foo bar foo");
PsiTestUtil.addExcludedRoot(myModule, excluded);
FindModel findModel = FindManagerTestUtils.configureFindModel("foo");
findModel.setWholeWordsOnly(true);
findModel.setProjectScope(false);
findModel.setDirectoryName(excluded.getPath());
assertSize(2, findUsages(findModel));
}
示例8: testExcludedFolder
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExcludedFolder() throws IOException {
VirtualFile excluded = createChildDirectory(myContentRoot, "exc");
PsiTestUtil.addExcludedRoot(myModule, excluded);
getChangeListManager().convertExcludedToIgnored();
assertFalse(getChangeListManager().isIgnoredFile(myContentRoot));
assertTrue(getChangeListManager().isIgnoredFile(excluded));
assertIgnored(excluded);
}
示例9: testModuleOutputUnderExcluded
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testModuleOutputUnderExcluded() throws IOException {
VirtualFile excluded = createChildDirectory(myContentRoot, "target");
PsiTestUtil.addExcludedRoot(myModule, excluded);
VirtualFile moduleOutput = createChildDirectory(excluded, "classes");
PsiTestUtil.setCompilerOutputPath(myModule, moduleOutput.getUrl(), false);
getChangeListManager().convertExcludedToIgnored();
assertTrue(getChangeListManager().isIgnoredFile(excluded));
assertTrue(getChangeListManager().isIgnoredFile(moduleOutput));
assertIgnored(excluded);
}
示例10: testDoNotIgnoreInnerModuleExplicitlyMarkedAsExcludedFromOuterModule
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testDoNotIgnoreInnerModuleExplicitlyMarkedAsExcludedFromOuterModule() throws IOException {
VirtualFile inner = createChildDirectory(myContentRoot, "inner");
PsiTestUtil.addModule(myProject, ModuleType.EMPTY, "inner", inner);
PsiTestUtil.addExcludedRoot(myModule, inner);
getChangeListManager().convertExcludedToIgnored();
assertFalse(getChangeListManager().isIgnoredFile(inner));
}
示例11: testExcludedTopLevelPackage
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExcludedTopLevelPackage() {
myFixture.copyDirectoryToProject(getTestName(true), "");
myFixture.configureByFile("a.py");
PsiTestUtil.addExcludedRoot(myFixture.getModule(), myFixture.findFileInTempDir("pkg1"));
final LookupElement[] variants = myFixture.completeBasic();
assertNotNull(variants);
assertEmpty(variants);
}
示例12: testExcludedSubPackage
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExcludedSubPackage() {
myFixture.copyDirectoryToProject(getTestName(true), "");
myFixture.configureByFile("a.py");
PsiTestUtil.addExcludedRoot(myFixture.getModule(), myFixture.findFileInTempDir("pkg1/subpkg1"));
final LookupElement[] variants = myFixture.completeBasic();
assertNotNull(variants);
assertEmpty(variants);
}
示例13: testExplicitExcludeOfInner
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExplicitExcludeOfInner() throws Exception {
PsiTestUtil.addExcludedRoot(myModule, myModule2Dir);
checkInfo(myModule2Dir, myModule2, false, false, null, null);
checkInfo(mySrcDir2, myModule2, false, false, "", JavaSourceRootType.SOURCE, myModule2, myModule3);
}
示例14: testExcludedDirShouldBeExcludedRightAfterItsCreation
import com.intellij.testFramework.PsiTestUtil; //导入方法依赖的package包/类
public void testExcludedDirShouldBeExcludedRightAfterItsCreation() throws Exception {
VirtualFile excluded = createChildDirectory(myModule1Dir, "excluded");
VirtualFile projectOutput = createChildDirectory(myModule1Dir, "projectOutput");
VirtualFile module2Output = createChildDirectory(myModule1Dir, "module2Output");
VirtualFile module2TestOutput = createChildDirectory(myModule2Dir, "module2TestOutput");
assertInProject(excluded);
assertInProject(projectOutput);
assertInProject(module2Output);
assertInProject(module2TestOutput);
getCompilerProjectExtension().setCompilerOutputUrl(projectOutput.getUrl());
PsiTestUtil.addExcludedRoot(myModule, excluded);
PsiTestUtil.setCompilerOutputPath(myModule2, module2Output.getUrl(), false);
PsiTestUtil.setCompilerOutputPath(myModule2, module2TestOutput.getUrl(), true);
PsiTestUtil.setExcludeCompileOutput(myModule2, true);
assertExcluded(excluded, myModule);
assertExcluded(projectOutput, myModule);
assertExcluded(module2Output, myModule);
assertExcluded(module2TestOutput, myModule2);
delete(excluded);
delete(projectOutput);
delete(module2Output);
delete(module2TestOutput);
final List<VirtualFile> created = new ArrayList<VirtualFile>();
VirtualFileListener l = new VirtualFileAdapter() {
@Override
public void fileCreated(@NotNull VirtualFileEvent e) {
VirtualFile file = e.getFile();
String fileName = e.getFileName();
assertExcluded(file, fileName.contains("module2TestOutput") ? myModule2 : myModule);
created.add(file);
}
};
VirtualFileManager.getInstance().addVirtualFileListener(l, getTestRootDisposable());
excluded = createChildDirectory(myModule1Dir, excluded.getName());
assertExcluded(excluded, myModule);
projectOutput = createChildDirectory(myModule1Dir, projectOutput.getName());
assertExcluded(projectOutput, myModule);
module2Output = createChildDirectory(myModule1Dir, module2Output.getName());
assertExcluded(module2Output, myModule);
module2TestOutput = createChildDirectory(myModule2Dir, module2TestOutput.getName());
assertExcluded(module2TestOutput, myModule2);
assertEquals(created.toString(), 4, created.size());
}
示例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);
}