本文整理汇总了Java中com.intellij.ide.util.importProject.ModuleDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java ModuleDescriptor类的具体用法?Java ModuleDescriptor怎么用?Java ModuleDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleDescriptor类属于com.intellij.ide.util.importProject包,在下文中一共展示了ModuleDescriptor类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createModule
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
private static Module createModule(
ProjectDescriptor projectDescriptor,
final ModuleDescriptor descriptor,
final Map<LibraryDescriptor, Library> projectLibs,
final ModifiableModuleModel moduleModel) {
logger.info("Starting createModule in ProjectFromSourcesBuilderImplModified");
final String moduleFilePath = descriptor.computeModuleFilePath();
ModuleBuilder.deleteModuleFile(moduleFilePath);
final Module module =
moduleModel.newModule(moduleFilePath, descriptor.getModuleType().getId());
final ModifiableRootModel modifiableModel =
ModuleRootManager.getInstance(module).getModifiableModel();
setupRootModel(projectDescriptor, descriptor, modifiableModel, projectLibs);
descriptor.updateModuleConfiguration(module, modifiableModel);
modifiableModel.commit();
logger.info("ending createModule in ProjectFromSourcesBuilderImplModified");
return module;
}
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:21,代码来源:ProjectFromSourcesBuilderImplModified.java
示例2: getModuleType
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Nullable
private static ModuleType getModuleType(ModuleDescriptor moduleDescriptor) throws InvalidDataException, JDOMException, IOException {
if (moduleDescriptor.isReuseExistingElement()) {
final File file = new File(moduleDescriptor.computeModuleFilePath());
if (file.exists()) {
final Element rootElement = JDOMUtil.loadDocument(file).getRootElement();
final String type = rootElement.getAttributeValue("type");
if (type != null) {
return ModuleTypeManager.getInstance().findByID(type);
}
}
return null;
}
else {
return moduleDescriptor.getModuleType();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ProjectFromSourcesBuilderImpl.java
示例3: create
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
/**
* Creates ProjectDescriptor so project can be build from it's info.
*
* @param path project root dir
* @param ignoredNames ie. compile output path
* @return ProjectDescriptor
*/
public static ProjectDescriptor create(String path, Set<String> ignoredNames) {
logger.info("Starting to create Project Descriptor in JavaProjectDescriptor.");
logger.info("Initializing ProjectDescriptor");
File contentFile = new File(path);
ProjectDescriptor projectDescriptor = new ProjectDescriptor();
List<ModuleDescriptor> moduleList = new ArrayList<>();
List<LibraryDescriptor> libraryList = new ArrayList<>();
projectDescriptor.setModules(moduleList);
projectDescriptor.setLibraries(libraryList);
logger.info("Searching for source files");
//test file is considered as source file at this point
Collection<JavaModuleSourceRoot> suggestedRoots =
JavaSourceRootDetectionUtil.suggestRoots(contentFile);
List<JavaModuleSourceRoot> rootList = new ArrayList<>();
rootList.addAll(suggestedRoots);
//Module insight creates module and library descriptors collecting data as long as roots are listed.
ModuleInsight insight = new JavaModuleInsight(null, new HashSet<>(), new HashSet<>());
List<File> entryPointRoots = new ArrayList<>();
entryPointRoots.add(contentFile);
logger.info("Setting up ModuleInsight roots");
insight.setRoots(entryPointRoots, rootList, ignoredNames);
logger.info("ModuleInsight scanning for modules and libraries");
insight.scanLibraries();
insight.scanModules();
logger.info("Adding moduleDescriptors and LibraryDescriptors to projectDescriptor");
libraryList.addAll(insight.getSuggestedLibraries());
moduleList.addAll(insight.getSuggestedModules());
logger.info("Ending to create Project Descriptor in JavaProjectDescriptor.");
return projectDescriptor;
}
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:47,代码来源:JavaProjectDescriptor.java
示例4: addSteps
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
public void addSteps(WizardContext context, ModulesProvider modulesProvider, StepSequence sequence, String specific) {
final ProjectFromSourcesBuilderImpl projectBuilder = new ProjectFromSourcesBuilderImpl(context, modulesProvider);
myProjectBuilder = projectBuilder;
final Icon icon = context.getStepIcon();
if (context.isCreatingNewProject()) {
addStep(sequence, new ProjectNameStep(context, this), specific);
}
addStep(sequence, new RootsDetectionStep(projectBuilder, context, sequence, icon, "reference.dialogs.new.project.fromCode.source"), specific);
Set<String> detectorTypes = new HashSet<String>();
for (ProjectStructureDetector detector : ProjectStructureDetector.EP_NAME.getExtensions()) {
detectorTypes.add(detector.getDetectorId());
for (ModuleWizardStep step : detector.createWizardSteps(projectBuilder, projectBuilder.getProjectDescriptor(detector), icon)) {
sequence.addSpecificStep(detector.getDetectorId(), step);
}
}
if (FrameworkDetectionStep.isEnabled()) {
FrameworkDetectionStep frameworkDetectionStep = new FrameworkDetectionStep(icon, projectBuilder) {
public List<ModuleDescriptor> getModuleDescriptors() {
final List<ModuleDescriptor> moduleDescriptors = new ArrayList<ModuleDescriptor>();
for (ProjectDescriptor descriptor : projectBuilder.getSelectedDescriptors()) {
moduleDescriptors.addAll(descriptor.getModules());
}
return moduleDescriptors;
}
};
projectBuilder.addConfigurationUpdater(frameworkDetectionStep);
sequence.addCommonFinishingStep(frameworkDetectionStep, detectorTypes);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:CreateFromSourcesMode.java
示例5: setupModulesByContentRoots
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public void setupModulesByContentRoots(ProjectDescriptor projectDescriptor, Collection<DetectedProjectRoot> roots) {
if (projectDescriptor.getModules().isEmpty()) {
List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
if (root instanceof DetectedContentRoot) {
modules.add(new ModuleDescriptor(root.getDirectory(), ((DetectedContentRoot)root).getModuleType(), Collections.<DetectedSourceRoot>emptyList()));
}
}
projectDescriptor.setModules(modules);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ProjectFromSourcesBuilderImpl.java
示例6: createModule
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@NotNull
private static Module createModule(ProjectDescriptor projectDescriptor, final ModuleDescriptor descriptor,
final Map<LibraryDescriptor, Library> projectLibs, final ModifiableModuleModel moduleModel)
throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
final String moduleFilePath = descriptor.computeModuleFilePath();
ModuleBuilder.deleteModuleFile(moduleFilePath);
final Module module = moduleModel.newModule(moduleFilePath, descriptor.getModuleType().getId());
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
setupRootModel(projectDescriptor, descriptor, modifiableModel, projectLibs);
descriptor.updateModuleConfiguration(module, modifiableModel);
modifiableModel.commit();
return module;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ProjectFromSourcesBuilderImpl.java
示例7: isSuitableSdkType
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public boolean isSuitableSdkType(final SdkTypeId sdkTypeId) {
for (ProjectDescriptor projectDescriptor : getSelectedDescriptors()) {
for (ModuleDescriptor moduleDescriptor : projectDescriptor.getModules()) {
try {
final ModuleType moduleType = getModuleType(moduleDescriptor);
if (moduleType != null && !moduleType.createModuleBuilder().isSuitableSdkType(sdkTypeId)) return false;
}
catch (Exception ignore) {
}
}
}
return true;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ProjectFromSourcesBuilderImpl.java
示例8: updateDataModel
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public void updateDataModel() {
super.updateDataModel();
List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : myBuilder.getProjectRoots(myDetector)) {
final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedSourceRoot>emptyList());
descriptor.addConfigurationUpdater(createModuleConfigurationUpdater());
modules.add(descriptor);
}
myProjectDescriptor.setModules(modules);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GroovySdkForProjectFromSourcesStep.java
示例9: setupProjectStructure
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots,
@NotNull ProjectDescriptor projectDescriptor,
@NotNull ProjectFromSourcesBuilder builder) {
if (!roots.isEmpty() && !builder.hasRootsFromOtherDetectors(this)) {
List<ModuleDescriptor> modules = projectDescriptor.getModules();
if (modules.isEmpty()) {
modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
modules.add(new ModuleDescriptor(root.getDirectory(), SquirrelModuleType.getInstance(), ContainerUtil.<DetectedSourceRoot>emptyList()));
}
projectDescriptor.setModules(modules);
}
}
}
开发者ID:shvetsgroup,项目名称:squirrel-lang-idea-plugin,代码行数:16,代码来源:SquirrelProjectStructureDetector.java
示例10: updateDataModel
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public void updateDataModel() {
super.updateDataModel();
List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : myBuilder.getProjectRoots(myDetector)) {
final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedProjectRoot>emptyList());
descriptor.addConfigurationUpdater(createModuleConfigurationUpdater());
modules.add(descriptor);
}
myProjectDescriptor.setModules(modules);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:GroovySdkForProjectFromSourcesStep.java
示例11: setupProjectStructure
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public void setupProjectStructure(@NotNull Collection<DetectedProjectRoot> roots,
@NotNull ProjectDescriptor projectDescriptor,
@NotNull final ProjectFromSourcesBuilder builder) {
if (!roots.isEmpty() && !builder.hasRootsFromOtherDetectors(this)) {
List<ModuleDescriptor> modules = projectDescriptor.getModules();
if (modules.isEmpty()) {
modules = new ArrayList<ModuleDescriptor>();
for (DetectedProjectRoot root : roots) {
modules.add(new ModuleDescriptor(new File(builder.getBaseProjectPath()), DeftModuleType.getInstance(), root));
}
projectDescriptor.setModules(modules);
}
}
}
开发者ID:dylan-foundry,项目名称:DeftIDEA,代码行数:16,代码来源:DeftProjectStructureDetector.java
示例12: setupRootModel
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
private static void setupRootModel(
ProjectDescriptor projectDescriptor,
final ModuleDescriptor descriptor,
final ModifiableRootModel rootModel,
final Map<LibraryDescriptor, Library> projectLibs) {
final CompilerModuleExtension compilerModuleExtension =
rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerModuleExtension.setExcludeOutput(true);
rootModel.inheritSdk();
//Module root model seems to store .iml files root dependencies. (src, test, lib)
logger.info("Starting setupRootModel in ProjectFromSourcesBuilderImplModified");
final Set<File> contentRoots = descriptor.getContentRoots();
for (File contentRoot : contentRoots) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile moduleContentRoot =
lfs.refreshAndFindFileByPath(
FileUtil.toSystemIndependentName(contentRoot.getPath()));
if (moduleContentRoot != null) {
final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
final Collection<DetectedSourceRoot> sourceRoots =
descriptor.getSourceRoots(contentRoot);
for (DetectedSourceRoot srcRoot : sourceRoots) {
final String srcpath =
FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
if (sourceRoot != null) {
contentEntry.addSourceFolder(
sourceRoot,
shouldBeTestRoot(srcRoot.getDirectory()),
getPackagePrefix(srcRoot));
}
}
}
}
logger.info("Inherits compiler output path from project");
compilerModuleExtension.inheritCompilerOutputPath(true);
logger.info("Starting to create module level libraries");
final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
for (LibraryDescriptor libDescriptor :
ModuleInsight.getLibraryDependencies(
descriptor, projectDescriptor.getLibraries())) {
final Library projectLib = projectLibs.get(libDescriptor);
if (projectLib != null) {
rootModel.addLibraryEntry(projectLib);
} else {
// add as module library
final Collection<File> jars = libDescriptor.getJars();
for (File file : jars) {
Library library = moduleLibraryTable.createLibrary();
Library.ModifiableModel modifiableModel = library.getModifiableModel();
modifiableModel.addRoot(
VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
modifiableModel.commit();
}
}
}
logger.info("Ending setupRootModel in ProjectFromSourcesBuilderImplModified");
}
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:61,代码来源:ProjectFromSourcesBuilderImplModified.java
示例13: setupRootModel
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
private static void setupRootModel(ProjectDescriptor projectDescriptor, final ModuleDescriptor descriptor,
final ModifiableRootModel rootModel, final Map<LibraryDescriptor, Library> projectLibs) {
final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerModuleExtension.setExcludeOutput(true);
rootModel.inheritSdk();
final Set<File> contentRoots = descriptor.getContentRoots();
for (File contentRoot : contentRoots) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile moduleContentRoot = lfs.refreshAndFindFileByPath(FileUtil.toSystemIndependentName(contentRoot.getPath()));
if (moduleContentRoot != null) {
final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
final Collection<DetectedSourceRoot> sourceRoots = descriptor.getSourceRoots(contentRoot);
for (DetectedSourceRoot srcRoot : sourceRoots) {
final String srcpath = FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
if (sourceRoot != null) {
contentEntry.addSourceFolder(sourceRoot, shouldBeTestRoot(srcRoot.getDirectory()), getPackagePrefix(srcRoot));
}
}
}
}
compilerModuleExtension.inheritCompilerOutputPath(true);
final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
for (LibraryDescriptor libDescriptor : ModuleInsight.getLibraryDependencies(descriptor, projectDescriptor.getLibraries())) {
final Library projectLib = projectLibs.get(libDescriptor);
if (projectLib != null) {
rootModel.addLibraryEntry(projectLib);
}
else {
// add as module library
final Collection<File> jars = libDescriptor.getJars();
for (File file : jars) {
Library library = moduleLibraryTable.createLibrary();
Library.ModifiableModel modifiableModel = library.getModifiableModel();
modifiableModel.addRoot(VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
modifiableModel.commit();
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:ProjectFromSourcesBuilderImpl.java
示例14: setupProjectStructure
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
public void setupProjectStructure(
final Collection<DetectedProjectRoot> roots,
final ProjectDescriptor projectDescriptor,
final ProjectFromSourcesBuilder builder) {
if (roots.isEmpty() || builder.hasRootsFromOtherDetectors(this))
return;
List<ModuleDescriptor> modules = projectDescriptor.getModules();
if (!modules.isEmpty())
return;
modules = new ArrayList<>();
for (final DetectedProjectRoot root : roots) {
final File rootDir = root.getDirectory();
final ModuleDescriptor descriptor = new ModuleDescriptor(
rootDir,
this.moduleType,
Collections.emptyList()
);
final ConfigRequest<ILanguageComponentConfig> request = this.configService.get(this.resourceService.resolve(rootDir));
final LanguageIdentifier languageId = request.config().identifier();
descriptor.addConfigurationUpdater(new ModuleBuilder.ModuleConfigurationUpdater() {
@Override
public void update(@NotNull final Module module, @NotNull final ModifiableRootModel rootModel) {
final ContentEntry contentEntry = rootModel.getContentEntries()[0];
final FileObject contentEntryFile = MetaborgProjectDetector.this.resourceService.resolve(contentEntry.getUrl());
try {
final List<Pair<String, String>> sourcePaths = ModuleBuilderUtils.getSourcePaths(languageId, contentEntryFile);
ModuleBuilderUtils.addSourceRoots(contentEntry, sourcePaths);
ModuleBuilderUtils.excludeRoots(contentEntry, contentEntryFile);
} catch (ConfigurationException e) {
throw new UnhandledException(e);
}
}
});
modules.add(descriptor);
}
projectDescriptor.setModules(modules);
}
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:45,代码来源:MetaborgProjectDetector.java
示例15: setupRootModel
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
private static void setupRootModel(ProjectDescriptor projectDescriptor, final ModuleDescriptor descriptor,
final ModifiableRootModel rootModel, final Map<LibraryDescriptor, Library> projectLibs) {
final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerModuleExtension.setExcludeOutput(true);
rootModel.inheritSdk();
final Set<File> contentRoots = descriptor.getContentRoots();
for (File contentRoot : contentRoots) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile moduleContentRoot = lfs.refreshAndFindFileByPath(FileUtil.toSystemIndependentName(contentRoot.getPath()));
if (moduleContentRoot != null) {
final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
final Collection<DetectedProjectRoot> sourceRoots = descriptor.getSourceRoots(contentRoot);
for (DetectedProjectRoot srcRoot : sourceRoots) {
final String srcpath = FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
if (sourceRoot != null) {
contentEntry.addSourceFolder(sourceRoot, shouldBeTestRoot(srcRoot.getDirectory()), getPackagePrefix(srcRoot));
}
}
}
}
compilerModuleExtension.inheritCompilerOutputPath(true);
final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
for (LibraryDescriptor libDescriptor : ModuleInsight.getLibraryDependencies(descriptor, projectDescriptor.getLibraries())) {
final Library projectLib = projectLibs.get(libDescriptor);
if (projectLib != null) {
rootModel.addLibraryEntry(projectLib);
}
else {
// add as module library
final Collection<File> jars = libDescriptor.getJars();
for (File file : jars) {
Library library = moduleLibraryTable.createLibrary();
Library.ModifiableModel modifiableModel = library.getModifiableModel();
modifiableModel.addRoot(VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
modifiableModel.commit();
}
}
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:43,代码来源:ProjectFromSourcesBuilderImpl.java
示例16: createModuleDescriptor
import com.intellij.ide.util.importProject.ModuleDescriptor; //导入依赖的package包/类
@Override
protected ModuleDescriptor createModuleDescriptor(File moduleContentRoot, Collection<DetectedSourceRoot> sourceRoots) {
return new ModuleDescriptor(moduleContentRoot, HaxeModuleType.getInstance(), sourceRoots);
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:5,代码来源:HaxeModuleInsight.java
注:本文中的com.intellij.ide.util.importProject.ModuleDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论