summaryrefslogtreecommitdiff
path: root/java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java')
-rw-r--r--java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java
index 19da149c99b8..3c84456a0a28 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaConstantExpressionEvaluator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 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.
@@ -41,27 +41,29 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking
private static final Object NO_VALUE = ObjectUtils.NULL;
private final ConstantExpressionVisitor myConstantExpressionVisitor;
- private JavaConstantExpressionEvaluator(Set<PsiVariable> visitedVars, final boolean throwExceptionOnOverflow, final Project project, final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
- myMapFactory = auxEvaluator != null ? new Factory<ConcurrentMap<PsiElement, Object>>() {
+ private JavaConstantExpressionEvaluator(Set<PsiVariable> visitedVars,
+ final boolean throwExceptionOnOverflow,
+ @NotNull Project project,
+ final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
+ myMapFactory = auxEvaluator == null ? new Factory<ConcurrentMap<PsiElement, Object>>() {
@Override
public ConcurrentMap<PsiElement, Object> create() {
- return auxEvaluator.getCacheMap(throwExceptionOnOverflow);
+ final Key<CachedValue<ConcurrentMap<PsiElement, Object>>> key =
+ throwExceptionOnOverflow ? CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY : CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY;
+ return CachedValuesManager.getManager(myProject).getCachedValue(myProject, key, PROVIDER, false);
}
} : new Factory<ConcurrentMap<PsiElement, Object>>() {
@Override
public ConcurrentMap<PsiElement, Object> create() {
- final Key<CachedValue<ConcurrentMap<PsiElement, Object>>> key =
- throwExceptionOnOverflow ? CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY : CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY;
- return CachedValuesManager.getManager(myProject).getCachedValue(myProject, key, PROVIDER, false);
+ return auxEvaluator.getCacheMap(throwExceptionOnOverflow);
}
};
myProject = project;
myConstantExpressionVisitor = new ConstantExpressionVisitor(visitedVars, throwExceptionOnOverflow, auxEvaluator);
-
}
@Override
- protected void elementFinished(PsiElement element) {
+ protected void elementFinished(@NotNull PsiElement element) {
Object value = getCached(element);
if (value == null) {
Object result = myConstantExpressionVisitor.handle(element);
@@ -109,7 +111,9 @@ public class JavaConstantExpressionEvaluator extends JavaRecursiveElementWalking
return computeConstantExpression(expression, visitedVars, throwExceptionOnOverflow, null);
}
- public static Object computeConstantExpression(@Nullable PsiExpression expression, @Nullable Set<PsiVariable> visitedVars, boolean throwExceptionOnOverflow,
+ public static Object computeConstantExpression(@Nullable PsiExpression expression,
+ @Nullable Set<PsiVariable> visitedVars,
+ boolean throwExceptionOnOverflow,
final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
if (expression == null) return null;