本文整理汇总了Java中com.intellij.pom.java.LanguageLevel.equals方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageLevel.equals方法的具体用法?Java LanguageLevel.equals怎么用?Java LanguageLevel.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.pom.java.LanguageLevel
的用法示例。
在下文中一共展示了LanguageLevel.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSourceCommandLineSwitch
import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
public static void addSourceCommandLineSwitch(final Sdk jdk, LanguageLevel chunkLanguageLevel, @NonNls final List<String> commandLine) {
final String versionString = jdk.getVersionString();
if (StringUtil.isEmpty(versionString)) {
throw new IllegalArgumentException(CompilerBundle.message("javac.error.unknown.jdk.version", jdk.getName()));
}
final LanguageLevel applicableLanguageLevel = getApplicableLanguageLevel(versionString, chunkLanguageLevel);
if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_8)) {
commandLine.add("-source");
commandLine.add("8");
}
else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_7)) {
commandLine.add("-source");
commandLine.add("1.7");
}
else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_6)) {
commandLine.add("-source");
commandLine.add("1.6");
}
else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_5)) {
commandLine.add("-source");
commandLine.add("1.5");
}
else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_4)) {
commandLine.add("-source");
commandLine.add("1.4");
}
else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_3)) {
if (!(isOfVersion(versionString, "1.3") || isOfVersion(versionString, "1.2") || isOfVersion(versionString, "1.1"))) {
//noinspection HardCodedStringLiteral
commandLine.add("-source");
commandLine.add("1.3");
}
}
}
示例2: setLanguageLevel
import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
@NotNull
@Override
public PsiClassType setLanguageLevel(@NotNull LanguageLevel level) {
return level.equals(myLanguageLevel) ? this : new PsiImmediateClassType(myClass, mySubstitutor, level, getAnnotations());
}
示例3: setLanguageLevel
import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
@NotNull
@Override
public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
if (languageLevel.equals(myLanguageLevel)) return this;
return new PsiClassReferenceType(myReference, languageLevel, getAnnotations());
}
示例4: doFix
import com.intellij.pom.java.LanguageLevel; //导入方法依赖的package包/类
@Override
public void doFix(Project project, ProblemDescriptor descriptor) {
final PsiElement element = descriptor.getPsiElement().getParent();
if (!(element instanceof PsiNewExpression)) {
return;
}
final PsiNewExpression expression = (PsiNewExpression)element;
final PsiExpressionList argumentList = expression.getArgumentList();
if (argumentList == null) {
return;
}
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
final PsiExpression argument = arguments[0];
final String text = argument.getText();
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(expression);
@NonNls final String newExpression;
if (PsiKeyword.TRUE.equals(text) || TRUE.equalsIgnoreCase(text)) {
newExpression = "java.lang.Boolean.TRUE";
}
else if (PsiKeyword.FALSE.equals(text) || FALSE.equalsIgnoreCase(text)) {
newExpression = "java.lang.Boolean.FALSE";
}
else if (languageLevel.equals(LanguageLevel.JDK_1_3)) {
newExpression = buildText(argument, false);
}
else {
final PsiClass booleanClass = ClassUtils.findClass(CommonClassNames.JAVA_LANG_BOOLEAN, argument);
boolean methodFound = false;
if (booleanClass != null) {
final PsiMethod[] methods = booleanClass.findMethodsByName("valueOf", false);
for (PsiMethod method : methods) {
final PsiParameterList parameterList = method.getParameterList();
final PsiParameter[] parameters = parameterList.getParameters();
if (parameters.length == 0) {
continue;
}
final PsiParameter parameter = parameters[0];
final PsiType type = parameter.getType();
if (PsiType.BOOLEAN.equals(type)) {
methodFound = true;
break;
}
}
}
newExpression = buildText(argument, methodFound);
}
PsiReplacementUtil.replaceExpression(expression, newExpression);
}