aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/beautifier/clangformat/clangformat.h
blob: 65fd23a43f15ff8ec2277e21bba1a599c5252b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2016 Lorenz Haas
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "../beautifierabstracttool.h"

#include "clangformatsettings.h"

namespace Beautifier::Internal {

class ClangFormat : public BeautifierAbstractTool
{
public:
    ClangFormat();

    QString id() const override;
    void updateActions(Core::IEditor *editor) override;
    TextEditor::Command command() const override;
    bool isApplicable(const Core::IDocument *document) const override;

private:
    void formatFile();
    void formatAtPosition(const int pos, const int length);
    void formatAtCursor();
    void formatLines();
    void disableFormattingSelectedText();
    TextEditor::Command command(int offset, int length) const;

    QAction *m_formatFile = nullptr;
    QAction *m_formatLines = nullptr;
    QAction *m_formatRange = nullptr;
    QAction *m_disableFormattingSelectedText = nullptr;
    ClangFormatSettings m_settings;
    ClangFormatOptionsPage m_page{&m_settings};
};

} // Beautifier::Internal