mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
[java] Use HighlightingFeature.LVTI
GitOrigin-RevId: ce2d4c1a6338457ff57f691fc6fdc2542de5022c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5b6191dd34
commit
a8f88fa062
@@ -1,6 +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.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.psi.*;
|
||||
@@ -15,7 +16,7 @@ public class VariableTypeCanBeExplicitInspection extends AbstractBaseJavaLocalIn
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
|
||||
if (!PsiUtil.isLanguageLevel10OrHigher(holder.getFile())) { //var won't be parsed as inferred type otherwise
|
||||
if (!HighlightingFeature.LVTI.isAvailable(holder.getFile())) { //var won't be parsed as inferred type otherwise
|
||||
return PsiElementVisitor.EMPTY_VISITOR;
|
||||
}
|
||||
return new JavaElementVisitor() {
|
||||
|
||||
@@ -1,6 +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.psi.*
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.psi.impl.source.resolve.JavaResolveUtil
|
||||
@@ -45,7 +46,7 @@ class CallBuilder(private val context: PsiElement) {
|
||||
PsiUtil.setModifierProperty(declaredVariable, PsiModifier.FINAL, declareFinal)
|
||||
|
||||
val isInferredVar = outputVariable?.typeElement?.isInferredType == true
|
||||
if (isInferredVar || PsiUtil.isLanguageLevel10OrHigher(context) && settings.INTRODUCE_LOCAL_CREATE_VAR_TYPE == true) {
|
||||
if (isInferredVar || HighlightingFeature.LVTI.isAvailable(context) && settings.INTRODUCE_LOCAL_CREATE_VAR_TYPE == true) {
|
||||
IntroduceVariableUtil.expandDiamondsAndReplaceExplicitTypeWithVar(declaredVariable.typeElement, declaredVariable)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
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;
|
||||
@@ -568,7 +569,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
}
|
||||
|
||||
public static boolean canBeExtractedWithoutExplicitType(PsiExpression expr) {
|
||||
if (PsiUtil.isLanguageLevel10OrHigher(expr)) {
|
||||
if (HighlightingFeature.LVTI.isAvailable(expr)) {
|
||||
PsiType type = getNormalizedType(expr);
|
||||
if (type != null && !PsiTypes.nullType().equals(type) && PsiTypesUtil.isDenotableType(type, expr)) {
|
||||
PsiExpression copy =
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
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;
|
||||
@@ -50,7 +51,7 @@ public class VariableAccessFromInnerClassJava10Fix extends PsiUpdateModCommandAc
|
||||
|
||||
@Override
|
||||
protected @Nullable Presentation getPresentation(@NotNull ActionContext context, @NotNull PsiElement element) {
|
||||
if (!PsiUtil.isLanguageLevel10OrHigher(context.file())) return null;
|
||||
if (!HighlightingFeature.LVTI.isAvailable(context.file())) return null;
|
||||
PsiReferenceExpression reference = tryCast(element, PsiReferenceExpression.class);
|
||||
if (reference == null) return null;
|
||||
PsiLocalVariable variable = tryCast(reference.resolve(), PsiLocalVariable.class);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.plushnikov.intellij.plugin.intention.valvar.to;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.HighlightingFeature;
|
||||
import com.intellij.codeInspection.RemoveRedundantTypeArgumentsUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -29,7 +30,7 @@ public abstract class AbstractReplaceExplicitTypeWithVariableIntentionAction ext
|
||||
|
||||
@Override
|
||||
public boolean isAvailableOnDeclarationStatement(PsiDeclarationStatement context) {
|
||||
if (PsiUtil.isLanguageLevel10OrHigher(context)) {
|
||||
if (HighlightingFeature.LVTI.isAvailable(context)) {
|
||||
return false;
|
||||
}
|
||||
PsiElement[] declaredElements = context.getDeclaredElements();
|
||||
|
||||
Reference in New Issue
Block a user