21 const QSharedPointer<QQmlJSScope> &scope)
23 using namespace QQmlJS::AST;
24 const QFileInfo info{ filePath };
25 const QString baseName = info.baseName();
26 scope->setInternalName(baseName.endsWith(QStringLiteral(
".ui")) ? baseName.chopped(3)
29 QQmlJS::Engine engine;
30 QQmlJS::Lexer lexer(&engine);
32 const QString lowerSuffix = info.suffix().toLower();
33 const bool isESModule = lowerSuffix == QLatin1String(
"mjs");
34 const bool isJavaScript = isESModule || lowerSuffix == QLatin1String(
"js");
37 if (!file.open(QFile::ReadOnly))
40 QString code = QString::fromUtf8(file.readAll());
43 lexer.setCode(code, 1, !isJavaScript);
44 QQmlJS::Parser parser(&engine);
46 isJavaScript ? (isESModule ? parser.parseModule() : parser.parseProgram()) : parser.parse();
48 QQmlJS::AST::Node *rootNode = parser.rootNode();
51 logger.setFilePath(filePath);
53 logger.setSilent(
true);
54 logger.setIsDisabled(
true);
56 importer->runImportVisitor(rootNode,
59 QQmlJSImportVisitor::implicitImportDirectory(
60 filePath, importer->resourceFileMapper()),