PsiFunctionalExpression (PsiFile file, int index) { StubbedSpine spine = ((PsiFileWithStubSupport)file).getStubbedSpine(); int funExprIndex = 0; for (int i = 0; i < spine.getStubCount(); i++) { IElementType type = spine.getStubType(i); if (type == JavaStubElementTypes.LAMBDA_EXPRESSION || type == JavaStubElementTypes.METHOD_REF_EXPRESSION) { if (funExprIndex == index) { return (PsiFunctionalExpression)spine.getStubPsi(i); } funExprIndex++; } } return null; }