forked from qt-creator/qt-creator
QmlDesigner.Rewriter: Cleaning up the warning code
The class is renamed to RewriterError and moved outside of RewriterView. Reason: Inner classes cannot be forward declared in C++. Changing RewriterView::Error to RewriterError, because inner classes cannot be forward declared. Change-Id: I51e3b08efeda44a8cd2abe84e833a5f8c190b84e Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
9b4512f906
commit
8cdfc4e097
@@ -171,7 +171,7 @@ Model* DesignDocument::createInFileComponentModel()
|
|||||||
/*!
|
/*!
|
||||||
Returns any errors that happened when parsing the latest qml file.
|
Returns any errors that happened when parsing the latest qml file.
|
||||||
*/
|
*/
|
||||||
QList<RewriterView::Error> DesignDocument::qmlSyntaxErrors() const
|
QList<RewriterError> DesignDocument::qmlSyntaxErrors() const
|
||||||
{
|
{
|
||||||
return m_rewriterView->errors();
|
return m_rewriterView->errors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
Model *documentModel() const;
|
Model *documentModel() const;
|
||||||
|
|
||||||
QString contextHelpId() const;
|
QString contextHelpId() const;
|
||||||
QList<RewriterView::Error> qmlSyntaxErrors() const;
|
QList<RewriterError> qmlSyntaxErrors() const;
|
||||||
bool hasQmlSyntaxErrors() const;
|
bool hasQmlSyntaxErrors() const;
|
||||||
|
|
||||||
RewriterView *rewriterView() const;
|
RewriterView *rewriterView() const;
|
||||||
@@ -111,7 +111,7 @@ signals:
|
|||||||
void undoAvailable(bool isAvailable);
|
void undoAvailable(bool isAvailable);
|
||||||
void redoAvailable(bool isAvailable);
|
void redoAvailable(bool isAvailable);
|
||||||
void designDocumentClosed();
|
void designDocumentClosed();
|
||||||
void qmlErrorsChanged(const QList<RewriterView::Error> &errors);
|
void qmlErrorsChanged(const QList<RewriterError> &errors);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void deleteSelected();
|
void deleteSelected();
|
||||||
|
|||||||
@@ -62,17 +62,7 @@ class ModelNodePositionStorage;
|
|||||||
|
|
||||||
} //Internal
|
} //Internal
|
||||||
|
|
||||||
class QMLDESIGNERCORE_EXPORT RewriterView : public AbstractView
|
class RewriterError {
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum DifferenceHandling {
|
|
||||||
Validate,
|
|
||||||
Amend
|
|
||||||
};
|
|
||||||
|
|
||||||
class Error {
|
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
NoError = 0,
|
NoError = 0,
|
||||||
@@ -81,10 +71,10 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error();
|
RewriterError();
|
||||||
Error(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document);
|
RewriterError(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document);
|
||||||
Error(const QString &shortDescription);
|
RewriterError(const QString &shortDescription);
|
||||||
Error(const Exception *exception);
|
RewriterError(Exception *exception);
|
||||||
|
|
||||||
Type type() const
|
Type type() const
|
||||||
{ return m_type; }
|
{ return m_type; }
|
||||||
@@ -111,6 +101,16 @@ public:
|
|||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class QMLDESIGNERCORE_EXPORT RewriterView : public AbstractView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DifferenceHandling {
|
||||||
|
Validate,
|
||||||
|
Amend
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RewriterView(DifferenceHandling differenceHandling, QObject *parent);
|
RewriterView(DifferenceHandling differenceHandling, QObject *parent);
|
||||||
~RewriterView();
|
~RewriterView();
|
||||||
@@ -171,10 +171,10 @@ public:
|
|||||||
Internal::ModelNodePositionStorage *positionStorage() const
|
Internal::ModelNodePositionStorage *positionStorage() const
|
||||||
{ return m_positionStorage; }
|
{ return m_positionStorage; }
|
||||||
|
|
||||||
QList<Error> errors() const;
|
QList<RewriterError> errors() const;
|
||||||
void clearErrors();
|
void clearErrors();
|
||||||
void setErrors(const QList<Error> &errors);
|
void setErrors(const QList<RewriterError> &errors);
|
||||||
void addError(const Error &error);
|
void addError(const RewriterError &error);
|
||||||
|
|
||||||
void enterErrorState(const QString &errorMessage);
|
void enterErrorState(const QString &errorMessage);
|
||||||
bool inErrorState() const { return !m_rewritingErrorMessage.isEmpty(); }
|
bool inErrorState() const { return !m_rewritingErrorMessage.isEmpty(); }
|
||||||
@@ -209,7 +209,7 @@ public:
|
|||||||
QSet<QPair<QString, QString> > qrcMapping() const;
|
QSet<QPair<QString, QString> > qrcMapping() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void errorsChanged(const QList<RewriterView::Error> &errors);
|
void errorsChanged(const QList<RewriterError> &errors);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void qmlTextChanged();
|
void qmlTextChanged();
|
||||||
@@ -233,7 +233,7 @@ private: //variables
|
|||||||
QScopedPointer<Internal::ModelToTextMerger> m_modelToTextMerger;
|
QScopedPointer<Internal::ModelToTextMerger> m_modelToTextMerger;
|
||||||
QScopedPointer<Internal::TextToModelMerger> m_textToModelMerger;
|
QScopedPointer<Internal::TextToModelMerger> m_textToModelMerger;
|
||||||
TextModifier *m_textModifier;
|
TextModifier *m_textModifier;
|
||||||
QList<Error> m_errors;
|
QList<RewriterError> m_errors;
|
||||||
int transactionLevel;
|
int transactionLevel;
|
||||||
RewriterTransaction m_removeDefaultPropertyTransaction;
|
RewriterTransaction m_removeDefaultPropertyTransaction;
|
||||||
QString m_rewritingErrorMessage;
|
QString m_rewritingErrorMessage;
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ using namespace QmlDesigner::Internal;
|
|||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
RewriterView::Error::Error():
|
RewriterError::RewriterError():
|
||||||
m_type(NoError),
|
m_type(NoError),
|
||||||
m_line(-1),
|
m_line(-1),
|
||||||
m_column(-1)
|
m_column(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RewriterView::Error::Error(const Exception *exception):
|
RewriterError::RewriterError(Exception *exception):
|
||||||
m_type(InternalError),
|
m_type(InternalError),
|
||||||
m_line(exception->line()),
|
m_line(exception->line()),
|
||||||
m_column(-1),
|
m_column(-1),
|
||||||
@@ -66,7 +66,7 @@ RewriterView::Error::Error(const Exception *exception):
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RewriterView::Error::Error(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document):
|
RewriterError::RewriterError(const QmlJS::DiagnosticMessage &qmlError, const QUrl &document):
|
||||||
m_type(ParseError),
|
m_type(ParseError),
|
||||||
m_line(qmlError.loc.startLine),
|
m_line(qmlError.loc.startLine),
|
||||||
m_column(qmlError.loc.startColumn),
|
m_column(qmlError.loc.startColumn),
|
||||||
@@ -75,7 +75,7 @@ RewriterView::Error::Error(const QmlJS::DiagnosticMessage &qmlError, const QUrl
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RewriterView::Error::Error(const QString &shortDescription) :
|
RewriterError::RewriterError(const QString &shortDescription) :
|
||||||
m_type(ParseError),
|
m_type(ParseError),
|
||||||
m_line(1),
|
m_line(1),
|
||||||
m_column(0),
|
m_column(0),
|
||||||
@@ -85,33 +85,33 @@ RewriterView::Error::Error(const QString &shortDescription) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RewriterView::Error::toString() const
|
QString RewriterError::toString() const
|
||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
if (m_type == ParseError)
|
if (m_type == ParseError)
|
||||||
str += tr("Error parsing");
|
str += RewriterView::tr("Error parsing");
|
||||||
else if (m_type == InternalError)
|
else if (m_type == InternalError)
|
||||||
str += tr("Internal error");
|
str += RewriterView::tr("Internal error");
|
||||||
|
|
||||||
if (url().isValid()) {
|
if (url().isValid()) {
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
str += QLatin1Char(' ');
|
str += QLatin1Char(' ');
|
||||||
|
|
||||||
str += tr("\"%1\"").arg(url().toString());
|
str += RewriterView::tr("\"%1\"").arg(url().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line() != -1) {
|
if (line() != -1) {
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
str += QLatin1Char(' ');
|
str += QLatin1Char(' ');
|
||||||
str += tr("line %1").arg(line());
|
str += RewriterView::tr("line %1").arg(line());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column() != -1) {
|
if (column() != -1) {
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
str += QLatin1Char(' ');
|
str += QLatin1Char(' ');
|
||||||
|
|
||||||
str += tr("column %1").arg(column());
|
str += RewriterView::tr("column %1").arg(column());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!str.isEmpty())
|
if (!str.isEmpty())
|
||||||
@@ -541,7 +541,7 @@ void RewriterView::applyChanges()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<RewriterView::Error> RewriterView::errors() const
|
QList<RewriterError> RewriterView::errors() const
|
||||||
{
|
{
|
||||||
return m_errors;
|
return m_errors;
|
||||||
}
|
}
|
||||||
@@ -552,13 +552,13 @@ void RewriterView::clearErrors()
|
|||||||
emit errorsChanged(m_errors);
|
emit errorsChanged(m_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RewriterView::setErrors(const QList<RewriterView::Error> &errors)
|
void RewriterView::setErrors(const QList<RewriterError> &errors)
|
||||||
{
|
{
|
||||||
m_errors = errors;
|
m_errors = errors;
|
||||||
emit errorsChanged(m_errors);
|
emit errorsChanged(m_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RewriterView::addError(const RewriterView::Error &error)
|
void RewriterView::addError(const RewriterError &error)
|
||||||
{
|
{
|
||||||
m_errors.append(error);
|
m_errors.append(error);
|
||||||
emit errorsChanged(m_errors);
|
emit errorsChanged(m_errors);
|
||||||
|
|||||||
@@ -885,9 +885,9 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
|||||||
doc->parseQml();
|
doc->parseQml();
|
||||||
|
|
||||||
if (!doc->isParsedCorrectly()) {
|
if (!doc->isParsedCorrectly()) {
|
||||||
QList<RewriterView::Error> errors;
|
QList<RewriterError> errors;
|
||||||
foreach (const DiagnosticMessage &message, doc->diagnosticMessages())
|
foreach (const QmlJS::DiagnosticMessage &message, doc->diagnosticMessages())
|
||||||
errors.append(RewriterView::Error(message, QUrl::fromLocalFile(doc->fileName())));
|
errors.append(RewriterError(message, QUrl::fromLocalFile(doc->fileName())));
|
||||||
m_rewriterView->setErrors(errors);
|
m_rewriterView->setErrors(errors);
|
||||||
setActive(false);
|
setActive(false);
|
||||||
return false;
|
return false;
|
||||||
@@ -899,66 +899,19 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
|||||||
new ScopeChain(ctxt.scopeChain()));
|
new ScopeChain(ctxt.scopeChain()));
|
||||||
m_document = doc;
|
m_document = doc;
|
||||||
|
|
||||||
QList<RewriterView::Error> errors;
|
QList<RewriterError> errors;
|
||||||
QList<RewriterView::Error> warnings;
|
QList<RewriterError> warnings;
|
||||||
|
|
||||||
foreach (const DiagnosticMessage &diagnosticMessage, ctxt.diagnosticLinkMessages()) {
|
collectLinkErrors(&errors, ctxt);
|
||||||
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
}
|
|
||||||
|
|
||||||
setupImports(doc, differenceHandler);
|
setupImports(doc, differenceHandler);
|
||||||
setupPossibleImports(snapshot, m_vContext);
|
setupPossibleImports(snapshot, m_vContext);
|
||||||
|
|
||||||
if (m_rewriterView->model()->imports().isEmpty()) {
|
collectImportErrors(&errors);
|
||||||
const DiagnosticMessage diagnosticMessage(Severity::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found"));
|
|
||||||
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const QmlDesigner::Import &import, m_rewriterView->model()->imports()) {
|
|
||||||
if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick") && !supportedQtQuickVersion(import.version())) {
|
|
||||||
const DiagnosticMessage diagnosticMessage(Severity::Error, AST::SourceLocation(0, 0, 0, 0),
|
|
||||||
QCoreApplication::translate("QmlDesigner::TextToModelMerger", "Unsupported QtQuick version"));
|
|
||||||
errors.append(RewriterView::Error(diagnosticMessage, QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view()->checkSemanticErrors()) {
|
if (view()->checkSemanticErrors()) {
|
||||||
Check check(doc, m_scopeChain->context());
|
|
||||||
check.disableMessage(StaticAnalysis::ErrPrototypeCycle);
|
|
||||||
check.disableMessage(StaticAnalysis::ErrCouldNotResolvePrototype);
|
|
||||||
check.disableMessage(StaticAnalysis::ErrCouldNotResolvePrototypeOf);
|
|
||||||
|
|
||||||
foreach (StaticAnalysis::Type type, StaticAnalysis::Message::allMessageTypes()) {
|
collectSemanticErrorsAndWarnings(&errors, &warnings);
|
||||||
StaticAnalysis::PrototypeMessageData prototypeMessageData = StaticAnalysis::Message::prototypeForMessageType(type);
|
|
||||||
if (prototypeMessageData.severity == Severity::MaybeWarning
|
|
||||||
|| prototypeMessageData.severity == Severity::Warning) {
|
|
||||||
check.disableMessage(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
check.enableMessage(StaticAnalysis::WarnImperativeCodeNotEditableInVisualDesigner);
|
|
||||||
check.enableMessage(StaticAnalysis::WarnUnsupportedTypeInVisualDesigner);
|
|
||||||
check.enableMessage(StaticAnalysis::WarnReferenceToParentItemNotSupportedByVisualDesigner);
|
|
||||||
check.enableMessage(StaticAnalysis::WarnReferenceToParentItemNotSupportedByVisualDesigner);
|
|
||||||
check.enableMessage(StaticAnalysis::WarnAboutQtQuick1InsteadQtQuick2);
|
|
||||||
check.enableMessage(StaticAnalysis::ErrUnsupportedRootTypeInVisualDesigner);
|
|
||||||
//## triggers too often ## check.enableMessage(StaticAnalysis::WarnUndefinedValueForVisualDesigner);
|
|
||||||
|
|
||||||
foreach (const StaticAnalysis::Message &message, check()) {
|
|
||||||
if (message.severity == Severity::Error) {
|
|
||||||
if (message.type == StaticAnalysis::ErrUnknownComponent)
|
|
||||||
warnings.append(RewriterView::Error(message.toDiagnosticMessage(), QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
else
|
|
||||||
errors.append(RewriterView::Error(message.toDiagnosticMessage(), QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
}
|
|
||||||
if (message.severity == Severity::Warning) {
|
|
||||||
if (message.type == StaticAnalysis::WarnAboutQtQuick1InsteadQtQuick2) {
|
|
||||||
errors.append(RewriterView::Error(message.toDiagnosticMessage(), QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
} else {
|
|
||||||
warnings.append(RewriterView::Error(message.toDiagnosticMessage(), QUrl::fromLocalFile(doc->fileName())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!errors.isEmpty()) {
|
if (!errors.isEmpty()) {
|
||||||
m_rewriterView->setErrors(errors);
|
m_rewriterView->setErrors(errors);
|
||||||
@@ -966,24 +919,19 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!warnings.isEmpty() && differenceHandler.isValidator() && !m_rewriterView->inErrorState()) {
|
/*
|
||||||
|
* If there are warnings and we are validating the document, then show a warning dialog.
|
||||||
QStringList message;
|
* If the warning dialog is not ignored we set the warnings as errors and do not load the document
|
||||||
|
*/
|
||||||
foreach (const RewriterView::Error &warning, warnings) {
|
if (!warnings.isEmpty()
|
||||||
QString string = QStringLiteral("Line: ") + QString::number(warning.line()) + QStringLiteral(": ") + warning.description();
|
&& differenceHandler.isValidator()
|
||||||
//string += QStringLiteral(" <a href=\"") + QString::number(warning.line()) + QStringLiteral("\">Go to error</a>") + QStringLiteral("<p>");
|
&& !m_rewriterView->inErrorState()
|
||||||
message << string;
|
&& !showWarningsDialogIgnored(warnings)) {
|
||||||
}
|
|
||||||
|
|
||||||
QmlWarningDialog warningDialog(0, message);
|
|
||||||
if (warningDialog.warningsEnabled() && warningDialog.exec()) {
|
|
||||||
m_rewriterView->setErrors(warnings);
|
m_rewriterView->setErrors(warnings);
|
||||||
setActive(false);
|
setActive(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
setupUsedImports();
|
setupUsedImports();
|
||||||
|
|
||||||
AST::UiObjectMember *astRootNode = 0;
|
AST::UiObjectMember *astRootNode = 0;
|
||||||
@@ -997,8 +945,8 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
|||||||
|
|
||||||
setActive(false);
|
setActive(false);
|
||||||
return true;
|
return true;
|
||||||
} catch (const Exception &e) {
|
} catch (Exception &e) {
|
||||||
RewriterView::Error error(&e);
|
RewriterError error(&e);
|
||||||
// Somehow, the error below gets eaten in upper levels, so printing the
|
// Somehow, the error below gets eaten in upper levels, so printing the
|
||||||
// exception info here for debugging purposes:
|
// exception info here for debugging purposes:
|
||||||
qDebug() << "*** An exception occurred while reading the QML file:"
|
qDebug() << "*** An exception occurred while reading the QML file:"
|
||||||
@@ -1932,6 +1880,80 @@ void TextToModelMerger::setupComponent(const ModelNode &node)
|
|||||||
ModelNode(node).setNodeSource(result);
|
ModelNode(node).setNodeSource(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextToModelMerger::collectLinkErrors(QList<RewriterError> *errors, const ReadingContext &ctxt)
|
||||||
|
{
|
||||||
|
foreach (const QmlJS::DiagnosticMessage &diagnosticMessage, ctxt.diagnosticLinkMessages()) {
|
||||||
|
errors->append(RewriterError(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextToModelMerger::collectImportErrors(QList<RewriterError> *errors)
|
||||||
|
{
|
||||||
|
if (m_rewriterView->model()->imports().isEmpty()) {
|
||||||
|
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0), QCoreApplication::translate("QmlDesigner::TextToModelMerger", "No import statements found"));
|
||||||
|
errors->append(RewriterError(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (const QmlDesigner::Import &import, m_rewriterView->model()->imports()) {
|
||||||
|
if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick") && !supportedQtQuickVersion(import.version())) {
|
||||||
|
const QmlJS::DiagnosticMessage diagnosticMessage(QmlJS::Severity::Error, AST::SourceLocation(0, 0, 0, 0),
|
||||||
|
QCoreApplication::translate("QmlDesigner::TextToModelMerger", "Unsupported QtQuick version"));
|
||||||
|
errors->append(RewriterError(diagnosticMessage, QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextToModelMerger::collectSemanticErrorsAndWarnings(QList<RewriterError> *errors, QList<RewriterError> *warnings)
|
||||||
|
{
|
||||||
|
Check check(m_document, m_scopeChain->context());
|
||||||
|
check.disableMessage(StaticAnalysis::ErrPrototypeCycle);
|
||||||
|
check.disableMessage(StaticAnalysis::ErrCouldNotResolvePrototype);
|
||||||
|
check.disableMessage(StaticAnalysis::ErrCouldNotResolvePrototypeOf);
|
||||||
|
|
||||||
|
foreach (StaticAnalysis::Type type, StaticAnalysis::Message::allMessageTypes()) {
|
||||||
|
StaticAnalysis::PrototypeMessageData prototypeMessageData = StaticAnalysis::Message::prototypeForMessageType(type);
|
||||||
|
if (prototypeMessageData.severity == Severity::MaybeWarning
|
||||||
|
|| prototypeMessageData.severity == Severity::Warning) {
|
||||||
|
check.disableMessage(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check.enableQmlDesignerChecks();
|
||||||
|
|
||||||
|
foreach (const StaticAnalysis::Message &message, check()) {
|
||||||
|
if (message.severity == Severity::Error) {
|
||||||
|
if (message.type == StaticAnalysis::ErrUnknownComponent)
|
||||||
|
warnings->append(RewriterError(message.toDiagnosticMessage(), QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
else
|
||||||
|
errors->append(RewriterError(message.toDiagnosticMessage(), QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
}
|
||||||
|
if (message.severity == Severity::Warning) {
|
||||||
|
if (message.type == StaticAnalysis::WarnAboutQtQuick1InsteadQtQuick2) {
|
||||||
|
errors->append(RewriterError(message.toDiagnosticMessage(), QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
} else {
|
||||||
|
warnings->append(RewriterError(message.toDiagnosticMessage(), QUrl::fromLocalFile(m_document->fileName())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextToModelMerger::showWarningsDialogIgnored(const QList<RewriterError> &warnings)
|
||||||
|
{
|
||||||
|
QStringList message;
|
||||||
|
|
||||||
|
foreach (const RewriterError &warning, warnings) {
|
||||||
|
QString string = QStringLiteral("Line: ") + QString::number(warning.line()) + QStringLiteral(": ") + warning.description();
|
||||||
|
message << string;
|
||||||
|
}
|
||||||
|
|
||||||
|
QmlWarningDialog warningDialog(0, message);
|
||||||
|
if (warningDialog.warningsEnabled() && warningDialog.exec()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void TextToModelMerger::populateQrcMapping(const QString &filePath)
|
void TextToModelMerger::populateQrcMapping(const QString &filePath)
|
||||||
{
|
{
|
||||||
QString path = removeFileFromQrcPath(filePath);
|
QString path = removeFileFromQrcPath(filePath);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class RewriterView;
|
class RewriterView;
|
||||||
|
class RewriterError;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -137,6 +138,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
void setupCustomParserNode(const ModelNode &node);
|
void setupCustomParserNode(const ModelNode &node);
|
||||||
void setupComponent(const ModelNode &node);
|
void setupComponent(const ModelNode &node);
|
||||||
|
void collectLinkErrors(QList<RewriterError> *errors, const ReadingContext &ctxt);
|
||||||
|
void collectImportErrors(QList<RewriterError> *errors);
|
||||||
|
void collectSemanticErrorsAndWarnings(QList<RewriterError> *errors,
|
||||||
|
QList<RewriterError> *warnings);
|
||||||
|
bool showWarningsDialogIgnored(const QList<RewriterError> &warnings);
|
||||||
|
|
||||||
void populateQrcMapping(const QString &filePath);
|
void populateQrcMapping(const QString &filePath);
|
||||||
|
|
||||||
|
|||||||
@@ -98,14 +98,14 @@ DocumentWarningWidget::DocumentWarningWidget(DesignModeWidget *parent) :
|
|||||||
layout->addWidget(m_goToError, 1, Qt::AlignRight);
|
layout->addWidget(m_goToError, 1, Qt::AlignRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentWarningWidget::setError(const RewriterView::Error &error)
|
void DocumentWarningWidget::setError(const RewriterError &error)
|
||||||
{
|
{
|
||||||
m_error = error;
|
m_error = error;
|
||||||
QString str;
|
QString str;
|
||||||
if (error.type() == RewriterView::Error::ParseError) {
|
if (error.type() == RewriterError::ParseError) {
|
||||||
str = tr("%3 (%1:%2)").arg(QString::number(error.line()), QString::number(error.column()), error.description());
|
str = tr("%3 (%1:%2)").arg(QString::number(error.line()), QString::number(error.column()), error.description());
|
||||||
m_goToError->show();
|
m_goToError->show();
|
||||||
} else if (error.type() == RewriterView::Error::InternalError) {
|
} else if (error.type() == RewriterError::InternalError) {
|
||||||
str = tr("Internal error (%1)").arg(error.description());
|
str = tr("Internal error (%1)").arg(error.description());
|
||||||
m_goToError->hide();
|
m_goToError->hide();
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ void DesignModeWidget::disableWidgets()
|
|||||||
m_isDisabled = true;
|
m_isDisabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignModeWidget::updateErrorStatus(const QList<RewriterView::Error> &errors)
|
void DesignModeWidget::updateErrorStatus(const QList<RewriterError> &errors)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << Q_FUNC_INFO << errors.count();
|
qDebug() << Q_FUNC_INFO << errors.count();
|
||||||
@@ -459,8 +459,8 @@ void DesignModeWidget::deleteSidebarWidgets()
|
|||||||
|
|
||||||
void DesignModeWidget::qmlPuppetCrashed()
|
void DesignModeWidget::qmlPuppetCrashed()
|
||||||
{
|
{
|
||||||
QList<RewriterView::Error> errorList;
|
QList<RewriterError> errorList;
|
||||||
RewriterView::Error error(tr("Qt Quick emulation layer crashed"));
|
RewriterError error(tr("Qt Quick emulation layer crashed"));
|
||||||
errorList.append(error);
|
errorList.append(error);
|
||||||
|
|
||||||
disableWidgets();
|
disableWidgets();
|
||||||
@@ -616,7 +616,7 @@ QWidget *DesignModeWidget::createCrumbleBarFrame()
|
|||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignModeWidget::showErrorMessage(const QList<RewriterView::Error> &errors)
|
void DesignModeWidget::showErrorMessage(const QList<RewriterError> &errors)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!errors.isEmpty());
|
Q_ASSERT(!errors.isEmpty());
|
||||||
m_warningWidget->setError(errors.first());
|
m_warningWidget->setError(errors.first());
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class DocumentWarningWidget : public Utils::FakeToolTip
|
|||||||
public:
|
public:
|
||||||
explicit DocumentWarningWidget(DesignModeWidget *parent = 0);
|
explicit DocumentWarningWidget(DesignModeWidget *parent = 0);
|
||||||
|
|
||||||
void setError(const RewriterView::Error &error);
|
void setError(const RewriterError &error);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void goToError();
|
void goToError();
|
||||||
@@ -81,7 +81,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
QLabel *m_errorMessage;
|
QLabel *m_errorMessage;
|
||||||
QLabel *m_goToError;
|
QLabel *m_goToError;
|
||||||
RewriterView::Error m_error;
|
RewriterError m_error;
|
||||||
DesignModeWidget *m_designModeWidget;
|
DesignModeWidget *m_designModeWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,12 +109,12 @@ public:
|
|||||||
|
|
||||||
void enableWidgets();
|
void enableWidgets();
|
||||||
void disableWidgets();
|
void disableWidgets();
|
||||||
void showErrorMessage(const QList<RewriterView::Error> &errors);
|
void showErrorMessage(const QList<RewriterError> &errors);
|
||||||
|
|
||||||
CrumbleBar* crumbleBar() const;
|
CrumbleBar* crumbleBar() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateErrorStatus(const QList<RewriterView::Error> &errors);
|
void updateErrorStatus(const QList<RewriterError> &errors);
|
||||||
void restoreDefaultView();
|
void restoreDefaultView();
|
||||||
void toggleSidebars();
|
void toggleSidebars();
|
||||||
void toggleLeftSidebar();
|
void toggleLeftSidebar();
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ void QmlDesignerPlugin::activateAutoSynchronization()
|
|||||||
viewManager().attachComponentView();
|
viewManager().attachComponentView();
|
||||||
viewManager().attachViewsExceptRewriterAndComponetView();
|
viewManager().attachViewsExceptRewriterAndComponetView();
|
||||||
|
|
||||||
QList<RewriterView::Error> errors = currentDesignDocument()->qmlSyntaxErrors();
|
QList<RewriterError> errors = currentDesignDocument()->qmlSyntaxErrors();
|
||||||
if (errors.isEmpty()) {
|
if (errors.isEmpty()) {
|
||||||
selectModelNodeUnderTextCursor();
|
selectModelNodeUnderTextCursor();
|
||||||
data->mainWidget->enableWidgets();
|
data->mainWidget->enableWidgets();
|
||||||
@@ -329,9 +329,9 @@ void QmlDesignerPlugin::activateAutoSynchronization()
|
|||||||
currentDesignDocument()->updateSubcomponentManager();
|
currentDesignDocument()->updateSubcomponentManager();
|
||||||
|
|
||||||
connect(rewriterView(),
|
connect(rewriterView(),
|
||||||
SIGNAL(errorsChanged(QList<RewriterView::Error>)),
|
SIGNAL(errorsChanged(QList<RewriterError>)),
|
||||||
data->mainWidget,
|
data->mainWidget,
|
||||||
SLOT(updateErrorStatus(QList<RewriterView::Error>)));
|
SLOT(updateErrorStatus(QList<RewriterError>)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDesignerPlugin::deactivateAutoSynchronization()
|
void QmlDesignerPlugin::deactivateAutoSynchronization()
|
||||||
@@ -342,9 +342,9 @@ void QmlDesignerPlugin::deactivateAutoSynchronization()
|
|||||||
documentManager().currentDesignDocument()->resetToDocumentModel();
|
documentManager().currentDesignDocument()->resetToDocumentModel();
|
||||||
|
|
||||||
disconnect(rewriterView(),
|
disconnect(rewriterView(),
|
||||||
SIGNAL(errorsChanged(QList<RewriterView::Error>)),
|
SIGNAL(errorsChanged(QList<RewriterError>)),
|
||||||
data->mainWidget,
|
data->mainWidget,
|
||||||
SLOT(updateErrorStatus(QList<RewriterView::Error>)));
|
SLOT(updateErrorStatus(QList<RewriterError>)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user