本文整理汇总了Java中com.intellij.openapi.projectRoots.Sdk.getSdkType方法的典型用法代码示例。如果您正苦于以下问题:Java Sdk.getSdkType方法的具体用法?Java Sdk.getSdkType怎么用?Java Sdk.getSdkType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.projectRoots.Sdk
的用法示例。
在下文中一共展示了Sdk.getSdkType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initArtifacts
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void initArtifacts(Project project, GenerationOptions genOptions, CompositeGenerator generator) {
final Collection<? extends Artifact> artifacts =
ArtifactManager.getInstance(project).getArtifactsByType(JavaFxApplicationArtifactType.getInstance());
if (artifacts.isEmpty()) return;
final Sdk[] jdks = BuildProperties.getUsedJdks(project);
Sdk javaSdk = null;
for (Sdk jdk : jdks) {
if (jdk.getSdkType() instanceof JavaSdkType) {
javaSdk = jdk;
break;
}
}
if (javaSdk != null) {
final Tag taskdef = new Tag("taskdef",
Couple.of("resource", "com/sun/javafx/tools/ant/antlib.xml"),
Couple.of("uri", "javafx:com.sun.javafx.tools.ant"),
Couple.of("classpath",
BuildProperties
.propertyRef(BuildProperties.getJdkHomeProperty(javaSdk.getName())) +
"/lib/ant-javafx.jar"));
generator.add(taskdef);
}
}
示例2: generateCommandLine
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
protected GeneralCommandLine generateCommandLine() {
GeneralCommandLine commandLine = new GeneralCommandLine();
final LuaRunConfiguration cfg = (LuaRunConfiguration) runConfiguration;
if (cfg.isOverrideSDKInterpreter()) {
if (!StringUtil.isEmptyOrSpaces(cfg.getInterpreterPath()))
commandLine.setExePath(cfg.getInterpreterPath());
} else {
final Sdk sdk = cfg.getSdk();
if (sdk == null) {
fillInterpreterCommandLine(commandLine);
} else if (sdk.getSdkType() instanceof LuaSdkType) {
String sdkHomePath = StringUtil.notNullize(sdk.getHomePath());
String sdkInterpreter = getTopLevelExecutable(sdkHomePath).getAbsolutePath();
commandLine.setExePath(sdkInterpreter);
}
}
commandLine.getEnvironment().putAll(cfg.getEnvs());
commandLine.setPassParentEnvironment(cfg.isPassParentEnvs());
return configureCommandLine(commandLine);
}
示例3: isInAndroidSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static boolean isInAndroidSdk(@NonNull PsiElement element) {
PsiFile file = element.getContainingFile();
if (file == null) {
return false;
}
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return false;
}
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(element.getProject()).getFileIndex();
List<OrderEntry> entries = projectFileIndex.getOrderEntriesForFile(virtualFile);
for (OrderEntry entry : entries) {
if (entry instanceof JdkOrderEntry) {
Sdk sdk = ((JdkOrderEntry)entry).getJdk();
if (sdk != null && sdk.getSdkType() instanceof AndroidSdkType) {
return true;
}
}
}
return false;
}
示例4: excludeSdkTestsScope
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
public static GlobalSearchScope excludeSdkTestsScope(Project project, Sdk sdk) {
if (sdk != null && sdk.getSdkType() instanceof PythonSdkType) {
VirtualFile libDir = findLibDir(sdk);
if (libDir != null) {
// superset of test dirs found in Python 2.5 to 3.1
List<VirtualFile> testDirs = findTestDirs(libDir, "test", "bsddb/test", "ctypes/test", "distutils/tests", "email/test",
"importlib/test", "json/tests", "lib2to3/tests", "sqlite3/test", "tkinter/test",
"idlelib/testcode.py");
if (!testDirs.isEmpty()) {
GlobalSearchScope scope = buildUnionScope(project, testDirs);
return GlobalSearchScope.notScope(scope);
}
}
}
return null;
}
示例5: run
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void run() {
final Set<String> sdkNames = getSdkNamesFromModules(myProblemModules);
if (sdkNames.size() == 1) {
final Sdk sdk = ProjectJdkTable.getInstance().findJdk(sdkNames.iterator().next());
if (sdk != null && sdk.getSdkType() instanceof AndroidSdkType) {
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
if (ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
@Override
public void run() {
config.select(sdk, true);
}
})) {
askAndRebuild(myProject);
}
return;
}
}
final String moduleToSelect = myProblemModules.size() > 0
? myProblemModules.iterator().next().getName()
: null;
if (ModulesConfigurator.showDialog(myProject, moduleToSelect, ClasspathEditor.NAME)) {
askAndRebuild(myProject);
}
}
示例6: addJavaHome
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public static void addJavaHome(@NotNull JavaParameters params, @NotNull Module module) {
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
String path = StringUtil.trimEnd(sdk.getHomePath(), File.separator);
if (StringUtil.isNotEmpty(path)) {
params.addEnv("JAVA_HOME", FileUtil.toSystemDependentName(path));
}
}
}
示例7: getJavaLanguageLevel
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
/**
* Returns null if the SDK is not a java JDK, or doesn't have a recognized java langauge level.
*/
@Nullable
private static LanguageLevel getJavaLanguageLevel(Sdk sdk) {
if (!(sdk.getSdkType() instanceof JavaSdk)) {
return null;
}
JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
return version != null ? version.getMaxLanguageLevel() : null;
}
示例8: setupExeParams
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private void setupExeParams(final Sdk jdk, GeneralCommandLine cmdLine) throws ExecutionException {
final String jdkPath =
jdk != null && jdk.getSdkType() instanceof JavaSdkType ? ((JavaSdkType)jdk.getSdkType()).getBinPath(jdk) : null;
if (jdkPath == null) {
throw new CantRunException(JavadocBundle.message("javadoc.generate.no.jdk.path"));
}
JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
if (myConfiguration.HEAP_SIZE != null && myConfiguration.HEAP_SIZE.trim().length() != 0) {
if (version == null || version.isAtLeast(JavaSdkVersion.JDK_1_2)) {
cmdLine.getParametersList().prepend("-J-Xmx" + myConfiguration.HEAP_SIZE + "m");
}
else {
cmdLine.getParametersList().prepend("-J-mx" + myConfiguration.HEAP_SIZE + "m");
}
}
cmdLine.setWorkDirectory((File)null);
@NonNls final String javadocExecutableName = File.separator + (SystemInfo.isWindows ? "javadoc.exe" : "javadoc");
@NonNls String exePath = jdkPath.replace('/', File.separatorChar) + javadocExecutableName;
if (new File(exePath).exists()) {
cmdLine.setExePath(exePath);
}
else { //try to use wrapper jdk
exePath = new File(jdkPath).getParent().replace('/', File.separatorChar) + javadocExecutableName;
if (!new File(exePath).exists()) {
final File parent = new File(System.getProperty("java.home")).getParentFile(); //try system jre
exePath = parent.getPath() + File.separator + "bin" + javadocExecutableName;
if (!new File(exePath).exists()) {
throw new CantRunException(JavadocBundle.message("javadoc.generate.no.jdk.path"));
}
}
cmdLine.setExePath(exePath);
}
}
示例9: forJdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@NotNull
@Override
public CellAppearanceEx forJdk(@Nullable final Sdk jdk, final boolean isInComboBox, final boolean selected, final boolean showVersion) {
if (jdk == null) {
return FileAppearanceService.getInstance().forInvalidUrl(NO_JDK);
}
String name = jdk.getName();
CompositeAppearance appearance = new CompositeAppearance();
SdkType sdkType = (SdkType)jdk.getSdkType();
appearance.setIcon(sdkType.getIcon());
SimpleTextAttributes attributes = getTextAttributes(sdkType.sdkHasValidPath(jdk), selected);
CompositeAppearance.DequeEnd ending = appearance.getEnding();
ending.addText(name, attributes);
if (showVersion) {
String versionString = jdk.getVersionString();
if (versionString != null && !versionString.equals(name)) {
SimpleTextAttributes textAttributes = isInComboBox && !selected ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES :
SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN,
Color.WHITE): SimpleTextAttributes.GRAY_ATTRIBUTES;
ending.addComment(versionString, textAttributes);
}
}
return ending.getAppearance();
}
示例10: getSdksOfType
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public List<Sdk> getSdksOfType(SdkTypeId type) {
List<Sdk> result = new ArrayList<Sdk>();
synchronized (mySdks) {
for (Sdk sdk : mySdks) {
if (sdk.getSdkType() == type) {
result.add(sdk);
}
}
}
return result;
}
示例11: isJdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public boolean isJdk() {
if (myNode instanceof NamedLibraryElementNode) {
NamedLibraryElement value = ((NamedLibraryElementNode)myNode).getValue();
assertNotNull(value);
LibraryOrSdkOrderEntry orderEntry = value.getOrderEntry();
if (orderEntry instanceof JdkOrderEntry) {
Sdk sdk = ((JdkOrderEntry)orderEntry).getJdk();
return sdk.getSdkType() instanceof JavaSdk;
}
}
return false;
}
示例12: getPythonSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
/** Find a python SDK associated with a blaze project, or its workspace module. */
@Nullable
public static Sdk getPythonSdk(Project project) {
Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (projectSdk != null && projectSdk.getSdkType() instanceof PythonSdkType) {
return projectSdk;
}
// look for a SDK associated with a python facet instead.
return PythonSdkType.findPythonSdk(
ModuleManager.getInstance(project)
.findModuleByName(BlazeDataStorage.WORKSPACE_MODULE_NAME));
}
示例13: getAllPythonSdks
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public List<Sdk> getAllPythonSdks(@Nullable final Project project) {
List<Sdk> result = new ArrayList<Sdk>();
for (Sdk sdk : getModel().getSdks()) {
if (sdk.getSdkType() instanceof PythonSdkType) {
result.add(sdk);
}
}
Collections.sort(result, new PyInterpreterComparator(project));
addDetectedSdks(result);
return result;
}
示例14: getSkeletonFile
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
public static PyFile getSkeletonFile(final @NotNull Project project, @NotNull Sdk sdk, @NotNull String name) {
SdkTypeId sdkType = sdk.getSdkType();
if (sdkType instanceof PythonSdkType) {
// dig out the builtins file, create an instance based on it
final String[] urls = sdk.getRootProvider().getUrls(PythonSdkType.BUILTIN_ROOT_TYPE);
for (String url : urls) {
if (url.contains(PythonSdkType.SKELETON_DIR_NAME)) {
final String builtins_url = url + "/" + name;
File builtins = new File(VfsUtilCore.urlToPath(builtins_url));
if (builtins.isFile() && builtins.canRead()) {
final VirtualFile builtins_vfile = LocalFileSystem.getInstance().findFileByIoFile(builtins);
if (builtins_vfile != null) {
final Ref<PyFile> result = Ref.create();
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
PsiFile file = PsiManager.getInstance(project).findFile(builtins_vfile);
if (file instanceof PyFile) {
result.set((PyFile)file);
}
}
});
return result.get();
}
}
}
}
}
return null;
}
示例15: getResolveScope
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Nullable
@Override
public GlobalSearchScope getResolveScope(@NotNull VirtualFile file, Project project) {
if (!ProjectFacetManager.getInstance(project).hasFacets(AndroidFacet.ID)) return null;
ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
JdkOrderEntry entry = ContainerUtil.findInstance(index.getOrderEntriesForFile(file), JdkOrderEntry.class);
final Sdk sdk = entry == null ? null : entry.getJdk();
if (sdk == null || !(sdk.getSdkType() instanceof AndroidSdkType)) {
return null;
}
return new MyJdkScope(project, entry, index.isInLibrarySource(file));
}