当前位置: 首页>>代码示例>>Java>>正文


Java JavaSdkVersion类代码示例

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


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


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