File indexing completed on 2024-05-05 04:38:45
0001 /* 0002 SPDX-FileCopyrightText: 2011 David Nolden <david.nolden.kdevelop@art-master.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KDEVPLATFORM_FORMATTINGHELPERS_H 0008 #define KDEVPLATFORM_FORMATTINGHELPERS_H 0009 0010 #include "utilexport.h" 0011 0012 class QString; 0013 class QStringView; 0014 0015 namespace KDevelop { 0016 /** 0017 * Helps extracting a re-formatted version of a text fragment, within a specific left and right context. 0018 * The re-formatting must be an operation which only changes whitespace or supported fuzzy characters 0019 * from the set "{}()\"/\\*", and keeps brackets of all types matched. That is, inserts or removes an equal 0020 * number of matching characters '{' and '}', '(' and ')', '"' and '"', as well as opening and closing 0021 * C-style comment sequences. If this is not the case, the original text is returned. 0022 * 0023 * @param formattedMergedText The re-formatted merged text: format(leftContext + text + rightContext) 0024 * @param text The text fragment of which the re-formatted version will be returned 0025 * @param leftContext The left context of the text fragment 0026 * @param rightContext The right context of the text fragment 0027 * @param tabWidth The width of one tab, required while matching tabs vs. spaces 0028 * 0029 * @return The re-formatted version of @p text 0030 * */ 0031 KDEVPLATFORMUTIL_EXPORT QString extractFormattedTextFromContext(const QString& formattedMergedText, const QString& text, 0032 QStringView leftContext, QStringView rightContext, 0033 int tabWidth = 4); 0034 } 0035 0036 #endif // KDEVPLATFORM_FORMATTINGHELPERS_H