summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/designercore/model/textmodifier.cpp
blob: 6711ec3e053e850c82cae97445660e9d603b45d0 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "textmodifier.h"

#include <qmljs/qmljsmodelmanagerinterface.h>

#include <utils/textutils.h>

using namespace QmlDesigner;

TextModifier::~TextModifier() = default;

int TextModifier::getLineInDocument(QTextDocument *document, int offset)
{
    int line = -1;
    int column = -1;
    Utils::Text::convertPosition(document, offset, &line, &column);
    return line;
}

QmlJS::Snapshot TextModifier::qmljsSnapshot()
{
    QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
    if (modelManager)
        return modelManager->snapshot();
    else
        return QmlJS::Snapshot();
}