Java 类com.intellij.psi.PsiConstantEvaluationHelper 实例源码

项目:consulo-java    文件:JavaConstantExpressionEvaluator.java   
private JavaConstantExpressionEvaluator(Set<PsiVariable> visitedVars, final boolean throwExceptionOnOverflow, final Project project, final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  myMapFactory = auxEvaluator != null ? new Factory<ConcurrentMap<PsiElement, Object>>() {
    @Override
    public ConcurrentMap<PsiElement, Object> create() {
      return auxEvaluator.getCacheMap(throwExceptionOnOverflow);
    }
  } : 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);
    }
  };
  myProject = project;
  myConstantExpressionVisitor = new ConstantExpressionVisitor(visitedVars, throwExceptionOnOverflow, auxEvaluator);

}
项目:consulo-java    文件:JavaConstantExpressionEvaluator.java   
public static Object computeConstantExpression(PsiExpression expression, @Nullable Set<PsiVariable> visitedVars, boolean throwExceptionOnOverflow,
                                               final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  if (expression == null) return null;

  JavaConstantExpressionEvaluator evaluator = new JavaConstantExpressionEvaluator(visitedVars, throwExceptionOnOverflow, expression.getProject(), auxEvaluator);

  if (expression instanceof PsiCompiledElement) {
    // in case of compiled elements we are not allowed to use PSI walking
    // but really in Cls there are only so many cases to handle
    if (expression instanceof PsiPrefixExpression) {
      PsiElement operand = ((PsiPrefixExpression)expression).getOperand();
      if (operand == null) return null;
      Object value = evaluator.myConstantExpressionVisitor.handle(operand);
      ConstantExpressionVisitor.store(operand, value);
    }
    return evaluator.myConstantExpressionVisitor.handle(expression);
  }
  expression.accept(evaluator);
  Object cached = evaluator.getCached(expression);
  return cached == NO_VALUE ? null : cached;
}
项目:intellij-ce-playground    文件:GroovyConstantExpressionEvaluator.java   
@Override
@Nullable
public Object computeExpression(PsiElement expression,
                                boolean throwExceptionOnOverflow,
                                @Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  if (!(expression instanceof GrExpression)) return null;
  return evaluate((GrExpression)expression);
}
项目:tools-idea    文件:GroovyConstantExpressionEvaluator.java   
@Nullable
public Object computeExpression(PsiElement expression,
                                boolean throwExceptionOnOverflow,
                                @Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  if (!(expression instanceof GrExpression)) return null;
  return evaluate((GrExpression)expression);
}
项目:intellij-ce-playground    文件:PsiExpressionEvaluator.java   
@Override
public Object computeExpression(PsiElement expression, boolean throwExceptionOnOverflow, @Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  return expression instanceof PsiExpression ? JavaConstantExpressionEvaluator.computeConstantExpression((PsiExpression)expression, null, throwExceptionOnOverflow, auxEvaluator) : null;
}
项目:intellij-ce-playground    文件:ConstantExpressionEvaluator.java   
Object computeExpression(PsiElement expression,
boolean throwExceptionOnOverflow,
@Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator);
项目:tools-idea    文件:PsiExpressionEvaluator.java   
@Override
public Object computeExpression(PsiElement expression, boolean throwExceptionOnOverflow, @Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  return expression instanceof PsiExpression ? JavaConstantExpressionEvaluator.computeConstantExpression((PsiExpression)expression, null, throwExceptionOnOverflow, auxEvaluator) : null;
}
项目:tools-idea    文件:ConstantExpressionEvaluator.java   
Object computeExpression(PsiElement expression,
boolean throwExceptionOnOverflow,
@Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator);
项目:consulo-java    文件:PsiExpressionEvaluator.java   
@Override
public Object computeExpression(PsiElement expression, boolean throwExceptionOnOverflow, @Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  return expression instanceof PsiExpression ? JavaConstantExpressionEvaluator.computeConstantExpression((PsiExpression)expression, null, throwExceptionOnOverflow, auxEvaluator) : null;
}
项目:consulo-java    文件:ConstantExpressionEvaluator.java   
Object computeExpression(PsiElement expression,
boolean throwExceptionOnOverflow,
@Nullable PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator);