本文整理汇总了Java中com.intellij.openapi.projectRoots.JavaSdkVersion.isAtLeast方法的典型用法代码示例。如果您正苦于以下问题:Java JavaSdkVersion.isAtLeast方法的具体用法?Java JavaSdkVersion.isAtLeast怎么用?Java JavaSdkVersion.isAtLeast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.projectRoots.JavaSdkVersion
的用法示例。
在下文中一共展示了JavaSdkVersion.isAtLeast方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkImplicitThisReferenceBeforeSuper
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
@Nullable
static HighlightInfo checkImplicitThisReferenceBeforeSuper(@NotNull PsiClass aClass, @NotNull JavaSdkVersion javaSdkVersion) {
if (javaSdkVersion.isAtLeast(JavaSdkVersion.JDK_1_7)) return null;
if (aClass instanceof PsiAnonymousClass || aClass instanceof PsiTypeParameter) return null;
PsiClass superClass = aClass.getSuperClass();
if (superClass == null || !PsiUtil.isInnerClass(superClass)) return null;
PsiClass outerClass = superClass.getContainingClass();
if (!InheritanceUtil.isInheritorOrSelf(aClass, outerClass, true)) {
return null;
}
// 'this' can be used as an (implicit) super() qualifier
PsiMethod[] constructors = aClass.getConstructors();
if (constructors.length == 0) {
TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
return createMemberReferencedError(aClass.getName() + ".this", range);
}
for (PsiMethod constructor : constructors) {
if (!isSuperCalledInConstructor(constructor)) {
return createMemberReferencedError(aClass.getName() + ".this", HighlightNamesUtil.getMethodDeclarationTextRange(constructor));
}
}
return null;
}
示例2: canHave15Suppressions
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
public static boolean canHave15Suppressions(@NotNull PsiElement file) {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module == null) return false;
final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
if (jdk == null) return false;
JavaSdkVersion version = getVersion(jdk);
if (version == null) return false;
final boolean is_1_5 = version.isAtLeast(JavaSdkVersion.JDK_1_5);
return DaemonCodeAnalyzerSettings.getInstance().isSuppressWarnings() && is_1_5 && PsiUtil.isLanguageLevel5OrHigher(file);
}
示例3: visitClass
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
@Override public void visitClass(PsiClass aClass) {
// Don't go into classes (anonymous, locals).
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
final Module module = ModuleUtilCore.findModuleForPsiElement(aClass);
final LanguageLevel effectiveLanguageLevel = module != null ? getEffectiveLanguageLevel(module) : null;
if (effectiveLanguageLevel != null && !effectiveLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
final JavaSdkVersion version = JavaVersionService.getInstance().getJavaSdkVersion(aClass);
if (version != null && version.isAtLeast(JavaSdkVersion.JDK_1_8)) {
final List<PsiMethod> methods = new ArrayList<PsiMethod>();
for (HierarchicalMethodSignature methodSignature : aClass.getVisibleSignatures()) {
final PsiMethod method = methodSignature.getMethod();
if (ourDefaultMethods.contains(getSignature(method))) {
methods.add(method);
}
}
if (!methods.isEmpty()) {
PsiElement element2Highlight = aClass.getNameIdentifier();
if (element2Highlight == null) {
element2Highlight = aClass;
}
myHolder.registerProblem(element2Highlight,
methods.size() == 1 ? InspectionsBundle.message("inspection.1.8.problem.single.descriptor", methods.get(0).getName(), getJdkName(effectiveLanguageLevel))
: InspectionsBundle.message("inspection.1.8.problem.descriptor", methods.size(), getJdkName(effectiveLanguageLevel)),
QuickFixFactory.getInstance().createImplementMethodsFix(aClass));
}
}
}
}
}
示例4: setupExeParams
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的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);
}
}
示例5: supportsNamedGroupSyntax
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
@Override
public boolean supportsNamedGroupSyntax(RegExpGroup group) {
if (group.isNamedGroup()) {
final JavaSdkVersion version = getJavaVersion(group);
return version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7);
}
return false;
}
示例6: supportsNamedGroupRefSyntax
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
@Override
public boolean supportsNamedGroupRefSyntax(RegExpNamedGroupRef ref) {
if (ref.isNamedGroupRef()) {
final JavaSdkVersion version = getJavaVersion(ref);
return version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7);
}
return false;
}
示例7: isJdk7
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
private static boolean isJdk7(@NotNull File path) {
String jdkVersion = JavaSdk.getJdkVersion(path.getAbsolutePath());
if (jdkVersion != null) {
JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdkVersion);
if (version != null && !version.isAtLeast(JavaSdkVersion.JDK_1_7)) {
return false;
}
}
return true;
}
示例8: isJre50
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
private static boolean isJre50(final @Nullable String versionString) {
if (versionString == null) return false;
JavaSdkVersion version = JavaSdk.getInstance().getVersion(versionString);
return version != null && version.isAtLeast(JavaSdkVersion.JDK_1_5);
}
示例9: supportsExtendedHexCharacter
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
@Override
public boolean supportsExtendedHexCharacter(RegExpChar regExpChar) {
final JavaSdkVersion version = getJavaVersion(regExpChar);
return version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7);
}
示例10: getBuildProcessRuntimeSdk
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
@NotNull
public static Pair<Sdk, JavaSdkVersion> getBuildProcessRuntimeSdk(Project project) {
Sdk projectJdk = null;
int sdkMinorVersion = 0;
JavaSdkVersion sdkVersion = null;
final Set<Sdk> candidates = new LinkedHashSet<Sdk>();
final Sdk defaultSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (defaultSdk != null && defaultSdk.getSdkType() instanceof JavaSdkType) {
candidates.add(defaultSdk);
}
for (Module module : ModuleManager.getInstance(project).getModules()) {
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
candidates.add(sdk);
}
}
// now select the latest version from the sdks that are used in the project, but not older than the internal sdk version
final JavaSdk javaSdkType = JavaSdk.getInstance();
for (Sdk candidate : candidates) {
final String vs = candidate.getVersionString();
if (vs != null) {
final JavaSdkVersion candidateVersion = javaSdkType.getVersion(vs);
if (candidateVersion != null) {
final int candidateMinorVersion = getMinorVersion(vs);
if (projectJdk == null) {
sdkVersion = candidateVersion;
sdkMinorVersion = candidateMinorVersion;
projectJdk = candidate;
}
else {
final int result = candidateVersion.compareTo(sdkVersion);
if (result > 0 || (result == 0 && candidateMinorVersion > sdkMinorVersion)) {
sdkVersion = candidateVersion;
sdkMinorVersion = candidateMinorVersion;
projectJdk = candidate;
}
}
}
}
}
final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
if (projectJdk == null || sdkVersion == null || !sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_6)) {
projectJdk = internalJdk;
sdkVersion = javaSdkType.getVersion(internalJdk);
}
return Pair.create(projectJdk, sdkVersion);
}
示例11: deriveValues
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
/**
* Fill in the values that can be derived from the selected min SDK level:
*
* minApiLevel will be set to the selected api level (string or number)
* minApi will be set to the numerical equivalent
* buildApi will be set to the highest installed platform, or to the preview platform if a preview is selected
* buildApiString will be set to the corresponding string
* targetApi will be set to the highest installed platform or to the preview platform if a preview is selected
* targetApiString will be set to the corresponding string
* @param stateStore
* @param modified
*/
public void deriveValues(@NotNull ScopedStateStore stateStore, @NotNull Set<Key> modified) {
if (modified.contains(myTargetComboBoxKey) || modified.contains(myInclusionKey)) {
AndroidTargetComboBoxItem targetItem = stateStore.get(myTargetComboBoxKey);
if (targetItem == null) {
return;
}
stateStore.put(getMinApiKey(myFormFactor), targetItem.id.toString());
stateStore.put(getMinApiLevelKey(myFormFactor), targetItem.apiLevel);
IAndroidTarget target = targetItem.target;
if (target != null && (target.getVersion().isPreview() || !target.isPlatform())) {
// Make sure we set target and build to the preview version as well
populateApiLevels(targetItem.apiLevel, target, stateStore);
} else {
int targetApiLevel;
if (ourHighestInstalledApiTarget != null) {
targetApiLevel = ourHighestInstalledApiTarget.getVersion().getFeatureLevel();
} else {
targetApiLevel = 0;
}
populateApiLevels(targetApiLevel, ourHighestInstalledApiTarget, stateStore);
}
// Check to see if this is installed. If not, request that we install it
if (myInstallRequest != null) {
// First remove the last request, no need to install more than one platform
stateStore.listRemove(INSTALL_REQUESTS_KEY, myInstallRequest);
}
if (target == null) {
AndroidVersion androidVersion = new AndroidVersion(targetItem.apiLevel, null);
// TODO: If the user has no APIs installed, we then request to install whichever version the user has targeted here.
// Instead, we should choose to install the highest stable API possible. However, users having no SDK at all installed is pretty
// unlikely, so this logic can wait for a followup CL.
if (ourHighestInstalledApiTarget == null ||
(androidVersion.getApiLevel() > ourHighestInstalledApiTarget.getVersion().getApiLevel() &&
!ourInstalledVersions.contains(androidVersion) &&
stateStore.get(myInclusionKey))) {
IPkgDesc platformDescription =
PkgDesc.Builder.newPlatform(androidVersion, new MajorRevision(1), FullRevision.NOT_SPECIFIED).create();
stateStore.listPush(INSTALL_REQUESTS_KEY, platformDescription);
myInstallRequest = platformDescription;
populateApiLevels(androidVersion.getApiLevel(), ourHighestInstalledApiTarget, stateStore);
}
}
PropertiesComponent.getInstance().setValue(getPropertiesComponentMinSdkKey(myFormFactor), targetItem.id.toString());
// Check Java language level; should be 7 for L; eventually this will be automatically defaulted by the Android Gradle plugin
// instead: https://code.google.com/p/android/issues/detail?id=76252
String javaVersion = null;
if (ourHighestInstalledApiTarget != null && ourHighestInstalledApiTarget.getVersion().getFeatureLevel() >= 21) {
AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
if (sdkData != null) {
JavaSdk jdk = JavaSdk.getInstance();
Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(jdk);
if (sdk != null) {
JavaSdkVersion version = jdk.getVersion(sdk);
if (version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7)) {
javaVersion = JavaSdkVersion.JDK_1_7.getDescription();
}
}
}
}
stateStore.put(getLanguageLevelKey(myFormFactor), javaVersion);
}
}
示例12: hasRequiredJdk
import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入方法依赖的package包/类
private static boolean hasRequiredJdk(@NotNull JavaSdkVersion jdkVersion) {
Sdk jdk = IdeSdks.getJdk();
assertNotNull("Expecting to have a JDK", jdk);
JavaSdkVersion currentVersion = JavaSdk.getInstance().getVersion(jdk);
return currentVersion != null && currentVersion.isAtLeast(jdkVersion);
}