Program: 130386
Project: 130386
Buggy source:
@RequiredReadAction public static LookupElementBuilder createLookupElementBuilder(@NotNull final PsiElement element,@NotNull DotNetGenericExtractor extractor,@Nullable final PsiElement completionParent){
  LookupElementBuilder builder=null;
  if (element instanceof CSharpMethodDeclaration) {
    final CSharpMethodDeclaration methodDeclaration=(CSharpMethodDeclaration)element;
    if (!methodDeclaration.isDelegate()) {
      String name=methodDeclaration.getName();
      if (name == null) {
        return null;
      }
      CSharpMethodUtil.Result inheritGeneric=CSharpMethodUtil.isCanInheritGeneric(methodDeclaration);
      String lookupString=inheritGeneric == CSharpMethodUtil.Result.CAN ? name + "String_Node_Str" : name;
      builder=LookupElementBuilder.create(methodDeclaration,lookupString);
      builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
      final CSharpSimpleParameterInfo[] parameterInfos=methodDeclaration.getParameterInfos();
      String genericText=DotNetElementPresentationUtil.formatGenericParameters((DotNetGenericParameterListOwner)element);
      String parameterText=genericText + "String_Node_Str" + StringUtil.join(parameterInfos,parameter -> CSharpTypeRefPresentationUtil.buildShortText(parameter.getTypeRef(),element) + "String_Node_Str" + parameter.getNotNullName(),"String_Node_Str")+ "String_Node_Str";
      if (inheritGeneric == CSharpMethodUtil.Result.CAN) {
        builder=builder.withPresentableText(name);
        builder=builder.withInsertHandler((context,item) -> {
          CaretModel caretModel=context.getEditor().getCaretModel();
          caretModel.moveToOffset(caretModel.getOffset() - 3);
        }
);
      }
 else {
        builder=builder.withInsertHandler(new CSharpParenthesesWithSemicolonInsertHandler(methodDeclaration));
      }
      if (CSharpMethodImplUtil.isExtensionWrapper(methodDeclaration)) {
        builder=builder.withItemTextUnderlined(true);
      }
      builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(methodDeclaration.getReturnTypeRef(),element));
      builder=builder.withTailText(parameterText,false);
    }
 else {
      builder=buildTypeLikeElement((CSharpMethodDeclaration)element,extractor);
    }
  }
 else   if (element instanceof CSharpIndexMethodDeclaration) {
    builder=LookupElementBuilder.create(element,"String_Node_Str");
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    final CSharpSimpleParameterInfo[] parameterInfos=((CSharpIndexMethodDeclaration)element).getParameterInfos();
    String parameterText="String_Node_Str" + StringUtil.join(parameterInfos,new Function<CSharpSimpleParameterInfo,String>(){
      @Override @RequiredReadAction public String fun(      CSharpSimpleParameterInfo parameter){
        return CSharpTypeRefPresentationUtil.buildShortText(parameter.getTypeRef(),element) + "String_Node_Str" + parameter.getNotNullName();
      }
    }
,"String_Node_Str") + "String_Node_Str";
    builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(((CSharpIndexMethodDeclaration)element).getReturnTypeRef(),element));
    builder=builder.withPresentableText(parameterText);
    builder=builder.withInsertHandler((context,item) -> {
      CharSequence charSequence=context.getDocument().getImmutableCharSequence();
      int start=-1, end=-1;
      for (int i=context.getTailOffset(); i != 0; i--) {
        char c=charSequence.charAt(i);
        if (c == '.') {
          start=i;
          break;
        }
 else         if (c == '[') {
          end=i;
        }
      }
      if (start != -1 && end != -1) {
        context.getDocument().replaceString(start,end + 1,"String_Node_Str");
      }
      context.getEditor().getCaretModel().moveToOffset(end);
    }
);
  }
 else   if (element instanceof DotNetNamespaceAsElement) {
    DotNetNamespaceAsElement namespaceAsElement=(DotNetNamespaceAsElement)element;
    String name=namespaceAsElement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    CSharpCompletionSorting.force(builder,CSharpCompletionSorting.KindSorter.Type.namespace);
  }
 else   if (element instanceof CSharpTypeDefStatement) {
    CSharpTypeDefStatement typeDefStatement=(CSharpTypeDefStatement)element;
    String name=typeDefStatement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(typeDefStatement.toTypeRef(),typeDefStatement));
  }
 else   if (element instanceof CSharpLabeledStatementImpl) {
    CSharpLabeledStatementImpl labeledStatement=(CSharpLabeledStatementImpl)element;
    String name=labeledStatement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
  }
 else   if (element instanceof DotNetGenericParameter) {
    DotNetGenericParameter typeDefStatement=(DotNetGenericParameter)element;
    String name=typeDefStatement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
  }
 else   if (element instanceof DotNetVariable) {
    DotNetVariable variable=(DotNetVariable)element;
    if ((variable instanceof CSharpFieldDeclaration || variable instanceof CSharpPropertyDeclaration) && needAddThisPrefix(variable,completionParent)) {
      builder=LookupElementBuilder.create(variable,"String_Node_Str" + variable.getName());
      builder=builder.withLookupString(variable.getName());
    }
 else {
      builder=LookupElementBuilder.create(variable);
    }
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(variable.toTypeRef(true),variable));
    builder=builder.withInsertHandler(new InsertHandler<LookupElement>(){
      @Override @RequiredDispatchThread public void handleInsert(      InsertionContext context,      LookupElement item){
        char completionChar=context.getCompletionChar();
switch (completionChar) {
case '=':
          context.setAddCompletionChar(false);
        TailType.EQ.processTail(context.getEditor(),context.getTailOffset());
      break;
case ',':
    if (completionParent != null && completionParent.getParent() instanceof CSharpCallArgument) {
      context.setAddCompletionChar(false);
      TailType.COMMA.processTail(context.getEditor(),context.getTailOffset());
    }
  break;
}
}
}
);
}
 else if (element instanceof CSharpPreprocessorDefine) {
builder=LookupElementBuilder.create(element);
builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
}
 else if (element instanceof CSharpTypeDeclaration) {
builder=buildTypeLikeElement((CSharpTypeDeclaration)element,extractor);
}
if (builder != null && DotNetAttributeUtil.hasAttribute(element,DotNetTypes.System.ObsoleteAttribute)) {
builder=builder.withStrikeoutness(true);
}
return builder;
}

Fixed version (ground truth):
@RequiredReadAction public static LookupElementBuilder createLookupElementBuilder(@NotNull final PsiElement element,@NotNull DotNetGenericExtractor extractor,@Nullable final PsiElement completionParent){
  LookupElementBuilder builder=null;
  if (element instanceof CSharpMethodDeclaration) {
    final CSharpMethodDeclaration methodDeclaration=(CSharpMethodDeclaration)element;
    if (!methodDeclaration.isDelegate()) {
      String name=methodDeclaration.getName();
      if (name == null) {
        return null;
      }
      CSharpMethodUtil.Result inheritGeneric=CSharpMethodUtil.isCanInheritGeneric(methodDeclaration);
      String lookupString=inheritGeneric == CSharpMethodUtil.Result.CAN ? name + "String_Node_Str" : name;
      builder=LookupElementBuilder.create(methodDeclaration,lookupString);
      builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
      final CSharpSimpleParameterInfo[] parameterInfos=methodDeclaration.getParameterInfos();
      String genericText=DotNetElementPresentationUtil.formatGenericParameters((DotNetGenericParameterListOwner)element);
      String parameterText=genericText + "String_Node_Str" + StringUtil.join(parameterInfos,parameter -> CSharpTypeRefPresentationUtil.buildShortText(parameter.getTypeRef(),element) + "String_Node_Str" + parameter.getNotNullName(),"String_Node_Str")+ "String_Node_Str";
      if (inheritGeneric == CSharpMethodUtil.Result.CAN) {
        builder=builder.withPresentableText(name);
        builder=builder.withInsertHandler((context,item) -> {
          CaretModel caretModel=context.getEditor().getCaretModel();
          caretModel.moveToOffset(caretModel.getOffset() - 3);
        }
);
      }
 else {
        builder=builder.withInsertHandler(new CSharpParenthesesWithSemicolonInsertHandler(methodDeclaration));
      }
      if (CSharpMethodImplUtil.isExtensionWrapper(methodDeclaration)) {
        builder=builder.withItemTextUnderlined(true);
      }
      builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(methodDeclaration.getReturnTypeRef(),element));
      builder=builder.withTailText(parameterText,false);
    }
 else {
      builder=buildTypeLikeElement((CSharpMethodDeclaration)element,extractor);
    }
  }
 else   if (element instanceof CSharpIndexMethodDeclaration) {
    builder=LookupElementBuilder.create(element,"String_Node_Str");
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    final CSharpSimpleParameterInfo[] parameterInfos=((CSharpIndexMethodDeclaration)element).getParameterInfos();
    String parameterText="String_Node_Str" + StringUtil.join(parameterInfos,new Function<CSharpSimpleParameterInfo,String>(){
      @Override @RequiredReadAction public String fun(      CSharpSimpleParameterInfo parameter){
        return CSharpTypeRefPresentationUtil.buildShortText(parameter.getTypeRef(),element) + "String_Node_Str" + parameter.getNotNullName();
      }
    }
,"String_Node_Str") + "String_Node_Str";
    builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(((CSharpIndexMethodDeclaration)element).getReturnTypeRef(),element));
    builder=builder.withPresentableText(parameterText);
    builder=builder.withInsertHandler((context,item) -> {
      CharSequence charSequence=context.getDocument().getImmutableCharSequence();
      int start=-1, end=-1;
      for (int i=context.getStartOffset(); i != 0; i--) {
        char c=charSequence.charAt(i);
        if (c == '.') {
          start=i;
          break;
        }
 else         if (c == '[') {
          end=i;
        }
      }
      if (start != -1 && end != -1) {
        context.getDocument().replaceString(start,end + 1,"String_Node_Str");
        context.getEditor().getCaretModel().moveToOffset(end);
      }
    }
);
  }
 else   if (element instanceof DotNetNamespaceAsElement) {
    DotNetNamespaceAsElement namespaceAsElement=(DotNetNamespaceAsElement)element;
    String name=namespaceAsElement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    CSharpCompletionSorting.force(builder,CSharpCompletionSorting.KindSorter.Type.namespace);
  }
 else   if (element instanceof CSharpTypeDefStatement) {
    CSharpTypeDefStatement typeDefStatement=(CSharpTypeDefStatement)element;
    String name=typeDefStatement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(typeDefStatement.toTypeRef(),typeDefStatement));
  }
 else   if (element instanceof CSharpLabeledStatementImpl) {
    CSharpLabeledStatementImpl labeledStatement=(CSharpLabeledStatementImpl)element;
    String name=labeledStatement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
  }
 else   if (element instanceof DotNetGenericParameter) {
    DotNetGenericParameter typeDefStatement=(DotNetGenericParameter)element;
    String name=typeDefStatement.getName();
    if (name == null) {
      return null;
    }
    builder=LookupElementBuilder.create(name);
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
  }
 else   if (element instanceof DotNetVariable) {
    DotNetVariable variable=(DotNetVariable)element;
    if ((variable instanceof CSharpFieldDeclaration || variable instanceof CSharpPropertyDeclaration) && needAddThisPrefix(variable,completionParent)) {
      builder=LookupElementBuilder.create(variable,"String_Node_Str" + variable.getName());
      builder=builder.withLookupString(variable.getName());
    }
 else {
      builder=LookupElementBuilder.create(variable);
    }
    builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
    builder=builder.withTypeText(CSharpTypeRefPresentationUtil.buildShortText(variable.toTypeRef(true),variable));
    builder=builder.withInsertHandler(new InsertHandler<LookupElement>(){
      @Override @RequiredDispatchThread public void handleInsert(      InsertionContext context,      LookupElement item){
        char completionChar=context.getCompletionChar();
switch (completionChar) {
case '=':
          context.setAddCompletionChar(false);
        TailType.EQ.processTail(context.getEditor(),context.getTailOffset());
      break;
case ',':
    if (completionParent != null && completionParent.getParent() instanceof CSharpCallArgument) {
      context.setAddCompletionChar(false);
      TailType.COMMA.processTail(context.getEditor(),context.getTailOffset());
    }
  break;
}
}
}
);
}
 else if (element instanceof CSharpPreprocessorDefine) {
builder=LookupElementBuilder.create(element);
builder=builder.withIcon(IconDescriptorUpdaters.getIcon(element,Iconable.ICON_FLAG_VISIBILITY));
}
 else if (element instanceof CSharpTypeDeclaration) {
builder=buildTypeLikeElement((CSharpTypeDeclaration)element,extractor);
}
if (builder != null && DotNetAttributeUtil.hasAttribute(element,DotNetTypes.System.ObsoleteAttribute)) {
builder=builder.withStrikeoutness(true);
}
return builder;
}