diff options
| author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-12-13 13:19:33 +0100 |
|---|---|---|
| committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-12-13 18:20:38 +0100 |
| commit | f5dc8ef19f4a92b307da38598955efd89922fc7e (patch) | |
| tree | 7f06a61974c5db3f21c8c583877e434464cf6084 /src/qmlcompiler/qqmljscompiler.cpp | |
| parent | e83fd85cce26823c6289a32fd5f7a0fa87639407 (diff) | |
qqmljscompiler: Allow for reading file contents from memory
This is necessary in order for the qmllint library to provide linting
in memory. This in turn is used by our LSP.
Pick-to: 6.3
Change-Id: Ice01c16b4d9ff90cddac87c8840dc5556981f9d5
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljscompiler.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljscompiler.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 79fa6a69ff..f9448f38ac 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -201,20 +201,24 @@ private: bool qCompileQmlFile(const QString &inputFileName, QQmlJSSaveFunction saveFunction, QQmlJSAotCompiler *aotCompiler, QQmlJSCompileError *error, - bool storeSourceLocation, QV4::Compiler::CodegenWarningInterface *interface) + bool storeSourceLocation, QV4::Compiler::CodegenWarningInterface *interface, + const QString *fileContents) { QmlIR::Document irDocument(/*debugMode*/false); return qCompileQmlFile(irDocument, inputFileName, saveFunction, aotCompiler, error, - storeSourceLocation, interface); + storeSourceLocation, interface, fileContents); } bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, QQmlJSSaveFunction saveFunction, QQmlJSAotCompiler *aotCompiler, QQmlJSCompileError *error, bool storeSourceLocation, - QV4::Compiler::CodegenWarningInterface *interface) + QV4::Compiler::CodegenWarningInterface *interface, const QString *fileContents) { QString sourceCode; - { + + if (fileContents != nullptr) { + sourceCode = *fileContents; + } else { QFile f(inputFileName); if (!f.open(QIODevice::ReadOnly)) { error->message = QLatin1String("Error opening ") + inputFileName + QLatin1Char(':') + f.errorString(); |
