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
qqmljstypereader.cpp
Go to the documentation of this file.
1
// Copyright (C) 2020 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
"qqmljstypereader_p.h"
6
#
include
"qqmljsimportvisitor_p.h"
7
8
#
include
<
QtQml
/
private
/
qqmljsast_p
.
h
>
9
#
include
<
QtQml
/
private
/
qqmljsengine_p
.
h
>
10
#
include
<
QtQml
/
private
/
qqmljslexer_p
.
h
>
11
#
include
<
QtQml
/
private
/
qqmljsparser_p
.
h
>
12
#
include
<
QtQml
/
private
/
qqmlimportresolver_p
.
h
>
13
14
#
include
<
QtCore
/
qfileinfo
.
h
>
15
#
include
<
QtCore
/
qdebug
.
h
>
16
17
QT_BEGIN_NAMESPACE
18
19
namespace
QQmlJS
{
20
void
defaultTypeReader
(QQmlJSImporter *importer,
const
QString &filePath,
21
const
QSharedPointer<QQmlJSScope> &scope)
22
{
23
using
namespace
QQmlJS::AST;
24
const
QFileInfo info{ filePath };
25
26
QQmlJS::Engine engine;
27
QQmlJS::Lexer lexer(&engine);
28
29
const
QString lowerSuffix = info.suffix().toLower();
30
const
bool
isESModule = lowerSuffix == QLatin1String(
"mjs"
);
31
const
bool
isJavaScript = isESModule || lowerSuffix == QLatin1String(
"js"
);
32
33
QFile file(filePath);
34
if
(!file.open(QFile::ReadOnly))
35
return
;
36
37
QString code = QString::fromUtf8(file.readAll());
38
file.close();
39
40
lexer.setCode(code,
/*line = */
1,
/*qmlMode=*/
!isJavaScript);
41
QQmlJS::Parser parser(&engine);
42
43
isJavaScript ? (isESModule ? parser.parseModule() : parser.parseProgram()) : parser.parse();
44
45
QQmlJS::AST::Node *rootNode = parser.rootNode();
46
47
QQmlJSLogger logger;
48
logger.setFilePath(filePath);
49
logger.setCode(code);
50
logger.setSilent(
true
);
51
logger.setIsDisabled(
true
);
52
53
importer->runImportVisitor(rootNode,
54
{ scope,
55
&logger,
56
QQmlJSImportVisitor::implicitImportDirectory(
57
filePath, importer->resourceFileMapper()),
58
{ } });
59
}
60
}
// namespace QQmlJS
61
62
QT_END_NAMESPACE
QQmlJS
Definition
qv4bytecodegenerator_p.h:27
QQmlJS::defaultTypeReader
void defaultTypeReader(QQmlJSImporter *importer, const QString &filePath, const QSharedPointer< QQmlJSScope > &scope)
Definition
qqmljstypereader.cpp:20
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
qmlcompiler
qqmljstypereader.cpp
Generated on
for Qt by
1.18.0