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