void (@NotNull PsiDeconstructionList deconstructionList) { super.visitDeconstructionList(deconstructionList); // We are checking the case when the pattern looks similar to method call in switch and want to show user-friendly message that here // only constant expressions are expected. // it is required to do it in deconstruction list because unresolved reference won't let any parents show any highlighting, // so we need element which is not parent PsiElement parent = deconstructionList.getParent(); PsiDeconstructionPattern pattern = tryCast(parent, PsiDeconstructionPattern.class); if (pattern == null) return; PsiElement grandParent = parent.getParent(); if (!(grandParent instanceof PsiCaseLabelElementList)) return; PsiTypeElement typeElement = pattern.getTypeElement(); PsiJavaCodeReferenceElement ref = PsiTreeUtil.getChildOfType(typeElement, PsiJavaCodeReferenceElement.class); if (ref == null) return; if (ref.multiResolve(true).length == 0) { PsiElementFactory elementFactory = PsiElementFactory.getInstance(myFile.getProject()); if (pattern.getPatternVariable() == null && pattern.getDeconstructionList().getDeconstructionComponents().length == 0) { PsiClassType type = tryCast(pattern.getTypeElement().getType(), PsiClassType.class); if (type != null && ContainerUtil.exists(type.getParameters(), PsiWildcardType.class::isInstance)) return; PsiExpression expression = elementFactory.createExpressionFromText(pattern.getText(), grandParent); PsiMethodCallExpression call = tryCast(expression, PsiMethodCallExpression.class); if (call == null) return; if (call.getMethodExpression().resolve() != null) { add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(pattern.getTextRange()) .descriptionAndTooltip(JavaErrorBundle.message("switch.constant.expression.required"))); } } } }