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


Java ModulesProvider.getRootModel方法代码示例

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


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

示例1: hasModuleExtension

import com.intellij.openapi.roots.ui.configuration.ModulesProvider; //导入方法依赖的package包/类
public static boolean hasModuleExtension(@Nonnull ModulesProvider modulesProvider, @Nonnull Class<? extends ModuleExtension> clazz) {
  for (Module module : modulesProvider.getModules()) {
    ModuleRootModel rootModel = modulesProvider.getRootModel(module);
    if (rootModel == null) {
      continue;
    }

    ModuleExtension extension = rootModel.getExtension(clazz);
    if (extension != null) {
      return true;
    }
  }
  return false;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:ModuleUtil.java

示例2: doCreateArtifactTemplate

import com.intellij.openapi.roots.ui.configuration.ModulesProvider; //导入方法依赖的package包/类
@NotNull
@RequiredReadAction
public static NewArtifactConfiguration doCreateArtifactTemplate(Module module, PackagingElementResolvingContext packagingElementResolvingContext)
{
	ModulesProvider modulesProvider = packagingElementResolvingContext.getModulesProvider();

	Project project = module.getProject();
	CompositePackagingElement<?> root = ExplodedWarArtifactType.getInstance().createRootElement(module.getName());

	DirectoryPackagingElement webInfDir = DirectoryElementType.getInstance().createEmpty(project);
	webInfDir.setDirectoryName(JavaWebConstants.WEB_INF);
	root.addFirstChild(webInfDir);

	DirectoryPackagingElement libDir = DirectoryElementType.getInstance().createEmpty(project);
	libDir.setDirectoryName("lib");
	webInfDir.addFirstChild(libDir);

	Set<Library> libraries = new ArrayListSet<>();
	Set<Module> modules = new ArrayListSet<>();

	collectInfo(modules, libraries, modulesProvider, module);

	for(Module toAddModule : modules)
	{
		NamedPointer<Module> pointer = ModuleUtilCore.createPointer(toAddModule);
		ModuleRootModel rootModel = modulesProvider.getRootModel(toAddModule);

		ZipArchivePackagingElement zipArchivePackagingElement = ZipArchiveElementType.getInstance().createEmpty(project);
		zipArchivePackagingElement.setArchiveFileName(toAddModule.getName() + ".jar");

		if(rootModel.getContentFolders(ContentFolderScopes.of(ProductionContentFolderTypeProvider.getInstance())).length > 0)
		{
			zipArchivePackagingElement.addFirstChild(ProductionModuleOutputElementType.getInstance().createElement(project, pointer));
		}

		if(rootModel.getContentFolders(ContentFolderScopes.of(ProductionResourceContentFolderTypeProvider.getInstance())).length > 0)
		{
			zipArchivePackagingElement.addFirstChild(ProductionResourceModuleOutputElementType.getInstance().createElement(project, pointer));
		}

		libDir.addFirstChild(zipArchivePackagingElement);

		if(rootModel.getContentFolders(ContentFolderScopes.of(WebResourcesFolderTypeProvider.getInstance())).length > 0)
		{
			root.addFirstChild(WebResourceModuleOutputElementType.getInstance().createElement(project, pointer));
		}
	}

	for(Library library : libraries)
	{
		LibraryPackagingElement libraryPackagingElement = LibraryElementType.getInstance().createEmpty(project);
		libraryPackagingElement.setLibraryName(library.getName());

		LibraryTable table = library.getTable();

		String tableLevel = table == null ? null : table.getTableLevel();
		libraryPackagingElement.setLevel(tableLevel);

		if(LibraryTableImplUtil.MODULE_LEVEL.equals(tableLevel))
		{
			libraryPackagingElement.setModuleName(((ModuleLibraryTable) table).getModule().getName());
		}

		libDir.addFirstChild(libraryPackagingElement);
	}

	return new NewArtifactConfiguration(root, ExplodedWarArtifactType.getInstance().getPresentableName() + ": " + module.getName(), ExplodedWarArtifactType.getInstance());
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:69,代码来源:ExplodedWarArtifactTemplate.java


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