ChainCompletionContext (CompletionParameters parameters) { PsiElement parent = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiAssignmentExpression.class, PsiLocalVariable.class, PsiMethodCallExpression.class, PsiReturnStatement.class); LOG.assertTrue(parent != null, "A completion position should match to a pattern"); if (parent instanceof PsiReturnStatement) { return extractContextFromReturn((PsiReturnStatement)parent, parameters); } if (parent instanceof PsiAssignmentExpression) { return extractContextFromAssignment((PsiAssignmentExpression)parent, parameters); } if (parent instanceof PsiLocalVariable) { return extractContextFromVariable((PsiLocalVariable)parent, parameters); } return extractContextFromMethodCall((PsiMethodCallExpression)parent, parameters); }