Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmldom_utils.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
6#include <QtCore/qdir.h>
7#include <QtCore/qdiriterator.h>
8#include <QtCore/qstring.h>
9#include <QtCore/qmetaobject.h>
10#include <QtCore/qcbormap.h>
11#include <QtCore/qvarlengtharray.h>
12
14
15Q_LOGGING_CATEGORY(QQmlJSDomImporting, "qt.qqmljsdom.importing")
16
17namespace QQmlJS {
18namespace Dom {
19
20using namespace Qt::StringLiterals;
21
23
24QString fileLocationRegionName(FileLocationRegion region)
25{
26 return QString::fromLatin1(regionEnum.key(region));
27}
28
29FileLocationRegion fileLocationRegionValue(QStringView region)
30{
31 return static_cast<FileLocationRegion>(regionEnum.keyToValue(region.toLatin1()));
32}
33
34QCborValue sourceLocationToQCborValue(QQmlJS::SourceLocation loc)
35{
36 QCborMap res({
37 {QStringLiteral(u"offset"), loc.offset},
38 {QStringLiteral(u"length"), loc.length},
39 {QStringLiteral(u"startLine"), loc.startLine},
40 {QStringLiteral(u"startColumn"), loc.startColumn}
41 });
42 return res;
43}
44
45} // namespace Dom
46}; // namespace QQmlJS
47
48QT_END_NAMESPACE
QString fileLocationRegionName(FileLocationRegion region)
FileLocationRegion fileLocationRegionValue(QStringView region)
static QMetaEnum regionEnum
QCborValue sourceLocationToQCborValue(QQmlJS::SourceLocation loc)