mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExpressionTypeMemoryState: better hashcode; GuessManagerImpl: place -> onlyForPlace
Review ID: IDEA-CR-27869
This commit is contained in:
+9
@@ -22,6 +22,8 @@ import com.intellij.codeInspection.dataFlow.value.DfaValue;
|
||||
import com.intellij.codeInspection.dataFlow.value.DfaValueFactory;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.PsiMethodCallExpression;
|
||||
import com.intellij.psi.PsiReferenceExpression;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
@@ -29,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -38,6 +41,12 @@ public class ExpressionTypeMemoryState extends DfaMemoryStateImpl {
|
||||
public static final TObjectHashingStrategy<PsiExpression> EXPRESSION_HASHING_STRATEGY = new TObjectHashingStrategy<PsiExpression>() {
|
||||
@Override
|
||||
public int computeHashCode(PsiExpression object) {
|
||||
if (object instanceof PsiReferenceExpression) {
|
||||
return Objects.hashCode(((PsiReferenceExpression)object).getReferenceName()) * 31 + 1;
|
||||
}
|
||||
else if (object instanceof PsiMethodCallExpression) {
|
||||
return Objects.hashCode(((PsiMethodCallExpression)object).getMethodExpression().getReferenceName()) * 31 + 2;
|
||||
}
|
||||
return object.getNode().getElementType().hashCode();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -136,7 +136,7 @@ public class GuessManagerImpl extends GuessManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static MultiMap<PsiExpression, PsiType> buildDataflowTypeMap(PsiExpression forPlace, boolean place) {
|
||||
private static MultiMap<PsiExpression, PsiType> buildDataflowTypeMap(PsiExpression forPlace, boolean onlyForPlace) {
|
||||
PsiElement scope = DfaPsiUtil.getTopmostBlockInSameClass(forPlace);
|
||||
if (scope == null) {
|
||||
PsiFile file = forPlace.getContainingFile();
|
||||
@@ -155,7 +155,7 @@ public class GuessManagerImpl extends GuessManager {
|
||||
}
|
||||
};
|
||||
|
||||
final ExpressionTypeInstructionVisitor visitor = new ExpressionTypeInstructionVisitor(forPlace, place);
|
||||
final ExpressionTypeInstructionVisitor visitor = new ExpressionTypeInstructionVisitor(forPlace, onlyForPlace);
|
||||
if (runner.analyzeMethodWithInlining(scope, visitor) == RunnerResult.OK) {
|
||||
return visitor.getResult();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user