void (final @NotNull PsiNewExpression expression) { PsiType expressionPsiType = expression.getType(); if (expressionPsiType instanceof PsiArrayType) { Evaluator dimensionEvaluator = null; PsiExpression[] dimensions = expression.getArrayDimensions(); if (dimensions.length == 1) { PsiExpression dimensionExpression = dimensions[0]; dimensionExpression.accept(this); if (myResult != null) { dimensionEvaluator = handleUnaryNumericPromotion(dimensionExpression.getType(), myResult); } else { throw evaluateException( JavaDebuggerBundle.message("evaluation.error.invalid.array.dimension.expression", dimensionExpression.getText())); } } else if (dimensions.length > 1) { throw evaluateException(JavaDebuggerBundle.message("evaluation.error.multi.dimensional.arrays.creation.not.supported")); } Evaluator initializerEvaluator = null; PsiArrayInitializerExpression arrayInitializer = expression.getArrayInitializer(); if (arrayInitializer != null) { if (dimensionEvaluator != null) { // initializer already exists throw expressionInvalid(expression); } arrayInitializer.accept(this); if (myResult != null) { initializerEvaluator = handleUnaryNumericPromotion(arrayInitializer.getType(), myResult); } else { throw expressionInvalid(arrayInitializer); } /* PsiExpression[] initializers = arrayInitializer.getInitializers(); initializerEvaluators = new Evaluator[initializers.length]; for (int idx = 0; idx < initializers.length; idx++) { PsiExpression initializer = initializers[idx]; initializer.accept(this); if (myResult instanceof Evaluator) { initializerEvaluators[idx] = myResult; } else { throw new EvaluateException("Invalid expression for array initializer: " + initializer.getText(), true); } } */ } if (dimensionEvaluator == null && initializerEvaluator == null) { throw expressionInvalid(expression); } myResult = new NewArrayInstanceEvaluator( new TypeEvaluator(JVMNameUtil.getJVMQualifiedName(expressionPsiType)), dimensionEvaluator, initializerEvaluator ); } else if (expressionPsiType instanceof PsiClassType) { // must be a class ref PsiClass aClass = CompilingEvaluatorTypesUtil.getClass((PsiClassType)expressionPsiType); if (aClass instanceof PsiAnonymousClass) { throw new EvaluateRuntimeException(new UnsupportedExpressionException( JavaDebuggerBundle.message("evaluation.error.anonymous.class.evaluation.not.supported"))); } PsiExpressionList argumentList = expression.getArgumentList(); if (argumentList == null) { throw expressionInvalid(expression); } final PsiExpression[] argExpressions = argumentList.getExpressions(); final JavaResolveResult constructorResolveResult = expression.resolveMethodGenerics(); PsiMethod constructor = CompilingEvaluatorTypesUtil.getReferencedConstructor((PsiMethod)constructorResolveResult.getElement()); if (constructor == null && argExpressions.length > 0) { throw new EvaluateRuntimeException(new EvaluateException( JavaDebuggerBundle.message("evaluation.error.cannot.resolve.constructor", expression.getText()), null)); } Evaluator[] argumentEvaluators = new Evaluator[argExpressions.length]; // evaluate arguments for (int idx = 0; idx < argExpressions.length; idx++) { PsiExpression argExpression = argExpressions[idx]; argExpression.accept(this); if (myResult != null) { argumentEvaluators[idx] = DisableGC.create(myResult); } else { throw expressionInvalid(argExpression); } } if (constructor != null) { processBoxingConversions(constructor.getParameterList().getParameters(), argExpressions, constructorResolveResult.getSubstitutor(), argumentEvaluators); } if (aClass != null) { PsiClass containingClass = aClass.getContainingClass(); if (containingClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) { PsiExpression qualifier = expression.getQualifier(); if (qualifier != null) { qualifier.accept(this); if (myResult != null) { argumentEvaluators = ArrayUtil.prepend(myResult, argumentEvaluators); } } else { argumentEvaluators = ArrayUtil.prepend( new ThisEvaluator(createTraverser(containingClass, "this", false)), argumentEvaluators); } } } JVMName signature = JVMNameUtil.getJVMConstructorSignature(constructor, aClass); PsiType instanceType = CompilingEvaluatorTypesUtil.getClassType((PsiClassType)expressionPsiType); myResult = new NewClassInstanceEvaluator( new TypeEvaluator(JVMNameUtil.getJVMQualifiedName(instanceType)), signature, argumentEvaluators ); } else { if (expressionPsiType != null) { throw evaluateException("Unsupported expression type: " + expressionPsiType.getPresentableText()); } else { throw evaluateException("Unknown type for expression: " + expression.getText()); } } }