本文整理汇总了Java中com.intellij.openapi.module.StdModuleTypes类的典型用法代码示例。如果您正苦于以下问题:Java StdModuleTypes类的具体用法?Java StdModuleTypes怎么用?Java StdModuleTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StdModuleTypes类属于com.intellij.openapi.module包,在下文中一共展示了StdModuleTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testModuleUnderIgnoredDir
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testModuleUnderIgnoredDir() throws IOException {
final VirtualFile ignored = createChildDirectory(myRootVFile, "RCS");
assertTrue(FileTypeManager.getInstance().isFileIgnored(ignored));
assertTrue(myFileIndex.isExcluded(ignored));
assertTrue(myFileIndex.isUnderIgnored(ignored));
final VirtualFile module4 = createChildDirectory(ignored, "module4");
assertFalse(FileTypeManager.getInstance().isFileIgnored(module4));
assertTrue(myFileIndex.isExcluded(module4));
assertTrue(myFileIndex.isUnderIgnored(module4));
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
Module module = moduleManager.newModule(myRootVFile.getPath() + "/newModule.iml", StdModuleTypes.JAVA.getId());
PsiTestUtil.addContentRoot(module, module4);
assertNotInProject(ignored);
checkInfo(module4, module, false, false, null, null);
}
}.execute().throwException();
}
示例2: testModuleInIgnoredDir
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testModuleInIgnoredDir() throws IOException {
final VirtualFile ignored = createChildDirectory(myRootVFile, "RCS");
assertTrue(FileTypeManager.getInstance().isFileIgnored(ignored));
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
ModifiableModuleModel model = moduleManager.getModifiableModel();
model.disposeModule(myModule);
model.disposeModule(myModule2);
model.disposeModule(myModule3);
model.commit();
Module module = moduleManager.newModule(myRootVFile.getPath() + "/newModule.iml", StdModuleTypes.JAVA.getId());
PsiTestUtil.addContentRoot(module, ignored);
checkInfo(ignored, module, false, false, null, null);
}
}.execute().throwException();
}
示例3: testBasics
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testBasics() throws Exception {
Module moduleA = createModule("a.iml", StdModuleTypes.JAVA);
addDependentModule(moduleA, DependencyScope.COMPILE);
addLibrary(moduleA, DependencyScope.COMPILE);
VirtualFile classB = myFixture.createFile("b/Test.java", "public class Test { }");
VirtualFile libraryClass = myFixture.createFile("lib/Test.class");
assertFalse(moduleA.getModuleScope().contains(classB));
assertFalse(moduleA.getModuleScope().contains(libraryClass));
assertFalse(moduleA.getModuleWithLibrariesScope().contains(classB));
assertTrue(moduleA.getModuleWithLibrariesScope().contains(libraryClass));
assertTrue(moduleA.getModuleWithDependenciesScope().contains(classB));
assertFalse(moduleA.getModuleWithDependenciesScope().contains(libraryClass));
assertTrue(moduleA.getModuleWithDependenciesAndLibrariesScope(true).contains(classB));
assertTrue(moduleA.getModuleWithDependenciesAndLibrariesScope(true).contains(libraryClass));
assertTrue(moduleA.getModuleRuntimeScope(true).contains(classB));
assertTrue(moduleA.getModuleRuntimeScope(true).contains(libraryClass));
}
示例4: testTestOnlyModuleDependency
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testTestOnlyModuleDependency() throws Exception {
Module moduleA = createModule("a.iml", StdModuleTypes.JAVA);
Module moduleB = addDependentModule(moduleA, DependencyScope.TEST);
VirtualFile classB = myFixture.createFile("b/Test.java", "public class Test { }");
assertTrue(moduleA.getModuleWithDependenciesAndLibrariesScope(true).contains(classB));
assertFalse(moduleA.getModuleWithDependenciesAndLibrariesScope(false).contains(classB));
assertFalse(moduleA.getModuleWithDependenciesAndLibrariesScope(false).isSearchInModuleContent(moduleB));
final VirtualFile[] compilationClasspath = getCompilationClasspath(moduleA);
assertEquals(1, compilationClasspath.length);
final VirtualFile[] productionCompilationClasspath = getProductionCompileClasspath(moduleA);
assertEmpty(productionCompilationClasspath);
final PathsList pathsList = OrderEnumerator.orderEntries(moduleA).recursively().getPathsList();
assertEquals(1, pathsList.getPathList().size());
final PathsList pathsListWithoutTests = OrderEnumerator.orderEntries(moduleA).productionOnly().recursively().getPathsList();
assertEquals(0, pathsListWithoutTests.getPathList().size());
}
示例5: addDependentModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
private Module addDependentModule(final String name, final Module moduleA,
final DependencyScope scope,
final boolean exported) {
final Module moduleB = createModule(name + ".iml", StdModuleTypes.JAVA);
ApplicationManager.getApplication().runWriteAction(() -> {
VirtualFile rootB = myFixture.findOrCreateDir(name);
VirtualFile outB = myFixture.findOrCreateDir("out");
ModuleRootModificationUtil.addDependency(moduleA, moduleB, scope, exported);
PsiTestUtil.addSourceRoot(moduleB, rootB);
PsiTestUtil.setCompilerOutputPath(moduleB, outB.getUrl(), false);
});
return moduleB;
}
示例6: testModuleTwiceInDependents
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的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));
}
示例7: testRuntimeLibraryDependency
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testRuntimeLibraryDependency() throws IOException {
Module m = createModule("a.iml", StdModuleTypes.JAVA);
VirtualFile libraryRoot = addLibrary(m, DependencyScope.RUNTIME);
final VirtualFile[] runtimeClasspath = getRuntimeClasspath(m);
assertOrderedEquals(runtimeClasspath, libraryRoot);
final VirtualFile[] compilationClasspath = getCompilationClasspath(m);
assertEquals(1, compilationClasspath.length);
VirtualFile[] production = getProductionCompileClasspath(m);
assertEmpty(production);
VirtualFile libraryClass = myFixture.createFile("lib/Test.class");
assertFalse(m.getModuleWithDependenciesAndLibrariesScope(true).contains(libraryClass));
assertFalse(m.getModuleWithDependenciesAndLibrariesScope(false).contains(libraryClass));
assertTrue(m.getModuleRuntimeScope(true).contains(libraryClass));
assertTrue(m.getModuleRuntimeScope(false).contains(libraryClass));
}
示例8: testProvidedLibraryDependency
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testProvidedLibraryDependency() throws IOException {
Module m = createModule("a.iml", StdModuleTypes.JAVA);
VirtualFile libraryRoot = addLibrary(m, DependencyScope.PROVIDED);
final VirtualFile[] runtimeClasspath = getRuntimeClasspath(m);
assertEmpty(runtimeClasspath);
final VirtualFile[] compilationClasspath = getCompilationClasspath(m);
assertOrderedEquals(compilationClasspath, libraryRoot);
VirtualFile libraryClass = myFixture.createFile("lib/Test.class");
assertTrue(m.getModuleWithDependenciesAndLibrariesScope(true).contains(libraryClass));
assertTrue(m.getModuleWithDependenciesAndLibrariesScope(false).contains(libraryClass));
assertTrue(m.getModuleRuntimeScope(true).contains(libraryClass));
assertTrue(m.getModuleRuntimeScope(false).contains(libraryClass));
}
示例9: testScopeEquality
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testScopeEquality() {
Module module = createModule("a.iml", StdModuleTypes.JAVA);
addDependentModule(module, DependencyScope.COMPILE);
addLibrary(module, DependencyScope.COMPILE);
GlobalSearchScope deps = module.getModuleWithDependentsScope();
GlobalSearchScope depsTests = module.getModuleTestsWithDependentsScope();
assertFalse(deps.equals(depsTests));
assertFalse(depsTests.equals(deps));
((ModuleEx)module).clearScopesCache();
GlobalSearchScope deps2 = module.getModuleWithDependentsScope();
GlobalSearchScope depsTests2 = module.getModuleTestsWithDependentsScope();
assertFalse(deps2.equals(depsTests2));
assertFalse(depsTests2.equals(deps2));
assertNotSame(deps, deps2);
assertNotSame(depsTests, depsTests2);
assertEquals(deps, deps2);
assertEquals(depsTests, depsTests2);
}
示例10: doLoadModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
private static Module doLoadModule(@NotNull String path, @NotNull Project project) throws IOException, JDOMException, InvalidDataException {
Module module;
AccessToken token = WriteAction.start();
try {
module = ModuleManager.getInstance(project).newModule(path + '/' + EclipseProjectFinder.findProjectName(path) + IdeaXml.IML_EXT, StdModuleTypes.JAVA.getId());
}
finally {
token.finish();
}
replaceRoot(path, EclipseXml.DOT_CLASSPATH_EXT, project);
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
new EclipseClasspathConverter(module).readClasspath(rootModel);
token = WriteAction.start();
try {
rootModel.commit();
}
finally {
token.finish();
}
return module;
}
示例11: addModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
protected Module addModule(final String name, final boolean withSource) {
return new WriteCommandAction<Module>(getProject()) {
@Override
protected void run(@NotNull Result<Module> result) throws Throwable {
final VirtualFile depRoot = myFixture.getTempDirFixture().findOrCreateDir(name);
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
String moduleName = moduleModel.newModule(depRoot.getPath() + "/" + name + ".iml", StdModuleTypes.JAVA.getId()).getName();
moduleModel.commit();
final Module dep = ModuleManager.getInstance(getProject()).findModuleByName(moduleName);
ModuleRootModificationUtil.setModuleSdk(dep, ModuleRootManager.getInstance(myModule).getSdk());
if (withSource) {
PsiTestUtil.addSourceRoot(dep, depRoot);
} else {
PsiTestUtil.addContentRoot(dep, depRoot);
}
IdeaTestUtil.setModuleLanguageLevel(dep, LanguageLevelModuleExtensionImpl.getInstance(myModule).getLanguageLevel());
result.setResult(dep);
}
}.execute().getResultObject();
}
示例12: testAddModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
public void testAddModule() throws Exception {
myIndex.checkConsistency();
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
VirtualFile newModuleContent = myRootVFile.createChildDirectory(DirectoryIndexTest.this, "newModule");
newModuleContent.createChildDirectory(DirectoryIndexTest.this, "subDir");
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
Module module = moduleManager.newModule(myRootVFile.getPath() + "/newModule.iml", StdModuleTypes.JAVA.getId());
PsiTestUtil.addContentRoot(module, newModuleContent);
}
}.execute().throwException();
myIndex.checkConsistency();
}
示例13: addDependentModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
private Module addDependentModule(final Module moduleA, final DependencyScope scope) {
final Module moduleB = createModule("b.iml", StdModuleTypes.JAVA);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
VirtualFile rootB = myFixture.findOrCreateDir("b");
VirtualFile outB = myFixture.findOrCreateDir("out");
ModuleRootModificationUtil.addDependency(moduleA, moduleB, scope, false);
PsiTestUtil.addSourceRoot(moduleB, rootB);
PsiTestUtil.setCompilerOutputPath(moduleB, outB.getUrl(), false);
}
});
return moduleB;
}
示例14: doLoadModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
private static Module doLoadModule(final String path, final Project project) throws IOException, JDOMException, InvalidDataException {
final Module module = ApplicationManager.getApplication().runWriteAction(new Computable<Module>() {
@Override
public Module compute() {
return ModuleManager.getInstance(project)
.newModule(path + "/" + EclipseProjectFinder.findProjectName(path) + IdeaXml.IML_EXT, StdModuleTypes.JAVA.getId());
}
});
replaceRoot(path, EclipseXml.DOT_CLASSPATH_EXT, project);
final EclipseClasspathStorageProvider.EclipseClasspathConverter converter =
new EclipseClasspathStorageProvider.EclipseClasspathConverter(module);
final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
final Element classpathElement =
JDOMUtil.loadDocument(FileUtil.loadFile(new File(path, EclipseXml.DOT_CLASSPATH_EXT))).getRootElement();
converter.getClasspath(rootModel, classpathElement);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
rootModel.commit();
}
});
return module;
}
示例15: addModule
import com.intellij.openapi.module.StdModuleTypes; //导入依赖的package包/类
protected Module addModule(final String name, final boolean withSource) {
return new WriteCommandAction<Module>(getProject()) {
@Override
protected void run(Result<Module> result) throws Throwable {
final VirtualFile depRoot = myFixture.getTempDirFixture().findOrCreateDir(name);
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(getProject()).getModifiableModel();
String moduleName = moduleModel.newModule(depRoot.getPath() + "/" + name + ".iml", StdModuleTypes.JAVA.getId()).getName();
moduleModel.commit();
final Module dep = ModuleManager.getInstance(getProject()).findModuleByName(moduleName);
ModuleRootModificationUtil.setModuleSdk(dep, ModuleRootManager.getInstance(myModule).getSdk());
if (withSource) {
PsiTestUtil.addSourceRoot(dep, depRoot);
} else {
PsiTestUtil.addContentRoot(dep, depRoot);
}
IdeaTestUtil.setModuleLanguageLevel(dep, LanguageLevelModuleExtension.getInstance(myModule).getLanguageLevel());
result.setResult(dep);
}
}.execute().getResultObject();
}