本文整理汇总了Java中com.intellij.ide.util.importProject.ModuleDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java ModuleDescriptor类的具体用法?Java ModuleDescriptor怎么用?Java ModuleDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleDescriptor类属于com.intellij.ide.util.importProject包,在下文中一共展示了ModuleDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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");
}
示例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();
}
}
}
}
示例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);
}
示例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();
}
}
}
}