mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[java-inspections] DuplicateExpressions: recognize stable methods from GetterDescriptor; add some methods from java.io.File
Fixes to some extent IDEA-114778 IntelliJ: add "locate multiple occurrence" GitOrigin-RevId: a20d9db31a79cdc963075993a09a6a6115947621
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cb1b1c7f61
commit
3c7271ac4e
@@ -36,7 +36,9 @@ public final class GetterDescriptor extends PsiVarDescriptor {
|
||||
CallMatcher.instanceCall("java.lang.reflect.Method", "getReturnType"),
|
||||
CallMatcher.instanceCall(CommonClassNames.JAVA_LANG_CLASS, "getName", "isInterface", "isArray", "isPrimitive", "isSynthetic",
|
||||
"isAnonymousClass", "isLocalClass", "isMemberClass", "getDeclaringClass", "getEnclosingClass",
|
||||
"getSimpleName", "getCanonicalName")
|
||||
"getSimpleName", "getCanonicalName"),
|
||||
CallMatcher.instanceCall(CommonClassNames.JAVA_IO_FILE, "getName", "getParent", "getPath", "getAbsolutePath",
|
||||
"getParentFile", "getAbsoluteFile", "toPath")
|
||||
);
|
||||
private final @NotNull PsiMethod myGetter;
|
||||
private final boolean myStable;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.intellij.codeInspection.duplicateExpressions;
|
||||
|
||||
import com.intellij.codeInspection.dataFlow.CommonDataflow;
|
||||
import com.intellij.codeInspection.dataFlow.jvm.descriptors.GetterDescriptor;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -182,6 +183,9 @@ final class SideEffectCalculator {
|
||||
if ("java.nio.file.Paths".equals(className)) {
|
||||
return !"get".equals(method.getName());
|
||||
}
|
||||
if (method.getParameterList().getParametersCount() == 0 && new GetterDescriptor(method).isStable()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user