com.intellij.openapi.roots.impl.ModuleRootManagerImpl Java Examples
The following examples show how to use
com.intellij.openapi.roots.impl.ModuleRootManagerImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HaxelibUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
/** * Get the libraries for the given module. This does not include any * libraries from projects or SDKs. * * @param module to look up haxelib for. * @return a (possibly empty) collection of libraries. These are NOT * necessarily properly ordered, but they are unique. */ // XXX: EMB - Not sure that I like this method here. It could be a static on HaxeLibraryList, // but that's not so great, either. The reason I don't like it in this module is // that this has to reach back out to HaxelibProjectUpdater to find the library cache for // the module. @NotNull public static HaxeLibraryList getModuleLibraries(@NotNull final Module module) { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); if (null == rootManager) return new HaxeLibraryList(module); final HaxeLibraryList moduleLibs = new HaxeLibraryList(module); if (rootManager instanceof ModuleRootManagerImpl) { ModuleRootManagerImpl rootManagerImpl = (ModuleRootManagerImpl)rootManager; RootModelBase modelBase = rootManagerImpl.getRootModel(); // Can't fail. OrderEnumerator entries = modelBase.orderEntries(); // Can't fail. entries.forEachLibrary(new Processor<Library>() { @Override public boolean process(Library library) { if (library == null || library.getName() == null) return true; HaxeLibraryReference ref = HaxeLibraryReference.create(module, library.getName()); if (null != ref) { moduleLibs.add(ref); } return true; } }); } else { LOG.assertLog(false, "Expected a ModuleRootManagerImpl, but didn't get one."); } return moduleLibs; }
Example #2
Source File: ModuleManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@RequiredReadAction public void getState0(Element element) { final Element modulesElement = new Element(ELEMENT_MODULES); final Module[] modules = getModules(); for (Module module : modules) { Element moduleElement = new Element(ELEMENT_MODULE); String name = module.getName(); final String[] moduleGroupPath = getModuleGroupPath(module); if (moduleGroupPath != null) { name = StringUtil.join(moduleGroupPath, MODULE_GROUP_SEPARATOR) + MODULE_GROUP_SEPARATOR + name; } moduleElement.setAttribute(ATTRIBUTE_NAME, name); String moduleDirUrl = module.getModuleDirUrl(); if (moduleDirUrl != null) { moduleElement.setAttribute(ATTRIBUTE_DIRURL, moduleDirUrl); } final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(module); moduleRootManager.saveState(moduleElement); collapseOrExpandMacros(module, moduleElement, true); modulesElement.addContent(moduleElement); } for (ModuleLoadItem failedModulePath : new ArrayList<>(myFailedModulePaths)) { final Element clone = failedModulePath.getElement().clone(); modulesElement.addContent(clone); } element.addContent(modulesElement); }
Example #3
Source File: ModuleManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected ModuleEx createAndLoadModule(@Nonnull final ModuleLoadItem moduleLoadItem, @Nonnull ModuleModelImpl moduleModel, @Nullable final ProgressIndicator progressIndicator) { final ModuleEx module = createModule(moduleLoadItem.getName(), moduleLoadItem.getDirUrl(), progressIndicator); moduleModel.initModule(module); collapseOrExpandMacros(module, moduleLoadItem.getElement(), false); final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(module); AccessRule.read(() -> moduleRootManager.loadState(moduleLoadItem.getElement(), progressIndicator)); return module; }
Example #4
Source File: ModuleEditor.java From consulo with Apache License 2.0 | 5 votes |
public ModifiableRootModel getModifiableRootModel() { if (myModifiableRootModel == null) { final Module module = getModule(); if (module != null) { myModifiableRootModel = ((ModuleRootManagerImpl)ModuleRootManager.getInstance(module)).getModifiableModel(new UIRootConfigurationAccessor(myProject)); } } return myModifiableRootModel; }
Example #5
Source File: ModuleManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private Module loadModuleInternal(@Nonnull ModuleLoadItem item, boolean firstLoad, @Nullable ProgressIndicator progressIndicator) throws ModuleWithNameAlreadyExistsException, ModuleDirIsNotExistsException, StateStorageException { final String moduleName = item.getName(); if (progressIndicator != null) { progressIndicator.setText2(moduleName); } if (firstLoad) { for (Module module : myModules) { if (module.getName().equals(moduleName)) { throw new ModuleWithNameAlreadyExistsException(ProjectBundle.message("module.already.exists.error", moduleName), moduleName); } } } ModuleEx oldModule = null; String dirUrl = item.getDirUrl(); if (dirUrl != null) { Ref<VirtualFile> ref = Ref.create(); ApplicationManager.getApplication().invokeAndWait(() -> ref.set(VirtualFileManager.getInstance().refreshAndFindFileByUrl(dirUrl))); VirtualFile moduleDir = ref.get(); if (moduleDir == null || !moduleDir.exists() || !moduleDir.isDirectory()) { throw new ModuleDirIsNotExistsException(ProjectBundle.message("module.dir.does.not.exist.error", FileUtil.toSystemDependentName(VirtualFileManager.extractPath(dirUrl)))); } oldModule = getModuleByDirUrl(moduleDir.getUrl()); } if (oldModule == null) { oldModule = createAndLoadModule(item, this, progressIndicator); } else { collapseOrExpandMacros(oldModule, item.getElement(), false); final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(oldModule); ApplicationManager.getApplication().runReadAction(() -> moduleRootManager.loadState(item.getElement(), progressIndicator)); } return oldModule; }
Example #6
Source File: ModuleImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public void moduleAdded() { ModuleRootManagerImpl manager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(this); manager.moduleAdded(); }