diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-23 14:57:09 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-06-14 19:08:51 +0200 |
commit | d4d197d06279f9257647628f7e1ccc9ec763a6bb (patch) | |
tree | fb2a69b85cb1d7aee173267062421058d5e9d57c /src/qml/compiler/qv4codegen.cpp | |
parent | 67191c2b3213259c6eaf045154e9370faa085868 (diff) |
Simplify errors and diagnostics
We only need two classes to describe all possible diagnostics:
* A low-level private POD DiagnosticMessage. This is easily copied and
passed around internally. It doesn't need to adhere to a stable API
and it doesn't carry any extra baggage.
* The high-level public QQmlError with its stable interface. This can
internally also use a DiagnosticMessage as storage.
Change-Id: I52be88d9b5d9855a661b8032b01eedb43a0fb0b3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4codegen.cpp')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 04e6efb1e9..99b73679c5 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -53,7 +53,8 @@ #include <private/qv4compilercontrolflow_p.h> #include <private/qv4bytecodegenerator_p.h> #include <private/qv4compilerscanfunctions_p.h> -#include <qqmlerror.h> +#include <private/qv4stringtoarrayindex_p.h> +#include <private/qqmljsdiagnosticmessage_p.h> #include <cmath> #include <iostream> @@ -3777,7 +3778,8 @@ void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail) hasError = true; QQmlJS::DiagnosticMessage error; error.message = detail; - error.loc = loc; + error.line = loc.startLine; + error.column = loc.startColumn; _errors << error; } @@ -3789,7 +3791,8 @@ void Codegen::throwReferenceError(const SourceLocation &loc, const QString &deta hasError = true; QQmlJS::DiagnosticMessage error; error.message = detail; - error.loc = loc; + error.line = loc.startLine; + error.column = loc.startColumn; _errors << error; } @@ -3961,28 +3964,9 @@ Codegen::VolatileMemoryLocations Codegen::scanVolatileMemoryLocations(AST::Node return scanner.scan(ast); } - -QList<QQmlError> Codegen::qmlErrors() const +QUrl Codegen::url() const { - QList<QQmlError> qmlErrors; - - // Short circuit to avoid costly (de)heap allocation of QUrl if there are no errors. - if (_errors.size() == 0) - return qmlErrors; - - qmlErrors.reserve(_errors.size()); - - QUrl url(_fileNameIsUrl ? QUrl(_module->fileName) : QUrl::fromLocalFile(_module->fileName)); - for (const QQmlJS::DiagnosticMessage &msg: qAsConst(_errors)) { - QQmlError e; - e.setUrl(url); - e.setLine(msg.loc.startLine); - e.setColumn(msg.loc.startColumn); - e.setDescription(msg.message); - qmlErrors << e; - } - - return qmlErrors; + return QUrl(_fileNameIsUrl ? QUrl(_module->fileName) : QUrl::fromLocalFile(_module->fileName)); } bool Codegen::RValue::operator==(const RValue &other) const |