本文整理汇总了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;
}
示例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));
}
}
示例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);
}
示例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();
}
示例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();
}
}