當前位置: 首頁>>代碼示例>>Java>>正文


Java ModuleManager.getModules方法代碼示例

本文整理匯總了Java中com.intellij.openapi.module.ModuleManager.getModules方法的典型用法代碼示例。如果您正苦於以下問題:Java ModuleManager.getModules方法的具體用法?Java ModuleManager.getModules怎麽用?Java ModuleManager.getModules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.module.ModuleManager的用法示例。


在下文中一共展示了ModuleManager.getModules方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAndroidSdkPath

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
public static String getAndroidSdkPath(Project project) {
    ModuleManager manager = ModuleManager.getInstance(project);
    String androidSdkPath = null;

    for (Module module : manager.getModules()) {
        if (androidSdkPath != null) {
            break;
        }
        Sdk sdk = ModuleRootManager.getInstance(module).getSdk();

        if (sdk != null && sdk.getHomePath() != null) {
            File file = new File(sdk.getHomePath());
            String[] contents = file.list();

            if (contents != null) {
                for (String path : contents) {
                    if (path.equals("build-tools")) {
                        androidSdkPath = sdk.getHomePath();
                        break;
                    }
                }
            }
        }
    }
    return androidSdkPath;
}
 
開發者ID:andreyfomenkov,項目名稱:green-cat,代碼行數:27,代碼來源:Utils.java

示例2: getReferences

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@NotNull
@Override
public PsiReference[] getReferences() {
    String filename = getFilename();
    if (filename == null) {
        return new PsiReference[0];
    }
    Module module = ModuleUtilCore.findModuleForPsiElement(this);
    if (module != null) {
        referenceProvider.getReferencesByElement(this, filename, 1, true);
    }
    // fallback: if we are inside of a dependency, current module is null
    // in this case we try to resolve reference in all dependencies of all modules
    // (might be not fully correct, but better than nothing)
    ModuleManager moduleManager = ModuleManager.getInstance(getProject());
    Module[] modules = moduleManager.getModules();
    return referenceProvider.getReferencesByElement(this, filename, 1, true, modules);
}
 
開發者ID:protostuff,項目名稱:protobuf-jetbrains-plugin,代碼行數:19,代碼來源:FileReferenceNode.java

示例3: configureProject

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Override
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, final Ref<Module> moduleRef) {
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  final Module[] modules = moduleManager.getModules();
  if (modules.length == 0) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        String moduleName = baseDir.getName().replace(":", "");     // correct module name when opening root of drive as project (RUBY-5181)
        String imlName = baseDir.getPath() + "/.idea/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION;
        ModuleTypeManager instance = ModuleTypeManager.getInstance();
        String id = instance == null ? "unknown" : instance.getDefaultModuleType().getId();
        final Module module = moduleManager.newModule(imlName, id);
        ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
        ModifiableRootModel rootModel = rootManager.getModifiableModel();
        if (rootModel.getContentRoots().length == 0) {
          rootModel.addContentEntry(baseDir);
        }
        rootModel.inheritSdk();
        rootModel.commit();
        moduleRef.set(module);
      }
    });
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:PlatformProjectConfigurator.java

示例4: getRoots

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private synchronized  Map<Module, MultiValuesMap<LogicalRootType, LogicalRoot>> getRoots(final ModuleManager moduleManager) {
  if (myRoots == null) {
    myRoots = new THashMap<Module, MultiValuesMap<LogicalRootType, LogicalRoot>>();

    final Module[] modules = moduleManager.getModules();
    for (Module module : modules) {
      final MultiValuesMap<LogicalRootType, LogicalRoot> map = new MultiValuesMap<LogicalRootType, LogicalRoot>();
      for (Map.Entry<LogicalRootType, Collection<NotNullFunction>> entry : myProviders.entrySet()) {
        final Collection<NotNullFunction> functions = entry.getValue();
        for (NotNullFunction function : functions) {
          map.putAll(entry.getKey(), (List<LogicalRoot>) function.fun(module));
        }
      }
      myRoots.put(module, map);
    }
  }

  return myRoots;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:LogicalRootsManagerImpl.java

示例5: excludeOutputFolders

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
/**
 * Even though {@link com.android.tools.idea.gradle.customizer.android.ContentRootModuleCustomizer} already excluded the folders
 * "$buildDir/intermediates" and "$buildDir/outputs" we go through the children of "$buildDir" and exclude any non-generated folders
 * that may have been created by other plug-ins. We need to be aggressive when excluding folder to prevent over-indexing files, which
 * will degrade the IDE's performance.
 */
private void excludeOutputFolders() {
  if (myProject.isDisposed()) {
    return;
  }
  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  if (myProject.isDisposed()) {
    return;
  }

  for (Module module : moduleManager.getModules()) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet != null && facet.isGradleProject()) {
      excludeOutputFolders(facet);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:PostProjectBuildTasksExecutor.java

示例6: guessLanguageLevel

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@NotNull
public static LanguageLevel guessLanguageLevel(@NotNull Project project) {
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  if (moduleManager != null) {
    LanguageLevel maxLevel = null;
    for (Module projectModule : moduleManager.getModules()) {
      final Sdk sdk = PythonSdkType.findPythonSdk(projectModule);
      if (sdk != null) {
        final LanguageLevel level = PythonSdkType.getLanguageLevelForSdk(sdk);
        if (maxLevel == null || maxLevel.isOlderThan(level)) {
          maxLevel = level;
        }
      }
    }
    if (maxLevel != null) {
      return maxLevel;
    }
  }
  return LanguageLevel.getDefault();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:PyUtil.java

示例7: syncSucceeded

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Override
public void syncSucceeded(@NotNull Project project) {
  disposeOnTearDown(project);
  // Verify that project was imported correctly.
  assertEquals(myProjectName, project.getName());
  assertEquals(myProjectRootDir.getPath(), project.getBasePath());

  // Verify that '.idea' directory was created.
  File ideaProjectDir = new File(myProjectRootDir, Project.DIRECTORY_STORE_FOLDER);
  assertTrue(ideaProjectDir.isDirectory());

  // Verify that module was created.
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  Module[] modules = moduleManager.getModules();
  assertEquals(1, modules.length);
  assertEquals(myModule.getName(), modules[0].getName());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:GradleProjectImporterTest.java

示例8: findPathOfSdkMissingOrEmptyAddonsFolder

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Nullable
private static File findPathOfSdkMissingOrEmptyAddonsFolder(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  for (Module module : moduleManager.getModules()) {
    Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk();
    if (moduleSdk != null && isAndroidSdk(moduleSdk)) {
      String homePath = moduleSdk.getHomePath();
      if (homePath != null) {
        File sdkHomeDirPath = new File(FileUtil.toSystemDependentName(homePath));
        File addonsDir = new File(sdkHomeDirPath, SdkConstants.FD_ADDONS);
        if (!addonsDir.isDirectory() || FileUtil.notNullize(addonsDir.listFiles()).length == 0) {
          return sdkHomeDirPath;
        }
      }
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:FailedToParseSdkErrorHandler.java

示例9: createAvailableTasks

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private List<String> createAvailableTasks() {
  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  List<String> gradleTasks = Lists.newArrayList();
  for (Module module : moduleManager.getModules()) {
    AndroidGradleFacet facet = AndroidGradleFacet.getInstance(module);
    if (facet == null) {
      continue;
    }

    IdeaGradleProject gradleProject = facet.getGradleProject();
    if (gradleProject == null) {
      continue;
    }

    gradleTasks.addAll(gradleProject.getTaskNames());
  }

  return gradleTasks;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:MakeBeforeRunTaskProvider.java

示例10: getMuleModules

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
public static List<Module> getMuleModules(Project project, boolean includeDomains)
{
    final List<Module> muleModules = new ArrayList<>();

    final ModuleManager moduleManager = ModuleManager.getInstance(project);
    Module[] allModules = moduleManager.getModules();
    for (Module m : allModules) {
        if (MuleConfigUtils.isMuleModule(m) || (includeDomains && MuleConfigUtils.isMuleDomainModule(m)))
            muleModules.add(m);
    }
    return muleModules;
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:13,代碼來源:MuleConfigUtils.java

示例11: isUniqueModuleName

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private boolean isUniqueModuleName(@NotNull String moduleName) {
  if (myProject == null) {
    return true;
  }
  // Check our modules
  ModuleManager moduleManager = ModuleManager.getInstance(myProject);
  for (Module m : moduleManager.getModules()) {
    if (m.getName().equalsIgnoreCase(moduleName)) {
      return false;
    }
  }
  return true;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:ConfigureAndroidModuleStep.java

示例12: testComputeModuleName

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
public void testComputeModuleName() throws Exception {
  ModuleManager manager = ModuleManager.getInstance(getProject());
  myStep = new ConfigureAndroidModuleStep(myState, getProject(), null, TemplateWizardStep.NONE);
  Module module = manager.getModules()[0];
  assertEquals("app", module.getName());

  myState.myHidden.add(ATTR_PROJECT_LOCATION);
  myState.put(ATTR_IS_LIBRARY_MODULE, true);
  // "Lib" and "lib2" already exist
  assertEquals("lib3", myStep.computeModuleName());

  myState.put(ATTR_IS_LIBRARY_MODULE, false);
  // "app" already exists
  assertEquals("app2", myStep.computeModuleName());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:ConfigureAndroidModuleStepTest.java

示例13: findGradleProjectModule

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
/**
 * @see #isGradleProjectModule(Module)
 */
@Nullable
public static Module findGradleProjectModule(@NotNull Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  Module[] modules = moduleManager.getModules();
  if (modules.length == 1) {
    return modules[0];
  }
  for (Module module : modules) {
    if (isGradleProjectModule(module)) {
      return module;
    }
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:Projects.java

示例14: getModulesWithAndroidFacet

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
private static Module[] getModulesWithAndroidFacet(Project project) {
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  final Module[] modules = moduleManager.getModules();
  List<Module> result = new ArrayList<Module>();
  for (Module module : modules) {
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet != null && !facet.isLibraryProject()) {
      result.add(module);
    }
  }
  return result.toArray(new Module[result.size()]);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:AndroidModulesComboBox.java

示例15: findAndroidFacetInProject

import com.intellij.openapi.module.ModuleManager; //導入方法依賴的package包/類
@Nullable
private static AndroidFacet findAndroidFacetInProject(@NonNull com.intellij.openapi.project.Project project) {
  ModuleManager moduleManager = ModuleManager.getInstance(project);
  for (Module module : moduleManager.getModules()) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet != null) {
      return facet;
    }
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:IntellijLintProject.java


注:本文中的com.intellij.openapi.module.ModuleManager.getModules方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。