TypeConstraint[] (@NotNull GrExpression expression) { MyCalculator calculator = new MyCalculator(expression); final PsiElement parent = expression.getParent(); if (parent instanceof GroovyPsiElement) { ((GroovyPsiElement)parent).accept(calculator); } else { parent.accept(new GroovyPsiElementVisitor(calculator)); } final TypeConstraint[] result = calculator.getResult(); List<TypeConstraint> custom = new ArrayList<>(); for (GroovyExpectedTypesContributor contributor : EP_NAME.getExtensionList()) { custom.addAll(contributor.calculateTypeConstraints(expression)); } if (!custom.isEmpty()) { custom.addAll(0, Arrays.asList(result)); return custom.toArray(TypeConstraint.EMPTY_ARRAY); } return result; }