Program: 130467
Project: 130467
Buggy source:
@Nullable private static LookupElementBuilder buildLookupItem(CSharpTypeDeclaration typeDeclaration,PsiElement element,boolean hide){
  Icon rightIcon=null;
  LookupElementBuilder lookupElementBuilder=null;
  if (element instanceof CSharpMethodDeclaration) {
    CSharpMethodDeclaration methodDeclaration=(CSharpMethodDeclaration)element;
    StringBuilder builder=new StringBuilder();
    CSharpAccessModifier modifier=hide || typeDeclaration.isInterface() ? CSharpAccessModifier.NONE : CSharpAccessModifier.findModifier(methodDeclaration);
    if (modifier != CSharpAccessModifier.NONE) {
      builder.append(modifier.getPresentableText()).append("String_Node_Str");
    }
    if (OverrideUtil.isRequireOverrideModifier(methodDeclaration)) {
      builder.append("String_Node_Str");
    }
    formatMethod(methodDeclaration,builder,hide);
    String presentationText=builder.toString();
    if (typeDeclaration.isInterface()) {
      builder.append("String_Node_Str");
      if (methodDeclaration.hasModifier(DotNetModifier.ABSTRACT)) {
        rightIcon=AllIcons.Gutter.OverridingMethod;
      }
 else {
        return null;
      }
    }
 else {
      builder.append("String_Node_Str");
      if (methodDeclaration.hasModifier(DotNetModifier.ABSTRACT)) {
        rightIcon=AllIcons.Gutter.ImplementingMethod;
        GenerateImplementMemberHandler.generateReturn(builder,element);
      }
 else {
        rightIcon=AllIcons.Gutter.OverridingMethod;
        GenerateOverrideMemberHandler.generateReturn(builder,element);
      }
      if (hide) {
        rightIcon=CSharpIcons.Gutter.HidingMethod;
      }
      builder.append("String_Node_Str");
    }
    lookupElementBuilder=LookupElementBuilder.create(builder.toString());
    lookupElementBuilder=lookupElementBuilder.withPresentableText(presentationText);
    lookupElementBuilder=lookupElementBuilder.withLookupString(methodDeclaration.getName());
    lookupElementBuilder=lookupElementBuilder.withTailText("String_Node_Str",true);
  }
  if (lookupElementBuilder == null) {
    return null;
  }
  IconDescriptor iconDescriptor=new IconDescriptor(IconDescriptorUpdaters.getIcon(element,0));
  iconDescriptor.setRightIcon(rightIcon);
  lookupElementBuilder=lookupElementBuilder.withIcon(iconDescriptor.toIcon());
  PsiElement parent=element.getParent();
  if (parent instanceof DotNetTypeDeclaration) {
    lookupElementBuilder=lookupElementBuilder.withTypeText(DotNetElementPresentationUtil.formatTypeWithGenericParameters((DotNetTypeDeclaration)parent));
  }
  lookupElementBuilder=lookupElementBuilder.withInsertHandler(new InsertHandler<LookupElement>(){
    @Override public void handleInsert(    InsertionContext context,    LookupElement item){
      CaretModel caretModel=context.getEditor().getCaretModel();
      PsiElement elementAt=context.getFile().findElementAt(caretModel.getOffset() - 1);
      if (elementAt == null) {
        return;
      }
      DotNetVirtualImplementOwner virtualImplementOwner=PsiTreeUtil.getParentOfType(elementAt,DotNetVirtualImplementOwner.class);
      if (virtualImplementOwner == null) {
        return;
      }
      if (virtualImplementOwner instanceof CSharpMethodDeclaration) {
        PsiElement codeBlock=((CSharpMethodDeclaration)virtualImplementOwner).getCodeBlock();
        if (codeBlock instanceof CSharpBlockStatementImpl) {
          DotNetStatement[] statements=((CSharpBlockStatementImpl)codeBlock).getStatements();
          if (statements.length > 0) {
            caretModel.moveToOffset(statements[0].getTextOffset() + statements[0].getTextLength());
          }
 else {
            caretModel.moveToOffset(((CSharpBlockStatementImpl)codeBlock).getLeftBrace().getTextOffset() + 1);
          }
        }
      }
      context.commitDocument();
      CodeStyleManager.getInstance(context.getProject()).reformat(virtualImplementOwner);
    }
  }
);
  return lookupElementBuilder;
}

Fixed version (ground truth):
@Nullable @RequiredReadAction private static LookupElementBuilder buildLookupItem(CSharpTypeDeclaration typeDeclaration,PsiElement element,boolean hide){
  Icon rightIcon=null;
  LookupElementBuilder lookupElementBuilder=null;
  if (element instanceof CSharpMethodDeclaration) {
    CSharpMethodDeclaration methodDeclaration=(CSharpMethodDeclaration)element;
    StringBuilder builder=new StringBuilder();
    CSharpAccessModifier modifier=hide || typeDeclaration.isInterface() ? CSharpAccessModifier.NONE : CSharpAccessModifier.findModifier(methodDeclaration);
    if (modifier != CSharpAccessModifier.NONE) {
      builder.append(modifier.getPresentableText()).append("String_Node_Str");
    }
    CSharpModifier requiredOverrideModifier=OverrideUtil.getRequiredOverrideModifier(methodDeclaration);
    if (requiredOverrideModifier != null) {
      builder.append(requiredOverrideModifier.getPresentableText()).append("String_Node_Str");
    }
    formatMethod(methodDeclaration,builder,hide);
    String presentationText=builder.toString();
    if (typeDeclaration.isInterface()) {
      builder.append("String_Node_Str");
      if (methodDeclaration.hasModifier(DotNetModifier.ABSTRACT)) {
        rightIcon=AllIcons.Gutter.OverridingMethod;
      }
 else {
        return null;
      }
    }
 else {
      builder.append("String_Node_Str");
      if (methodDeclaration.hasModifier(DotNetModifier.ABSTRACT)) {
        rightIcon=AllIcons.Gutter.ImplementingMethod;
        GenerateImplementMemberHandler.generateReturn(builder,element);
      }
 else {
        rightIcon=AllIcons.Gutter.OverridingMethod;
        GenerateOverrideMemberHandler.generateReturn(builder,element);
      }
      if (hide) {
        rightIcon=CSharpIcons.Gutter.HidingMethod;
      }
      builder.append("String_Node_Str");
    }
    lookupElementBuilder=LookupElementBuilder.create(builder.toString());
    lookupElementBuilder=lookupElementBuilder.withPresentableText(presentationText);
    lookupElementBuilder=lookupElementBuilder.withLookupString(methodDeclaration.getName());
    lookupElementBuilder=lookupElementBuilder.withTailText("String_Node_Str",true);
  }
  if (lookupElementBuilder == null) {
    return null;
  }
  IconDescriptor iconDescriptor=new IconDescriptor(IconDescriptorUpdaters.getIcon(element,0));
  iconDescriptor.setRightIcon(rightIcon);
  lookupElementBuilder=lookupElementBuilder.withIcon(iconDescriptor.toIcon());
  PsiElement parent=element.getParent();
  if (parent instanceof DotNetTypeDeclaration) {
    lookupElementBuilder=lookupElementBuilder.withTypeText(DotNetElementPresentationUtil.formatTypeWithGenericParameters((DotNetTypeDeclaration)parent));
  }
  lookupElementBuilder=lookupElementBuilder.withInsertHandler(new InsertHandler<LookupElement>(){
    @Override public void handleInsert(    InsertionContext context,    LookupElement item){
      CaretModel caretModel=context.getEditor().getCaretModel();
      PsiElement elementAt=context.getFile().findElementAt(caretModel.getOffset() - 1);
      if (elementAt == null) {
        return;
      }
      DotNetVirtualImplementOwner virtualImplementOwner=PsiTreeUtil.getParentOfType(elementAt,DotNetVirtualImplementOwner.class);
      if (virtualImplementOwner == null) {
        return;
      }
      if (virtualImplementOwner instanceof CSharpMethodDeclaration) {
        PsiElement codeBlock=((CSharpMethodDeclaration)virtualImplementOwner).getCodeBlock();
        if (codeBlock instanceof CSharpBlockStatementImpl) {
          DotNetStatement[] statements=((CSharpBlockStatementImpl)codeBlock).getStatements();
          if (statements.length > 0) {
            caretModel.moveToOffset(statements[0].getTextOffset() + statements[0].getTextLength());
          }
 else {
            caretModel.moveToOffset(((CSharpBlockStatementImpl)codeBlock).getLeftBrace().getTextOffset() + 1);
          }
        }
      }
      context.commitDocument();
      CodeStyleManager.getInstance(context.getProject()).reformat(virtualImplementOwner);
    }
  }
);
  return lookupElementBuilder;
}