aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/formatter.h
blob: 4020392f0d635c3587fe2d7026f68952649d784a (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
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "refactoringchanges.h"

#include <utils/changeset.h>

#include <QFutureWatcher>
#include <QString>

QT_BEGIN_NAMESPACE
class QChar;
class QTextCursor;
QT_END_NAMESPACE

namespace TextEditor {

class TabSettings;

class Formatter
{
public:
    Formatter() = default;
    virtual ~Formatter() = default;

    virtual QFutureWatcher<Utils::ChangeSet> *format(
        const QTextCursor & /*cursor*/, const TextEditor::TabSettings & /*tabSettings*/)
    {
        return nullptr;
    }

    virtual bool isElectricCharacter(const QChar & /*ch*/) const { return false; }
    virtual bool supportsAutoFormat() const { return false; }
    virtual QFutureWatcher<Utils::ChangeSet> *autoFormat(
        const QTextCursor & /*cursor*/, const TextEditor::TabSettings & /*tabSettings*/)
    {
        return nullptr;
    }

    virtual bool supportsFormatOnSave() const { return false; }
    virtual QFutureWatcher<Utils::ChangeSet> *formatOnSave(
        const QTextCursor & /*cursor*/, const TextEditor::TabSettings & /*tabSettings*/)
    {
        return nullptr;
    }
};

} // namespace TextEditor