forked from qt-creator/qt-creator
Retain ".pragma library" when reformatting JavaScript files
For ".pragma library" there is a special flag in QmlJS::Directives. We just need to actually set the flag and query it when re-emitting the code. Change-Id: Ia3455fda18aba3219b02ecf092bb28987a6ccef5 Fixes: QTCREATORBUG-22326 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -265,6 +265,11 @@ public:
|
||||
addLocation(line, column);
|
||||
}
|
||||
|
||||
void pragmaLibrary() override
|
||||
{
|
||||
isLibrary = true;
|
||||
}
|
||||
|
||||
virtual QList<SourceLocation> locations() { return _locations; }
|
||||
|
||||
const QString documentPath;
|
||||
|
@@ -24,8 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmljsreformatter.h"
|
||||
|
||||
#include "qmljscodeformatter.h"
|
||||
#include "qmljsbind.h"
|
||||
|
||||
#include "parser/qmljsast_p.h"
|
||||
#include "parser/qmljsastvisitor_p.h"
|
||||
#include "parser/qmljsengine_p.h"
|
||||
@@ -122,6 +123,10 @@ public:
|
||||
|
||||
|
||||
// emit directives
|
||||
if (_doc->bind()->isJsLibrary()) {
|
||||
out(QLatin1String(".pragma library"));
|
||||
newLine();
|
||||
}
|
||||
const QList<SourceLocation> &directives = _doc->jsDirectives();
|
||||
for (const auto &d: directives) {
|
||||
quint32 line = 1;
|
||||
|
3
tests/auto/qml/reformatter/pragmalibrary.js
Normal file
3
tests/auto/qml/reformatter/pragmalibrary.js
Normal file
@@ -0,0 +1,3 @@
|
||||
.pragma library
|
||||
|
||||
function foo() {}
|
Reference in New Issue
Block a user