Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qqmltctyperesolver.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
// Qt-Security score:significant
4
5
#
include
"qqmltctyperesolver_p.h"
6
7
#
include
<
private
/
qqmljsimporter_p
.
h
>
8
#
include
<
private
/
qqmljsliteralbindingcheck_p
.
h
>
9
#
include
<
private
/
qv4value_p
.
h
>
10
11
#
include
<
QtCore
/
qqueue
.
h
>
12
#
include
<
QtCore
/
qloggingcategory
.
h
>
13
#
include
<
QtCore
/
qfileinfo
.
h
>
14
#
include
<
QtCore
/
qdiriterator
.
h
>
15
16
Q_STATIC_LOGGING_CATEGORY
(lcTypeResolver2,
"qml.qmltc.typeresolver"
, QtInfoMsg);
17
18
QT_BEGIN_NAMESPACE
19
20
namespace
QQmltc
{
21
22
void
TypeResolver
::
init
(Visitor *visitor, QQmlJS::AST::Node *program)
23
{
24
QQmlJSTypeResolver::init(visitor, program);
25
26
m_root = visitor->result();
27
28
QQueue<QQmlJSScope::Ptr> objects;
29
objects.enqueue(m_root);
30
while
(!objects.isEmpty()) {
31
const
QQmlJSScope::Ptr object = objects.dequeue();
32
const
QQmlJS::SourceLocation location = object->sourceLocation();
33
qCDebug(lcTypeResolver2()).nospace() <<
"inserting "
<< object.data() <<
" at "
34
<< location.startLine <<
':'
<< location.startColumn;
35
m_objectsByLocationNonConst.insert({ location.startLine, location.startColumn }, object);
36
37
const
auto
childScopes = object->childScopes();
38
for
(
const
auto
&childScope : childScopes)
39
objects.enqueue(childScope);
40
}
41
}
42
43
QQmlJSScope
::
Ptr
44
TypeResolver
::
scopeForLocation
(
const
QV4::CompiledData::Location &location)
const
45
{
46
qCDebug(lcTypeResolver2()).nospace()
47
<<
"looking for object at "
<< location.line() <<
':'
<< location.column();
48
return
m_objectsByLocationNonConst.value(location);
49
}
50
51
std
::
pair
<
QString
,
QQmlJSScope
::
Ptr
>
52
TypeResolver
::
importedType
(
const
QQmlJSScope::ConstPtr &type)
const
53
{
54
const
auto
files = m_importer->importedFiles();
55
auto
it = std::find_if(files.cbegin(), files.cend(), [&](
const
QQmlJSScope::Ptr &importedType) {
56
return
importedType.data() == type.data();
57
});
58
if
(it == files.cend())
59
return
{};
60
return
{ it.key(), it.value() };
61
}
62
63
}
// namespace QQmltc
64
65
QT_END_NAMESPACE
QQmltc::TypeResolver
Definition
qqmltctyperesolver_p.h:31
QQmltc::TypeResolver::importedType
std::pair< QString, QQmlJSScope::Ptr > importedType(const QQmlJSScope::ConstPtr &type) const
Definition
qqmltctyperesolver.cpp:52
QQmltc::TypeResolver::scopeForLocation
QQmlJSScope::Ptr scopeForLocation(const QV4::CompiledData::Location &location) const
Definition
qqmltctyperesolver.cpp:44
QQmltc::TypeResolver::init
void init(Visitor *visitor, QQmlJS::AST::Node *program)
Definition
qqmltctyperesolver.cpp:22
QQmltc
Definition
qqmltccodewriter.cpp:19
Q_STATIC_LOGGING_CATEGORY
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
qtdeclarative
src
qmltc
qqmltctyperesolver.cpp
Generated on
for Qt by
1.18.0