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


Java ModuleManager.findModuleByName方法代码示例

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


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

示例1: tearDown

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
  try {
    ModuleManager moduleManager = ModuleManager.getInstance(myProject);
    List<Throwable> errors = null;
    AccessToken token = WriteAction.start();
    try {
      for (Module module : myModulesToDispose) {
        try {
          String moduleName = module.getName();
          if (moduleManager.findModuleByName(moduleName) != null) {
            moduleManager.disposeModule(module);
          }
        }
        catch (Throwable e) {
          if (errors == null) {
            errors = new SmartList<Throwable>();
          }
          errors.add(e);
        }
      }
    }
    finally {
      token.finish();
    }

    CompoundRuntimeException.throwIfNotEmpty(errors);
  }
  finally {
    myModulesToDispose.clear();
    super.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:ModuleTestCase.java

示例2: test

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
public void test() throws Exception {
  ModuleManager moduleManager = ModuleManager.getInstance(getProject());
  Module[] modules = moduleManager.getModules();
  assertEquals(3, modules.length);

  Module module1 = moduleManager.findModuleByName("test1");
  Module module2 = moduleManager.findModuleByName("test2");
  Module module3 = moduleManager.findModuleByName("test3");
  final GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(module1);
  PsiClass test1 = myJavaFacade.findClass("com.test.TestI", moduleScope);
  PsiClass test2 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module2));
  PsiClass test3 = myJavaFacade.findClass("com.test.TestI", GlobalSearchScope.moduleScope(module3));
  HashSet<PsiElement> expectedImpls1 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", moduleScope),
    myJavaFacade.findClass("com.test.TestIImpl2", moduleScope)
  ));
  assertEquals(expectedImpls1, new HashSet<PsiElement>(getClassImplementations(test1)));

  PsiMethod psiMethod = test1.findMethodsByName("test", false)[0];
  Set<PsiElement> expectedMethodImpl1 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", moduleScope).findMethodsByName("test",false)[0],
    myJavaFacade.findClass("com.test.TestIImpl2", moduleScope).findMethodsByName("test",false)[0]
  ));
  CommonProcessors.CollectProcessor<PsiElement> processor = new CommonProcessors.CollectProcessor<PsiElement>();
  MethodImplementationsSearch.processImplementations(psiMethod, processor, moduleScope);
  assertEquals(expectedMethodImpl1, new HashSet<PsiElement>(processor.getResults()));

  HashSet<PsiElement> expectedImpls2 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module2)),
    myJavaFacade.findClass("com.test.TestIImpl3", GlobalSearchScope.moduleScope(module2))
  ));
  assertEquals(expectedImpls2, new HashSet<PsiElement>(getClassImplementations(test2)));

  HashSet<PsiElement> expectedImpls3 = new HashSet<PsiElement>(Arrays.asList(
    myJavaFacade.findClass("com.test.TestIImpl1", GlobalSearchScope.moduleScope(module3))
  ));
  assertEquals(expectedImpls3, new HashSet<PsiElement>(getClassImplementations(test3)));

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:GotoImplementationTest.java

示例3: removeGenModule

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
private static void removeGenModule(@NotNull final ModifiableRootModel model, @NotNull Ref<Boolean> modelChangedFlag) {
  final String genModuleName = getGenModuleName(model.getModule());
  final Project project = model.getProject();
  final ModuleManager moduleManager = ModuleManager.getInstance(project);

  final Module genModule = moduleManager.findModuleByName(genModuleName);
  if (genModule == null) {
    return;
  }

  for (OrderEntry entry : model.getOrderEntries()) {
    if (entry instanceof ModuleOrderEntry &&
        genModuleName.equals(((ModuleOrderEntry)entry).getModuleName())) {
      model.removeOrderEntry(entry);
      modelChangedFlag.set(true);
    }
  }
  final VirtualFile moduleFile = genModule.getModuleFile();
  moduleManager.disposeModule(genModule);

  if (moduleFile != null) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            try {
              moduleFile.delete(project);
            }
            catch (IOException e) {
              LOG.error(e);
            }
          }
        });
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:AndroidCompileUtil.java

示例4: generateUniqueModuleName

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
private static String generateUniqueModuleName(@NotNull Project project, String prefix) {
  ModuleManager manager = ModuleManager.getInstance(project);
  int i = 0;
  do {
    String res = i == 0 ? prefix : prefix + i;
    i++;

    if (manager.findModuleByName(res) == null) return res;
  }
  while (true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MvcModuleStructureUtil.java

示例5: findModule

import com.intellij.openapi.module.ModuleManager; //导入方法依赖的package包/类
@Nullable
private static Module findModule(@NotNull Project project, @NotNull String moduleName) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  return moduleManager.findModuleByName(moduleName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:BuildVariantUpdater.java


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