forked from qt-creator/qt-creator
ClangFormat: Pimpl ClangFormatBaseIndenter
This avoids the large-scale exposure of #include <clang/Format/Format.h> which otherwise confuses moc. Change-Id: I1d48174bd5f940e03986b58a7efa5e537cc99781 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -5,16 +5,15 @@
|
||||
|
||||
#include <texteditor/indenter.h>
|
||||
|
||||
#include <clang/Format/Format.h>
|
||||
namespace clang::format { struct FormatStyle; }
|
||||
|
||||
namespace ClangFormat {
|
||||
|
||||
enum class ReplacementsToKeep { OnlyIndent, IndentAndBefore, All };
|
||||
|
||||
class ClangFormatBaseIndenter : public TextEditor::Indenter
|
||||
{
|
||||
public:
|
||||
ClangFormatBaseIndenter(QTextDocument *doc);
|
||||
~ClangFormatBaseIndenter();
|
||||
|
||||
TextEditor::IndentationForBlock indentationForBlocks(const QVector<QTextBlock> &blocks,
|
||||
const TextEditor::TabSettings &tabSettings,
|
||||
@@ -57,38 +56,8 @@ protected:
|
||||
virtual int lastSaveRevision() const { return 0; }
|
||||
|
||||
private:
|
||||
void indent(const QTextCursor &cursor, const QChar &typedChar, int cursorPositionInEditor);
|
||||
void indentBlocks(const QTextBlock &startBlock,
|
||||
const QTextBlock &endBlock,
|
||||
const QChar &typedChar,
|
||||
int cursorPositionInEditor);
|
||||
Utils::ChangeSet indentsFor(QTextBlock startBlock,
|
||||
const QTextBlock &endBlock,
|
||||
const QChar &typedChar,
|
||||
int cursorPositionInEditor,
|
||||
bool trimTrailingWhitespace = true);
|
||||
Utils::ChangeSet replacements(QByteArray buffer,
|
||||
const QTextBlock &startBlock,
|
||||
const QTextBlock &endBlock,
|
||||
int cursorPositionInEditor,
|
||||
ReplacementsToKeep replacementsToKeep,
|
||||
const QChar &typedChar = QChar::Null,
|
||||
bool secondTry = false) const;
|
||||
|
||||
struct CachedStyle {
|
||||
clang::format::FormatStyle style = clang::format::getNoStyle();
|
||||
QDateTime expirationTime;
|
||||
void setCache(clang::format::FormatStyle newStyle, std::chrono::milliseconds timeout)
|
||||
{
|
||||
style = newStyle;
|
||||
expirationTime = QDateTime::currentDateTime().addMSecs(timeout.count());
|
||||
}
|
||||
};
|
||||
|
||||
mutable CachedStyle m_cachedStyle;
|
||||
|
||||
clang::format::FormatStyle customSettingsStyle(const Utils::FilePath &fileName) const;
|
||||
TextEditor::ICodeStylePreferences *m_overriddenPreferences = nullptr;
|
||||
friend class ClangFormatBaseIndenterPrivate;
|
||||
class ClangFormatBaseIndenterPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ClangFormat
|
||||
|
||||
Reference in New Issue
Block a user