qmljs: handle js directives .pragma and .import

The directives .pragma and .import are not included in the AST.
Their source code locations are not stored in any other place.
As a result, when reformatting the source, they simply disappear.

This patch keep track of their source code locations, so they are
not removed when reformatting the source code.
This patch contains also some modification in the lexer that should
probably be ported to the qtdeclarative version.

Task-number: QTCREATORBUG-13038
Change-Id: I5d568abf02d37a584d4d246939736aaec5af5053
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Benelli
2017-10-19 17:14:12 +02:00
parent c637c66ebb
commit d7f431482d
5 changed files with 62 additions and 13 deletions

View File

@@ -1312,7 +1312,7 @@ bool Lexer::scanDirectives(Directives *directives, DiagnosticMessage *error)
}
// we found a .pragma library directive
directives->pragmaLibrary();
directives->pragmaLibrary(lineNumber, column);
} else {
Q_ASSERT(directiveName == QLatin1String("import"));