qmllint: Fix parsing js files with .import directives
authorSérgio Martins <sergio.martins@kdab.com>
Fri, 8 May 2015 19:10:06 +0000 (20:10 +0100)
committerSérgio Martins <sergio.martins@kdab.com>
Sat, 9 May 2015 08:41:54 +0000 (08:41 +0000)
For .pragmas we removed them explicitly but the correct fix is to
not use "qmlMode" when setting code in the lexer.

Change-Id: I6ffc0ca9e7ebab09fbf91e647d292ff0a3a1fd7d
Task-number: QTBUG-45916
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
tools/qmllint/main.cpp

index 3b412b0..cd81a5b 100644 (file)
@@ -41,7 +41,6 @@
 #include <private/qqmljslexer_p.h>
 #include <private/qqmljsparser_p.h>
 #include <private/qqmljsengine_p.h>
-#include <private/qqmlirbuilder_p.h>
 
 static bool lint_file(const QString &filename, bool silent)
 {
@@ -59,10 +58,7 @@ static bool lint_file(const QString &filename, bool silent)
 
     QFileInfo info(filename);
     bool isJavaScript = info.suffix().toLower() == QLatin1String("js");
-    if (isJavaScript)
-        QmlIR::Document::removeScriptPragmas(/*by-ref*/code);
-
-    lexer.setCode(code, /*line = */ 1, true);
+    lexer.setCode(code, /*line = */ 1, /*qmlMode=*/ !isJavaScript);
     QQmlJS::Parser parser(&engine);
 
     bool success = isJavaScript ? parser.parseProgram() : parser.parse();