boolean (@NotNull String constraintName, @Nullable PsiElement variableNode, boolean completePattern, boolean target) { switch (constraintName) { case UIUtil.TEXT: return !completePattern; case UIUtil.TEXT_HIERARCHY: if (variableNode != null) { final PsiElement parent = variableNode.getParent(); if (parent instanceof PsiJavaCodeReferenceElement) { final PsiElement grandParent = parent.getParent(); if (grandParent instanceof PsiTypeElement || grandParent instanceof PsiReferenceList || grandParent instanceof PsiReferenceExpression || grandParent instanceof PsiNewExpression || grandParent instanceof PsiAnonymousClass) return true; } else if (parent instanceof PsiClass) return true; else if (isMemberSurroundedByClass(parent)) return true; } return false; case UIUtil.EXPECTED_TYPE: if (variableNode != null) { final PsiElement grandParent = variableNode.getParent().getParent(); if (grandParent instanceof PsiExpressionStatement) { if (isCompleteStatement((PsiExpressionStatement)grandParent)) return false; } else if (grandParent instanceof PsiStatement) return false; } case UIUtil.TYPE: case UIUtil.TYPE_REGEX: if (variableNode instanceof PsiExpressionStatement) { final PsiElement child = variableNode.getLastChild(); if (child instanceof PsiErrorElement errorElement) { return JavaPsiBundle.message("expected.semicolon").equals(errorElement.getErrorDescription()); } } return variableNode != null && variableNode.getParent() instanceof PsiExpression; case UIUtil.MINIMUM_ZERO: if (target || variableNode == null) return false; return isApplicableMinCount(variableNode) || isApplicableMinMaxCount(variableNode); case UIUtil.MAXIMUM_UNLIMITED: if (target || variableNode == null) return false; return isApplicableMaxCount(variableNode) || isApplicableMinMaxCount(variableNode); case UIUtil.REFERENCE: if (completePattern || variableNode == null) return false; if (variableNode instanceof PsiLiteralExpression && ((PsiLiteralExpression)variableNode).getValue() instanceof String) return true; final PsiElement parent = variableNode.getParent(); return parent instanceof PsiJavaCodeReferenceElement; default: return super.isApplicableConstraint(constraintName, variableNode, completePattern, target); } }