int (@NotNull Document document, @NotNull PsiElement elementAtStartLineEnd, @NotNull PsiVariable firstVar, @NotNull PsiVariable secondVar) { PsiTypeElement firstTypeElement = firstVar.getTypeElement(); if (firstTypeElement == null || firstTypeElement.isInferredType()) return -1; PsiTypeElement secondTypeElement = secondVar.getTypeElement(); if (secondTypeElement == null || secondTypeElement.isInferredType()) return -1; if (!PsiEquivalenceUtil.areElementsEquivalent(firstTypeElement, secondTypeElement)) return -1; PsiModifierList firstModifiers = firstVar.getModifierList(); PsiModifierList secondModifiers = secondVar.getModifierList(); if (firstModifiers == null) { if (secondModifiers != null) return -1; } else { if (secondModifiers == null || !PsiEquivalenceUtil.areElementsEquivalent(firstModifiers, secondModifiers)) return -1; } int startOffset = elementAtStartLineEnd.getTextRange().getStartOffset(); int endOffset = secondTypeElement.getTextRange().getEndOffset(); document.replaceString(startOffset, endOffset, ","); return startOffset; }