本文整理匯總了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();
}
}