类com.intellij.openapi.roots.impl.ModuleRootManagerImpl源码实例Demo

下面列出了怎么用com.intellij.openapi.roots.impl.ModuleRootManagerImpl的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: intellij-haxe   文件: HaxelibUtil.java
/**
 * 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;
}
 
源代码2 项目: consulo   文件: ModuleManagerImpl.java
@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);
}
 
源代码3 项目: consulo   文件: ModuleManagerImpl.java
@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;
}
 
源代码4 项目: consulo   文件: ModuleEditor.java
public ModifiableRootModel getModifiableRootModel() {
  if (myModifiableRootModel == null) {
    final Module module = getModule();
    if (module != null) {
      myModifiableRootModel = ((ModuleRootManagerImpl)ModuleRootManager.getInstance(module)).getModifiableModel(new UIRootConfigurationAccessor(myProject));
    }
  }
  return myModifiableRootModel;
}
 
源代码5 项目: consulo   文件: ModuleManagerImpl.java
@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;
}
 
源代码6 项目: consulo   文件: ModuleImpl.java
@Override
public void moduleAdded() {
  ModuleRootManagerImpl manager = (ModuleRootManagerImpl)ModuleRootManager.getInstance(this);

  manager.moduleAdded();
}
 
 类方法
 同包方法