Java 类com.intellij.openapi.projectRoots.JavaSdkVersion 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:ImportProjectProgressModalWindow.java   
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());
        }
    }
}
项目:intellij-ce-playground    文件:JavaResolveUtil.java   
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;
}
项目:intellij-ce-playground    文件:CandidateInfo.java   
@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;
}
项目:intellij-ce-playground    文件:RenderErrorPanel.java   
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);
}
项目:intellij-ce-playground    文件:HighlightMethodUtil.java   
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);
}
项目:intellij-ce-playground    文件:GenericsHighlightUtil.java   
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);
}
项目:intellij-ce-playground    文件:GenerateEqualsWizard.java   
@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;
}
项目:intellij-ce-playground    文件:JavaProjectDataService.java   
@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;
}
项目:intellij-ce-playground    文件:CoverageJavaRunConfigurationExtension.java   
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));
    }
  }
}
项目:intellij-ce-playground    文件:MethodCandidateInfo.java   
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());
}
项目:intellij-ce-playground    文件:JavaSuppressionUtil.java   
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);
}
项目:intellij-ce-playground    文件:Java15APIUsageInspectionBase.java   
@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));
        }
      }
    }
  }
}
项目:intellij-ce-playground    文件:JavacQuirksInspectionVisitor.java   
@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);
  }
}
项目:intellij-ce-playground    文件:GenericsHighlightUtil.java   
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);
    }
  }
}
项目:intellij-ce-playground    文件:GenerateEqualsWizard.java   
@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);
}
项目:intellij-ce-playground    文件:GenerateEqualsWizard.java   
@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;
}
项目:intellij-ce-playground    文件:GenerateEqualsWizard.java   
@Override
public String getTooltip(MemberInfo memberInfo) {
  if (isMemberEnabled(memberInfo)) return null;
  if (!(memberInfo.getMember() instanceof PsiField)) return CodeInsightBundle.message("generate.equals.hashcode.internal.error");
  final PsiField field = (PsiField)memberInfo.getMember();
  final PsiType type = field.getType();
  if (!(type instanceof PsiArrayType) || JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5)) return null;
  return CodeInsightBundle.message("generate.equals.hashcode.warning.hashcode.for.arrays.is.not.supported");
}
项目:intellij-ce-playground    文件:ReplaceAddAllArrayToCollectionFix.java   
@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;
}
项目:intellij-ce-playground    文件:LanguageLevelProjectExtensionImpl.java   
private void projectSdkChanged(@Nullable Sdk sdk) {
  if (isDefault() && sdk != null) {
    JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
    if (version != null) {
      setLanguageLevel(version.getMaxLanguageLevel());
    }
  }
}
项目:intellij-ce-playground    文件:JavaRegExpHost.java   
@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;
}
项目:intellij-ce-playground    文件:JavaRegExpHost.java   
@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;
}
项目:intellij-ce-playground    文件:Jdks.java   
public static boolean isApplicableJdk(@NotNull Sdk jdk, @Nullable LanguageLevel langLevel) {
  if (!(jdk.getSdkType() instanceof JavaSdk)) {
    return false;
  }
  if (langLevel == null) {
    langLevel = DEFAULT_LANG_LEVEL;
  }
  JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
  if (version != null) {
    //noinspection TestOnlyProblems
    return hasMatchingLangLevel(version, langLevel);
  }
  return false;
}
项目:intellij-ce-playground    文件:TypeInference18Test.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  myOldLanguageLevel = LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).getLanguageLevel();
  LanguageLevelProjectExtension.getInstance(myJavaFacade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
  IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
}
项目:intellij-ce-playground    文件:JdkDetection.java   
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;
}
项目:intellij-ce-playground    文件:Jdks.java   
@NotNull
private static JavaSdkVersion getVersion(@NotNull String jdkRoot) {
  String version = JavaSdk.getInstance().getVersionString(jdkRoot);
  if (version == null) {
    return JavaSdkVersion.JDK_1_0;
  }
  JavaSdkVersion sdkVersion = JavaSdk.getInstance().getVersion(version);
  return sdkVersion == null ? JavaSdkVersion.JDK_1_0 : sdkVersion;
}
项目:intellij-ce-playground    文件:LightAdvHighlightingJdk8Test.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  enableInspectionTools(new JavacQuirksInspection());
  setLanguageLevel(LanguageLevel.JDK_1_8);
  IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
}
项目:intellij-ce-playground    文件:PsiDiamondTypeImpl.java   
public static DiamondInferenceResult resolveInferredTypesNoCheck(final PsiNewExpression newExpression, final PsiElement context) {
  final Ref<MethodCandidateInfo> staticFactoryRef = new Ref<MethodCandidateInfo>();
  final PsiSubstitutor inferredSubstitutor = ourDiamondGuard.doPreventingRecursion(context, false, new Computable<PsiSubstitutor>() {
    @Override
    public PsiSubstitutor compute() {
      final MethodCandidateInfo staticFactoryCandidateInfo = context == newExpression ? 
                                                             CachedValuesManager.getCachedValue(context,
                                                                                                new CachedValueProvider<MethodCandidateInfo>() {
                                                                                                  @Nullable
                                                                                                  @Override
                                                                                                  public Result<MethodCandidateInfo> compute() {
                                                                                                    return new Result<MethodCandidateInfo>(getStaticFactoryCandidateInfo(newExpression, newExpression), 
                                                                                                                                           PsiModificationTracker.MODIFICATION_COUNT);
                                                                                                  }
                                                                                                }) 
                                                                                      : getStaticFactoryCandidateInfo(newExpression, context);
      staticFactoryRef.set(staticFactoryCandidateInfo);
      return staticFactoryCandidateInfo != null ? staticFactoryCandidateInfo.getSubstitutor() : null;
    }
  });
  if (inferredSubstitutor == null) {
    return DiamondInferenceResult.NULL_RESULT;
  }
  final MethodCandidateInfo staticFactoryInfo = staticFactoryRef.get();
  if (staticFactoryInfo == null) {
    LOG.error(inferredSubstitutor);
    return DiamondInferenceResult.NULL_RESULT;
  }
  final PsiMethod staticFactory = staticFactoryInfo.getElement();
  final PsiTypeParameter[] parameters = staticFactory.getTypeParameters();
  final PsiElement staticFactoryContext = staticFactory.getContext();
  final PsiClass psiClass = PsiTreeUtil.getContextOfType(staticFactoryContext, PsiClass.class, false);
  if (psiClass == null) {
    LOG.error("failed for expression:" + newExpression);
    return DiamondInferenceResult.NULL_RESULT;
  }
  final PsiTypeParameter[] classParameters = psiClass.getTypeParameters();
  final PsiJavaCodeReferenceElement classOrAnonymousClassReference = newExpression.getClassOrAnonymousClassReference();
  LOG.assertTrue(classOrAnonymousClassReference != null);
  final DiamondInferenceResult result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>");

  if (PsiUtil.isRawSubstitutor(staticFactory, inferredSubstitutor)) {
    if (!JavaVersionService.getInstance().isAtLeast(newExpression, JavaSdkVersion.JDK_1_8) && 
        PsiUtil.skipParenthesizedExprUp(newExpression.getParent()) instanceof PsiExpressionList) {
      for (PsiTypeParameter ignored : parameters) {
        result.addInferredType(PsiType.getJavaLangObject(newExpression.getManager(), GlobalSearchScope.allScope(newExpression.getProject())));
      }
    }
    return result;
  }

  for (PsiTypeParameter parameter : parameters) {
    for (PsiTypeParameter classParameter : classParameters) {
      if (Comparing.strEqual(classParameter.getName(), parameter.getName())) {
        result.addInferredType(inferredSubstitutor.substitute(parameter));
        break;
      }
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:GenericsHighlightingTest.java   
public void testIDEA127767() {
  doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
项目:intellij-ce-playground    文件:AdvHighlightingJdk7Test.java   
public void testAmbiguousVarargs() throws Exception {
  doTestAmbiguous(JavaSdkVersion.JDK_1_8);
}
项目:intellij-ce-playground    文件:Jdks.java   
@VisibleForTesting
static boolean hasMatchingLangLevel(@NotNull JavaSdkVersion jdkVersion, @NotNull LanguageLevel langLevel) {
  LanguageLevel max = jdkVersion.getMaxLanguageLevel();
  return max.isAtLeast(langLevel);
}
项目:intellij-ce-playground    文件:GenericsHighlightingTest.java   
public void testTypeDistinctProverForWildcardAndTypeParameter() throws Exception {
  doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
项目:intellij-ce-playground    文件:GenericsHighlightingTest.java   
public void testNestedLevelsToCheckTypeArguments() throws Exception {
  doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
项目:intellij-ce-playground    文件:GenericsHighlightingTest.java   
public void testMethodCallTypeNotErasedWhenUncheckedConversionWasAppliedButNoTypeParamsProvided() {
  doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
项目:intellij-ce-playground    文件:JreVersionDetector.java   
private static boolean isJre50(final Sdk jdk) {
  if (jdk == null) return false;
  return JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5);
}
项目:intellij-ce-playground    文件:JreVersionDetector.java   
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);
}
项目:intellij-ce-playground    文件:GenericsHighlightingTest.java   
public void testExpectedTypeFromOuterArrayCreation() throws Exception {
  doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
}
项目:intellij-ce-playground    文件:ClassLoadingErrorHandler.java   
@Override
public boolean handleError(@NotNull List<String> message,
                           @NotNull ExternalSystemException error,
                           @NotNull NotificationData notification,
                           @NotNull final Project project) {
  String firstLine = message.get(0);
  boolean classNotFound = firstLine.startsWith("Unable to load class");
  if (classNotFound || firstLine.startsWith("Unable to find method") || firstLine.contains("cannot be cast to")) {
    NotificationHyperlink openJdkSettingsHyperlink = null;
    NotificationHyperlink syncProjectHyperlink = SyncProjectWithExtraCommandLineOptionsHyperlink.syncProjectRefreshingDependencies();
    NotificationHyperlink stopDaemonsHyperlink = StopGradleDaemonsHyperlink.createStopGradleDaemonsHyperlink();

    boolean unitTestMode = ApplicationManager.getApplication().isUnitTestMode();

    boolean isJdk7 = false;
    String jdkVersion = null;
    if (unitTestMode) {
      isJdk7 = true;
    }
    else if (classNotFound) {
      Sdk jdk = IdeSdks.getJdk();
      if (jdk != null) {
        String jdkHomePath = jdk.getHomePath();
        if (jdkHomePath != null) {
          jdkVersion = JavaSdk.getJdkVersion(jdkHomePath);
        }
        JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
        isJdk7 = version == JDK_1_7;
      }
    }

    String jdk7Hint = "";
    if (isJdk7) {
      jdk7Hint = "<li>";
      if (jdkVersion != null) {
        jdk7Hint += String.format("You are using JDK version '%1$s'. ", jdkVersion);
      }
      jdk7Hint += "Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.\n" +
                  "Please update to a newer version (e.g. 1.7.0_67).";

      if (!unitTestMode) {
        openJdkSettingsHyperlink = OpenProjectStructureHyperlink.openJdkSettings(project);
        if (openJdkSettingsHyperlink != null) {
          jdk7Hint = jdk7Hint +"\n" + openJdkSettingsHyperlink.toHtml();
        }
      }

      jdk7Hint += "</li>";
    }

    String newMsg = firstLine + "\nPossible causes for this unexpected error include:<ul>" + jdk7Hint +
                    "<li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)\n" +
                    syncProjectHyperlink.toHtml() + "</li>" +
                    "<li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.\n" +
                    stopDaemonsHyperlink.toHtml() + "</li>" +
                    "<li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project " +
                    "or the version of Gradle requested by the project.</li></ul>" +
                    "In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.";

    String title = String.format(FAILED_TO_SYNC_GRADLE_PROJECT_ERROR_GROUP_FORMAT, project.getName());
    notification.setTitle(title);
    notification.setMessage(newMsg);
    notification.setNotificationCategory(NotificationCategory.convert(DEFAULT_NOTIFICATION_TYPE));

    if (openJdkSettingsHyperlink != null) {
      addNotificationListener(notification, project, openJdkSettingsHyperlink, syncProjectHyperlink, stopDaemonsHyperlink);
    }
    else {
      addNotificationListener(notification, project, syncProjectHyperlink, stopDaemonsHyperlink);
    }
    return true;
  }

  return false;
}
项目:intellij-ce-playground    文件:JavaProjectData.java   
@NotNull
public JavaSdkVersion getJdkVersion() {
  return myJdkVersion;
}
项目:intellij-ce-playground    文件:JavaProjectData.java   
public void setJdkVersion(@NotNull JavaSdkVersion jdkVersion) {
  myJdkVersion = jdkVersion;
}
项目:intellij-ce-playground    文件:AdvHighlightingJdk7Test.java   
private void doTestAmbiguous(@NotNull JavaSdkVersion javaSdkVersion) throws Exception {
  final String name = getTestName(true);
  IdeaTestUtil.setTestVersion(javaSdkVersion, getModule(), myTestRootDisposable);
  doTest(BASE_PATH + name + "/pck/AmbiguousMethodCall.java", BASE_PATH + "/" + name, false, false);
}