forked from qt-creator/qt-creator
QmlDesigner: keep warnings for later showing
Change-Id: I5f9c51480a1d0276a356737ab1f91a8f76443c5a Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -163,15 +163,22 @@ Model* DesignDocument::createInFileComponentModel()
|
||||
return model;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns any errors that happened when parsing the latest qml file.
|
||||
*/
|
||||
QList<RewriterError> DesignDocument::qmlSyntaxErrors() const
|
||||
QList<RewriterError> DesignDocument::qmlParseWarnings() const
|
||||
{
|
||||
return m_rewriterView->warnings();
|
||||
}
|
||||
|
||||
bool DesignDocument::hasQmlParseWarnings() const
|
||||
{
|
||||
return currentModel()->rewriterView() && !currentModel()->rewriterView()->warnings().isEmpty();
|
||||
}
|
||||
|
||||
QList<RewriterError> DesignDocument::qmlParseErrors() const
|
||||
{
|
||||
return m_rewriterView->errors();
|
||||
}
|
||||
|
||||
bool DesignDocument::hasQmlSyntaxErrors() const
|
||||
bool DesignDocument::hasQmlParseErrors() const
|
||||
{
|
||||
return currentModel()->rewriterView() && !currentModel()->rewriterView()->errors().isEmpty();
|
||||
}
|
||||
|
@@ -77,8 +77,10 @@ public:
|
||||
Model *documentModel() const;
|
||||
|
||||
QString contextHelpId() const;
|
||||
QList<RewriterError> qmlSyntaxErrors() const;
|
||||
bool hasQmlSyntaxErrors() const;
|
||||
QList<RewriterError> qmlParseWarnings() const;
|
||||
bool hasQmlParseWarnings() const;
|
||||
QList<RewriterError> qmlParseErrors() const;
|
||||
bool hasQmlParseErrors() const;
|
||||
|
||||
RewriterView *rewriterView() const;
|
||||
|
||||
|
@@ -143,9 +143,11 @@ public:
|
||||
Internal::ModelNodePositionStorage *positionStorage() const
|
||||
{ return m_positionStorage; }
|
||||
|
||||
QList<RewriterError> warnings() const;
|
||||
QList<RewriterError> errors() const;
|
||||
void clearErrors();
|
||||
void clearErrorAndWarnings();
|
||||
void setErrors(const QList<RewriterError> &errors);
|
||||
void setWarnings(const QList<RewriterError> &warnings);
|
||||
void addError(const RewriterError &error);
|
||||
|
||||
void enterErrorState(const QString &errorMessage);
|
||||
@@ -206,6 +208,7 @@ private: //variables
|
||||
QScopedPointer<Internal::TextToModelMerger> m_textToModelMerger;
|
||||
TextModifier *m_textModifier;
|
||||
QList<RewriterError> m_errors;
|
||||
QList<RewriterError> m_warnings;
|
||||
int transactionLevel;
|
||||
RewriterTransaction m_removeDefaultPropertyTransaction;
|
||||
QString m_rewritingErrorMessage;
|
||||
|
@@ -440,7 +440,7 @@ void RewriterView::applyChanges()
|
||||
if (modelToTextMerger()->hasNoPendingChanges())
|
||||
return; // quick exit: nothing to be done.
|
||||
|
||||
clearErrors();
|
||||
clearErrorAndWarnings();
|
||||
|
||||
if (inErrorState()) {
|
||||
const QString content = textModifierContent();
|
||||
@@ -474,17 +474,28 @@ void RewriterView::applyChanges()
|
||||
}
|
||||
}
|
||||
|
||||
QList<RewriterError> RewriterView::warnings() const
|
||||
{
|
||||
return m_warnings;
|
||||
}
|
||||
|
||||
QList<RewriterError> RewriterView::errors() const
|
||||
{
|
||||
return m_errors;
|
||||
}
|
||||
|
||||
void RewriterView::clearErrors()
|
||||
void RewriterView::clearErrorAndWarnings()
|
||||
{
|
||||
m_errors.clear();
|
||||
m_warnings.clear();
|
||||
emit errorsChanged(m_errors);
|
||||
}
|
||||
|
||||
void RewriterView::setWarnings(const QList<RewriterError> &warnings)
|
||||
{
|
||||
m_warnings = warnings;
|
||||
}
|
||||
|
||||
void RewriterView::setErrors(const QList<RewriterError> &errors)
|
||||
{
|
||||
m_errors = errors;
|
||||
|
@@ -943,7 +943,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
|
||||
ModelNode modelRootNode = m_rewriterView->rootModelNode();
|
||||
syncNode(modelRootNode, astRootNode, &ctxt, differenceHandler);
|
||||
m_rewriterView->positionStorage()->cleanupInvalidOffsets();
|
||||
m_rewriterView->clearErrors();
|
||||
m_rewriterView->clearErrorAndWarnings();
|
||||
|
||||
setActive(false);
|
||||
return true;
|
||||
|
@@ -233,7 +233,7 @@ void QmlDesignerPlugin::hideDesigner()
|
||||
{
|
||||
if (currentDesignDocument()
|
||||
&& currentModel()
|
||||
&& !currentDesignDocument()->hasQmlSyntaxErrors())
|
||||
&& !currentDesignDocument()->hasQmlParseErrors())
|
||||
jumpTextCursorToSelectedModelNode();
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ void QmlDesignerPlugin::activateAutoSynchronization()
|
||||
viewManager().attachComponentView();
|
||||
viewManager().attachViewsExceptRewriterAndComponetView();
|
||||
|
||||
QList<RewriterError> errors = currentDesignDocument()->qmlSyntaxErrors();
|
||||
QList<RewriterError> errors = currentDesignDocument()->qmlParseErrors();
|
||||
if (errors.isEmpty()) {
|
||||
selectModelNodeUnderTextCursor();
|
||||
data->mainWidget->enableWidgets();
|
||||
|
Reference in New Issue
Block a user