Collection<PsiExpression> (@Nullable PsiVariable variable, @Nullable PsiElement context) { if (variable == null || context == null) return Collections.emptyList(); final PsiCodeBlock codeBlock = tryCast(getEnclosingCodeBlock(variable, context), PsiCodeBlock.class); if (codeBlock == null) return Collections.emptyList(); PsiElement[] defs = DefUseUtil.getDefs(codeBlock, variable, context); List<PsiExpression> results = new ArrayList<>(); for (PsiElement def : defs) { if (def instanceof PsiLocalVariable) { ContainerUtil.addIfNotNull(results, ((PsiLocalVariable)def).getInitializer()); } else if (def instanceof PsiReferenceExpression) { PsiAssignmentExpression assignment = tryCast(def.getParent(), PsiAssignmentExpression.class); if(assignment != null && assignment.getLExpression() == def) { ContainerUtil.addIfNotNull(results, unrollConcatenation(assignment, variable, codeBlock)); } } else if (def instanceof PsiExpression) { results.add((PsiExpression)def); } } return results; }