本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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() + "'");
}
}
示例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;
}