void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { final PsiFile file = parameters.getOriginalFile(); final PsiElement stringNode = parameters.getOriginalPosition(); assert stringNode != null; final int offset = parameters.getOffset(); final DocStringFormat format = DocStringUtil.getConfiguredDocStringFormat(file); if (!(format == DocStringFormat.GOOGLE || format == DocStringFormat.NUMPY)) { return; } // Numpy docstring format is ambiguous. Because parameters have the same indentation as section headers, // beginning of section header can be parsed as parameter reference if (format == DocStringFormat.GOOGLE && file.findReferenceAt(offset) != null) { return; } final Document document = parameters.getEditor().getDocument(); final TextRange linePrefixRange = new TextRange(document.getLineStartOffset(document.getLineNumber(offset)), offset); final String prefix = StringUtil.trimLeading(document.getText(linePrefixRange)); result = result.withPrefixMatcher(prefix).caseInsensitive(); final Iterable<String> names = format == DocStringFormat.GOOGLE ? GoogleCodeStyleDocString.PREFERRED_SECTION_HEADERS : NumpyDocString.PREFERRED_SECTION_HEADERS; for (String tag : names) { result.addElement(LookupElementBuilder.create(tag)); } }