Commit 6682df07 authored by hjk's avatar hjk

Debugger: Rename and shuffle some QmlEngine functions

One more step to make it more similar to the other engines.

Change-Id: I0f028bf55b980c8acee9d80875ed5e9b4b565980
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 366f0dac
This diff is collapsed.
......@@ -39,6 +39,8 @@
#include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <QTextBlock>
using namespace Core;
using namespace QmlDebug;
using namespace QmlJS;
......@@ -266,5 +268,44 @@ void clearExceptionSelection()
}
}
QStringList highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage)
{
QStringList messages;
QList<IEditor *> editors = DocumentModel::editorsForFilePath(filePath);
// set up the format for the errors
QTextCharFormat errorFormat;
errorFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
errorFormat.setUnderlineColor(Qt::red);
foreach (IEditor *editor, editors) {
TextEditorWidget *ed = qobject_cast<TextEditorWidget *>(editor->widget());
if (!ed)
continue;
QList<QTextEdit::ExtraSelection> selections;
QTextEdit::ExtraSelection sel;
sel.format = errorFormat;
QTextCursor c(ed->document()->findBlockByNumber(lineNumber - 1));
const QString text = c.block().text();
for (int i = 0; i < text.size(); ++i) {
if (!text.at(i).isSpace()) {
c.setPosition(c.position() + i);
break;
}
}
c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
sel.cursor = c;
sel.format.setToolTip(errorMessage);
selections.append(sel);
ed->setExtraSelections(TextEditorWidget::DebuggerExceptionSelection, selections);
messages.append(QString::fromLatin1("%1: %2: %3").arg(filePath).arg(lineNumber).arg(errorMessage));
}
return messages;
}
} // Internal
} // Debugger
......@@ -39,7 +39,9 @@ namespace Internal {
bool adjustBreakpointLineAndColumn(const QString &filePath, quint32 *line, quint32 *column, bool *valid);
void appendDebugOutput(QtMsgType type, const QString &message, const QmlDebug::QDebugContextInfo &info);
void clearExceptionSelection();
QStringList highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage);
} // namespace Internal
} // namespace Debugger
......
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