void () { final List<AddParameter> newParams = new ArrayList<>(); for (AddParameter param : myAddParameterRequests) { if (param.type != null) { final Substring typeSub = myOriginalDocString.getParamTypeSubstring(param.name); if (typeSub != null) { replace(typeSub.getTextRange(), param.type); continue; } final Substring nameSub = findParamNameSubstring(param.name); if (nameSub != null) { updateParamDeclarationWithType(nameSub, param.type); continue; } } newParams.add(param); } if (!newParams.isEmpty()) { final SectionBasedDocStringBuilder paramBlockBuilder = createBuilder(); final Section firstParamSection = findFirstParametersSection(); // Insert whole new parameter block if (firstParamSection == null) { paramBlockBuilder.startParametersSection(); final SectionBasedDocStringBuilder builder = addParametersInBlock(paramBlockBuilder, newParams, getExpectedFieldIndent()); insertNewSection(builder, SectionBasedDocString.PARAMETERS_SECTION); } // Update existing parameter block else { final SectionField firstParamField = ContainerUtil.getFirstItem(firstParamSection.getFields()); // Section exist, but empty if (firstParamField == null) { final String blockText = buildBlock(paramBlockBuilder, newParams, getExpectedFieldIndent(), getSectionIndent(firstParamSection)); insertAfterLine(getSectionTitleLastLine(firstParamSection), blockText); } else { // Section contain other parameter declarations final String blockText = buildBlock(paramBlockBuilder, newParams, getFieldIndent(firstParamSection, firstParamField), getSectionIndent(firstParamSection)); insertBeforeLine(getFieldStartLine(firstParamField), blockText); } } } }