Set<PsiField> (@NotNull PsiSwitchBlock sw) { final PsiCodeBlock body = sw.getBody(); if (body == null) return Collections.emptySet(); Set<PsiField> used = new LinkedHashSet<>(); for (PsiStatement statement : body.getStatements()) { if (statement instanceof PsiSwitchLabelStatementBase) { final PsiCaseLabelElementList labelElementList = ((PsiSwitchLabelStatementBase)statement).getCaseLabelElementList(); if (labelElementList != null) { for (PsiCaseLabelElement labelElement : labelElementList.getElements()) { if (labelElement instanceof PsiReferenceExpression) { final PsiElement target = ((PsiReferenceExpression)labelElement).resolve(); if (target instanceof PsiField) { used.add(CompletionUtil.getOriginalOrSelf((PsiField)target)); } } } } } } return used; }