mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] IDEA-345355 Refactor HighlightingFeature (in progress)
Merge JavaLanguageFeature into JavaFeature GitOrigin-RevId: 212b31d072450df03fc9eeeeb2cf0861b2b32bc1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d8ab6ce154
commit
7625b3c7a2
+3
-4
@@ -3,7 +3,6 @@ package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.java.analysis.JavaAnalysisBundle;
|
||||
@@ -12,7 +11,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.text.HtmlBuilder;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.JavaReflectionReferenceUtil;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
@@ -84,7 +83,7 @@ final public class JavaServiceUtil {
|
||||
@Nullable PsiClass implementerClass,
|
||||
@Nullable PsiClass resultClass) {
|
||||
if (identifier == null || implementerClass == null || resultClass == null) return Collections.emptyList();
|
||||
if (!JavaLanguageFeature.MODULES.isAvailable(identifier)) return Collections.emptyList();
|
||||
if (!JavaFeature.MODULES.isAvailable(identifier)) return Collections.emptyList();
|
||||
|
||||
String implementerClassName = implementerClass.getQualifiedName();
|
||||
if (implementerClassName == null) return Collections.emptyList();
|
||||
@@ -128,7 +127,7 @@ final public class JavaServiceUtil {
|
||||
|
||||
static List<LineMarkerInfo<PsiElement>> collectServiceLoaderLoadCall(@NotNull PsiIdentifier identifier,
|
||||
@NotNull PsiMethodCallExpression methodCall) {
|
||||
if (!JavaLanguageFeature.MODULES.isAvailable(methodCall)) return Collections.emptyList();
|
||||
if (!JavaFeature.MODULES.isAvailable(methodCall)) return Collections.emptyList();
|
||||
PsiExpression[] arguments = methodCall.getArgumentList().getExpressions();
|
||||
|
||||
JavaReflectionReferenceUtil.ReflectiveType serviceType = findServiceTypeInArguments(arguments);
|
||||
|
||||
+6
-4
@@ -3,9 +3,11 @@ package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPass;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.VisualPosition;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
@@ -17,7 +19,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.JavaRecursiveElementWalkingVisitor;
|
||||
import com.intellij.psi.PsiJavaFile;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
@@ -50,7 +52,7 @@ public class JavaTextBlockIndentPass extends TextEditorHighlightingPass {
|
||||
|
||||
@Override
|
||||
public void doCollectInformation(@NotNull ProgressIndicator progress) {
|
||||
if (!myEditor.getSettings().isIndentGuidesShown() || !JavaLanguageFeature.TEXT_BLOCKS.isAvailable(myFile)) {
|
||||
if (!myEditor.getSettings().isIndentGuidesShown() || !JavaFeature.TEXT_BLOCKS.isAvailable(myFile)) {
|
||||
return;
|
||||
}
|
||||
Document document = myEditor.getDocument();
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
@@ -399,7 +399,7 @@ public final class AnnotationsHighlightUtil {
|
||||
}
|
||||
|
||||
if (!(owner instanceof PsiModifierList)) {
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(annotation, JavaLanguageFeature.TYPE_ANNOTATIONS, level, file);
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(annotation, JavaFeature.TYPE_ANNOTATIONS, level, file);
|
||||
if (info != null) return info;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiClassImplUtil;
|
||||
@@ -1037,7 +1037,7 @@ public final class GenericsHighlightUtil {
|
||||
PsiTypeElement checkTypeElement = InstanceOfUtils.findCheckTypeElement(expression);
|
||||
if (checkTypeElement == null) return null;
|
||||
PsiType checkType = checkTypeElement.getType();
|
||||
if (JavaLanguageFeature.PATTERNS.isSufficient(languageLevel)) {
|
||||
if (JavaFeature.PATTERNS.isSufficient(languageLevel)) {
|
||||
PsiPrimaryPattern pattern = expression.getPattern();
|
||||
if (pattern != null) {
|
||||
return PatternHighlightingModel.getUncheckedPatternConversionError(pattern);
|
||||
|
||||
+19
-19
@@ -28,7 +28,7 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaImplicitClassIndex;
|
||||
@@ -351,10 +351,10 @@ public final class HighlightClassUtil {
|
||||
* @return true if given name cannot be used as a type name at given language level
|
||||
*/
|
||||
public static boolean isRestrictedIdentifier(@Nullable String typeName, @NotNull LanguageLevel level) {
|
||||
return PsiKeyword.VAR.equals(typeName) && JavaLanguageFeature.LVTI.isSufficient(level) ||
|
||||
PsiKeyword.YIELD.equals(typeName) && JavaLanguageFeature.SWITCH_EXPRESSION.isSufficient(level) ||
|
||||
PsiKeyword.RECORD.equals(typeName) && JavaLanguageFeature.RECORDS.isSufficient(level) ||
|
||||
(PsiKeyword.SEALED.equals(typeName) || PsiKeyword.PERMITS.equals(typeName)) && JavaLanguageFeature.SEALED_CLASSES.isSufficient(level);
|
||||
return PsiKeyword.VAR.equals(typeName) && JavaFeature.LVTI.isSufficient(level) ||
|
||||
PsiKeyword.YIELD.equals(typeName) && JavaFeature.SWITCH_EXPRESSION.isSufficient(level) ||
|
||||
PsiKeyword.RECORD.equals(typeName) && JavaFeature.RECORDS.isSufficient(level) ||
|
||||
(PsiKeyword.SEALED.equals(typeName) || PsiKeyword.PERMITS.equals(typeName)) && JavaFeature.SEALED_CLASSES.isSufficient(level);
|
||||
}
|
||||
|
||||
static HighlightInfo.Builder checkClassAndPackageConflict(@NotNull PsiClass aClass) {
|
||||
@@ -420,8 +420,8 @@ public final class HighlightClassUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
HighlightInfo.Builder result = HighlightUtil.checkFeature(keyword, JavaLanguageFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(field), field.getContainingFile());
|
||||
HighlightInfo.Builder result = HighlightUtil.checkFeature(keyword, JavaFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(field), field.getContainingFile());
|
||||
|
||||
IntentionAction action = QuickFixFactory.getInstance().createModifierListFix(field, PsiModifier.STATIC, false, false);
|
||||
if (result != null) {
|
||||
@@ -447,8 +447,8 @@ public final class HighlightClassUtil {
|
||||
}
|
||||
PsiMethod method = (PsiMethod)keyword.getParent().getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(method)) return null;
|
||||
HighlightInfo.Builder result = HighlightUtil.checkFeature(keyword, JavaLanguageFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(method), method.getContainingFile());
|
||||
HighlightInfo.Builder result = HighlightUtil.checkFeature(keyword, JavaFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(method), method.getContainingFile());
|
||||
IntentionAction action = QuickFixFactory.getInstance().createModifierListFix(method, PsiModifier.STATIC, false, false);
|
||||
if (result != null) {
|
||||
result.registerFix(action, null, null, null, null);
|
||||
@@ -463,8 +463,8 @@ public final class HighlightClassUtil {
|
||||
}
|
||||
PsiClassInitializer initializer = (PsiClassInitializer)keyword.getParent().getParent();
|
||||
if (PsiUtilCore.hasErrorElementChild(initializer)) return null;
|
||||
HighlightInfo.Builder result = HighlightUtil.checkFeature(keyword, JavaLanguageFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(initializer), initializer.getContainingFile());
|
||||
HighlightInfo.Builder result = HighlightUtil.checkFeature(keyword, JavaFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(initializer), initializer.getContainingFile());
|
||||
IntentionAction action = QuickFixFactory.getInstance().createModifierListFix(initializer, PsiModifier.STATIC, false, false);
|
||||
if (result != null) {
|
||||
result.registerFix(action, null, null, null, null);
|
||||
@@ -514,8 +514,8 @@ public final class HighlightClassUtil {
|
||||
}
|
||||
|
||||
TextRange range = context == null ? HighlightNamesUtil.getClassDeclarationTextRange(aClass) : context.getTextRange();
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(range, JavaLanguageFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(aClass), aClass.getContainingFile());
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(range, JavaFeature.INNER_STATICS,
|
||||
PsiUtil.getLanguageLevel(aClass), aClass.getContainingFile());
|
||||
if (context != keyword) {
|
||||
QuickFixAction.registerQuickFixActions(info, null, JvmElementActionFactories
|
||||
.createModifierActions(aClass, MemberRequestsKt.modifierRequest(JvmModifier.STATIC, false)));
|
||||
@@ -709,14 +709,14 @@ public final class HighlightClassUtil {
|
||||
|
||||
static HighlightInfo.Builder checkMustNotBeLocal(@NotNull PsiClass aClass) {
|
||||
IElementType token;
|
||||
JavaLanguageFeature feature;
|
||||
JavaFeature feature;
|
||||
if (aClass.isEnum()) {
|
||||
token = JavaTokenType.ENUM_KEYWORD;
|
||||
feature = JavaLanguageFeature.LOCAL_ENUMS;
|
||||
feature = JavaFeature.LOCAL_ENUMS;
|
||||
}
|
||||
else if (aClass.isInterface()) {
|
||||
token = JavaTokenType.INTERFACE_KEYWORD;
|
||||
feature = aClass.isAnnotationType() ? null : JavaLanguageFeature.LOCAL_INTERFACES;
|
||||
feature = aClass.isAnnotationType() ? null : JavaFeature.LOCAL_INTERFACES;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -1207,7 +1207,7 @@ public final class HighlightClassUtil {
|
||||
if (!(parent instanceof PsiClass aClass) || !list.equals(aClass.getPermitsList())) {
|
||||
return;
|
||||
}
|
||||
HighlightInfo.Builder feature = HighlightUtil.checkFeature(list.getFirstChild(), JavaLanguageFeature.SEALED_CLASSES,
|
||||
HighlightInfo.Builder feature = HighlightUtil.checkFeature(list.getFirstChild(), JavaFeature.SEALED_CLASSES,
|
||||
PsiUtil.getLanguageLevel(list), list.getContainingFile());
|
||||
if (feature != null) {
|
||||
errorSink.accept(feature);
|
||||
@@ -1407,10 +1407,10 @@ public final class HighlightClassUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
HighlightInfo.Builder builder = HighlightUtil.checkFeature(member, JavaLanguageFeature.IMPLICIT_CLASSES, languageLevel, psiFile);
|
||||
HighlightInfo.Builder builder = HighlightUtil.checkFeature(member, JavaFeature.IMPLICIT_CLASSES, languageLevel, psiFile);
|
||||
if (builder == null) return null;
|
||||
|
||||
if (!(member instanceof PsiClass) && !JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(member)) {
|
||||
if (!(member instanceof PsiClass) && !JavaFeature.IMPLICIT_CLASSES.isAvailable(member)) {
|
||||
boolean hasClassToRelocate = PsiTreeUtil.findChildOfType(implicitClass, PsiClass.class) != null;
|
||||
if (hasClassToRelocate) {
|
||||
MoveMembersIntoClassFix fix = new MoveMembersIntoClassFix(implicitClass);
|
||||
|
||||
+6
-6
@@ -7,7 +7,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInsight.intention.QuickFixFactory;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.JavaImplicitClassUtil;
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public final class HighlightImplicitClassUtil {
|
||||
|
||||
static HighlightInfo.@Nullable Builder checkImplicitClassHasMainMethod(@NotNull PsiJavaFile file) {
|
||||
if (!JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(file)) return null;
|
||||
if (!JavaFeature.IMPLICIT_CLASSES.isAvailable(file)) return null;
|
||||
PsiImplicitClass implicitClass = JavaImplicitClassUtil.getImplicitClassFor(file);
|
||||
if (implicitClass == null) return null;
|
||||
PsiMethod[] methods = implicitClass.getMethods();
|
||||
@@ -38,7 +38,7 @@ public final class HighlightImplicitClassUtil {
|
||||
}
|
||||
|
||||
static HighlightInfo.@Nullable Builder checkImplicitClassFileIsValidIdentifier(@NotNull PsiJavaFile file) {
|
||||
if (!JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(file)) return null;
|
||||
if (!JavaFeature.IMPLICIT_CLASSES.isAvailable(file)) return null;
|
||||
PsiImplicitClass implicitClass = JavaImplicitClassUtil.getImplicitClassFor(file);
|
||||
if (implicitClass == null) return null;
|
||||
String name = implicitClass.getQualifiedName();
|
||||
@@ -52,7 +52,7 @@ public final class HighlightImplicitClassUtil {
|
||||
}
|
||||
|
||||
static HighlightInfo.@Nullable Builder checkInitializersInImplicitClass(@NotNull PsiClassInitializer initializer) {
|
||||
if (initializer.getContainingClass() instanceof PsiImplicitClass && JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(initializer)) {
|
||||
if (initializer.getContainingClass() instanceof PsiImplicitClass && JavaFeature.IMPLICIT_CLASSES.isAvailable(initializer)) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(initializer)
|
||||
.descriptionAndTooltip(JavaErrorBundle.message("error.initializers.are.not.allowed.in.implicit.classes"))
|
||||
@@ -63,7 +63,7 @@ public final class HighlightImplicitClassUtil {
|
||||
|
||||
static HighlightInfo.@Nullable Builder checkPackageNotAllowedInImplicitClass(@NotNull PsiPackageStatement statement,
|
||||
@NotNull PsiFile file) {
|
||||
if (JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(file) && JavaImplicitClassUtil.isFileWithImplicitClass(file)) {
|
||||
if (JavaFeature.IMPLICIT_CLASSES.isAvailable(file) && JavaImplicitClassUtil.isFileWithImplicitClass(file)) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(statement)
|
||||
.descriptionAndTooltip(JavaErrorBundle.message("error.package.statement.not.allowed.for.implicit.class"))
|
||||
@@ -74,7 +74,7 @@ public final class HighlightImplicitClassUtil {
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo.Builder checkDuplicateClasses(@NotNull PsiJavaFile file) {
|
||||
if (!JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(file)) return null;
|
||||
if (!JavaFeature.IMPLICIT_CLASSES.isAvailable(file)) return null;
|
||||
PsiImplicitClass implicitClass = JavaImplicitClassUtil.getImplicitClassFor(file);
|
||||
if (implicitClass == null) return null;
|
||||
|
||||
|
||||
+5
-5
@@ -27,7 +27,7 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.HtmlBuilder;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiSuperMethodImplUtil;
|
||||
@@ -432,7 +432,7 @@ public final class HighlightMethodUtil {
|
||||
PsiClass containingClass = ((PsiMethod)resolved).getContainingClass();
|
||||
if (containingClass != null && containingClass.isInterface()) {
|
||||
PsiElement element = ObjectUtils.notNull(referenceToMethod.getReferenceNameElement(), referenceToMethod);
|
||||
builder = HighlightUtil.checkFeature(element, JavaLanguageFeature.STATIC_INTERFACE_CALLS, languageLevel, file);
|
||||
builder = HighlightUtil.checkFeature(element, JavaFeature.STATIC_INTERFACE_CALLS, languageLevel, file);
|
||||
if (builder == null) {
|
||||
builder = checkStaticInterfaceCallQualifier(referenceToMethod, resolveResult, methodCall, containingClass);
|
||||
}
|
||||
@@ -885,7 +885,7 @@ public final class HighlightMethodUtil {
|
||||
if (element instanceof PsiMethod && ((PsiMethod)element).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
PsiClass containingClass = ((PsiMethod)element).getContainingClass();
|
||||
if (containingClass != null && containingClass.isInterface()) {
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(elementToHighlight, JavaLanguageFeature.STATIC_INTERFACE_CALLS, languageLevel, file);
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(elementToHighlight, JavaFeature.STATIC_INTERFACE_CALLS, languageLevel, file);
|
||||
if (info != null) return info;
|
||||
info = checkStaticInterfaceCallQualifier(referenceToMethod, resolveResult, elementToHighlight, containingClass);
|
||||
if (info != null) return info;
|
||||
@@ -1487,8 +1487,8 @@ public final class HighlightMethodUtil {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCall).descriptionAndTooltip(message);
|
||||
}
|
||||
String message = JavaErrorBundle.message("constructor.call.must.be.first.statement", expression.getText() + "()");
|
||||
return HighlightUtil.checkFeature(methodCall, JavaLanguageFeature.STATEMENTS_BEFORE_SUPER, PsiUtil.getLanguageLevel(methodCall),
|
||||
methodCall.getContainingFile(), message, HighlightInfoType.ERROR);
|
||||
return HighlightUtil.checkFeature(methodCall, JavaFeature.STATEMENTS_BEFORE_SUPER, PsiUtil.getLanguageLevel(methodCall),
|
||||
methodCall.getContainingFile(), message, HighlightInfoType.ERROR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+20
-20
@@ -33,7 +33,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -242,7 +242,7 @@ public final class HighlightUtil {
|
||||
if (castTypeElement == null || !isIntersection(castTypeElement, castTypeElement.getType())) {
|
||||
return null;
|
||||
}
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaLanguageFeature.INTERSECTION_CASTS, languageLevel, file);
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaFeature.INTERSECTION_CASTS, languageLevel, file);
|
||||
if (info != null) return info;
|
||||
|
||||
PsiTypeElement[] conjuncts = PsiTreeUtil.getChildrenOfType(castTypeElement, PsiTypeElement.class);
|
||||
@@ -831,9 +831,9 @@ public final class HighlightUtil {
|
||||
PsiElement parent = identifier.getParent();
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_9) && !(parent instanceof PsiUnnamedPattern) &&
|
||||
!(parent instanceof PsiVariable var && var.isUnnamed())) {
|
||||
String text = JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isSufficient(languageLevel) ?
|
||||
String text = JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isSufficient(languageLevel) ?
|
||||
JavaErrorBundle.message("underscore.identifier.error.unnamed")
|
||||
: JavaErrorBundle.message("underscore.identifier.error");
|
||||
: JavaErrorBundle.message("underscore.identifier.error");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(text);
|
||||
}
|
||||
else if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
@@ -1015,7 +1015,7 @@ public final class HighlightUtil {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(label).descriptionAndTooltip(message);
|
||||
}
|
||||
|
||||
if (JavaLanguageFeature.ENHANCED_SWITCH.isSufficient(level)) {
|
||||
if (JavaFeature.ENHANCED_SWITCH.isSufficient(level)) {
|
||||
PsiSwitchExpression expression = PsiImplUtil.findEnclosingSwitchExpression(statement);
|
||||
if (expression != null && (target == null || PsiTreeUtil.isAncestor(target, expression, true))) {
|
||||
String message = JavaErrorBundle.message(crossingKey);
|
||||
@@ -1266,10 +1266,10 @@ public final class HighlightUtil {
|
||||
if (file != null) {
|
||||
if (isFP) {
|
||||
if (text.startsWith(PsiLiteralUtil.HEX_PREFIX)) {
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaLanguageFeature.HEX_FP_LITERALS, level, file);
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaFeature.HEX_FP_LITERALS, level, file);
|
||||
if (info != null) {
|
||||
if (description != null) {
|
||||
description.set(getUnsupportedFeatureMessage(JavaLanguageFeature.HEX_FP_LITERALS, level, file));
|
||||
description.set(getUnsupportedFeatureMessage(JavaFeature.HEX_FP_LITERALS, level, file));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
@@ -1277,10 +1277,10 @@ public final class HighlightUtil {
|
||||
}
|
||||
if (isInt) {
|
||||
if (text.startsWith(PsiLiteralUtil.BIN_PREFIX)) {
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaLanguageFeature.BIN_LITERALS, level, file);
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaFeature.BIN_LITERALS, level, file);
|
||||
if (info != null) {
|
||||
if (description != null) {
|
||||
description.set(getUnsupportedFeatureMessage(JavaLanguageFeature.BIN_LITERALS, level, file));
|
||||
description.set(getUnsupportedFeatureMessage(JavaFeature.BIN_LITERALS, level, file));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
@@ -1288,10 +1288,10 @@ public final class HighlightUtil {
|
||||
}
|
||||
if (isInt || isFP) {
|
||||
if (text.contains("_")) {
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaLanguageFeature.UNDERSCORES, level, file);
|
||||
HighlightInfo.Builder info = checkFeature(expression, JavaFeature.UNDERSCORES, level, file);
|
||||
if (info != null) {
|
||||
if (description != null) {
|
||||
description.set(getUnsupportedFeatureMessage(JavaLanguageFeature.UNDERSCORES, level, file));
|
||||
description.set(getUnsupportedFeatureMessage(JavaFeature.UNDERSCORES, level, file));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
@@ -1574,10 +1574,10 @@ public final class HighlightUtil {
|
||||
if (file == null) return null;
|
||||
TextRange errorRange = calculateUnescapedRange(text, "\\s", expression.getTextOffset());
|
||||
if (errorRange == null) return null;
|
||||
HighlightInfo.Builder info = checkFeature(errorRange, JavaLanguageFeature.TEXT_BLOCK_ESCAPES, level, file);
|
||||
HighlightInfo.Builder info = checkFeature(errorRange, JavaFeature.TEXT_BLOCK_ESCAPES, level, file);
|
||||
if (info == null) return null;
|
||||
if (description != null) {
|
||||
description.set(getUnsupportedFeatureMessage(JavaLanguageFeature.TEXT_BLOCK_ESCAPES, level, file));
|
||||
description.set(getUnsupportedFeatureMessage(JavaFeature.TEXT_BLOCK_ESCAPES, level, file));
|
||||
}
|
||||
return info;
|
||||
}
|
||||
@@ -2295,7 +2295,7 @@ public final class HighlightUtil {
|
||||
}
|
||||
|
||||
static HighlightInfo.Builder checkTemplateExpression(@NotNull PsiTemplateExpression templateExpression) {
|
||||
HighlightInfo.Builder builder = checkFeature(templateExpression, JavaLanguageFeature.STRING_TEMPLATES,
|
||||
HighlightInfo.Builder builder = checkFeature(templateExpression, JavaFeature.STRING_TEMPLATES,
|
||||
PsiUtil.getLanguageLevel(templateExpression), templateExpression.getContainingFile());
|
||||
if (builder != null) return builder;
|
||||
PsiExpression processor = templateExpression.getProcessor();
|
||||
@@ -3787,7 +3787,7 @@ public final class HighlightUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static LanguageLevel getApplicableLevel(@NotNull PsiFile file, @NotNull JavaLanguageFeature feature) {
|
||||
private static LanguageLevel getApplicableLevel(@NotNull PsiFile file, @NotNull JavaFeature feature) {
|
||||
LanguageLevel standardLevel = feature.getStandardLevel();
|
||||
if (feature.getLevel().isPreview()) {
|
||||
JavaSdkVersion sdkVersion = JavaSdkVersionUtil.getJavaSdkVersion(file);
|
||||
@@ -3806,7 +3806,7 @@ public final class HighlightUtil {
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo.Builder checkFeature(@NotNull PsiElement element,
|
||||
@NotNull JavaLanguageFeature feature,
|
||||
@NotNull JavaFeature feature,
|
||||
@NotNull LanguageLevel level,
|
||||
@NotNull PsiFile file) {
|
||||
return checkFeature(element, feature, level, file, null, HighlightInfoType.ERROR);
|
||||
@@ -3814,7 +3814,7 @@ public final class HighlightUtil {
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo.Builder checkFeature(@NotNull PsiElement element,
|
||||
@NotNull JavaLanguageFeature feature,
|
||||
@NotNull JavaFeature feature,
|
||||
@NotNull LanguageLevel level,
|
||||
@NotNull PsiFile file,
|
||||
@Nullable @NlsContexts.DetailedDescription String message,
|
||||
@@ -3834,7 +3834,7 @@ public final class HighlightUtil {
|
||||
}
|
||||
|
||||
static HighlightInfo.Builder checkFeature(@NotNull TextRange range,
|
||||
@NotNull JavaLanguageFeature feature,
|
||||
@NotNull JavaFeature feature,
|
||||
@NotNull LanguageLevel level,
|
||||
@NotNull PsiFile file) {
|
||||
if (!feature.isSufficient(level)) {
|
||||
@@ -3852,7 +3852,7 @@ public final class HighlightUtil {
|
||||
}
|
||||
|
||||
public static void registerIncreaseLanguageLevelFixes(@NotNull PsiElement element,
|
||||
@NotNull JavaLanguageFeature feature,
|
||||
@NotNull JavaFeature feature,
|
||||
@NotNull List<? super IntentionAction> registrar) {
|
||||
if (feature.isAvailable(element)) return;
|
||||
if (feature.isLimited()) return; //no reason for applying it because it can be outdated
|
||||
@@ -3862,7 +3862,7 @@ public final class HighlightUtil {
|
||||
registrar.add(getFixFactory().createShowModulePropertiesFix(element));
|
||||
}
|
||||
|
||||
private static @NotNull @NlsContexts.DetailedDescription String getUnsupportedFeatureMessage(@NotNull JavaLanguageFeature feature,
|
||||
private static @NotNull @NlsContexts.DetailedDescription String getUnsupportedFeatureMessage(@NotNull JavaFeature feature,
|
||||
@NotNull LanguageLevel level,
|
||||
@NotNull PsiFile file) {
|
||||
String name = feature.getFeatureName();
|
||||
|
||||
+40
-40
@@ -23,7 +23,7 @@ import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
@@ -249,7 +249,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
myLanguageLevel = PsiUtil.getLanguageLevel(file);
|
||||
myJavaSdkVersion = ObjectUtils
|
||||
.notNull(JavaVersionService.getInstance().getJavaSdkVersion(file), JavaSdkVersion.fromLanguageLevel(myLanguageLevel));
|
||||
myJavaModule = myLanguageLevel.isAtLeast(JavaLanguageFeature.MODULES.getLevel()) ? JavaModuleGraphUtil.findDescriptorByElement(file) : null;
|
||||
myJavaModule = myLanguageLevel.isAtLeast(JavaFeature.MODULES.getLevel()) ? JavaModuleGraphUtil.findDescriptorByElement(file) : null;
|
||||
myPreviewFeatureVisitor = myLanguageLevel.isPreview() ? null : new PreviewFeatureUtil.PreviewFeatureVisitor(myLanguageLevel, myErrorSink);
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitAnnotation(@NotNull PsiAnnotation annotation) {
|
||||
super.visitAnnotation(annotation);
|
||||
if (!hasErrorResults()) add(checkFeature(annotation, JavaLanguageFeature.ANNOTATIONS));
|
||||
if (!hasErrorResults()) add(checkFeature(annotation, JavaFeature.ANNOTATIONS));
|
||||
if (!hasErrorResults()) add(AnnotationsHighlightUtil.checkApplicability(annotation, myLanguageLevel, myFile));
|
||||
if (!hasErrorResults()) add(AnnotationsHighlightUtil.checkAnnotationType(annotation));
|
||||
if (!hasErrorResults()) add(AnnotationsHighlightUtil.checkMissingAttributes(annotation));
|
||||
@@ -392,7 +392,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
|
||||
@Override
|
||||
public void visitLambdaExpression(@NotNull PsiLambdaExpression expression) {
|
||||
add(checkFeature(expression, JavaLanguageFeature.LAMBDA_EXPRESSIONS));
|
||||
add(checkFeature(expression, JavaFeature.LAMBDA_EXPRESSIONS));
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
|
||||
if (toReportFunctionalExpressionProblemOnParent(parent)) return;
|
||||
if (!hasErrorResults() && !LambdaUtil.isValidLambdaContext(parent)) {
|
||||
@@ -580,7 +580,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
|
||||
IElementType type = token.getTokenType();
|
||||
if (!hasErrorResults() && type == JavaTokenType.TEXT_BLOCK_LITERAL) {
|
||||
add(checkFeature(token, JavaLanguageFeature.TEXT_BLOCKS));
|
||||
add(checkFeature(token, JavaFeature.TEXT_BLOCKS));
|
||||
}
|
||||
|
||||
if (!hasErrorResults() && type == JavaTokenType.RBRACE && token.getParent() instanceof PsiCodeBlock) {
|
||||
@@ -726,7 +726,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
|
||||
@Override
|
||||
public void visitImportStaticStatement(@NotNull PsiImportStaticStatement statement) {
|
||||
add(checkFeature(statement, JavaLanguageFeature.STATIC_IMPORTS));
|
||||
add(checkFeature(statement, JavaFeature.STATIC_IMPORTS));
|
||||
if (!hasErrorResults()) add(ImportsHighlightUtil.checkStaticOnDemandImportResolvesToClass(statement));
|
||||
if (!hasErrorResults()) {
|
||||
PsiJavaCodeReferenceElement importReference = statement.getImportReference();
|
||||
@@ -749,7 +749,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (parent instanceof PsiVariable variable) {
|
||||
add(HighlightUtil.checkVariableAlreadyDefined(variable));
|
||||
if (variable.isUnnamed()) {
|
||||
HighlightInfo.Builder notAvailable = checkFeature(variable, JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES);
|
||||
HighlightInfo.Builder notAvailable = checkFeature(variable, JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES);
|
||||
if (notAvailable != null) {
|
||||
add(notAvailable);
|
||||
} else {
|
||||
@@ -764,7 +764,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
else if (parent instanceof PsiClass aClass) {
|
||||
if (aClass.isAnnotationType()) {
|
||||
add(checkFeature(identifier, JavaLanguageFeature.ANNOTATIONS));
|
||||
add(checkFeature(identifier, JavaFeature.ANNOTATIONS));
|
||||
}
|
||||
|
||||
add(HighlightClassUtil.checkClassAlreadyImported(aClass, identifier));
|
||||
@@ -926,7 +926,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitTemplate(@NotNull PsiTemplate template) {
|
||||
super.visitTemplate(template);
|
||||
add(checkFeature(template, JavaLanguageFeature.STRING_TEMPLATES));
|
||||
add(checkFeature(template, JavaFeature.STRING_TEMPLATES));
|
||||
if (hasErrorResults()) return;
|
||||
|
||||
for (PsiExpression embeddedExpression : template.getEmbeddedExpressions()) {
|
||||
@@ -952,7 +952,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
if (!hasErrorResults() &&
|
||||
expression.getParent() instanceof PsiCaseLabelElementList &&
|
||||
expression.textMatches(PsiKeyword.NULL)) {
|
||||
add(checkFeature(expression, JavaLanguageFeature.PATTERNS_IN_SWITCH));
|
||||
add(checkFeature(expression, JavaFeature.PATTERNS_IN_SWITCH));
|
||||
}
|
||||
|
||||
if (!hasErrorResults()) HighlightUtil.checkIllegalUnicodeEscapes(expression, myErrorSink);
|
||||
@@ -992,10 +992,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
add(HighlightClassUtil.checkThingNotAllowedInInterface(method, aClass));
|
||||
}
|
||||
if (!hasErrorResults() && method.hasModifierProperty(PsiModifier.DEFAULT)) {
|
||||
add(checkFeature(method, JavaLanguageFeature.EXTENSION_METHODS));
|
||||
add(checkFeature(method, JavaFeature.EXTENSION_METHODS));
|
||||
}
|
||||
if (!hasErrorResults() && aClass != null && aClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
add(checkFeature(method, JavaLanguageFeature.EXTENSION_METHODS));
|
||||
add(checkFeature(method, JavaFeature.EXTENSION_METHODS));
|
||||
}
|
||||
if (!hasErrorResults() && aClass != null) {
|
||||
add(HighlightMethodUtil.checkDuplicateMethod(aClass, method, getDuplicateMethods(aClass)));
|
||||
@@ -1134,7 +1134,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitPackageStatement(@NotNull PsiPackageStatement statement) {
|
||||
super.visitPackageStatement(statement);
|
||||
add(AnnotationsHighlightUtil.checkPackageAnnotationContainingFile(statement, myFile));
|
||||
if (myLanguageLevel.isAtLeast(JavaLanguageFeature.MODULES.getLevel())) {
|
||||
if (myLanguageLevel.isAtLeast(JavaFeature.MODULES.getLevel())) {
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkPackageStatement(statement, myFile, myJavaModule));
|
||||
}
|
||||
if (!hasErrorResults()) add(HighlightImplicitClassUtil.checkPackageNotAllowedInImplicitClass(statement, myFile));
|
||||
@@ -1156,20 +1156,20 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
|
||||
PsiElement parent = parameter.getParent();
|
||||
if (parent instanceof PsiParameterList && parameter.isVarArgs()) {
|
||||
if (!hasErrorResults()) add(checkFeature(parameter, JavaLanguageFeature.VARARGS));
|
||||
if (!hasErrorResults()) add(checkFeature(parameter, JavaFeature.VARARGS));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkVarArgParameterIsLast(parameter));
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkCStyleDeclaration(parameter));
|
||||
}
|
||||
else if (parent instanceof PsiCatchSection) {
|
||||
if (!hasErrorResults() && parameter.getType() instanceof PsiDisjunctionType) {
|
||||
add(checkFeature(parameter, JavaLanguageFeature.MULTI_CATCH));
|
||||
add(checkFeature(parameter, JavaFeature.MULTI_CATCH));
|
||||
}
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkCatchParameterIsThrowable(parameter));
|
||||
if (!hasErrorResults()) GenericsHighlightUtil.checkCatchParameterIsClass(parameter, myErrorSink);
|
||||
if (!hasErrorResults()) HighlightUtil.checkCatchTypeIsDisjoint(parameter, myErrorSink);
|
||||
}
|
||||
else if (parent instanceof PsiForeachStatement forEach) {
|
||||
add(checkFeature(forEach, JavaLanguageFeature.FOR_EACH));
|
||||
add(checkFeature(forEach, JavaFeature.FOR_EACH));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkForEachParameterType((PsiForeachStatement)parent, parameter));
|
||||
}
|
||||
}
|
||||
@@ -1429,7 +1429,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasErrorResults() && resultForIncompleteCode != null && JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) {
|
||||
if (!hasErrorResults() && resultForIncompleteCode != null && JavaFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) {
|
||||
add(HighlightUtil.checkPatternVariableRequired(expression, resultForIncompleteCode));
|
||||
}
|
||||
|
||||
@@ -1466,7 +1466,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
|
||||
@Override
|
||||
public void visitMethodReferenceExpression(@NotNull PsiMethodReferenceExpression expression) {
|
||||
add(checkFeature(expression, JavaLanguageFeature.METHOD_REFERENCES));
|
||||
add(checkFeature(expression, JavaFeature.METHOD_REFERENCES));
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
|
||||
if (toReportFunctionalExpressionProblemOnParent(parent)) return;
|
||||
PsiType functionalInterfaceType = expression.getFunctionalInterfaceType();
|
||||
@@ -1674,13 +1674,13 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitReferenceParameterList(@NotNull PsiReferenceParameterList list) {
|
||||
if (list.getTextLength() == 0) return;
|
||||
|
||||
add(checkFeature(list, JavaLanguageFeature.GENERICS));
|
||||
add(checkFeature(list, JavaFeature.GENERICS));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkParametersAllowed(list));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkParametersOnRaw(list, myLanguageLevel));
|
||||
if (!hasErrorResults()) {
|
||||
for (PsiTypeElement typeElement : list.getTypeParameterElements()) {
|
||||
if (typeElement.getType() instanceof PsiDiamondType) {
|
||||
add(checkFeature(list, JavaLanguageFeature.DIAMOND_TYPES));
|
||||
add(checkFeature(list, JavaFeature.DIAMOND_TYPES));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1689,7 +1689,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
|
||||
super.visitStatement(statement);
|
||||
if (!hasErrorResults() && JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(myFile)) {
|
||||
if (!hasErrorResults() && JavaFeature.ENHANCED_SWITCH.isAvailable(myFile)) {
|
||||
add(HighlightUtil.checkReturnFromSwitchExpr(statement));
|
||||
}
|
||||
if (!hasErrorResults()) {
|
||||
@@ -1761,7 +1761,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitSwitchExpression(@NotNull PsiSwitchExpression expression) {
|
||||
super.visitSwitchExpression(expression);
|
||||
if (!hasErrorResults()) add(checkFeature(expression, JavaLanguageFeature.SWITCH_EXPRESSION));
|
||||
if (!hasErrorResults()) add(checkFeature(expression, JavaFeature.SWITCH_EXPRESSION));
|
||||
checkSwitchBlock(expression);
|
||||
if (!hasErrorResults()) HighlightUtil.checkSwitchExpressionReturnTypeCompatible(expression, myErrorSink);
|
||||
if (!hasErrorResults()) HighlightUtil.checkSwitchExpressionHasResult(expression, myErrorSink);
|
||||
@@ -1812,7 +1812,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitResourceList(@NotNull PsiResourceList resourceList) {
|
||||
super.visitResourceList(resourceList);
|
||||
if (!hasErrorResults()) add(checkFeature(resourceList, JavaLanguageFeature.TRY_WITH_RESOURCES));
|
||||
if (!hasErrorResults()) add(checkFeature(resourceList, JavaFeature.TRY_WITH_RESOURCES));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1825,7 +1825,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitResourceExpression(@NotNull PsiResourceExpression resource) {
|
||||
super.visitResourceExpression(resource);
|
||||
if (!hasErrorResults()) add(checkFeature(resource, JavaLanguageFeature.REFS_AS_RESOURCE));
|
||||
if (!hasErrorResults()) add(checkFeature(resource, JavaFeature.REFS_AS_RESOURCE));
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkResourceVariableIsFinal(resource));
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkTryResourceIsAutoCloseable(resource));
|
||||
if (!hasErrorResults()) add(HighlightUtil.checkUnhandledCloserExceptions(resource));
|
||||
@@ -1858,7 +1858,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitTypeParameterList(@NotNull PsiTypeParameterList list) {
|
||||
PsiTypeParameter[] typeParameters = list.getTypeParameters();
|
||||
if (typeParameters.length > 0) {
|
||||
add(checkFeature(list, JavaLanguageFeature.GENERICS));
|
||||
add(checkFeature(list, JavaFeature.GENERICS));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkTypeParametersList(list, typeParameters, myLanguageLevel));
|
||||
}
|
||||
}
|
||||
@@ -1872,9 +1872,9 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
PsiCaseLabelElementList.class,
|
||||
PsiForeachPatternStatement.class);
|
||||
if (!(context instanceof PsiForeachPatternStatement)) {
|
||||
JavaLanguageFeature feature = context instanceof PsiInstanceOfExpression ?
|
||||
JavaLanguageFeature.PATTERNS :
|
||||
JavaLanguageFeature.PATTERNS_IN_SWITCH;
|
||||
JavaFeature feature = context instanceof PsiInstanceOfExpression ?
|
||||
JavaFeature.PATTERNS :
|
||||
JavaFeature.PATTERNS_IN_SWITCH;
|
||||
PsiIdentifier varIdentifier = ((PsiPatternVariable)variable).getNameIdentifier();
|
||||
add(checkFeature(varIdentifier, feature));
|
||||
}
|
||||
@@ -1930,7 +1930,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitReceiverParameter(@NotNull PsiReceiverParameter parameter) {
|
||||
super.visitReceiverParameter(parameter);
|
||||
if (!hasErrorResults()) add(checkFeature(parameter, JavaLanguageFeature.RECEIVERS));
|
||||
if (!hasErrorResults()) add(checkFeature(parameter, JavaFeature.RECEIVERS));
|
||||
if (!hasErrorResults()) add(AnnotationsHighlightUtil.checkReceiverPlacement(parameter));
|
||||
if (!hasErrorResults()) add(AnnotationsHighlightUtil.checkReceiverType(parameter));
|
||||
}
|
||||
@@ -1938,7 +1938,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitModule(@NotNull PsiJavaModule module) {
|
||||
super.visitModule(module);
|
||||
if (!hasErrorResults()) add(checkFeature(module, JavaLanguageFeature.MODULES));
|
||||
if (!hasErrorResults()) add(checkFeature(module, JavaFeature.MODULES));
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkFileName(module, myFile));
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkFileDuplicates(module, myFile));
|
||||
if (!hasErrorResults()) ModuleHighlightUtil.checkDuplicateStatements(module, myErrorSink);
|
||||
@@ -1958,7 +1958,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitRequiresStatement(@NotNull PsiRequiresStatement statement) {
|
||||
super.visitRequiresStatement(statement);
|
||||
if (myLanguageLevel.isAtLeast(JavaLanguageFeature.MODULES.getLevel())) {
|
||||
if (myLanguageLevel.isAtLeast(JavaFeature.MODULES.getLevel())) {
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkModuleReference(statement));
|
||||
if (!hasErrorResults() && myLanguageLevel.isAtLeast(LanguageLevel.JDK_10)) {
|
||||
ModuleHighlightUtil.checkModifiers(statement, myErrorSink);
|
||||
@@ -1969,7 +1969,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitPackageAccessibilityStatement(@NotNull PsiPackageAccessibilityStatement statement) {
|
||||
super.visitPackageAccessibilityStatement(statement);
|
||||
if (myLanguageLevel.isAtLeast(JavaLanguageFeature.MODULES.getLevel())) {
|
||||
if (myLanguageLevel.isAtLeast(JavaFeature.MODULES.getLevel())) {
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkHostModuleStrength(statement));
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkPackageReference(statement, myFile));
|
||||
if (!hasErrorResults()) ModuleHighlightUtil.checkPackageAccessTargets(statement, myErrorSink);
|
||||
@@ -1979,7 +1979,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitUsesStatement(@NotNull PsiUsesStatement statement) {
|
||||
super.visitUsesStatement(statement);
|
||||
if (myLanguageLevel.isAtLeast(JavaLanguageFeature.MODULES.getLevel())) {
|
||||
if (myLanguageLevel.isAtLeast(JavaFeature.MODULES.getLevel())) {
|
||||
if (!hasErrorResults()) add(ModuleHighlightUtil.checkServiceReference(statement.getClassReference()));
|
||||
}
|
||||
}
|
||||
@@ -1987,7 +1987,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitProvidesStatement(@NotNull PsiProvidesStatement statement) {
|
||||
super.visitProvidesStatement(statement);
|
||||
if (myLanguageLevel.isAtLeast(JavaLanguageFeature.MODULES.getLevel())) {
|
||||
if (myLanguageLevel.isAtLeast(JavaFeature.MODULES.getLevel())) {
|
||||
if (!hasErrorResults()) ModuleHighlightUtil.checkServiceImplementations(statement, myFile, myErrorSink);
|
||||
}
|
||||
}
|
||||
@@ -2006,7 +2006,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitParenthesizedPattern(@NotNull PsiParenthesizedPattern pattern) {
|
||||
super.visitParenthesizedPattern(pattern);
|
||||
add(checkFeature(pattern, JavaLanguageFeature.PARENTHESIZED_PATTERNS));
|
||||
add(checkFeature(pattern, JavaFeature.PARENTHESIZED_PATTERNS));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2024,7 +2024,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
add(PatternHighlightingModel.checkReferenceTypeIsNotAnnotated(deconstructionPattern.getTypeElement()));
|
||||
PsiElement parent = deconstructionPattern.getParent();
|
||||
if (parent instanceof PsiForeachPatternStatement forEach) {
|
||||
add(checkFeature(deconstructionPattern, JavaLanguageFeature.RECORD_PATTERNS_IN_FOR_EACH));
|
||||
add(checkFeature(deconstructionPattern, JavaFeature.RECORD_PATTERNS_IN_FOR_EACH));
|
||||
if (hasErrorResults()) return;
|
||||
PsiTypeElement typeElement = JavaPsiPatternUtil.getPatternTypeElement(deconstructionPattern);
|
||||
if (typeElement == null) return;
|
||||
@@ -2046,7 +2046,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
}
|
||||
else {
|
||||
add(checkFeature(deconstructionPattern, JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS));
|
||||
add(checkFeature(deconstructionPattern, JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2085,18 +2085,18 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
public void visitTypeTestPattern(@NotNull PsiTypeTestPattern pattern) {
|
||||
super.visitTypeTestPattern(pattern);
|
||||
if (pattern.getParent() instanceof PsiCaseLabelElementList) {
|
||||
add(checkFeature(pattern, JavaLanguageFeature.PATTERNS_IN_SWITCH));
|
||||
add(checkFeature(pattern, JavaFeature.PATTERNS_IN_SWITCH));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitUnnamedPattern(@NotNull PsiUnnamedPattern pattern) {
|
||||
super.visitUnnamedPattern(pattern);
|
||||
add(checkFeature(pattern, JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES));
|
||||
add(checkFeature(pattern, JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private HighlightInfo.Builder checkFeature(@NotNull PsiElement element, @NotNull JavaLanguageFeature feature) {
|
||||
private HighlightInfo.Builder checkFeature(@NotNull PsiElement element, @NotNull JavaFeature feature) {
|
||||
return HighlightUtil.checkFeature(element, feature, myLanguageLevel, myFile);
|
||||
}
|
||||
|
||||
|
||||
+45
-45
@@ -1,62 +1,62 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link JavaLanguageFeature} and {@link PreviewFeatureUtil}.
|
||||
* @deprecated use {@link JavaFeature} and {@link PreviewFeatureUtil}.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public enum HighlightingFeature {
|
||||
GENERICS(JavaLanguageFeature.GENERICS),
|
||||
ANNOTATIONS(JavaLanguageFeature.ANNOTATIONS),
|
||||
STATIC_IMPORTS(JavaLanguageFeature.STATIC_IMPORTS),
|
||||
FOR_EACH(JavaLanguageFeature.FOR_EACH),
|
||||
VARARGS(JavaLanguageFeature.VARARGS),
|
||||
HEX_FP_LITERALS(JavaLanguageFeature.HEX_FP_LITERALS),
|
||||
DIAMOND_TYPES(JavaLanguageFeature.DIAMOND_TYPES),
|
||||
MULTI_CATCH(JavaLanguageFeature.MULTI_CATCH),
|
||||
TRY_WITH_RESOURCES(JavaLanguageFeature.TRY_WITH_RESOURCES),
|
||||
BIN_LITERALS(JavaLanguageFeature.BIN_LITERALS),
|
||||
UNDERSCORES(JavaLanguageFeature.UNDERSCORES),
|
||||
EXTENSION_METHODS(JavaLanguageFeature.EXTENSION_METHODS),
|
||||
METHOD_REFERENCES(JavaLanguageFeature.METHOD_REFERENCES),
|
||||
LAMBDA_EXPRESSIONS(JavaLanguageFeature.LAMBDA_EXPRESSIONS),
|
||||
TYPE_ANNOTATIONS(JavaLanguageFeature.TYPE_ANNOTATIONS),
|
||||
RECEIVERS(JavaLanguageFeature.RECEIVERS),
|
||||
INTERSECTION_CASTS(JavaLanguageFeature.INTERSECTION_CASTS),
|
||||
STATIC_INTERFACE_CALLS(JavaLanguageFeature.STATIC_INTERFACE_CALLS),
|
||||
REFS_AS_RESOURCE(JavaLanguageFeature.REFS_AS_RESOURCE),
|
||||
MODULES(JavaLanguageFeature.MODULES),
|
||||
LVTI(JavaLanguageFeature.LVTI),
|
||||
VAR_LAMBDA_PARAMETER(JavaLanguageFeature.VAR_LAMBDA_PARAMETER),
|
||||
ENHANCED_SWITCH(JavaLanguageFeature.ENHANCED_SWITCH),
|
||||
SWITCH_EXPRESSION(JavaLanguageFeature.SWITCH_EXPRESSION),
|
||||
RECORDS(JavaLanguageFeature.RECORDS),
|
||||
PATTERNS(JavaLanguageFeature.PATTERNS),
|
||||
TEXT_BLOCK_ESCAPES(JavaLanguageFeature.TEXT_BLOCK_ESCAPES),
|
||||
TEXT_BLOCKS(JavaLanguageFeature.TEXT_BLOCKS),
|
||||
SEALED_CLASSES(JavaLanguageFeature.SEALED_CLASSES),
|
||||
LOCAL_INTERFACES(JavaLanguageFeature.LOCAL_INTERFACES),
|
||||
LOCAL_ENUMS(JavaLanguageFeature.LOCAL_ENUMS),
|
||||
INNER_STATICS(JavaLanguageFeature.INNER_STATICS),
|
||||
PARENTHESIZED_PATTERNS(JavaLanguageFeature.PARENTHESIZED_PATTERNS),
|
||||
PATTERNS_IN_SWITCH(JavaLanguageFeature.PATTERNS_IN_SWITCH),
|
||||
PATTERN_GUARDS_AND_RECORD_PATTERNS(JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS),
|
||||
RECORD_PATTERNS_IN_FOR_EACH(JavaLanguageFeature.RECORD_PATTERNS_IN_FOR_EACH),
|
||||
ENUM_QUALIFIED_NAME_IN_SWITCH(JavaLanguageFeature.ENUM_QUALIFIED_NAME_IN_SWITCH),
|
||||
STRING_TEMPLATES(JavaLanguageFeature.STRING_TEMPLATES),
|
||||
UNNAMED_PATTERNS_AND_VARIABLES(JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES),
|
||||
IMPLICIT_CLASSES(JavaLanguageFeature.IMPLICIT_CLASSES),
|
||||
STATEMENTS_BEFORE_SUPER(JavaLanguageFeature.STATEMENTS_BEFORE_SUPER),
|
||||
GENERICS(JavaFeature.GENERICS),
|
||||
ANNOTATIONS(JavaFeature.ANNOTATIONS),
|
||||
STATIC_IMPORTS(JavaFeature.STATIC_IMPORTS),
|
||||
FOR_EACH(JavaFeature.FOR_EACH),
|
||||
VARARGS(JavaFeature.VARARGS),
|
||||
HEX_FP_LITERALS(JavaFeature.HEX_FP_LITERALS),
|
||||
DIAMOND_TYPES(JavaFeature.DIAMOND_TYPES),
|
||||
MULTI_CATCH(JavaFeature.MULTI_CATCH),
|
||||
TRY_WITH_RESOURCES(JavaFeature.TRY_WITH_RESOURCES),
|
||||
BIN_LITERALS(JavaFeature.BIN_LITERALS),
|
||||
UNDERSCORES(JavaFeature.UNDERSCORES),
|
||||
EXTENSION_METHODS(JavaFeature.EXTENSION_METHODS),
|
||||
METHOD_REFERENCES(JavaFeature.METHOD_REFERENCES),
|
||||
LAMBDA_EXPRESSIONS(JavaFeature.LAMBDA_EXPRESSIONS),
|
||||
TYPE_ANNOTATIONS(JavaFeature.TYPE_ANNOTATIONS),
|
||||
RECEIVERS(JavaFeature.RECEIVERS),
|
||||
INTERSECTION_CASTS(JavaFeature.INTERSECTION_CASTS),
|
||||
STATIC_INTERFACE_CALLS(JavaFeature.STATIC_INTERFACE_CALLS),
|
||||
REFS_AS_RESOURCE(JavaFeature.REFS_AS_RESOURCE),
|
||||
MODULES(JavaFeature.MODULES),
|
||||
LVTI(JavaFeature.LVTI),
|
||||
VAR_LAMBDA_PARAMETER(JavaFeature.VAR_LAMBDA_PARAMETER),
|
||||
ENHANCED_SWITCH(JavaFeature.ENHANCED_SWITCH),
|
||||
SWITCH_EXPRESSION(JavaFeature.SWITCH_EXPRESSION),
|
||||
RECORDS(JavaFeature.RECORDS),
|
||||
PATTERNS(JavaFeature.PATTERNS),
|
||||
TEXT_BLOCK_ESCAPES(JavaFeature.TEXT_BLOCK_ESCAPES),
|
||||
TEXT_BLOCKS(JavaFeature.TEXT_BLOCKS),
|
||||
SEALED_CLASSES(JavaFeature.SEALED_CLASSES),
|
||||
LOCAL_INTERFACES(JavaFeature.LOCAL_INTERFACES),
|
||||
LOCAL_ENUMS(JavaFeature.LOCAL_ENUMS),
|
||||
INNER_STATICS(JavaFeature.INNER_STATICS),
|
||||
PARENTHESIZED_PATTERNS(JavaFeature.PARENTHESIZED_PATTERNS),
|
||||
PATTERNS_IN_SWITCH(JavaFeature.PATTERNS_IN_SWITCH),
|
||||
PATTERN_GUARDS_AND_RECORD_PATTERNS(JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS),
|
||||
RECORD_PATTERNS_IN_FOR_EACH(JavaFeature.RECORD_PATTERNS_IN_FOR_EACH),
|
||||
ENUM_QUALIFIED_NAME_IN_SWITCH(JavaFeature.ENUM_QUALIFIED_NAME_IN_SWITCH),
|
||||
STRING_TEMPLATES(JavaFeature.STRING_TEMPLATES),
|
||||
UNNAMED_PATTERNS_AND_VARIABLES(JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES),
|
||||
IMPLICIT_CLASSES(JavaFeature.IMPLICIT_CLASSES),
|
||||
STATEMENTS_BEFORE_SUPER(JavaFeature.STATEMENTS_BEFORE_SUPER),
|
||||
;
|
||||
|
||||
private final JavaLanguageFeature myFeature;
|
||||
private final JavaFeature myFeature;
|
||||
|
||||
HighlightingFeature(@NotNull JavaLanguageFeature feature) {
|
||||
HighlightingFeature(@NotNull JavaFeature feature) {
|
||||
myFeature = feature;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiJavaModuleModificationTracker;
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaModuleNameIndex;
|
||||
@@ -219,7 +219,7 @@ public final class JavaModuleGraphUtil {
|
||||
@Nullable DependencyScope scope,
|
||||
boolean isExported) {
|
||||
if (to.equals(JAVA_BASE)) return false;
|
||||
if (!JavaLanguageFeature.MODULES.isAvailable(from)) return false;
|
||||
if (!JavaFeature.MODULES.isAvailable(from)) return false;
|
||||
if (alreadyContainsRequires(from, to)) return false;
|
||||
PsiUtil.addModuleStatement(from, PsiKeyword.REQUIRES + " " +
|
||||
(isStaticModule(to, scope) ? PsiKeyword.STATIC + " " : "") +
|
||||
@@ -232,7 +232,7 @@ public final class JavaModuleGraphUtil {
|
||||
@NotNull PsiJavaModule to,
|
||||
@Nullable DependencyScope scope) {
|
||||
if (to.getName().equals(JAVA_BASE)) return false;
|
||||
if (!JavaLanguageFeature.MODULES.isAvailable(from)) return false;
|
||||
if (!JavaFeature.MODULES.isAvailable(from)) return false;
|
||||
if (alreadyContainsRequires(from, to.getName())) return false;
|
||||
PsiUtil.addModuleStatement(from, PsiKeyword.REQUIRES + " " +
|
||||
(isStaticModule(to.getName(), scope) ? PsiKeyword.STATIC + " " : "") +
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ import com.intellij.openapi.util.Predicates;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -403,7 +403,7 @@ class PostHighlightingVisitor extends JavaElementVisitor {
|
||||
if (message != null) {
|
||||
PsiPattern pattern = variable.getPattern();
|
||||
IntentionAction action = null;
|
||||
if (JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(parameter)) {
|
||||
if (JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(parameter)) {
|
||||
if (pattern instanceof PsiTypeTestPattern ttPattern && pattern.getParent() instanceof PsiDeconstructionList) {
|
||||
PsiRecordComponent component = JavaPsiPatternUtil.getRecordComponentForPattern(pattern);
|
||||
PsiTypeElement checkType = ttPattern.getCheckType();
|
||||
@@ -426,7 +426,7 @@ class PostHighlightingVisitor extends JavaElementVisitor {
|
||||
}
|
||||
}
|
||||
else if ((myUnusedSymbolInspection.checkParameterExcludingHierarchy() ||
|
||||
JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(declarationScope))
|
||||
JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(declarationScope))
|
||||
&& declarationScope instanceof PsiLambdaExpression) {
|
||||
checkUnusedParameter(parameter, null);
|
||||
if (message != null) {
|
||||
@@ -444,7 +444,7 @@ class PostHighlightingVisitor extends JavaElementVisitor {
|
||||
if (!"main".equals(method.getName())) {
|
||||
return true;
|
||||
}
|
||||
if (!JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(method)) {
|
||||
if (!JavaFeature.IMPLICIT_CLASSES.isAvailable(method)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.lang.jvm.JvmModifier;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil;
|
||||
@@ -42,7 +42,7 @@ public final class PreviewFeatureUtil {
|
||||
*/
|
||||
@Nullable
|
||||
@Contract(value = "null -> null", pure = true)
|
||||
public static JavaLanguageFeature fromPreviewFeatureAnnotation(@Nullable PsiAnnotation annotation) {
|
||||
public static JavaFeature fromPreviewFeatureAnnotation(@Nullable PsiAnnotation annotation) {
|
||||
if (annotation == null) return null;
|
||||
if (!annotation.hasQualifiedName(JDK_INTERNAL_PREVIEW_FEATURE) &&
|
||||
!annotation.hasQualifiedName(JDK_INTERNAL_JAVAC_PREVIEW_FEATURE)) {
|
||||
@@ -58,7 +58,7 @@ public final class PreviewFeatureUtil {
|
||||
PsiEnumConstant enumConstant = tryCast(referenceExpression.resolve(), PsiEnumConstant.class);
|
||||
if (enumConstant == null) return null;
|
||||
|
||||
return JavaLanguageFeature.convertFromPreviewFeatureName(enumConstant.getName());
|
||||
return JavaFeature.convertFromPreviewFeatureName(enumConstant.getName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -103,7 +103,7 @@ public final class PreviewFeatureUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerProblem(PsiElement element, String description, JavaLanguageFeature feature, PsiAnnotation annotation) {
|
||||
protected void registerProblem(PsiElement element, String description, JavaFeature feature, PsiAnnotation annotation) {
|
||||
boolean isReflective = Boolean.TRUE.equals(AnnotationUtil.getBooleanAttributeValue(annotation, "reflective"));
|
||||
|
||||
HighlightInfoType type = isReflective ? HighlightInfoType.WARNING : HighlightInfoType.ERROR;
|
||||
|
||||
+5
-5
@@ -3,7 +3,7 @@ package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.codeInspection.util.InspectionMessage;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -41,7 +41,7 @@ public abstract class PreviewFeatureVisitorBase extends JavaElementVisitor {
|
||||
if (module == null) return;
|
||||
|
||||
PsiAnnotation annotation = getPreviewFeatureAnnotation(module);
|
||||
@Nullable JavaLanguageFeature feature = PreviewFeatureUtil.fromPreviewFeatureAnnotation(annotation);
|
||||
@Nullable JavaFeature feature = PreviewFeatureUtil.fromPreviewFeatureAnnotation(annotation);
|
||||
if (feature == null) return;
|
||||
|
||||
String description = JavaBundle.message("inspection.preview.feature.0.is.preview.api.message", module.getName());
|
||||
@@ -55,7 +55,7 @@ public abstract class PreviewFeatureVisitorBase extends JavaElementVisitor {
|
||||
PsiElement resolved = element.resolve();
|
||||
if (resolved instanceof PsiClass psiClass) {
|
||||
PsiAnnotation annotation = getPreviewFeatureAnnotation(psiClass);
|
||||
JavaLanguageFeature feature = PreviewFeatureUtil.fromPreviewFeatureAnnotation(annotation);
|
||||
JavaFeature feature = PreviewFeatureUtil.fromPreviewFeatureAnnotation(annotation);
|
||||
if (feature == null) continue;
|
||||
String description =
|
||||
JavaBundle.message("inspection.preview.feature.0.is.preview.api.message", psiClass.getQualifiedName());
|
||||
@@ -87,7 +87,7 @@ public abstract class PreviewFeatureVisitorBase extends JavaElementVisitor {
|
||||
*/
|
||||
private void checkPreviewFeature(@NotNull PsiElement context, @NotNull PsiJavaCodeReferenceElement reference, @NotNull PsiModifierListOwner owner) {
|
||||
PsiAnnotation annotation = getPreviewFeatureAnnotation(owner);
|
||||
JavaLanguageFeature feature = PreviewFeatureUtil.fromPreviewFeatureAnnotation(annotation);
|
||||
JavaFeature feature = PreviewFeatureUtil.fromPreviewFeatureAnnotation(annotation);
|
||||
if (feature == null) return;
|
||||
if (isParticipating(reference, owner)) return;
|
||||
|
||||
@@ -116,7 +116,7 @@ public abstract class PreviewFeatureVisitorBase extends JavaElementVisitor {
|
||||
|
||||
protected abstract void registerProblem(PsiElement element,
|
||||
@InspectionMessage String description,
|
||||
JavaLanguageFeature feature,
|
||||
JavaFeature feature,
|
||||
PsiAnnotation annotation);
|
||||
|
||||
/**
|
||||
|
||||
+9
-9
@@ -10,7 +10,7 @@ import com.intellij.codeInsight.intention.impl.PriorityIntentionActionWrapper;
|
||||
import com.intellij.modcommand.ModCommandAction;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.*;
|
||||
@@ -66,7 +66,7 @@ public class SwitchBlockHighlightingModel {
|
||||
if (selector == null) return null;
|
||||
PsiType selectorType = selector.getType();
|
||||
if (selectorType == null) return null;
|
||||
if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isSufficient(languageLevel)) {
|
||||
if (JavaFeature.PATTERNS_IN_SWITCH.isSufficient(languageLevel)) {
|
||||
return new PatternsInSwitchBlockHighlightingModel(languageLevel, switchBlock, psiFile);
|
||||
}
|
||||
return new SwitchBlockHighlightingModel(languageLevel, switchBlock, psiFile);
|
||||
@@ -106,7 +106,7 @@ public class SwitchBlockHighlightingModel {
|
||||
while (element != null && !PsiUtil.isJavaToken(element, JavaTokenType.RBRACE)) {
|
||||
if (element instanceof PsiSwitchLabeledRuleStatement) {
|
||||
if (!levelChecked) {
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(element, JavaLanguageFeature.ENHANCED_SWITCH, myLevel, myFile);
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(element, JavaFeature.ENHANCED_SWITCH, myLevel, myFile);
|
||||
if (info != null) {
|
||||
errorSink.accept(info);
|
||||
return;
|
||||
@@ -130,7 +130,7 @@ public class SwitchBlockHighlightingModel {
|
||||
if (!levelChecked && element instanceof PsiSwitchLabelStatementBase label) {
|
||||
@Nullable PsiCaseLabelElementList values = label.getCaseLabelElementList();
|
||||
if (values != null && values.getElementCount() > 1) {
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(values, JavaLanguageFeature.ENHANCED_SWITCH, myLevel, myFile);
|
||||
HighlightInfo.Builder info = HighlightUtil.checkFeature(values, JavaFeature.ENHANCED_SWITCH, myLevel, myFile);
|
||||
if (info != null) {
|
||||
errorSink.accept(info);
|
||||
return;
|
||||
@@ -289,7 +289,7 @@ public class SwitchBlockHighlightingModel {
|
||||
|
||||
@Nullable
|
||||
private static HighlightInfo.Builder createQualifiedEnumConstantInfo(@NotNull PsiReferenceExpression expr) {
|
||||
if (JavaLanguageFeature.ENUM_QUALIFIED_NAME_IN_SWITCH.isAvailable(expr)) return null;
|
||||
if (JavaFeature.ENUM_QUALIFIED_NAME_IN_SWITCH.isAvailable(expr)) return null;
|
||||
PsiElement qualifier = expr.getQualifier();
|
||||
if (qualifier == null) return null;
|
||||
HighlightInfo.Builder result = createError(expr, JavaErrorBundle.message("qualified.enum.constant.in.switch"));
|
||||
@@ -451,7 +451,7 @@ public class SwitchBlockHighlightingModel {
|
||||
PsiExpression guardingExpr = statement.getGuardExpression();
|
||||
if (guardingExpr == null) return null;
|
||||
HighlightInfo.Builder info =
|
||||
HighlightUtil.checkFeature(guardingExpr, JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS, languageLevel, psiFile);
|
||||
HighlightUtil.checkFeature(guardingExpr, JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS, languageLevel, psiFile);
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
@@ -798,7 +798,7 @@ public class SwitchBlockHighlightingModel {
|
||||
// 14.30.3 A type pattern that declares a pattern variable of a reference type U is
|
||||
// applicable at another reference type T if T is checkcast convertible to U (JEP 440-441)
|
||||
// There is no rule that says that a reference type applies to a primitive type
|
||||
(mySelectorType instanceof PsiPrimitiveType && JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(label))) &&
|
||||
(mySelectorType instanceof PsiPrimitiveType && JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(label))) &&
|
||||
//null type is applicable to any class type
|
||||
!mySelectorType.equals(PsiTypes.nullType())) {
|
||||
HighlightInfo.Builder error =
|
||||
@@ -1085,7 +1085,7 @@ public class SwitchBlockHighlightingModel {
|
||||
if (nonPattern != null) {
|
||||
return getPatternConstantCombinationProblem(nonPattern);
|
||||
}
|
||||
if (JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(firstElement)) {
|
||||
if (JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(firstElement)) {
|
||||
PsiCaseLabelElement patternVarElement = ContainerUtil.find(elements, JavaPsiPatternUtil::containsNamedPatternVariable);
|
||||
if (patternVarElement != null) {
|
||||
return new CaseLabelCombinationProblem(patternVarElement, "invalid.case.label.combination.several.patterns.unnamed", null);
|
||||
@@ -1099,7 +1099,7 @@ public class SwitchBlockHighlightingModel {
|
||||
|
||||
@NotNull
|
||||
private static CaseLabelCombinationProblem getPatternConstantCombinationProblem(PsiCaseLabelElement anchor) {
|
||||
if (JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(anchor)) {
|
||||
if (JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(anchor)) {
|
||||
return new CaseLabelCombinationProblem(anchor, "invalid.case.label.combination.constants.and.patterns.unnamed", null);
|
||||
} else {
|
||||
return new CaseLabelCombinationProblem(anchor, "invalid.case.label.combination.constants.and.patterns", null);
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil
|
||||
import com.intellij.codeInspection.util.IntentionName
|
||||
import com.intellij.modcommand.ActionContext
|
||||
@@ -10,7 +9,7 @@ import com.intellij.modcommand.ModPsiUpdater
|
||||
import com.intellij.modcommand.Presentation
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.PsiElementFactory
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiKeyword
|
||||
@@ -24,7 +23,7 @@ abstract class AddModuleDirectiveFix(module: PsiJavaModule) : PsiUpdateModComman
|
||||
abstract fun getText(): String
|
||||
|
||||
override fun getPresentation(context: ActionContext, module: PsiJavaModule): Presentation? {
|
||||
return if (JavaLanguageFeature.MODULES.isAvailable(module)) Presentation.of(getText()) else null
|
||||
return if (JavaFeature.MODULES.isAvailable(module)) Presentation.of(getText()) else null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,14 +1,13 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.util.IntentionName;
|
||||
import com.intellij.modcommand.ActionContext;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.Presentation;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
@@ -28,7 +27,7 @@ public abstract class MergeModuleStatementsFix<T extends PsiStatement> extends P
|
||||
|
||||
@Override
|
||||
protected @Nullable Presentation getPresentation(@NotNull ActionContext context, @NotNull PsiJavaModule element) {
|
||||
return JavaLanguageFeature.MODULES.isAvailable(element) ? Presentation.of(getText()) : null;
|
||||
return JavaFeature.MODULES.isAvailable(element) ? Presentation.of(getText()) : null;
|
||||
}
|
||||
|
||||
@IntentionName
|
||||
|
||||
+2
-4
@@ -1,13 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.ReplaceVarWithExplicitTypeFix;
|
||||
import com.intellij.java.analysis.JavaAnalysisBundle;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,7 +15,7 @@ public final class VariableTypeCanBeExplicitInspection extends AbstractBaseJavaL
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.LVTI.isAvailable(holder.getFile())) { //var won't be parsed as inferred type otherwise
|
||||
if (!JavaFeature.LVTI.isAvailable(holder.getFile())) { //var won't be parsed as inferred type otherwise
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
+2
-3
@@ -3,7 +3,6 @@
|
||||
package com.intellij.codeInspection.dataFlow;
|
||||
|
||||
import com.intellij.codeInsight.*;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.SwitchBlockHighlightingModel;
|
||||
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
@@ -28,7 +27,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiImplUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
@@ -740,7 +739,7 @@ public abstract class DataFlowInspectionBase extends AbstractBaseJavaLocalInspec
|
||||
PsiType type = ((PsiInstanceOfExpression)anchor).getOperand().getType();
|
||||
if (type == null || !TypeConstraints.instanceOf(type).isResolved()) return true;
|
||||
// 5.20.2 Removed restriction on pattern instanceof for unconditional patterns (JEP 427)
|
||||
if (JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(anchor)) return false;
|
||||
if (JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(anchor)) return false;
|
||||
PsiPattern pattern = ((PsiInstanceOfExpression)anchor).getPattern();
|
||||
if (pattern instanceof PsiTypeTestPattern && ((PsiTypeTestPattern)pattern).getPatternVariable() != null) {
|
||||
PsiTypeElement checkType = ((PsiTypeTestPattern)pattern).getCheckType();
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInspection.java19modules;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.JavaServiceUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
import com.intellij.codeInspection.visibility.EntryPointWithVisibilityLevel;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.java.analysis.JavaAnalysisBundle;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightJavaModule;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
@@ -117,7 +116,7 @@ public final class Java9ModuleEntryPoint extends EntryPointWithVisibilityLevel {
|
||||
}
|
||||
|
||||
private static @Nullable PsiJavaModule getJavaModule(@Nullable PsiElement element) {
|
||||
return element != null && JavaLanguageFeature.MODULES.isAvailable(element) ? JavaModuleGraphUtil.findDescriptorByElement(element) : null;
|
||||
return element != null && JavaFeature.MODULES.isAvailable(element) ? JavaModuleGraphUtil.findDescriptorByElement(element) : null;
|
||||
}
|
||||
|
||||
private static boolean isInExportedPackage(@NotNull PsiClass psiClass, @NotNull PsiJavaModule javaModule) {
|
||||
|
||||
@@ -4,12 +4,11 @@ package com.intellij.psi.util;
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.Nullability;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.RecaptureTypeMapper;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
@@ -814,7 +813,7 @@ public final class RedundantCastUtil {
|
||||
}
|
||||
}
|
||||
if (opType instanceof PsiPrimitiveType) {
|
||||
if (JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(switchBlock)) {
|
||||
if (JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(switchBlock)) {
|
||||
for (PsiElement branch : SwitchUtils.getSwitchBranches(switchBlock)) {
|
||||
// 14.11.1 A null case element is switch compatible with T if T is a reference type (JEP 427)
|
||||
if (branch instanceof PsiExpression expression && TypeConversionUtil.isNullType(expression.getType())) return;
|
||||
@@ -824,7 +823,7 @@ public final class RedundantCastUtil {
|
||||
if (branch instanceof PsiPattern) return;
|
||||
}
|
||||
}
|
||||
else if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(switchBlock)) {
|
||||
else if (JavaFeature.PATTERNS_IN_SWITCH.isAvailable(switchBlock)) {
|
||||
boolean needToCheckCompleteness = switchBlock instanceof PsiSwitchExpression;
|
||||
boolean hasDefault = false;
|
||||
for (PsiElement branch : SwitchUtils.getSwitchBranches(switchBlock)) {
|
||||
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.siyeh.ig.abstraction;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -78,7 +77,7 @@ public final class MethodOnlyUsedFromInnerClassInspection extends BaseInspection
|
||||
if (innerClass == null) {
|
||||
return;
|
||||
}
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC) && !JavaLanguageFeature.INNER_STATICS.isAvailable(method)) {
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC) && !JavaFeature.INNER_STATICS.isAvailable(method)) {
|
||||
final PsiElement parent = innerClass.getParent();
|
||||
if (parent instanceof PsiClass && !innerClass.hasModifierProperty(PsiModifier.STATIC) || PsiUtil.isLocalClass(innerClass)) {
|
||||
return;
|
||||
|
||||
+2
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
@@ -23,7 +22,7 @@ import com.intellij.modcommand.ModCommand;
|
||||
import com.intellij.modcommand.ModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
@@ -205,7 +204,7 @@ public final class ClassMayBeInterfaceInspection extends BaseInspection {
|
||||
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return;
|
||||
}
|
||||
if (PsiUtil.isLocalClass(aClass) && !JavaLanguageFeature.LOCAL_INTERFACES.isAvailable(aClass)) {
|
||||
if (PsiUtil.isLocalClass(aClass) && !JavaFeature.LOCAL_INTERFACES.isAvailable(aClass)) {
|
||||
return;
|
||||
}
|
||||
if (!mayBeInterface(aClass)) {
|
||||
|
||||
+2
-3
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.controlflow;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -26,7 +25,7 @@ import java.util.*;
|
||||
public final class SwitchExpressionCanBePushedDownInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.SWITCH_EXPRESSION.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.SWITCH_EXPRESSION.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitSwitchExpression(@NotNull PsiSwitchExpression expression) {
|
||||
|
||||
+6
-4
@@ -1,20 +1,22 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.inheritance;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.search.PackageScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.Query;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -185,7 +187,7 @@ public final class RedundantMethodOverrideInspection extends BaseInspection {
|
||||
method.isVarArgs() != superMethod.isVarArgs()) {
|
||||
return;
|
||||
}
|
||||
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT) && !JavaLanguageFeature.EXTENSION_METHODS.isAvailable(method)) {
|
||||
if (superMethod.hasModifierProperty(PsiModifier.DEFAULT) && !JavaFeature.EXTENSION_METHODS.isAvailable(method)) {
|
||||
return;
|
||||
}
|
||||
boolean canBeRemoved = AbstractMethodOverridesAbstractMethodInspection.haveSameParameterTypes(method, superMethod);
|
||||
|
||||
+2
-3
@@ -5,11 +5,10 @@
|
||||
*/
|
||||
package com.siyeh.ig.performance;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
@@ -61,7 +60,7 @@ public final class ClassInitializerMayBeStaticInspection extends BaseInspection
|
||||
final PsiElement scope = containingClass.getScope();
|
||||
if (!(scope instanceof PsiJavaFile) &&
|
||||
!containingClass.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!JavaLanguageFeature.INNER_STATICS.isAvailable(containingClass)) {
|
||||
!JavaFeature.INNER_STATICS.isAvailable(containingClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,14 +1,13 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.performance;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.util.IntentionFamilyName;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiLiteralUtil;
|
||||
@@ -34,7 +33,7 @@ public final class RedundantStringFormatCallInspection extends LocalInspectionTo
|
||||
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
|
||||
return new RemoveRedundantStringFormatVisitor(holder, isOnTheFly, JavaLanguageFeature.TEXT_BLOCKS.isAvailable(holder.getFile()));
|
||||
return new RemoveRedundantStringFormatVisitor(holder, isOnTheFly, JavaFeature.TEXT_BLOCKS.isAvailable(holder.getFile()));
|
||||
}
|
||||
|
||||
private static final class RemoveRedundantStringFormatVisitor extends JavaElementVisitor {
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
package com.siyeh.ig.psiutils;
|
||||
|
||||
import com.intellij.codeInsight.BlockUtils;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.intention.impl.SplitConditionUtil;
|
||||
import com.intellij.codeInspection.ConditionalBreakInInfiniteLoopInspection;
|
||||
import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection;
|
||||
import com.intellij.codeInspection.dataFlow.DfaPsiUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
@@ -274,7 +273,7 @@ public abstract class CodeBlockSurrounder {
|
||||
if (parentContext != ParentContext.ASSIGNMENT && parentContext != ParentContext.RETURN) return null;
|
||||
return new TernaryToIfSurrounder(expression, conditional, parentSurrounder);
|
||||
}
|
||||
if (JavaPsiConstructorUtil.isConstructorCall(parent) && !JavaLanguageFeature.STATEMENTS_BEFORE_SUPER.isAvailable(parent)) {
|
||||
if (JavaPsiConstructorUtil.isConstructorCall(parent) && !JavaFeature.STATEMENTS_BEFORE_SUPER.isAvailable(parent)) {
|
||||
return null;
|
||||
}
|
||||
cur = parent;
|
||||
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package com.siyeh.ig.psiutils;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.SwitchBlockHighlightingModel;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -185,7 +184,7 @@ public final class SwitchUtils {
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
public static boolean isRuleFormatSwitch(@NotNull PsiSwitchBlock block) {
|
||||
if (!JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(block)) {
|
||||
if (!JavaFeature.ENHANCED_SWITCH.isAvailable(block)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,7 +233,7 @@ public final class SwitchUtils {
|
||||
if (languageLevel.isAtLeast(LanguageLevel.JDK_1_7) && type.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
|
||||
return true;
|
||||
}
|
||||
return JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(expression);
|
||||
return JavaFeature.PATTERNS_IN_SWITCH.isAvailable(expression);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -270,7 +269,7 @@ public final class SwitchUtils {
|
||||
return left;
|
||||
}
|
||||
}
|
||||
if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) {
|
||||
if (JavaFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) {
|
||||
final PsiExpression patternSwitchExpression = findPatternSwitchExpression(expression);
|
||||
if (patternSwitchExpression != null) return patternSwitchExpression;
|
||||
}
|
||||
@@ -432,7 +431,7 @@ public final class SwitchUtils {
|
||||
final PsiExpression instanceOf = ContainerUtil.find(operands, operand -> operand instanceof PsiInstanceOfExpression);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(createPatternCaseText(instanceOf));
|
||||
boolean needAppendWhen = JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(expression);
|
||||
boolean needAppendWhen = JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(expression);
|
||||
for (PsiExpression operand : operands) {
|
||||
if (operand != instanceOf) {
|
||||
builder.append(needAppendWhen ? " when " : " && ").append(operand.getText());
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.PsiReplacementUtil;
|
||||
@@ -22,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public final class EscapedSpaceInspection extends AbstractBaseJavaLocalInspectionTool implements CleanupLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.TEXT_BLOCK_ESCAPES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.TEXT_BLOCK_ESCAPES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitFragment(@NotNull PsiFragment fragment) {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import com.intellij.openapi.module.LanguageLevelUtil
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.popup.Balloon
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.siyeh.InspectionGadgetsBundle
|
||||
import com.siyeh.IntentionPowerPackBundle
|
||||
import org.jetbrains.annotations.Nls
|
||||
@@ -72,7 +72,7 @@ class JavaOnboardingTourLesson : OnboardingTourLessonBase(ideaOnboardingLessonId
|
||||
fun getIntentionMessage(project: Project): @Nls String {
|
||||
val module = ModuleManager.getInstance(project).modules.firstOrNull() ?: error("Not found modules in project '${project.name}'")
|
||||
val langLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module)
|
||||
val messageKey = if (JavaLanguageFeature.TEXT_BLOCKS.isSufficient(langLevel)) {
|
||||
val messageKey = if (JavaFeature.TEXT_BLOCKS.isSufficient(langLevel)) {
|
||||
"replace.concatenation.with.format.string.intention.name.formatted"
|
||||
}
|
||||
else "replace.concatenation.with.format.string.intention.name"
|
||||
|
||||
@@ -63,6 +63,9 @@ feature.multi.catch=Multi-catches
|
||||
feature.try.with.resources=Try-with-resources
|
||||
feature.binary.literals=Binary literals
|
||||
feature.underscores.in.literals=Underscores in literals
|
||||
feature.stream.api=Stream API
|
||||
feature.advanced.collection.api=Lambda methods in collections
|
||||
feature.with.initial=ThreadLocal.withInitial()
|
||||
feature.extension.methods=Extension methods
|
||||
feature.method.references=Method references
|
||||
feature.lambda.expressions=Lambda expressions
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.impl.light.LightRecordField;
|
||||
@@ -28,7 +27,7 @@ public final class DeconstructionCanBeUsedInspection extends AbstractBaseJavaLoc
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitInstanceOfExpression(@NotNull PsiInstanceOfExpression expression) {
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.util.InspectionMessage;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
@@ -9,7 +8,7 @@ import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
@@ -1080,7 +1079,7 @@ public final class DuplicateBranchesInSwitchInspection extends LocalInspectionTo
|
||||
if (labelElementList == null) return false;
|
||||
PsiCaseLabelElement[] elements = labelElementList.getElements();
|
||||
return !ContainerUtil.exists(elements,
|
||||
element -> element instanceof PsiPattern && (!JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(element) ||
|
||||
element -> element instanceof PsiPattern && (!JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(element) ||
|
||||
JavaPsiPatternUtil.containsNamedPatternVariable(element)) ||
|
||||
element instanceof PsiExpression expr && ExpressionUtils.isNullLiteral(expr));
|
||||
}
|
||||
|
||||
+2
-3
@@ -3,7 +3,6 @@ package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
import com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.java.JavaBundle;
|
||||
@@ -11,7 +10,7 @@ import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.PackageScope;
|
||||
import com.intellij.psi.search.PsiSearchHelper;
|
||||
@@ -28,7 +27,7 @@ public final class ExplicitToImplicitClassMigrationInspection extends AbstractBa
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.IMPLICIT_CLASSES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
|
||||
+2
-3
@@ -1,10 +1,9 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.intention.impl.FillPermitsListFix;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.DirectClassInheritorsSearch;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -19,7 +18,7 @@ public final class FillPermitsListInspection extends AbstractBaseJavaLocalInspec
|
||||
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.SEALED_CLASSES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.SEALED_CLASSES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitClass(@NotNull PsiClass psiClass) {
|
||||
|
||||
+2
-3
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.util.JavaPsiRecordUtil;
|
||||
@@ -70,7 +69,7 @@ public final class ForEachWithRecordPatternCanBeUsedInspection extends AbstractB
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.RECORD_PATTERNS_IN_FOR_EACH.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.RECORD_PATTERNS_IN_FOR_EACH.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
boolean useVar = IntroduceVariableBase.createVarType() || forceUseVar;
|
||||
return new JavaElementVisitor() {
|
||||
private final Options options = new Options(maxNotUsedComponentCounts,
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiMethodUtil;
|
||||
@@ -21,7 +20,7 @@ public final class ImplicitToExplicitClassBackwardMigrationInspection extends Ab
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.IMPLICIT_CLASSES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.IMPLICIT_CLASSES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitImplicitClass(@NotNull PsiImplicitClass aClass) {
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.util.IntentionFamilyName;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.java.JavaBundle;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
@@ -29,7 +28,7 @@ import static com.intellij.util.ObjectUtils.tryCast;
|
||||
public final class InconsistentTextBlockIndentInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.TEXT_BLOCKS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.TEXT_BLOCKS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
|
||||
|
||||
+2
-3
@@ -2,10 +2,9 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationTargetUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.DeleteElementFix;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.PsiAnnotation.TargetType;
|
||||
import com.intellij.psi.util.JavaPsiRecordUtil;
|
||||
@@ -24,7 +23,7 @@ public final class MeaninglessRecordAnnotationInspection extends AbstractBaseJav
|
||||
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.RECORDS.isAvailable(holder.getFile())) {
|
||||
if (!JavaFeature.RECORDS.isAvailable(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
+3
-4
@@ -2,11 +2,10 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
@@ -30,11 +29,11 @@ public final class PatternVariableCanBeUsedInspection extends AbstractBaseJavaLo
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.PATTERNS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.PATTERNS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
|
||||
if (!JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(holder.getFile())) return;
|
||||
if (!JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(holder.getFile())) return;
|
||||
PsiTypeCastExpression qualifier = getQualifierReferenceExpression(call);
|
||||
if (qualifier == null) return;
|
||||
PsiInstanceOfExpression candidate = InstanceOfUtils.findPatternCandidate(qualifier);
|
||||
|
||||
+2
-3
@@ -1,10 +1,9 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -12,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public final class RecordCanBeClassInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.RECORDS.isAvailable(holder.getFile())) {
|
||||
if (!JavaFeature.RECORDS.isAvailable(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
+2
-3
@@ -4,14 +4,13 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.codeInsight.AnnotationTargetUtil;
|
||||
import com.intellij.codeInsight.ExpressionUtil;
|
||||
import com.intellij.codeInsight.PsiEquivalenceUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.DeleteElementFix;
|
||||
import com.intellij.codeInspection.util.IntentionFamilyName;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.JavaElementKind;
|
||||
import com.intellij.psi.util.JavaPsiRecordUtil;
|
||||
@@ -34,7 +33,7 @@ import java.util.Set;
|
||||
public final class RedundantRecordConstructorInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.RECORDS.isAvailable(holder.getFile())) {
|
||||
if (!JavaFeature.RECORDS.isAvailable(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
+2
-3
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiLiteralUtil;
|
||||
@@ -28,7 +27,7 @@ public final class StringTemplateMigrationInspection extends AbstractBaseJavaLoc
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.STRING_TEMPLATES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.STRING_TEMPLATES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitPolyadicExpression(@NotNull PsiPolyadicExpression expression) {
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiLiteralUtil;
|
||||
@@ -39,7 +38,7 @@ public final class TextBlockMigrationInspection extends AbstractBaseJavaLocalIns
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.TEXT_BLOCKS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.TEXT_BLOCKS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitPolyadicExpression(@NotNull PsiPolyadicExpression expression) {
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.util.IntentionFamilyName;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
@@ -9,7 +8,7 @@ import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiFragmentImpl;
|
||||
@@ -24,7 +23,7 @@ import java.util.function.Function;
|
||||
public final class TrailingWhitespacesInTextBlockInspection extends AbstractBaseJavaLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.TEXT_BLOCKS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.TEXT_BLOCKS.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitTemplate(@NotNull PsiTemplate template) {
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.classCanBeRecord;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.AddToInspectionOptionListFix;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.classCanBeRecord.ConvertToRecordFix.RecordCandidate;
|
||||
@@ -11,7 +10,7 @@ import com.intellij.java.JavaBundle;
|
||||
import com.intellij.openapi.compiler.JavaCompilerBundle;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.text.HtmlChunk;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -48,7 +47,7 @@ public final class ClassCanBeRecordInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
public boolean shouldInspect(@NotNull PsiFile file) {
|
||||
return JavaLanguageFeature.RECORDS.isAvailable(file);
|
||||
return JavaFeature.RECORDS.isAvailable(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.dataFlow;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.UnwrapSwitchLabelFix;
|
||||
import com.intellij.codeInsight.options.JavaInspectionButtons;
|
||||
import com.intellij.codeInsight.options.JavaInspectionControls;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.codeInspection.dataFlow.fix.*;
|
||||
import com.intellij.codeInspection.nullable.NullableStuffInspection;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiPrecedenceUtil;
|
||||
@@ -189,7 +188,7 @@ public final class DataFlowInspection extends DataFlowInspectionBase {
|
||||
}
|
||||
|
||||
private static void addCreateNullBranchFix(@NotNull PsiExpression qualifier, @NotNull List<? super @NotNull LocalQuickFix> fixes) {
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(qualifier)) return;
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(qualifier)) return;
|
||||
PsiElement parent = PsiUtil.skipParenthesizedExprUp(qualifier.getParent());
|
||||
if (parent instanceof PsiSwitchBlock block && PsiUtil.skipParenthesizedExprDown(block.getExpression()) == qualifier) {
|
||||
fixes.add(LocalQuickFix.from(new CreateNullBranchFix(block)));
|
||||
|
||||
+2
-3
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.enhancedSwitch;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
@@ -21,7 +20,7 @@ public final class RedundantLabeledSwitchRuleCodeBlockInspection extends LocalIn
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) {
|
||||
if (!JavaFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
+2
-3
@@ -1,14 +1,13 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.enhancedSwitch;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -22,7 +21,7 @@ public final class SwitchLabeledRuleCanBeCodeBlockInspection extends LocalInspec
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) {
|
||||
if (!JavaFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.java19api;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddUsesDirectiveFix;
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.JavaReflectionReferenceUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -20,7 +19,7 @@ public final class Java9UndeclaredServiceUsageInspection extends AbstractBaseJav
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.MODULES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.MODULES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ package com.intellij.codeInspection.preview;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.PreviewFeatureVisitorBase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
@@ -38,7 +38,7 @@ public final class PreviewFeatureInspection extends LocalInspectionTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerProblem(PsiElement element, String description, JavaLanguageFeature feature, PsiAnnotation annotation) {
|
||||
protected void registerProblem(PsiElement element, String description, JavaFeature feature, PsiAnnotation annotation) {
|
||||
myHolder.registerProblem(element, description);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.refactoring.extractMethod.newImpl
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil
|
||||
@@ -47,7 +46,7 @@ class CallBuilder(private val context: PsiElement) {
|
||||
PsiUtil.setModifierProperty(declaredVariable, PsiModifier.FINAL, declareFinal)
|
||||
|
||||
val isInferredVar = outputVariable?.typeElement?.isInferredType == true
|
||||
if (isInferredVar || JavaLanguageFeature.LVTI.isAvailable(context) && settings.INTRODUCE_LOCAL_CREATE_VAR_TYPE == true) {
|
||||
if (isInferredVar || JavaFeature.LVTI.isAvailable(context) && settings.INTRODUCE_LOCAL_CREATE_VAR_TYPE == true) {
|
||||
IntroduceVariableUtil.expandDiamondsAndReplaceExplicitTypeWithVar(declaredVariable.typeElement, declaredVariable)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@
|
||||
package com.intellij.refactoring.extractMethod.newImpl
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil.*
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AnonymousTargetClassPreselectionUtil
|
||||
import com.intellij.codeInsight.navigation.PsiTargetNavigator
|
||||
@@ -10,7 +9,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.formatter.java.MultipleFieldDeclarationHelper
|
||||
import com.intellij.psi.search.LocalSearchScope
|
||||
@@ -207,7 +206,7 @@ object ExtractMethodPipeline {
|
||||
fun withForcedStatic(analyzer: CodeFragmentAnalyzer, extractOptions: ExtractOptions): ExtractOptions? {
|
||||
val targetClass = extractOptions.targetClass
|
||||
val isInnerClass = PsiUtil.isLocalOrAnonymousClass(targetClass) || PsiUtil.isInnerClass(targetClass)
|
||||
if (isInnerClass && !JavaLanguageFeature.INNER_STATICS.isAvailable(targetClass)) return null
|
||||
if (isInnerClass && !JavaFeature.INNER_STATICS.isAvailable(targetClass)) return null
|
||||
val memberUsages = analyzer.findInstanceMemberUsages(targetClass, extractOptions.elements)
|
||||
if (memberUsages.any(::isNotExtractableUsage)) return null
|
||||
val addedParameters = memberUsages.groupBy(MemberUsage::member).entries
|
||||
|
||||
+2
-3
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.refactoring.extractMethod.newImpl.parameterObject
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
@@ -14,7 +13,7 @@ object ParameterObjectUtils {
|
||||
val factory = PsiElementFactory.getInstance(introducedClass.project)
|
||||
val typeParameters = introducedClass.typeParameters.map(factory::createType).toTypedArray()
|
||||
val type = factory.createType(introducedClass, *typeParameters)
|
||||
val typeElement = if (JavaLanguageFeature.DIAMOND_TYPES.isAvailable(introducedClass) && typeParameters.isNotEmpty()) {
|
||||
val typeElement = if (JavaFeature.DIAMOND_TYPES.isAvailable(introducedClass) && typeParameters.isNotEmpty()) {
|
||||
"${type.name}<>"
|
||||
} else {
|
||||
type.canonicalText
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.refactoring.extractMethod.newImpl.parameterObject
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.codeInsight.hint.EditorCodePreview
|
||||
import com.intellij.codeInsight.hint.HintManager
|
||||
import com.intellij.java.refactoring.JavaRefactoringBundle
|
||||
@@ -12,7 +11,7 @@ import com.intellij.openapi.command.impl.StartMarkAction
|
||||
import com.intellij.openapi.diff.DiffColors
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.refactoring.extractMethod.ExtractMethodHandler
|
||||
@@ -44,7 +43,7 @@ object ResultObjectExtractor {
|
||||
InplaceExtractUtils.showExtractErrorHint(editor, ExtractMultipleVariablesException(variables, scope))
|
||||
return
|
||||
}
|
||||
val shouldInsertRecord = JavaLanguageFeature.RECORDS.isAvailable(variables.first())
|
||||
val shouldInsertRecord = JavaFeature.RECORDS.isAvailable(variables.first())
|
||||
val objectBuilder = if (shouldInsertRecord) {
|
||||
RecordResultObjectBuilder.create(variables)
|
||||
} else {
|
||||
|
||||
+2
-3
@@ -3,7 +3,6 @@ package com.intellij.refactoring.inline;
|
||||
|
||||
import com.intellij.codeInsight.ChangeContextUtil;
|
||||
import com.intellij.codeInsight.ExpressionUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.history.LocalHistory;
|
||||
import com.intellij.history.LocalHistoryAction;
|
||||
import com.intellij.java.refactoring.JavaRefactoringBundle;
|
||||
@@ -21,7 +20,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -933,7 +932,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
|
||||
public static @DialogMessage String checkUnableToInsertCodeBlock(PsiCodeBlock methodBody, PsiElement element) {
|
||||
if (!JavaLanguageFeature.STATEMENTS_BEFORE_SUPER.isAvailable(element) &&
|
||||
if (!JavaFeature.STATEMENTS_BEFORE_SUPER.isAvailable(element) &&
|
||||
checkUnableToInsertCodeBlock(methodBody, element,
|
||||
expr -> JavaPsiConstructorUtil.isConstructorCall(expr) && expr.getMethodExpression() != element)) {
|
||||
return JavaRefactoringBundle.message("inline.method.multiline.method.in.ctor.call");
|
||||
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.refactoring.introduceField;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.refactoring.JavaRefactoringBundle;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -9,7 +8,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -123,7 +122,7 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler implemen
|
||||
declareStatic = isInSuperOrThis = isInSuperOrThis(occurrences[i]);
|
||||
}
|
||||
}
|
||||
if (isInSuperOrThis && JavaLanguageFeature.STATIC_INTERFACE_CALLS.isAvailable(expr != null ? expr : anchorElement)) {
|
||||
if (isInSuperOrThis && JavaFeature.STATIC_INTERFACE_CALLS.isAvailable(expr != null ? expr : anchorElement)) {
|
||||
isInSuperOrThis = false;
|
||||
}
|
||||
int occurrencesNumber = occurrences.length;
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@ package com.intellij.refactoring.introduceField;
|
||||
import com.intellij.codeInsight.ChangeContextUtil;
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.codeInsight.TestFrameworks;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AnonymousTargetClassPreselectionUtil;
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.codeInsight.navigation.PsiTargetNavigator;
|
||||
@@ -15,7 +14,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
@@ -123,7 +122,7 @@ public abstract class LocalToFieldHandler {
|
||||
* @return true, if adding a non-compile-time constants static field to the specified class is allowed. False otherwise.
|
||||
*/
|
||||
public static boolean isStaticFieldAllowed(@NotNull PsiClass aClass) {
|
||||
if (JavaLanguageFeature.INNER_STATICS.isAvailable(aClass)) {
|
||||
if (JavaFeature.INNER_STATICS.isAvailable(aClass)) {
|
||||
return true;
|
||||
}
|
||||
return aClass.hasModifierProperty(PsiModifier.STATIC) || aClass.getParent() instanceof PsiJavaFile;
|
||||
|
||||
+3
-4
@@ -2,7 +2,6 @@
|
||||
package com.intellij.refactoring.introduceVariable;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.highlighting.HighlightManager;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.unwrap.ScopeHighlighter;
|
||||
@@ -27,7 +26,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
@@ -564,7 +563,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
}
|
||||
|
||||
public static boolean canBeExtractedWithoutExplicitType(PsiExpression expr) {
|
||||
if (JavaLanguageFeature.LVTI.isAvailable(expr)) {
|
||||
if (JavaFeature.LVTI.isAvailable(expr)) {
|
||||
PsiType type = getNormalizedType(expr);
|
||||
if (type != null && !PsiTypes.nullType().equals(type) && PsiTypesUtil.isDenotableType(type, expr)) {
|
||||
PsiExpression copy =
|
||||
@@ -833,7 +832,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
}
|
||||
|
||||
private boolean checkAnchorBeforeThisOrSuper(Project project, Editor editor, PsiElement tempAnchorElement) {
|
||||
if (JavaLanguageFeature.STATEMENTS_BEFORE_SUPER.isAvailable(tempAnchorElement)) {
|
||||
if (JavaFeature.STATEMENTS_BEFORE_SUPER.isAvailable(tempAnchorElement)) {
|
||||
return false;
|
||||
}
|
||||
if (tempAnchorElement instanceof PsiExpressionStatement) {
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@ package com.intellij.refactoring.introduceVariable;
|
||||
import com.intellij.codeInsight.BlockUtils;
|
||||
import com.intellij.codeInsight.NullabilityAnnotationInfo;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewUtils;
|
||||
import com.intellij.codeInspection.dataFlow.DfaPsiUtil;
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
@@ -18,7 +17,7 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.impl.light.LightJavaToken;
|
||||
@@ -337,7 +336,7 @@ final class VariableExtractor {
|
||||
}
|
||||
Set<PsiExpression> allOccurrences = StreamEx.of(occurrences).filter(PsiElement::isPhysical).append(expr).toSet();
|
||||
PsiExpression firstOccurrence = Collections.min(allOccurrences, Comparator.comparing(e -> e.getTextRange().getStartOffset()));
|
||||
if (JavaLanguageFeature.PATTERNS.isAvailable(anchor)) {
|
||||
if (JavaFeature.PATTERNS.isAvailable(anchor)) {
|
||||
PsiTypeCastExpression cast = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprDown(firstOccurrence), PsiTypeCastExpression.class);
|
||||
if (cast != null) {
|
||||
PsiType castType = cast.getType();
|
||||
|
||||
+2
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.refactoring.introduceparameterobject;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -24,7 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -140,7 +139,7 @@ public class JavaIntroduceParameterObjectClassDescriptor extends IntroduceParame
|
||||
if (bean != null && bean.getField() != null) {
|
||||
getter = GenerateMembersUtil.suggestGetterName(bean.getField());
|
||||
}
|
||||
else if (bean == null && access == ReadWriteAccessDetector.Access.Read && JavaLanguageFeature.RECORDS.isAvailable(context)) {
|
||||
else if (bean == null && access == ReadWriteAccessDetector.Access.Read && JavaFeature.RECORDS.isAvailable(context)) {
|
||||
getter = paramInfo.getName();
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-3
@@ -16,11 +16,10 @@
|
||||
package com.intellij.refactoring.introduceparameterobject;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.generation.GenerateMembersUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -77,7 +76,7 @@ class ParameterObjectBuilder {
|
||||
}
|
||||
|
||||
public String buildBeanClass() {
|
||||
boolean recordsAvailable = JavaLanguageFeature.RECORDS.isAvailable(myFile) &&
|
||||
boolean recordsAvailable = JavaFeature.RECORDS.isAvailable(myFile) &&
|
||||
!ContainerUtil.exists(fields, ParameterSpec::isSetterRequired);
|
||||
@NonNls final StringBuilder out = new StringBuilder(1024);
|
||||
if (packageName.length() > 0) out.append("package ").append(packageName).append(';');
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@
|
||||
|
||||
package com.intellij.refactoring.makeStatic;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.refactoring.JavaRefactoringBundle;
|
||||
import com.intellij.lang.ContextAwareActionHandler;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
@@ -14,7 +13,7 @@ import com.intellij.openapi.editor.ScrollType;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -139,7 +138,7 @@ public class MakeStaticHandler implements RefactoringActionHandler, ContextAware
|
||||
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("cannot.make.abstract.method.static"));
|
||||
}
|
||||
|
||||
if(PsiUtil.isLocalOrAnonymousClass(containingClass) && !JavaLanguageFeature.INNER_STATICS.isAvailable(member) ||
|
||||
if(PsiUtil.isLocalOrAnonymousClass(containingClass) && !JavaFeature.INNER_STATICS.isAvailable(member) ||
|
||||
containingClass.getContainingClass() != null && !containingClass.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
return RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("inner.classes.cannot.have.static.members"));
|
||||
}
|
||||
|
||||
+2
-3
@@ -2,11 +2,10 @@
|
||||
package com.intellij.refactoring.memberPushDown;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.java.refactoring.JavaRefactoringBundle;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
@@ -218,7 +217,7 @@ public class PushDownConflicts {
|
||||
if (movedMember.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!targetClass.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!(targetClass.getParent() instanceof PsiFile) &&
|
||||
!JavaLanguageFeature.INNER_STATICS.isAvailable(targetClass)) {
|
||||
!JavaFeature.INNER_STATICS.isAvailable(targetClass)) {
|
||||
myConflicts.putValue(movedMember, JavaBundle.message("push.down.static.nonstatic.conflict",
|
||||
RefactoringUIUtil.getDescription(movedMember, false),
|
||||
RefactoringUIUtil.getDescription(targetClass, false)));
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeEditor;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.impl.PsiBasedStripTrailingSpacesFilter;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.JavaRecursiveElementWalkingVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
@@ -32,7 +31,7 @@ public final class JavaStripTrailingSpacesFilterFactory extends PsiBasedStripTra
|
||||
|
||||
@Override
|
||||
protected void process(@NotNull PsiFile psiFile) {
|
||||
if (!JavaLanguageFeature.TEXT_BLOCKS.isAvailable(psiFile)) return;
|
||||
if (!JavaFeature.TEXT_BLOCKS.isAvailable(psiFile)) return;
|
||||
psiFile.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) {
|
||||
|
||||
+2
-3
@@ -4,7 +4,6 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.ExpectedTypesProvider;
|
||||
import com.intellij.codeInsight.NullableNotNullManager;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.PsiTypeLookupItem;
|
||||
@@ -13,7 +12,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtilEx;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -117,7 +116,7 @@ class JavaClassNameInsertHandler implements InsertHandler<JavaPsiClassReferenceE
|
||||
}
|
||||
}
|
||||
|
||||
if (ref != null && JavaLanguageFeature.PATTERNS.isAvailable(ref) && psiClass.getTypeParameters().length > 0) {
|
||||
if (ref != null && JavaFeature.PATTERNS.isAvailable(ref) && psiClass.getTypeParameters().length > 0) {
|
||||
PsiExpression instanceOfOperand = JavaCompletionUtil.getInstanceOfOperand(ref);
|
||||
if (instanceOfOperand != null) {
|
||||
PsiClassType origType = JavaPsiFacade.getElementFactory(project).createType(psiClass);
|
||||
|
||||
+4
-5
@@ -6,7 +6,6 @@ import com.intellij.codeInsight.*;
|
||||
import com.intellij.codeInsight.completion.scope.CompletionElement;
|
||||
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.LambdaHighlightingUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.BringVariableIntoScopeFix;
|
||||
@@ -39,7 +38,7 @@ import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PatternCondition;
|
||||
import com.intellij.patterns.PsiJavaElementPattern;
|
||||
import com.intellij.patterns.PsiNameValuePairPattern;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
@@ -275,7 +274,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
|
||||
return element instanceof PsiEnumConstant;
|
||||
}
|
||||
};
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(position)) {
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(position)) {
|
||||
return enumClassFilter;
|
||||
}
|
||||
|
||||
@@ -322,7 +321,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
|
||||
}
|
||||
};
|
||||
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(position) ||
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(position) ||
|
||||
isPrimitive(selectorType) || TypeUtils.isJavaLangString(selectorType)) {
|
||||
ClassFilter classFilter = new ClassFilter(PsiClass.class) {
|
||||
@Override
|
||||
@@ -1013,7 +1012,7 @@ public final class JavaCompletionContributor extends CompletionContributor imple
|
||||
}
|
||||
|
||||
if (IN_SWITCH_LABEL.accepts(position)) {
|
||||
return JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(parent);
|
||||
return JavaFeature.PATTERNS_IN_SWITCH.isAvailable(parent);
|
||||
}
|
||||
|
||||
if (psiElement().inside(PsiImportStatement.class).accepts(parent)) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.intellij.codeInsight.completion.scope.CompletionElement;
|
||||
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
|
||||
import com.intellij.codeInsight.completion.util.CompletionStyleUtil;
|
||||
import com.intellij.codeInsight.completion.util.ParenthesesInsertHandler;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.LambdaHighlightingUtil;
|
||||
import com.intellij.codeInsight.editorActions.TabOutScopesTracker;
|
||||
@@ -29,7 +28,7 @@ import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.patterns.PsiJavaPatterns;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
@@ -536,7 +535,7 @@ public final class JavaCompletionUtil {
|
||||
if (ReferenceListWeigher.INSTANCE.getApplicability(psiClass, myPlace) == inapplicable) {
|
||||
return new MarkProblem(MarkType.RED, null);
|
||||
}
|
||||
if (JavaLanguageFeature.MODULES.isAvailable(myPlace)) {
|
||||
if (JavaFeature.MODULES.isAvailable(myPlace)) {
|
||||
final PsiJavaModule currentModule = ReadAction.compute(() -> JavaModuleGraphUtil.findDescriptorByFile(myOriginalFile, myPlace.getProject()));
|
||||
if (currentModule != null) {
|
||||
final PsiJavaModule targetModule = ReadAction.compute(() -> JavaModuleGraphUtil.findDescriptorByElement(psiClass));
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.codeInsight.completion;
|
||||
import com.intellij.codeInsight.*;
|
||||
import com.intellij.codeInsight.completion.util.CompletionStyleUtil;
|
||||
import com.intellij.codeInsight.completion.util.ParenthesesInsertHandler;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.CreateClassKind;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -14,7 +13,7 @@ import com.intellij.openapi.util.Conditions;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.patterns.ElementPattern;
|
||||
import com.intellij.patterns.PsiElementPattern;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
@@ -258,7 +257,7 @@ public class JavaKeywordCompletion {
|
||||
if (!canAddKeywords()) return;
|
||||
|
||||
PsiFile file = myPosition.getContainingFile();
|
||||
if (PsiJavaModule.MODULE_INFO_FILE.equals(file.getName()) && JavaLanguageFeature.MODULES.isAvailable(file)) {
|
||||
if (PsiJavaModule.MODULE_INFO_FILE.equals(file.getName()) && JavaFeature.MODULES.isAvailable(file)) {
|
||||
addModuleKeywords();
|
||||
return;
|
||||
}
|
||||
@@ -327,7 +326,7 @@ public class JavaKeywordCompletion {
|
||||
}
|
||||
|
||||
private void addCaseAfterNullDefault() {
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(myPosition)) return;
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(myPosition)) return;
|
||||
PsiCaseLabelElementList labels = PsiTreeUtil.getParentOfType(myPosition, PsiCaseLabelElementList.class);
|
||||
if (labels == null || labels.getElementCount() != 2 ||
|
||||
!(labels.getElements()[0] instanceof PsiLiteralExpression literalExpression &&
|
||||
@@ -363,7 +362,7 @@ public class JavaKeywordCompletion {
|
||||
}
|
||||
|
||||
private void addWhen() {
|
||||
if (!JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(myPosition)) {
|
||||
if (!JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(myPosition)) {
|
||||
return;
|
||||
}
|
||||
PsiElement element = PsiTreeUtil.skipWhitespacesAndCommentsForward(myPrevLeaf);
|
||||
@@ -458,7 +457,7 @@ public class JavaKeywordCompletion {
|
||||
}
|
||||
|
||||
private boolean isInsideCaseLabel() {
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(myPosition)) return false;
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(myPosition)) return false;
|
||||
return psiElement().withSuperParent(2, PsiCaseLabelElementList.class).accepts(myPosition);
|
||||
}
|
||||
|
||||
@@ -469,11 +468,11 @@ public class JavaKeywordCompletion {
|
||||
}
|
||||
|
||||
private boolean isVarAllowed() {
|
||||
if (JavaLanguageFeature.VAR_LAMBDA_PARAMETER.isAvailable(myPosition) && isLambdaParameterType()) {
|
||||
if (JavaFeature.VAR_LAMBDA_PARAMETER.isAvailable(myPosition) && isLambdaParameterType()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!JavaLanguageFeature.LVTI.isAvailable(myPosition)) return false;
|
||||
if (!JavaFeature.LVTI.isAvailable(myPosition)) return false;
|
||||
|
||||
if (isAtCatchOrResourceVariableStart(myPosition) && PsiTreeUtil.getParentOfType(myPosition, PsiCatchSection.class) == null) {
|
||||
return true;
|
||||
@@ -533,7 +532,7 @@ public class JavaKeywordCompletion {
|
||||
}
|
||||
|
||||
private void addPatternMatchingInSwitchCases() {
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(myPosition)) return;
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(myPosition)) return;
|
||||
|
||||
PsiSwitchBlock switchBlock = getSwitchFromLabelPosition(myPosition);
|
||||
if (switchBlock == null) return;
|
||||
@@ -733,7 +732,7 @@ public class JavaKeywordCompletion {
|
||||
if (SUPER_OR_THIS_PATTERN.accepts(myPosition)) {
|
||||
final boolean afterDot = AFTER_DOT.accepts(myPosition);
|
||||
final boolean insideQualifierClass = isInsideQualifierClass();
|
||||
final boolean insideInheritorClass = JavaLanguageFeature.EXTENSION_METHODS.isAvailable(myPosition) && isInsideInheritorClass();
|
||||
final boolean insideInheritorClass = JavaFeature.EXTENSION_METHODS.isAvailable(myPosition) && isInsideInheritorClass();
|
||||
if (!afterDot || insideQualifierClass || insideInheritorClass) {
|
||||
if (!afterDot || insideQualifierClass) {
|
||||
addKeyword(createKeyword(PsiKeyword.THIS));
|
||||
@@ -772,7 +771,7 @@ public class JavaKeywordCompletion {
|
||||
if (PsiTreeUtil.getParentOfType(myPosition, PsiAnnotation.class) == null) {
|
||||
if (!statementPosition) {
|
||||
addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.NEW), TailTypes.insertSpaceType()));
|
||||
if (JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(myPosition)) {
|
||||
if (JavaFeature.ENHANCED_SWITCH.isAvailable(myPosition)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.SWITCH), JavaTailTypes.SWITCH_LPARENTH));
|
||||
}
|
||||
}
|
||||
@@ -828,7 +827,7 @@ public class JavaKeywordCompletion {
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaLanguageFeature.STATIC_IMPORTS.isAvailable(file) && myPrevLeaf != null && myPrevLeaf.textMatches(PsiKeyword.IMPORT)) {
|
||||
if (JavaFeature.STATIC_IMPORTS.isAvailable(file) && myPrevLeaf != null && myPrevLeaf.textMatches(PsiKeyword.IMPORT)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.STATIC), TailTypes.humbleSpaceBeforeWordType()));
|
||||
}
|
||||
}
|
||||
@@ -879,13 +878,13 @@ public class JavaKeywordCompletion {
|
||||
if (psiElement().insideStarting(psiElement(PsiLocalVariable.class, PsiExpressionStatement.class)).accepts(myPosition)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.CLASS), TailTypes.humbleSpaceBeforeWordType()));
|
||||
addKeyword(new OverridableSpace(LookupElementBuilder.create("abstract class").bold(), TailTypes.humbleSpaceBeforeWordType()));
|
||||
if (JavaLanguageFeature.RECORDS.isAvailable(myPosition)) {
|
||||
if (JavaFeature.RECORDS.isAvailable(myPosition)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.RECORD), TailTypes.humbleSpaceBeforeWordType()));
|
||||
}
|
||||
if (JavaLanguageFeature.LOCAL_ENUMS.isAvailable(myPosition)) {
|
||||
if (JavaFeature.LOCAL_ENUMS.isAvailable(myPosition)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.ENUM), TailTypes.humbleSpaceBeforeWordType()));
|
||||
}
|
||||
if (JavaLanguageFeature.LOCAL_INTERFACES.isAvailable(myPosition)) {
|
||||
if (JavaFeature.LOCAL_INTERFACES.isAvailable(myPosition)) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.INTERFACE), TailTypes.humbleSpaceBeforeWordType()));
|
||||
}
|
||||
}
|
||||
@@ -894,7 +893,7 @@ public class JavaKeywordCompletion {
|
||||
List<String> keywords = new ArrayList<>();
|
||||
keywords.add(PsiKeyword.CLASS);
|
||||
keywords.add(PsiKeyword.INTERFACE);
|
||||
if (JavaLanguageFeature.RECORDS.isAvailable(myPosition)) {
|
||||
if (JavaFeature.RECORDS.isAvailable(myPosition)) {
|
||||
keywords.add(PsiKeyword.RECORD);
|
||||
}
|
||||
if (PsiUtil.isLanguageLevel5OrHigher(myPosition)) {
|
||||
@@ -1040,7 +1039,7 @@ public class JavaKeywordCompletion {
|
||||
if (psiClass != null) {
|
||||
if (!psiClass.isEnum() && !psiClass.isRecord()) {
|
||||
addKeyword(new OverridableSpace(createKeyword(PsiKeyword.EXTENDS), TailTypes.humbleSpaceBeforeWordType()));
|
||||
if (JavaLanguageFeature.SEALED_CLASSES.isAvailable(psiClass)) {
|
||||
if (JavaFeature.SEALED_CLASSES.isAvailable(psiClass)) {
|
||||
PsiModifierList modifiers = psiClass.getModifierList();
|
||||
if (myParameters.getInvocationCount() > 1 ||
|
||||
(modifiers != null &&
|
||||
@@ -1277,7 +1276,7 @@ public class JavaKeywordCompletion {
|
||||
addKeyword(br);
|
||||
}
|
||||
else if (psiElement().inside(PsiSwitchExpression.class).accepts(myPosition) &&
|
||||
JavaLanguageFeature.SWITCH_EXPRESSION.isAvailable(myPosition)) {
|
||||
JavaFeature.SWITCH_EXPRESSION.isAvailable(myPosition)) {
|
||||
addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.YIELD), TailTypes.insertSpaceType()));
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -1,13 +1,12 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation;
|
||||
import com.intellij.codeInsight.lookup.LookupItem;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
@@ -27,7 +26,7 @@ public final class JavaPatternCompletionUtil {
|
||||
* @return true if patterns should be suggested here
|
||||
*/
|
||||
public static boolean isPatternContext(@NotNull PsiFile psiFile, @NotNull PsiElement element) {
|
||||
if (!JavaLanguageFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(psiFile)) return false;
|
||||
if (!JavaFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(psiFile)) return false;
|
||||
if (!(element instanceof PsiIdentifier)) return false;
|
||||
PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof PsiJavaCodeReferenceElement)) return false;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.filters.FilterPositionUtil;
|
||||
import com.intellij.psi.impl.source.jsp.jspJava.JspClassLevelDeclarationStatement;
|
||||
@@ -96,7 +95,7 @@ public final class ModifierChooser {
|
||||
}
|
||||
|
||||
public static String[] addClassModifiers(PsiModifierList list, @NotNull PsiElement scope) {
|
||||
if (JavaLanguageFeature.SEALED_CLASSES.isAvailable(scope)) {
|
||||
if (JavaFeature.SEALED_CLASSES.isAvailable(scope)) {
|
||||
if (list == null) {
|
||||
return CLASS_MODIFIERS_WITH_SEALED.clone();
|
||||
}
|
||||
@@ -137,7 +136,7 @@ public final class ModifierChooser {
|
||||
}
|
||||
|
||||
private static String[][] getInterfaceMemberModifiers(@NotNull PsiElement list) {
|
||||
if (JavaLanguageFeature.SEALED_CLASSES.isAvailable(list)) {
|
||||
if (JavaFeature.SEALED_CLASSES.isAvailable(list)) {
|
||||
return INTERFACE_MEMBER_MODIFIERS_WITH_SEALED;
|
||||
}
|
||||
if (PsiUtil.isLanguageLevel9OrHigher(list)) {
|
||||
@@ -150,7 +149,7 @@ public final class ModifierChooser {
|
||||
}
|
||||
|
||||
private static String[][] getClassMemberModifiers(@NotNull PsiElement list) {
|
||||
if (JavaLanguageFeature.SEALED_CLASSES.isAvailable(list)) {
|
||||
if (JavaFeature.SEALED_CLASSES.isAvailable(list)) {
|
||||
return CLASS_MEMBER_MODIFIERS_WITH_SEALED;
|
||||
}
|
||||
return CLASS_MEMBER_MODIFIERS;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.codeInsight.daemon.impl.analysis.com.intellij.pom.java.JavaLanguageFeature.PATTERNS_IN_SWITCH;
|
||||
import static com.intellij.pom.java.JavaFeature.PATTERNS_IN_SWITCH;
|
||||
|
||||
public final class JavaCompletionProcessor implements PsiScopeProcessor, ElementClassHint {
|
||||
private static final Logger LOG = Logger.getInstance(JavaCompletionProcessor.class);
|
||||
|
||||
+7
-7
@@ -7,7 +7,7 @@ import com.intellij.codeInsight.intention.QuickFixFactory;
|
||||
import com.intellij.codeInsight.intention.impl.PriorityIntentionActionWrapper;
|
||||
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
@@ -39,17 +39,17 @@ public final class JavaFutureKeywordUseFixProvider extends UnresolvedReferenceQu
|
||||
if ((parent instanceof PsiMethod || parent instanceof PsiField) && parent.getParent() instanceof PsiClass) {
|
||||
// record R() {} is parsed as method if records aren't supported
|
||||
// record R incomplete declaration is also possible
|
||||
registerIncreaseLevelFixes(ref, JavaLanguageFeature.RECORDS, registrar);
|
||||
registerIncreaseLevelFixes(ref, JavaFeature.RECORDS, registrar);
|
||||
}
|
||||
if (parent instanceof PsiLocalVariable && parent.getParent() instanceof PsiDeclarationStatement
|
||||
&& ((PsiDeclarationStatement)parent.getParent()).getDeclaredElements().length == 1) {
|
||||
// record R() declaration inside method
|
||||
registerIncreaseLevelFixes(ref, JavaLanguageFeature.RECORDS, registrar);
|
||||
registerIncreaseLevelFixes(ref, JavaFeature.RECORDS, registrar);
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerIncreaseLevelFixes(@NotNull PsiJavaCodeReferenceElement ref,
|
||||
@NotNull JavaLanguageFeature feature,
|
||||
@NotNull JavaFeature feature,
|
||||
@NotNull QuickFixActionRegistrar registrar) {
|
||||
List<IntentionAction> fixes = new ArrayList<>();
|
||||
HighlightUtil.registerIncreaseLanguageLevelFixes(ref, feature, fixes);
|
||||
@@ -61,12 +61,12 @@ public final class JavaFutureKeywordUseFixProvider extends UnresolvedReferenceQu
|
||||
private static void registerVarLanguageLevelFix(@NotNull PsiJavaCodeReferenceElement ref,
|
||||
PsiElement parent,
|
||||
@NotNull QuickFixActionRegistrar registrar) {
|
||||
JavaLanguageFeature feature;
|
||||
JavaFeature feature;
|
||||
if (parent instanceof PsiParameter && ((PsiParameter)parent).getDeclarationScope() instanceof PsiLambdaExpression) {
|
||||
feature = JavaLanguageFeature.VAR_LAMBDA_PARAMETER;
|
||||
feature = JavaFeature.VAR_LAMBDA_PARAMETER;
|
||||
}
|
||||
else {
|
||||
feature = JavaLanguageFeature.LVTI;
|
||||
feature = JavaFeature.LVTI;
|
||||
}
|
||||
registerIncreaseLevelFixes(ref, feature, registrar);
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import com.intellij.codeInsight.daemon.QuickFixActionRegistrar;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
|
||||
import com.intellij.codeInspection.ConvertRecordToClassFix;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiJavaCodeReferenceElement;
|
||||
import com.intellij.psi.PsiKeyword;
|
||||
@@ -19,9 +19,9 @@ import static com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil.regist
|
||||
public final class SealedClassUnresolvedReferenceFixProvider extends UnresolvedReferenceQuickFixProvider<PsiJavaCodeReferenceElement> {
|
||||
@Override
|
||||
public void registerFixes(@NotNull PsiJavaCodeReferenceElement ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
if (!JavaLanguageFeature.SEALED_CLASSES.isAvailable(ref) && ref.textMatches(PsiKeyword.SEALED)) {
|
||||
if (!JavaFeature.SEALED_CLASSES.isAvailable(ref) && ref.textMatches(PsiKeyword.SEALED)) {
|
||||
ArrayList<IntentionAction> intentions = new ArrayList<>();
|
||||
registerIncreaseLanguageLevelFixes(ref, JavaLanguageFeature.SEALED_CLASSES, intentions);
|
||||
registerIncreaseLanguageLevelFixes(ref, JavaFeature.SEALED_CLASSES, intentions);
|
||||
for (IntentionAction intention : intentions) {
|
||||
registrar.register(intention);
|
||||
}
|
||||
|
||||
+3
-4
@@ -3,14 +3,13 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixActionRegistrar;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightMethodUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.impl.PriorityIntentionActionWrapper;
|
||||
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
|
||||
import com.intellij.lang.java.request.CreateFieldFromUsage;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -108,7 +107,7 @@ public class DefaultQuickFixProvider extends UnresolvedReferenceQuickFixProvider
|
||||
result.add(new CreateClassFromUsageFix(ref, CreateClassKind.ENUM));
|
||||
result.add(new CreateClassFromUsageFix(ref, CreateClassKind.ANNOTATION));
|
||||
}
|
||||
if (JavaLanguageFeature.RECORDS.isAvailable(ref)) {
|
||||
if (JavaFeature.RECORDS.isAvailable(ref)) {
|
||||
if (isNewExpression) {
|
||||
result.add(new CreateRecordFromNewFix((PsiNewExpression)parent));
|
||||
}
|
||||
@@ -119,7 +118,7 @@ public class DefaultQuickFixProvider extends UnresolvedReferenceQuickFixProvider
|
||||
|
||||
if (isNewExpression) {
|
||||
result.add(new CreateInnerClassFromNewFix((PsiNewExpression)parent));
|
||||
if (JavaLanguageFeature.RECORDS.isAvailable(ref) && ((PsiNewExpression)parent).getQualifier() == null) {
|
||||
if (JavaFeature.RECORDS.isAvailable(ref) && ((PsiNewExpression)parent).getQualifier() == null) {
|
||||
result.add(new CreateInnerRecordFromNewFix((PsiNewExpression)parent));
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -56,7 +55,7 @@ public class RenameToIgnoredFix extends RenameElementFix {
|
||||
}
|
||||
|
||||
private static boolean canBeUnnamed(PsiVariable variable) {
|
||||
if (!JavaLanguageFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(variable)) return false;
|
||||
if (!JavaFeature.UNNAMED_PATTERNS_AND_VARIABLES.isAvailable(variable)) return false;
|
||||
if (variable instanceof PsiPatternVariable || variable instanceof PsiResourceVariable) return true;
|
||||
if (variable instanceof PsiLocalVariable) {
|
||||
return variable.getParent() instanceof PsiDeclarationStatement decl && decl.getParent() instanceof PsiCodeBlock;
|
||||
|
||||
+2
-3
@@ -2,14 +2,13 @@
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.CommonQuickFixBundle;
|
||||
import com.intellij.modcommand.ActionContext;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.Presentation;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -29,7 +28,7 @@ public class ReplaceWithTypePatternFix extends PsiUpdateModCommandAction<PsiRefe
|
||||
|
||||
@Override
|
||||
protected @Nullable Presentation getPresentation(@NotNull ActionContext context, @NotNull PsiReferenceExpression expression) {
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(expression) || !(expression.getParent() instanceof PsiCaseLabelElementList)) {
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(expression) || !(expression.getParent() instanceof PsiCaseLabelElementList)) {
|
||||
return null;
|
||||
}
|
||||
PsiClass resolvedExprClass = getResolvedExprClass();
|
||||
|
||||
+2
-3
@@ -2,14 +2,13 @@
|
||||
package com.intellij.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.modcommand.ActionContext;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.Presentation;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -52,7 +51,7 @@ public final class VariableAccessFromInnerClassJava10Fix extends PsiUpdateModCom
|
||||
|
||||
@Override
|
||||
protected @Nullable Presentation getPresentation(@NotNull ActionContext context, @NotNull PsiElement element) {
|
||||
if (!JavaLanguageFeature.LVTI.isAvailable(context.file())) return null;
|
||||
if (!JavaFeature.LVTI.isAvailable(context.file())) return null;
|
||||
PsiReferenceExpression reference = tryCast(element, PsiReferenceExpression.class);
|
||||
if (reference == null) return null;
|
||||
PsiLocalVariable variable = tryCast(reference.resolve(), PsiLocalVariable.class);
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
package com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -14,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public final class CaseJoinLinesHandler implements JoinLinesHandlerDelegate {
|
||||
@Override
|
||||
public int tryJoinLines(@NotNull final Document document, @NotNull final PsiFile psiFile, final int start, final int end) {
|
||||
if (!JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(psiFile)) return -1;
|
||||
if (!JavaFeature.ENHANCED_SWITCH.isAvailable(psiFile)) return -1;
|
||||
PsiElement elementAtStartLineEnd = psiFile.findElementAt(start);
|
||||
PsiElement elementAtNextLineStart = psiFile.findElementAt(end);
|
||||
if (elementAtStartLineEnd == null || elementAtNextLineStart == null) return -1;
|
||||
|
||||
+3
-4
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInsight.intention.impl
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.ModifierFix
|
||||
import com.intellij.codeInsight.intention.AddAnnotationPsiFix
|
||||
import com.intellij.codeInsight.intention.FileModifier
|
||||
@@ -18,7 +17,7 @@ import com.intellij.modcommand.ModPsiUpdater
|
||||
import com.intellij.modcommand.Presentation
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction
|
||||
import com.intellij.openapi.util.text.StringUtilRt
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager
|
||||
import com.intellij.psi.impl.light.LightRecordMember
|
||||
@@ -137,11 +136,11 @@ class JavaElementActionsFactory : JvmElementActionsFactory() {
|
||||
|
||||
if (staticMethodRequested) {
|
||||
// static methods in interfaces are allowed starting with Java 8
|
||||
if (javaClass.isInterface && !JavaLanguageFeature.STATIC_INTERFACE_CALLS.isAvailable(javaClass)) return emptyList()
|
||||
if (javaClass.isInterface && !JavaFeature.STATIC_INTERFACE_CALLS.isAvailable(javaClass)) return emptyList()
|
||||
// static methods in inner classes are disallowed before Java 16: see JLS 8.1.3
|
||||
if (javaClass.containingClass != null &&
|
||||
!javaClass.hasModifierProperty(PsiModifier.STATIC) &&
|
||||
!JavaLanguageFeature.INNER_STATICS.isAvailable(javaClass)) return emptyList()
|
||||
!JavaFeature.INNER_STATICS.isAvailable(javaClass)) return emptyList()
|
||||
}
|
||||
|
||||
val result = ArrayList<IntentionAction>()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
@@ -11,7 +10,7 @@ import com.intellij.modcommand.Presentation;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ClassInheritorsSearch;
|
||||
import com.intellij.psi.search.searches.FunctionalExpressionSearch;
|
||||
@@ -43,7 +42,7 @@ public final class SealClassAction extends PsiUpdateModCommandAction<PsiClass> {
|
||||
}
|
||||
|
||||
private static boolean isAvailable(@NotNull ActionContext context, @NotNull PsiClass aClass) {
|
||||
if (!JavaLanguageFeature.SEALED_CLASSES.isAvailable(aClass)) return false;
|
||||
if (!JavaFeature.SEALED_CLASSES.isAvailable(aClass)) return false;
|
||||
int offset = context.offset();
|
||||
PsiElement lBrace = aClass.getLBrace();
|
||||
if (lBrace == null) return false;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInsight.lookup;
|
||||
|
||||
import com.intellij.codeInsight.completion.*;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
|
||||
import com.intellij.codeInsight.editorActions.TabOutScopesTracker;
|
||||
import com.intellij.diagnostic.CoreAttachmentFactory;
|
||||
@@ -13,7 +12,7 @@ import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ClassConditionKey;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.PsiClassReferenceType;
|
||||
import com.intellij.psi.util.PsiFormatUtil;
|
||||
@@ -350,7 +349,7 @@ public final class PsiTypeLookupItem extends LookupItem<Object> implements Typed
|
||||
}
|
||||
|
||||
// jigsaw module
|
||||
if (JavaLanguageFeature.MODULES.isAvailable(file)) {
|
||||
if (JavaFeature.MODULES.isAvailable(file)) {
|
||||
final PsiJavaModule currentModule = JavaModuleGraphUtil.findDescriptorByElement(file);
|
||||
if (currentModule != null) {
|
||||
final PsiJavaModule targetModule = JavaModuleGraphUtil.findDescriptorByElement(aClass);
|
||||
|
||||
+4
-5
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInsight.template.postfix.templates;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilCore;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.generation.surroundWith.JavaExpressionSurrounder;
|
||||
import com.intellij.codeInsight.template.postfix.util.JavaPostfixTemplatesUtils;
|
||||
import com.intellij.java.JavaBundle;
|
||||
@@ -14,7 +13,7 @@ import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
@@ -39,7 +38,7 @@ public class SwitchStatementPostfixTemplate extends SurroundPostfixTemplateBase
|
||||
if (type == null) return false;
|
||||
if (PsiTypes.intType().isAssignableFrom(type)) return true;
|
||||
if (type instanceof PsiClassType classType) {
|
||||
if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) return true;
|
||||
if (JavaFeature.PATTERNS_IN_SWITCH.isAvailable(expression)) return true;
|
||||
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass != null && psiClass.isEnum()) return true;
|
||||
@@ -77,7 +76,7 @@ public class SwitchStatementPostfixTemplate extends SurroundPostfixTemplateBase
|
||||
PsiSwitchStatement switchStatement = (PsiSwitchStatement)factory.createStatementFromText("switch(1){case 1:}", null);
|
||||
return postprocessSwitch(editor, expr, codeStyleManager, parent, switchStatement);
|
||||
}
|
||||
else if (JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(expr)) {
|
||||
else if (JavaFeature.ENHANCED_SWITCH.isAvailable(expr)) {
|
||||
PsiSwitchExpression switchExpression = (PsiSwitchExpression)factory.createExpressionFromText("switch(1){case 1->1;}", null);
|
||||
return postprocessSwitch(editor, expr, codeStyleManager, expr, switchExpression);
|
||||
}
|
||||
@@ -123,7 +122,7 @@ public class SwitchStatementPostfixTemplate extends SurroundPostfixTemplateBase
|
||||
return new PostfixTemplateExpressionSelectorBase(additionalFilter) {
|
||||
@Override
|
||||
protected List<PsiElement> getNonFilteredExpressions(@NotNull PsiElement context, @NotNull Document document, int offset) {
|
||||
boolean isEnhancedSwitchAvailable = JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(context);
|
||||
boolean isEnhancedSwitchAvailable = JavaFeature.ENHANCED_SWITCH.isAvailable(context);
|
||||
List<PsiElement> result = new ArrayList<>();
|
||||
|
||||
for (PsiElement element = PsiTreeUtil.getNonStrictParentOfType(context, PsiExpression.class, PsiStatement.class);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationTargetUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
|
||||
import com.intellij.codeInsight.intention.PriorityAction;
|
||||
import com.intellij.codeInsight.intention.impl.ConvertCompactConstructorToCanonicalAction;
|
||||
@@ -16,7 +15,7 @@ import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.Presentation;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
@@ -327,7 +326,7 @@ public class ConvertRecordToClassFix extends PsiUpdateModCommandAction<PsiElemen
|
||||
:
|
||||
"if(obj == this) return true;\n" +
|
||||
"if(obj == null || obj.getClass() != this.getClass()) return false;\n" +
|
||||
(myLanguageLevel.isAtLeast(JavaLanguageFeature.LVTI.getLevel()) ? PsiKeyword.VAR : psiClass.getName()) +
|
||||
(myLanguageLevel.isAtLeast(JavaFeature.LVTI.getLevel()) ? PsiKeyword.VAR : psiClass.getName()) +
|
||||
" that = (" + psiClass.getName() + ")obj;\n" +
|
||||
"return " + equalsExpression + ";\n";
|
||||
return "@" + CommonClassNames.JAVA_LANG_OVERRIDE + "\n" +
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.BlockUtils;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.SwitchBlockHighlightingModel.PatternsInSwitchBlockHighlightingModel.CompletenessResult;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.java.JavaBundle;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
@@ -56,7 +55,7 @@ public final class EnhancedSwitchMigrationInspection extends AbstractBaseJavaLoc
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.ENHANCED_SWITCH.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) {
|
||||
|
||||
+2
-4
@@ -2,18 +2,16 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.Nullability;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.compiler.JavacQuirksInspectionVisitor;
|
||||
import com.intellij.codeInspection.dataFlow.NullabilityUtil;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
@@ -61,7 +59,7 @@ public final class LambdaCanBeMethodReferenceInspection extends AbstractBaseJava
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.LAMBDA_EXPRESSIONS.isAvailable(holder.getFile())) {
|
||||
if (!JavaFeature.LAMBDA_EXPRESSIONS.isAvailable(holder.getFile())) {
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.codeInsight.daemon.JavaErrorBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightClassUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
import com.intellij.ide.fileTemplates.*;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -13,7 +12,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.InputValidatorEx;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -39,7 +38,7 @@ public class CreateClassAction extends JavaCreateTemplateInPackageAction<PsiClas
|
||||
.setTitle(JavaBundle.message("action.create.new.class"))
|
||||
.addKind(JavaPsiBundle.message("node.class.tooltip"), IconManager.getInstance().getPlatformIcon(com.intellij.ui.PlatformIcons.Class), JavaTemplateUtil.INTERNAL_CLASS_TEMPLATE_NAME)
|
||||
.addKind(JavaPsiBundle.message("node.interface.tooltip"), PlatformIcons.INTERFACE_ICON, JavaTemplateUtil.INTERNAL_INTERFACE_TEMPLATE_NAME);
|
||||
if (JavaLanguageFeature.RECORDS.isAvailable(directory)) {
|
||||
if (JavaFeature.RECORDS.isAvailable(directory)) {
|
||||
builder.addKind(JavaPsiBundle.message("node.record.tooltip"), PlatformIcons.RECORD_ICON, JavaTemplateUtil.INTERNAL_RECORD_TEMPLATE_NAME);
|
||||
}
|
||||
LanguageLevel level = PsiUtil.getLanguageLevel(directory);
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.intellij.codeInsight.JavaModuleSystemEx
|
||||
import com.intellij.codeInsight.JavaModuleSystemEx.ErrorWithFixes
|
||||
import com.intellij.codeInsight.daemon.JavaErrorBundle
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddExportsDirectiveFix
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddRequiresDirectiveFix
|
||||
@@ -21,7 +20,7 @@ import com.intellij.openapi.roots.JdkOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.ProjectFileIndex
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.pom.java.JavaLanguageFeature
|
||||
import com.intellij.pom.java.JavaFeature
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.impl.light.LightJavaModule
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
@@ -59,7 +58,7 @@ internal class JavaPlatformModuleSystem : JavaModuleSystemEx {
|
||||
isAccessible: (targetModule: PsiJavaModule, packageName: String, useModule: PsiJavaModule) -> Boolean): ErrorWithFixes? {
|
||||
val originalTargetFile = targetFile?.originalFile
|
||||
val useFile = place.containingFile?.originalFile ?: return null
|
||||
if (!JavaLanguageFeature.MODULES.isAvailable(useFile)) return null
|
||||
if (!JavaFeature.MODULES.isAvailable(useFile)) return null
|
||||
|
||||
val useVFile = useFile.virtualFile
|
||||
val index = ProjectFileIndex.getInstance(useFile.project)
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.psi.impl.source.codeStyle;
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.ImportFilter;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightVisitorImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.jsp.JspSpiUtil;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -15,7 +14,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.NlsSafe;
|
||||
import com.intellij.openapi.util.Predicates;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
@@ -130,7 +129,7 @@ public final class ImportHelper{
|
||||
classesToUseSingle.addAll(toReimport);
|
||||
|
||||
try {
|
||||
boolean stringTemplates = JavaLanguageFeature.STRING_TEMPLATES.isAvailable(file);
|
||||
boolean stringTemplates = JavaFeature.STRING_TEMPLATES.isAvailable(file);
|
||||
StringBuilder text = buildImportListText(resultList, classesOrPackagesToImportOnDemand.keySet(), classesToUseSingle, stringTemplates);
|
||||
for (PsiElement nonImport : nonImports) {
|
||||
text.append("\n").append(nonImport.getText());
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.siyeh.ig.classlayout;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddDefaultConstructorFix;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -23,7 +22,7 @@ import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -69,7 +68,7 @@ public final class ClassInitializerInspection extends BaseInspection {
|
||||
PsiClassInitializer classInitializer = (PsiClassInitializer)infos[0];
|
||||
final PsiClass aClass = classInitializer.getContainingClass();
|
||||
assert aClass != null;
|
||||
if (PsiUtil.isInnerClass(aClass) && !JavaLanguageFeature.INNER_STATICS.isAvailable(aClass) ||
|
||||
if (PsiUtil.isInnerClass(aClass) && !JavaFeature.INNER_STATICS.isAvailable(aClass) ||
|
||||
ClassInitializerMayBeStaticInspection.dependsOnInstanceMembers(classInitializer)) {
|
||||
return new LocalQuickFix[] {new MoveToConstructorFix()};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.siyeh.ig.controlflow;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.SwitchBlockHighlightingModel.PatternsInSwitchBlockHighlightingModel;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.SwitchBlockHighlightingModel.PatternsInSwitchBlockHighlightingModel.CompletenessResult;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -25,7 +24,7 @@ import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.modcommand.ActionContext;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.controlFlow.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -96,7 +95,7 @@ public final class UnnecessaryDefaultInspection extends BaseInspection {
|
||||
|
||||
@Override
|
||||
public boolean shouldInspect(@NotNull PsiFile file) {
|
||||
return !onlyReportSwitchExpressions || JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(file);
|
||||
return !onlyReportSwitchExpressions || JavaFeature.ENHANCED_SWITCH.isAvailable(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.dataflow;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.modcommand.ActionContext;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
@@ -37,7 +36,7 @@ public final class CreateNullBranchFix extends BaseSwitchFix {
|
||||
|
||||
@Override
|
||||
protected void invoke(@NotNull ActionContext context, @NotNull PsiSwitchBlock switchBlock, @NotNull ModPsiUpdater updater) {
|
||||
if (!JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(switchBlock)) return;
|
||||
if (!JavaFeature.PATTERNS_IN_SWITCH.isAvailable(switchBlock)) return;
|
||||
PsiCodeBlock body = switchBlock.getBody();
|
||||
if (body == null) return;
|
||||
PsiExpression selector = switchBlock.getExpression();
|
||||
|
||||
@@ -16,15 +16,17 @@
|
||||
package com.siyeh.ig.memory;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.options.JavaClassValidator;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.codeInspection.util.SpecialAnnotationsUtilBase;
|
||||
import com.intellij.modcommand.*;
|
||||
import com.intellij.modcommand.ActionContext;
|
||||
import com.intellij.modcommand.ModCommand;
|
||||
import com.intellij.modcommand.ModCommandBatchQuickFix;
|
||||
import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
@@ -176,7 +178,7 @@ public final class InnerClassMayBeStaticInspection extends BaseInspection {
|
||||
public void visitClass(@NotNull PsiClass aClass) {
|
||||
if (aClass.getContainingClass() != null && !aClass.hasModifierProperty(PsiModifier.STATIC) ||
|
||||
PsiUtil.isLocalOrAnonymousClass(aClass)) {
|
||||
if (!JavaLanguageFeature.INNER_STATICS.isAvailable(aClass)) {
|
||||
if (!JavaFeature.INNER_STATICS.isAvailable(aClass)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.siyeh.ig.migration;
|
||||
|
||||
import com.intellij.codeInsight.Nullability;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightControlFlowUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.CommonQuickFixBundle;
|
||||
import com.intellij.codeInspection.EnhancedSwitchMigrationInspection;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
@@ -15,7 +14,7 @@ import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
@@ -110,7 +109,7 @@ public final class IfCanBeSwitchInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
ifStatement = concatenateIfStatements(ifStatement);
|
||||
if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(ifStatement)) {
|
||||
if (JavaFeature.PATTERNS_IN_SWITCH.isAvailable(ifStatement)) {
|
||||
for (PsiIfStatement ifStatementInChain : getAllConditionalBranches(ifStatement)) {
|
||||
replaceCastsWithPatternVariable(ifStatementInChain);
|
||||
}
|
||||
@@ -320,7 +319,7 @@ public final class IfCanBeSwitchInspection extends BaseInspection {
|
||||
branches.add(new IfStatementBranch(new PsiEmptyStatementImpl(), true));
|
||||
}
|
||||
}
|
||||
if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(switchExpression)){
|
||||
if (JavaFeature.PATTERNS_IN_SWITCH.isAvailable(switchExpression)){
|
||||
if (getNullability(switchExpression) != Nullability.NOT_NULL && findNullCheckedOperand(statementToReplace) == null) {
|
||||
final IfStatementBranch defaultBranch = ContainerUtil.find(branches, (branch) -> branch.isElse());
|
||||
final PsiElementFactory factory = PsiElementFactory.getInstance(ifStatement.getProject());
|
||||
@@ -350,7 +349,7 @@ public final class IfCanBeSwitchInspection extends BaseInspection {
|
||||
final PsiStatement newStatement = factory.createStatementFromText(switchStatementText.toString(), ifStatement);
|
||||
final PsiSwitchStatement replacement = (PsiSwitchStatement)statementToReplace.replace(newStatement);
|
||||
updater.moveCaretTo(replacement);
|
||||
if (JavaLanguageFeature.ENHANCED_SWITCH.isAvailable(replacement)) {
|
||||
if (JavaFeature.ENHANCED_SWITCH.isAvailable(replacement)) {
|
||||
final EnhancedSwitchMigrationInspection.SwitchReplacer replacer = EnhancedSwitchMigrationInspection.findSwitchReplacer(replacement);
|
||||
if (replacer != null) {
|
||||
replacer.replace(replacement);
|
||||
@@ -675,7 +674,7 @@ public final class IfCanBeSwitchInspection extends BaseInspection {
|
||||
return false;
|
||||
}
|
||||
Nullability nullability = getNullability(switchExpression);
|
||||
if (JavaLanguageFeature.PATTERNS_IN_SWITCH.isAvailable(switchExpression) && !ClassUtils.isPrimitive(switchExpression.getType())) {
|
||||
if (JavaFeature.PATTERNS_IN_SWITCH.isAvailable(switchExpression) && !ClassUtils.isPrimitive(switchExpression.getType())) {
|
||||
if (hasDefaultElse(ifStatement) || findNullCheckedOperand(ifStatement) != null || hasUnconditionalPatternCheck(ifStatement, switchExpression)) {
|
||||
nullability = Nullability.NOT_NULL;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
package com.siyeh.ig.performance;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.options.JavaInspectionButtons;
|
||||
import com.intellij.codeInsight.options.JavaInspectionControls;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.dataFlow.CommonDataflow;
|
||||
import com.intellij.codeInspection.dataFlow.Mutability;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
@@ -90,7 +89,7 @@ public final class FieldMayBeStaticInspection extends BaseInspection {
|
||||
if (containingClass != null
|
||||
&& !containingClass.hasModifierProperty(PsiModifier.STATIC)
|
||||
&& containingClass.getContainingClass() != null
|
||||
&& !JavaLanguageFeature.INNER_STATICS.isAvailable(containingClass)
|
||||
&& !JavaFeature.INNER_STATICS.isAvailable(containingClass)
|
||||
&& !PsiUtil.isCompileTimeConstant(field)) {
|
||||
// inner class cannot have static declarations in earlier Java versions
|
||||
return;
|
||||
@@ -99,7 +98,7 @@ public final class FieldMayBeStaticInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
if (containingClass instanceof PsiAnonymousClass &&
|
||||
!JavaLanguageFeature.INNER_STATICS.isAvailable(containingClass) &&
|
||||
!JavaFeature.INNER_STATICS.isAvailable(containingClass) &&
|
||||
!PsiUtil.isCompileTimeConstant(field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.siyeh.ig.performance;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
|
||||
import com.intellij.codeInspection.InspectionManager;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
@@ -23,7 +22,7 @@ import com.intellij.codeInspection.options.OptPane;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.FindSuperElementsHelper;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -154,7 +153,7 @@ public final class MethodMayBeStaticInspection extends BaseInspection {
|
||||
}
|
||||
final PsiElement scope = containingClass.getScope();
|
||||
if (!(scope instanceof PsiJavaFile) && !containingClass.hasModifierProperty(PsiModifier.STATIC) && !containingClass.isInterface() &&
|
||||
!JavaLanguageFeature.INNER_STATICS.isAvailable(scope)) {
|
||||
!JavaFeature.INNER_STATICS.isAvailable(scope)) {
|
||||
return;
|
||||
}
|
||||
if (m_onlyPrivateOrFinal && !method.hasModifierProperty(PsiModifier.FINAL) && !method.hasModifierProperty(PsiModifier.PRIVATE)) {
|
||||
|
||||
+2
-5
@@ -1,7 +1,6 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.redundancy;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
import com.intellij.codeInspection.CleanupLocalInspectionTool;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.modcommand.ModPsiUpdater;
|
||||
import com.intellij.modcommand.PsiUpdateModCommandAction;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiEmptyExpressionImpl;
|
||||
import com.intellij.psi.util.JavaPsiStringTemplateUtil;
|
||||
@@ -22,12 +21,10 @@ import com.siyeh.ig.psiutils.CommentTracker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class RedundantEmbeddedExpressionInspection extends AbstractBaseJavaLocalInspectionTool implements CleanupLocalInspectionTool {
|
||||
@Override
|
||||
public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!JavaLanguageFeature.STRING_TEMPLATES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
if (!JavaFeature.STRING_TEMPLATES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR;
|
||||
return new JavaElementVisitor() {
|
||||
@Override
|
||||
public void visitTemplateExpression(@NotNull PsiTemplateExpression expression) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.siyeh.ig.redundancy;
|
||||
|
||||
import com.intellij.codeInsight.BlockUtils;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.DeleteElementFix;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.options.OptPane;
|
||||
@@ -15,7 +14,7 @@ import com.intellij.modcommand.PsiUpdateModCommandQuickFix;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiLiteralUtil;
|
||||
@@ -153,7 +152,7 @@ public final class RedundantStringOperationInspection extends AbstractBaseJavaLo
|
||||
|
||||
@Override
|
||||
public void visitTemplateExpression(@NotNull PsiTemplateExpression element) {
|
||||
if (!JavaLanguageFeature.STRING_TEMPLATES.isAvailable(element) || element.getLiteralExpression() == null) {
|
||||
if (!JavaFeature.STRING_TEMPLATES.isAvailable(element) || element.getLiteralExpression() == null) {
|
||||
return;
|
||||
}
|
||||
PsiExpression processor = element.getProcessor();
|
||||
|
||||
+3
-4
@@ -1,9 +1,8 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ipp.concatenation;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.pom.java.JavaLanguageFeature;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiConcatenationUtil;
|
||||
import com.intellij.psi.util.PsiLiteralUtil;
|
||||
@@ -54,7 +53,7 @@ public final class ReplaceConcatenationWithFormatStringIntention extends MCInten
|
||||
}
|
||||
CommentTracker commentTracker = new CommentTracker();
|
||||
final StringBuilder newExpression = new StringBuilder();
|
||||
if (JavaLanguageFeature.TEXT_BLOCKS.isAvailable(element)) {
|
||||
if (JavaFeature.TEXT_BLOCKS.isAvailable(element)) {
|
||||
appendFormatString(expression, formatString, false, newExpression);
|
||||
newExpression.append(".formatted(");
|
||||
} else {
|
||||
@@ -71,7 +70,7 @@ public final class ReplaceConcatenationWithFormatStringIntention extends MCInten
|
||||
|
||||
@Override
|
||||
protected String getTextForElement(@NotNull PsiElement element) {
|
||||
return IntentionPowerPackBundle.message(JavaLanguageFeature.TEXT_BLOCKS.isAvailable(element)
|
||||
return IntentionPowerPackBundle.message(JavaFeature.TEXT_BLOCKS.isAvailable(element)
|
||||
? "replace.concatenation.with.format.string.intention.name.formatted"
|
||||
: "replace.concatenation.with.format.string.intention.name");
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user