mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DFA-related performance fixes
This commit is contained in:
+7
@@ -27,10 +27,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.codeInspection.dataFlow.ControlFlowAnalyzer.ORG_JETBRAINS_ANNOTATIONS_CONTRACT;
|
||||
|
||||
public class InferredAnnotationsManagerImpl extends InferredAnnotationsManager {
|
||||
private static final Set<String> INFERRED_ANNOTATIONS =
|
||||
ContainerUtil.set(AnnotationUtil.NOT_NULL, AnnotationUtil.NULLABLE, ORG_JETBRAINS_ANNOTATIONS_CONTRACT);
|
||||
private final Project myProject;
|
||||
|
||||
public InferredAnnotationsManagerImpl(Project project) {
|
||||
@@ -40,6 +43,10 @@ public class InferredAnnotationsManagerImpl extends InferredAnnotationsManager {
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiAnnotation findInferredAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN) {
|
||||
if (!INFERRED_ANNOTATIONS.contains(annotationFQN)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
listOwner = PsiUtil.preferCompiledElement(listOwner);
|
||||
|
||||
if (ORG_JETBRAINS_ANNOTATIONS_CONTRACT.equals(annotationFQN) && listOwner instanceof PsiMethod) {
|
||||
|
||||
+3
@@ -1015,6 +1015,9 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
public LongRangeSet getRange(DfaValue value) {
|
||||
if (value instanceof DfaVariableValue) {
|
||||
DfaVariableValue var = (DfaVariableValue)value;
|
||||
if (!TypeConversionUtil.isPrimitiveAndNotNull(var.getVariableType())) {
|
||||
return null;
|
||||
}
|
||||
DfaVariableState state = getVariableState(var);
|
||||
LongRangeSet range = state.getRange();
|
||||
if (range == null) {
|
||||
|
||||
@@ -439,7 +439,7 @@ class StateMerger {
|
||||
myVar = var;
|
||||
myPositive = positive;
|
||||
myArg = arg;
|
||||
myHash = Objects.hash(myType, myVar, myPositive, myArg);
|
||||
myHash = ((type.ordinal() * 31 + var.hashCode()) * 31 + arg.hashCode()) * 31 + (positive ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-5
@@ -73,7 +73,6 @@ public class DfaExpressionFactory {
|
||||
return getExpressionDfaValue(((PsiParenthesizedExpression)expression).getExpression());
|
||||
}
|
||||
|
||||
PsiType type = expression.getType();
|
||||
if (expression instanceof PsiArrayAccessExpression) {
|
||||
PsiExpression arrayExpression = ((PsiArrayAccessExpression)expression).getArrayExpression();
|
||||
DfaValue qualifier = getExpressionDfaValue(arrayExpression);
|
||||
@@ -83,6 +82,7 @@ public class DfaExpressionFactory {
|
||||
return myFactory.getVarFactory().createVariableValue(indexVar, expression.getType(), false, (DfaVariableValue)qualifier);
|
||||
}
|
||||
}
|
||||
PsiType type = expression.getType();
|
||||
if (type != null) {
|
||||
return myFactory.createTypeValue(type, DfaPsiUtil.getElementNullability(type, null));
|
||||
}
|
||||
@@ -105,11 +105,11 @@ public class DfaExpressionFactory {
|
||||
}
|
||||
|
||||
final Object value = JavaConstantExpressionEvaluator.computeConstantExpression(expression, false);
|
||||
if (value != null && type != null) {
|
||||
if (value instanceof String) {
|
||||
return myFactory.createTypeValue(type, Nullness.NOT_NULL); // Non-null string literal.
|
||||
if (value != null) {
|
||||
PsiType type = expression.getType();
|
||||
if (type != null) {
|
||||
return myFactory.getConstFactory().createFromValue(value, type, null);
|
||||
}
|
||||
return myFactory.getConstFactory().createFromValue(value, type, null);
|
||||
}
|
||||
|
||||
if (expression instanceof PsiThisExpression) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -182,12 +182,12 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
|
||||
|
||||
@NotNull
|
||||
private List<AnnotationData> doCollect(@NotNull PsiModifierListOwner listOwner, boolean onlyWritable) {
|
||||
String externalName = getExternalName(listOwner, false);
|
||||
if (externalName == null) return NO_DATA;
|
||||
|
||||
List<PsiFile> files = findExternalAnnotationsFiles(listOwner);
|
||||
if (files == null) return NO_DATA;
|
||||
|
||||
String externalName = getExternalName(listOwner, false);
|
||||
if (externalName == null) return NO_DATA;
|
||||
|
||||
SmartList<AnnotationData> result = new SmartList<>();
|
||||
for (PsiFile file : files) {
|
||||
if (!file.isValid()) continue;
|
||||
|
||||
Reference in New Issue
Block a user