Commit 628375a5 authored by Marco Bubke's avatar Marco Bubke Committed by Kai Koehne

Extent the rewriter exception with a document text attribute

This makes it easier to find problems.

Reviewed-by: kkoehne
parent 386dac2c
......@@ -4,8 +4,10 @@ using namespace QmlDesigner;
RewritingException::RewritingException(int line,
const QString &function,
const QString &file, const QString &description):
Exception(line, function, file), m_description(description)
const QString &file,
const QString &description,
const QString &documentTextContent):
Exception(line, function, file), m_description(description), m_documentTextContent(documentTextContent)
{
}
......@@ -18,3 +20,8 @@ QString RewritingException::description() const
{
return m_description;
}
QString RewritingException::documentTextContent() const
{
return m_documentTextContent;
}
......@@ -134,6 +134,7 @@ public:
TextModifier *textModifier() const;
void setTextModifier(TextModifier *textModifier);
QString textModifierContent() const;
Internal::ModelNodePositionStorage *positionStorage() const
{ return m_positionStorage; }
......
......@@ -10,12 +10,16 @@ class RewritingException: public Exception
public:
RewritingException(int line,
const QString &function,
const QString &file, const QString &description);
const QString &file,
const QString &description,
const QString &documentTextContent);
virtual QString type() const;
virtual QString description() const;
QString documentTextContent() const;
private:
QString m_description;
QString m_documentTextContent;
};
} // namespace QmlDesigner
......
......@@ -403,7 +403,7 @@ void ModelPrivate::resetModelByRewriter(const QString &description)
}
Q_ASSERT(rewriterView);
rewriterView->resetToLastCorrectQml();
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, description);
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, description, rewriterView->textModifierContent());
}
......
......@@ -382,6 +382,14 @@ void RewriterView::setTextModifier(TextModifier *textModifier)
connect(m_textModifier, SIGNAL(textChanged()), this, SLOT(qmlTextChanged()));
}
QString RewriterView::textModifierContent() const
{
if (textModifier())
return textModifier()->text();
return QString();
}
void RewriterView::applyModificationGroupChanges()
{
Q_ASSERT(transactionLevel == 0);
......@@ -397,7 +405,7 @@ void RewriterView::applyChanges()
if (inErrorState()) {
qDebug() << "RewriterView::applyChanges() got called while in error state. Will do a quick-exit now.";
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, "RewriterView::applyChanges() already in error state");
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, "RewriterView::applyChanges() already in error state", textModifierContent());
}
try {
......@@ -410,7 +418,7 @@ void RewriterView::applyChanges()
}
if (inErrorState()) {
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, m_rewritingErrorMessage);
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, m_rewritingErrorMessage, textModifierContent());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment