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


Java LanguageLevel.compareTo方法代码示例

本文整理汇总了Java中com.intellij.pom.java.LanguageLevel.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageLevel.compareTo方法的具体用法?Java LanguageLevel.compareTo怎么用?Java LanguageLevel.compareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.pom.java.LanguageLevel的用法示例。


在下文中一共展示了LanguageLevel.compareTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMaxJavaLangLevel

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
@VisibleForTesting
@Nullable
LanguageLevel getMaxJavaLangLevel() {
  LanguageLevel maxLangLevel = null;

  Module[] modules = ModuleManager.getInstance(myProject).getModules();
  for (Module module : modules) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null) {
      continue;
    }
    IdeaAndroidProject androidProject = facet.getIdeaAndroidProject();
    if (androidProject != null) {
      LanguageLevel langLevel = androidProject.getJavaLanguageLevel();
      if (langLevel != null && (maxLangLevel == null || maxLangLevel.compareTo(langLevel) < 0)) {
        maxLangLevel = langLevel;
      }
    }
  }
  return maxLangLevel;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PostProjectBuildTasksExecutor.java

示例2: getResultType

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
@Nullable
private static PsiType getResultType(PsiMethodCallExpression call,
                                     PsiReferenceExpression methodExpression,
                                     JavaResolveResult result,
                                     @NotNull final LanguageLevel languageLevel) {
  final PsiMethod method = (PsiMethod)result.getElement();
  if (method == null) return null;

  boolean is15OrHigher = languageLevel.compareTo(LanguageLevel.JDK_1_5) >= 0;
  final PsiType getClassReturnType = PsiTypesUtil.patchMethodGetClassReturnType(call, methodExpression, method,
                                                                                new Condition<IElementType>() {
                                                                                  @Override
                                                                                  public boolean value(IElementType type) {
                                                                                    return type != JavaElementType.CLASS;
                                                                                  }
                                                                                }, languageLevel);

  if (getClassReturnType != null) {
    return getClassReturnType;
  }

  PsiType ret = method.getReturnType();
  if (ret == null) return null;
  if (ret instanceof PsiClassType) {
    ret = ((PsiClassType)ret).setLanguageLevel(languageLevel);
  }
  if (is15OrHigher) {
    return captureReturnType(call, method, ret, result, languageLevel);
  }
  return TypeConversionUtil.erasure(ret);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PsiMethodCallExpressionImpl.java

示例3: checkSuperTypesWithDifferentTypeArguments

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
private static boolean checkSuperTypesWithDifferentTypeArguments(@NotNull PsiClassType.ClassResolveResult baseResult,
                                                                 @NotNull PsiClass derived,
                                                                 @NotNull PsiManager manager,
                                                                 @NotNull PsiSubstitutor derivedSubstitutor,
                                                                 Set<PsiClass> visited,
                                                                 @NotNull LanguageLevel languageLevel) {
  if (visited != null && visited.contains(derived)) return true;

  if (languageLevel.compareTo(LanguageLevel.JDK_1_5) < 0) return true;
  PsiClass base = baseResult.getElement();
  PsiClass[] supers = derived.getSupers();
  if (manager.areElementsEquivalent(base, derived)) {
    derivedSubstitutor = getSuperClassSubstitutor(derived, derived, derivedSubstitutor);
    return areSameArgumentTypes(derived, baseResult.getSubstitutor(), derivedSubstitutor, 1);
  }
  else {
    PsiSubstitutor baseSubstitutor = getMaybeSuperClassSubstitutor(derived, base, baseResult.getSubstitutor(), null);
    if (baseSubstitutor != null) {
      derivedSubstitutor = getSuperClassSubstitutor(derived, derived, derivedSubstitutor);
      if (!areSameArgumentTypes(derived, baseSubstitutor, derivedSubstitutor)) return false;
    }
  }

  if (visited == null) visited = new THashSet<PsiClass>();
  visited.add(derived);
  for (PsiClass aSuper : supers) {
    PsiSubstitutor s = getSuperClassSubstitutor(aSuper, derived, derivedSubstitutor);
    if (!checkSuperTypesWithDifferentTypeArguments(baseResult, aSuper, manager, s, visited, languageLevel)) return false;
  }

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

示例4: isForbiddenSignature

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
private static boolean isForbiddenSignature(@NotNull String signature, @NotNull LanguageLevel languageLevel, @NotNull Set<String> forbiddenApi) {
  if (forbiddenApi.contains(signature)) {
    return true;
  }
  if (languageLevel.compareTo(LanguageLevel.HIGHEST) == 0) {
    return false;
  }
  LanguageLevel nextLanguageLevel = LanguageLevel.values()[languageLevel.ordinal() + 1];
  Set<String> nextForbiddenApi = getForbiddenApi(nextLanguageLevel);
  return nextForbiddenApi != null && isForbiddenSignature(signature, nextLanguageLevel, nextForbiddenApi);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:Java15APIUsageInspectionBase.java

示例5: applyJdkToProject

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
public static void applyJdkToProject(@NotNull Project project, @NotNull Sdk jdk) {
  ProjectRootManagerEx rootManager = ProjectRootManagerEx.getInstanceEx(project);
  rootManager.setProjectSdk(jdk);

  JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
  if (version != null) {
    LanguageLevel maxLevel = version.getMaxLanguageLevel();
    LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(ProjectManager.getInstance().getDefaultProject());
    LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(project);
    if (extension.isDefault() || maxLevel.compareTo(ext.getLanguageLevel()) < 0) {
      ext.setLanguageLevel(maxLevel);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:NewProjectUtil.java

示例6: createClassOrInterface

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
public static PsiClass createClassOrInterface(Project project,
                                              PsiDirectory directory,
                                              String content,
                                              boolean reformat,
                                              String extension) throws IncorrectOperationException {
  if (extension == null) extension = StdFileTypes.JAVA.getDefaultExtension();
  final String name = "myClass" + "." + extension;
  final PsiFile psiFile = PsiFileFactory.getInstance(project).createFileFromText(name, StdFileTypes.JAVA, content);
  if (!(psiFile instanceof PsiJavaFile)){
    throw new IncorrectOperationException("This template did not produce a Java class or an interface\n"+psiFile.getText());
  }
  PsiJavaFile psiJavaFile = (PsiJavaFile)psiFile;
  final PsiClass[] classes = psiJavaFile.getClasses();
  if (classes.length == 0) {
    throw new IncorrectOperationException("This template did not produce a Java class or an interface\n"+psiFile.getText());
  }
  PsiClass createdClass = classes[0];
  if(reformat){
    CodeStyleManager.getInstance(project).reformat(psiJavaFile);
  }
  String className = createdClass.getName();
  JavaDirectoryServiceImpl.checkCreateClassOrInterface(directory, className);

  final LanguageLevel ll = JavaDirectoryService.getInstance().getLanguageLevel(directory);
  if (ll.compareTo(LanguageLevel.JDK_1_5) < 0) {
    if (createdClass.isAnnotationType()) {
      throw new IncorrectOperationException("Annotations only supported at language level 1.5 and higher");
    }

    if (createdClass.isEnum()) {
      throw new IncorrectOperationException("Enums only supported at language level 1.5 and higher");
    }
  }

  psiJavaFile = (PsiJavaFile)psiJavaFile.setName(className + "." + extension);
  PsiElement addedElement = directory.add(psiJavaFile);
  if (addedElement instanceof PsiJavaFile) {
    psiJavaFile = (PsiJavaFile)addedElement;

    return psiJavaFile.getClasses()[0];
  }
  else {
    PsiFile containingFile = addedElement.getContainingFile();
    throw new IncorrectOperationException("Selected class file name '" +
                                          containingFile.getName() +  "' mapped to not java file type '"+
                                          containingFile.getFileType().getDescription() + "'");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:JavaCreateFromTemplateHandler.java

示例7: isNotSupported

import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
private static boolean isNotSupported(@Nullable LanguageLevel languageLevel) {
  return languageLevel == null || languageLevel.compareTo(JDK_1_8) >= 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:JavaLanguageLevelModuleCustomizer.java


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