mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-314576 [java]: skip array initializers in "Local variable type can be omitted" inspection
GitOrigin-RevId: 6285f111eca09a9f17ec5c83a595197e44d8e7a0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
073d07284d
commit
8671e867cc
+3
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2026 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.AnnotationTargetUtil;
|
||||
@@ -9,6 +9,7 @@ import com.intellij.pom.java.JavaFeature;
|
||||
import com.intellij.psi.JavaElementVisitor;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import com.intellij.psi.PsiAnonymousClass;
|
||||
import com.intellij.psi.PsiArrayInitializerExpression;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDeclarationStatement;
|
||||
import com.intellij.psi.PsiDeconstructionList;
|
||||
@@ -56,7 +57,7 @@ public final class RedundantExplicitVariableTypeInspection extends AbstractBaseJ
|
||||
return;
|
||||
}
|
||||
PsiExpression initializer = variable.getInitializer();
|
||||
if (initializer instanceof PsiFunctionalExpression) {
|
||||
if (initializer instanceof PsiFunctionalExpression || initializer instanceof PsiArrayInitializerExpression) {
|
||||
return;
|
||||
}
|
||||
doCheck(variable, (PsiLocalVariable)variable.copy(), typeElement);
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// "Replace explicit type with 'var'" "true-preview"
|
||||
class Main {
|
||||
{
|
||||
var args = new String[]{"hello, world"};
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace explicit type with 'var'" "true-preview"
|
||||
// "Replace explicit type with 'var'" "false"
|
||||
class Main {
|
||||
{
|
||||
<caret>String[] args = {"hello, world"};
|
||||
|
||||
Reference in New Issue
Block a user