• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JavaSdkVersion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.projectRoots.JavaSdkVersion的典型用法代码示例。如果您正苦于以下问题:Java JavaSdkVersion类的具体用法?Java JavaSdkVersion怎么用?Java JavaSdkVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JavaSdkVersion类属于com.intellij.openapi.projectRoots包,在下文中一共展示了JavaSdkVersion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: selectSdk

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
private void selectSdk(@NotNull final Project project) {
    Validate.notNull(project);

    final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);

    final Sdk projectSdk = projectRootManager.getProjectSdk();

    if (null == projectSdk) {
        return;
    }

    if (StringUtils.isNotBlank(projectSdk.getVersionString())) {
        final JavaSdkVersion sdkVersion = JdkVersionUtil.getVersion(projectSdk.getVersionString());
        final LanguageLevelProjectExtension languageLevelExt = LanguageLevelProjectExtension.getInstance(project);

        if (sdkVersion.getMaxLanguageLevel() != languageLevelExt.getLanguageLevel()) {
            languageLevelExt.setLanguageLevel(sdkVersion.getMaxLanguageLevel());
        }
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:ImportProjectProgressModalWindow.java


示例2: getTopLevelClass

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
private static PsiClass getTopLevelClass(@NotNull PsiElement place, PsiClass memberClass) {
  PsiClass lastClass = null;
  Boolean isAtLeast17 = null;
  for (PsiElement placeParent = place; placeParent != null; placeParent = placeParent.getContext()) {
    if (placeParent instanceof PsiClass && !(placeParent instanceof PsiAnonymousClass)) {
      final boolean isTypeParameter = placeParent instanceof PsiTypeParameter;
      if (isTypeParameter && isAtLeast17 == null) {
        isAtLeast17 = JavaVersionService.getInstance().isAtLeast(placeParent, JavaSdkVersion.JDK_1_7);
      }
      if (!isTypeParameter || isAtLeast17) {
        PsiClass aClass = (PsiClass)placeParent;

        if (memberClass != null && aClass.isInheritor(memberClass, true)) return aClass;

        lastClass = aClass;
      }
    }
  }

  return lastClass;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:JavaResolveUtil.java


示例3: isAccessible

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Override
public boolean isAccessible() {
  Boolean Accessible = myAccessible;
  boolean accessible = true;
  if(Accessible == null) {
    if (myPlace != null && myCandidate instanceof PsiMember) {
      final PsiMember member = (PsiMember)myCandidate;
      accessible = JavaPsiFacade.getInstance(myPlace.getProject()).getResolveHelper()
        .isAccessible(member, member.getModifierList(), myPlace, myAccessClass, myCurrentFileResolveContext);
      if (accessible && member.hasModifierProperty(PsiModifier.PRIVATE) && myPlace instanceof PsiReferenceExpression && JavaVersionService.getInstance().isAtLeast(myPlace, JavaSdkVersion.JDK_1_7)) {
        accessible = !isAccessedThroughTypeParameterBound();
      }
    }
    myAccessible = accessible;
  }
  else {
    accessible = Accessible;
  }
  return accessible;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:CandidateInfo.java


示例4: isBuiltByJdk7OrHigher

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
private static boolean isBuiltByJdk7OrHigher(@NotNull Module module) {
  Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
  if (sdk == null) {
    return false;
  }

  if (isAndroidSdk(sdk)) {
    AndroidSdkAdditionalData data = getAndroidSdkAdditionalData(sdk);
    if (data != null) {
      Sdk jdk = data.getJavaSdk();
      if (jdk != null) {
        sdk = jdk;
      }
    }
  }
  return sdk.getSdkType() instanceof JavaSdk &&
         JavaSdk.getInstance().isOfVersionOrHigher(sdk, JavaSdkVersion.JDK_1_7);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:RenderErrorPanel.java


示例5: checkNewExpression

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
static void checkNewExpression(@NotNull PsiNewExpression expression,
                               PsiType type,
                               @NotNull HighlightInfoHolder holder,
                               @NotNull JavaSdkVersion javaSdkVersion) {
  if (!(type instanceof PsiClassType)) return;
  PsiClassType.ClassResolveResult typeResult = ((PsiClassType)type).resolveGenerics();
  PsiClass aClass = typeResult.getElement();
  if (aClass == null) return;
  if (aClass instanceof PsiAnonymousClass) {
    type = ((PsiAnonymousClass)aClass).getBaseClassType();
    typeResult = ((PsiClassType)type).resolveGenerics();
    aClass = typeResult.getElement();
    if (aClass == null) return;
  }

  PsiJavaCodeReferenceElement classReference = expression.getClassOrAnonymousClassReference();
  checkConstructorCall(typeResult, expression, type, classReference, holder, javaSdkVersion);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:HighlightMethodUtil.java


示例6: checkEnumConstantForConstructorProblems

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
static void checkEnumConstantForConstructorProblems(@NotNull PsiEnumConstant enumConstant,
                                                    @NotNull HighlightInfoHolder holder,
                                                    @NotNull JavaSdkVersion javaSdkVersion) {
  PsiClass containingClass = enumConstant.getContainingClass();
  if (enumConstant.getInitializingClass() == null) {
    HighlightInfo highlightInfo = HighlightClassUtil.checkInstantiationOfAbstractClass(containingClass, enumConstant.getNameIdentifier());
    if (highlightInfo != null) {
      QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createImplementMethodsFix(enumConstant));
      holder.add(highlightInfo);
      return;
    }
    highlightInfo = HighlightClassUtil.checkClassWithAbstractMethods(enumConstant.getContainingClass(), enumConstant, enumConstant.getNameIdentifier().getTextRange());
    if (highlightInfo != null) {
      holder.add(highlightInfo);
      return;
    }
  }
  PsiClassType type = JavaPsiFacade.getInstance(holder.getProject()).getElementFactory().createType(containingClass);

  HighlightMethodUtil.checkConstructorCall(type.resolveGenerics(), enumConstant, type, null, holder, javaSdkVersion);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:GenericsHighlightUtil.java


示例7: getTooltip

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Override
public String getTooltip(MemberInfo memberInfo) {
  if (checkForProblems(memberInfo) == OK) return null;
  if (!(memberInfo.getMember() instanceof PsiField)) return CodeInsightBundle.message("generate.equals.hashcode.internal.error");
  final PsiField field = (PsiField)memberInfo.getMember();
  if (!JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5)) {
    final PsiType type = field.getType();
    if (PsiAdapter.isNestedArray(type)) {
      return CodeInsightBundle .message("generate.equals.warning.equals.for.nested.arrays.not.supported");
    }
    if (GenerateEqualsHelper.isArrayOfObjects(type)) {
      return CodeInsightBundle.message("generate.equals.warning.generated.equals.could.be.incorrect");
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GenerateEqualsWizard.java


示例8: findJdk

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Nullable
private static Sdk findJdk(@NotNull JavaSdkVersion version) {
  JavaSdk javaSdk = JavaSdk.getInstance();
  List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk);
  Sdk candidate = null;
  for (Sdk sdk : javaSdks) {
    JavaSdkVersion v = javaSdk.getVersion(sdk);
    if (v == version) {
      return sdk;
    }
    else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
      candidate = sdk;
    }
  }
  return candidate;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaProjectDataService.java


示例9: updateJavaParameters

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
public void updateJavaParameters(RunConfigurationBase configuration, JavaParameters params, RunnerSettings runnerSettings) {
  if (!isApplicableFor(configuration)) {
    return;
  }

  final JavaCoverageEnabledConfiguration coverageConfig = JavaCoverageEnabledConfiguration.getFrom(configuration);
  //noinspection ConstantConditions
  coverageConfig.setCurrentCoverageSuite(null);
  final CoverageRunner coverageRunner = coverageConfig.getCoverageRunner();
  if (runnerSettings instanceof CoverageRunnerData && coverageRunner != null) {
    final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(configuration.getProject());
    coverageConfig.setCurrentCoverageSuite(coverageDataManager.addCoverageSuite(coverageConfig));
    coverageConfig.appendCoverageArgument(configuration, params);

    final Sdk jdk = params.getJdk();
    if (jdk != null && JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_7) && coverageRunner instanceof JavaCoverageRunner && !((JavaCoverageRunner)coverageRunner).isJdk7Compatible()) {
      Notifications.Bus.notify(new Notification("Coverage", "Coverage instrumentation is not fully compatible with JDK 7",
                                                coverageRunner.getPresentableName() +
                                                " coverage instrumentation can lead to java.lang.VerifyError errors with JDK 7. If so, please try IDEA coverage runner.",
                                                NotificationType.WARNING));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CoverageJavaRunConfigurationExtension.java


示例10: isTypeArgumentsApplicable

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
private boolean isTypeArgumentsApplicable(Computable<PsiSubstitutor> computable) {
  final PsiMethod psiMethod = getElement();
  PsiTypeParameter[] typeParams = psiMethod.getTypeParameters();
  if (myTypeArguments != null && typeParams.length != myTypeArguments.length && !PsiUtil.isLanguageLevel7OrHigher(psiMethod)){
    return typeParams.length == 0 && JavaVersionService.getInstance().isAtLeast(psiMethod, JavaSdkVersion.JDK_1_7);
  }
  return GenericsUtil.isTypeArgumentsApplicable(typeParams, computable.compute(), getParent());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MethodCandidateInfo.java


示例11: 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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaSuppressionUtil.java


示例12: 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));
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:Java15APIUsageInspectionBase.java


示例13: visitIdentifier

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Override
public void visitIdentifier(PsiIdentifier identifier) {
  super.visitIdentifier(identifier);
  if ("_".equals(identifier.getText()) &&
      mySdkVersion != null && mySdkVersion.isAtLeast(JavaSdkVersion.JDK_1_8) &&
      myLanguageLevel.isLessThan(LanguageLevel.JDK_1_9)) {
    final String message = JavaErrorMessages.message("underscore.identifier.warn");
    myHolder.registerProblem(identifier, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavacQuirksInspectionVisitor.java


示例14: registerVariableParameterizedTypeFixes

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
private static void registerVariableParameterizedTypeFixes(HighlightInfo highlightInfo,
                                                           @NotNull PsiVariable variable,
                                                           @NotNull PsiReferenceParameterList parameterList,
                                                           @NotNull JavaSdkVersion version) {
  PsiType type = variable.getType();
  if (!(type instanceof PsiClassType)) return;

  if (DumbService.getInstance(variable.getProject()).isDumb()) return;

  String shortName = ((PsiClassType)type).getClassName();
  PsiManager manager = parameterList.getManager();
  final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject());
  PsiShortNamesCache shortNamesCache = PsiShortNamesCache.getInstance(parameterList.getProject());
  PsiClass[] classes = shortNamesCache.getClassesByName(shortName, GlobalSearchScope.allScope(manager.getProject()));
  PsiElementFactory factory = facade.getElementFactory();
  for (PsiClass aClass : classes) {
    if (checkReferenceTypeArgumentList(aClass, parameterList, PsiSubstitutor.EMPTY, false, version) == null) {
      PsiType[] actualTypeParameters = parameterList.getTypeArguments();
      PsiTypeParameter[] classTypeParameters = aClass.getTypeParameters();
      Map<PsiTypeParameter, PsiType> map = new java.util.HashMap<PsiTypeParameter, PsiType>();
      for (int j = 0; j < classTypeParameters.length; j++) {
        PsiTypeParameter classTypeParameter = classTypeParameters[j];
        PsiType actualTypeParameter = actualTypeParameters[j];
        map.put(classTypeParameter, actualTypeParameter);
      }
      PsiSubstitutor substitutor = factory.createSubstitutor(map);
      PsiType suggestedType = factory.createType(aClass, substitutor);
      HighlightUtil.registerChangeVariableTypeFixes(variable, suggestedType, variable.getInitializer(), highlightInfo);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:GenericsHighlightUtil.java


示例15: isMemberEnabled

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Override
public boolean isMemberEnabled(MemberInfo member) {
  if (!(member.getMember() instanceof PsiField)) return false;
  final PsiField field = (PsiField)member.getMember();
  final PsiType type = field.getType();
  return JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5) || !PsiAdapter.isNestedArray(type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:GenerateEqualsWizard.java


示例16: checkForProblems

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Override
public int checkForProblems(@NotNull MemberInfo member) {
  if (!(member.getMember() instanceof PsiField)) return ERROR;
  final PsiField field = (PsiField)member.getMember();
  final PsiType type = field.getType();
  if (!JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5)) {
    if (PsiAdapter.isNestedArray(type)) return ERROR;
    if (GenerateEqualsHelper.isArrayOfObjects(type)) return WARNING;
  }
  return OK;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GenerateEqualsWizard.java


示例17: isAvailable

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull final Project project, final Editor editor, final PsiFile file) {
  if (!myMethodCall.isValid()) return false;

  final Module module = ModuleUtilCore.findModuleForPsiElement(file);
  if (module == null) return false;
  final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
  if (jdk == null || !JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5)) return false;

  final PsiReferenceExpression expression = myMethodCall.getMethodExpression();
  final PsiElement element = expression.resolve();
  if (element instanceof PsiMethod) {
    final PsiMethod method = (PsiMethod)element;
    final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
    final PsiClass collectionsClass = psiFacade.findClass("java.util.Collection", GlobalSearchScope.allScope(project));
    if (collectionsClass != null && InheritanceUtil.isInheritorOrSelf(method.getContainingClass(), collectionsClass, true)) {
      if (Comparing.strEqual(method.getName(), "addAll") && PsiType.BOOLEAN.equals(method.getReturnType())) {
        final PsiParameter[] psiParameters = method.getParameterList().getParameters();
        if (psiParameters.length == 1 &&
            psiParameters[0].getType() instanceof PsiClassType &&
            InheritanceUtil.isInheritorOrSelf(((PsiClassType)psiParameters[0].getType()).resolve(), collectionsClass, true)) {
          final PsiExpressionList list = myMethodCall.getArgumentList();
          final PsiExpression[] expressions = list.getExpressions();
          if (expressions.length == 1) {
            if (expressions[0].getType() instanceof PsiArrayType) {
              return true;
            }
          }
        }
      }
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:ReplaceAddAllArrayToCollectionFix.java


示例18: projectSdkChanged

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
private void projectSdkChanged(@Nullable Sdk sdk) {
  if (isDefault() && sdk != null) {
    JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
    if (version != null) {
      setLanguageLevel(version.getMaxLanguageLevel());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:LanguageLevelProjectExtensionImpl.java


示例19: 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaRegExpHost.java


示例20: getJavaVersion

import com.intellij.openapi.projectRoots.JavaSdkVersion; //导入依赖的package包/类
@Nullable
private static JavaSdkVersion getJavaVersion(PsiElement element) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return JavaSdkVersion.JDK_1_9;
  }
  final Module module = ModuleUtilCore.findModuleForPsiElement(element);
  if (module != null) {
    final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
    if (sdk != null && sdk.getSdkType() instanceof JavaSdk) {
      return JavaSdk.getInstance().getVersion(sdk);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaRegExpHost.java



注:本文中的com.intellij.openapi.projectRoots.JavaSdkVersion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MetaData类代码示例发布时间:2022-05-22
下一篇:
Java Constants类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap