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


Java ModuleRootManager.getSdk方法代码示例

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


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

示例1: getCandidateModules

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
public static List<Module> getCandidateModules(Module module) {
  final ModuleRootManager manager = ModuleRootManager.getInstance(module);

  final Sdk jdk = manager.getSdk();
  // don't allow modules that don't use an IDEA-JDK
  if (IdeaJdk.findIdeaJdk(jdk) == null) {
    return Collections.emptyList();
  }

  final Module[] modules = ModuleManager.getInstance(module.getProject()).getModules();
  final List<Module> candidates = new ArrayList<Module>(modules.length);
  final Set<Module> deps = new HashSet<Module>(modules.length);
  for (Module m : modules) {
    if (get(m) == getInstance()) {
      deps.clear();
      PluginBuildUtil.getDependencies(m, deps);

      if (deps.contains(module) && getPluginXml(m) != null) {
        candidates.add(m);
      }
    }
  }
  return candidates;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PluginModuleType.java

示例2: checkConfiguration

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
  if (getModule() == null) {
    throw new RuntimeConfigurationException(DevKitBundle.message("run.configuration.no.module.specified"));
  }
  String moduleName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return getModule().getName();
    }
  });
  if (ModuleManager.getInstance(getProject()).findModuleByName(moduleName) == null){
    throw new RuntimeConfigurationException(DevKitBundle.message("run.configuration.no.module.specified"));
  }
  final ModuleRootManager rootManager = ModuleRootManager.getInstance(getModule());
  final Sdk sdk = rootManager.getSdk();
  if (sdk == null) {
    throw new RuntimeConfigurationException(DevKitBundle.message("sdk.no.specified", moduleName));
  }
  if (IdeaJdk.findIdeaJdk(sdk) == null) {
    throw new RuntimeConfigurationException(DevKitBundle.message("sdk.type.incorrect", moduleName));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PluginRunConfiguration.java

示例3: getState

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
  final Module module = getModule();
  if (module == null) {
    throw new ExecutionException("Module is not specified");
  }

  if (!isSupport(module)) {
    throw new ExecutionException(getNoSdkMessage());
  }

  final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
  final Sdk sdk = rootManager.getSdk();
  if (sdk == null || !(sdk.getSdkType() instanceof JavaSdkType)) {
    throw CantRunException.noJdkForModule(module);
  }

  return createCommandLineState(environment, module);

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

示例4: getSdk

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Nullable
private Sdk getSdk() {
  if (myModule == null) {
    return ProjectRootManager.getInstance(myProject).getProjectSdk();
  }
  final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule);
  return rootManager.getSdk();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PythonSdkDetailsDialog.java

示例5: configureJdk

import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
private static void configureJdk(Element cfg, @NotNull Module module) {
  String jdkName = cfg.getChildTextTrim("jdkName");
  if (StringUtil.isEmptyOrSpaces(jdkName)) return;

  ModuleRootManager rootManager = ModuleRootManager.getInstance(module);

  String currentSdkName = null;
  Sdk sdk = rootManager.getSdk();
  if (sdk != null) {
    currentSdkName = sdk.getName();
  }

  if (!jdkName.equals(currentSdkName)) {
    ModifiableRootModel model = rootManager.getModifiableModel();

    if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
      model.inheritSdk();
    }
    else {
      Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
      if (jdk != null) {
        model.setSdk(jdk);
      }
      else {
        model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
      }
    }

    model.commit();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:MavenIdeaPluginConfigurer.java


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