當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。