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