21 using namespace QQmlJS::AST;
22 const QFileInfo info { m_file };
23 const QString baseName = info.baseName();
24 scope->setInternalName(baseName.endsWith(QStringLiteral(
".ui")) ? baseName.chopped(3)
27 QQmlJS::Engine engine;
28 QQmlJS::Lexer lexer(&engine);
30 const QString lowerSuffix = info.suffix().toLower();
31 const bool isESModule = lowerSuffix == QLatin1String(
"mjs");
32 const bool isJavaScript = isESModule || lowerSuffix == QLatin1String(
"js");
36 if (!file.open(QFile::ReadOnly))
39 QString code = QString::fromUtf8(file.readAll());
42 lexer.setCode(code, 1, !isJavaScript);
43 QQmlJS::Parser parser(&engine);
45 const bool success = isJavaScript ? (isESModule ? parser.parseModule()
46 : parser.parseProgram())
49 QQmlJS::AST::Node *rootNode = parser.rootNode();
52 logger.setFilePath(m_file);
54 logger.setSilent(
true);
55 logger.setIsDisabled(
true);
57 m_importer->runImportVisitor(rootNode,
60 QQmlJSImportVisitor::implicitImportDirectory(
61 m_file, m_importer->resourceFileMapper()),
63 return success && rootNode;