Commit e622d706 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

There's no need to store the diagnostic messages in the editor.

Store the error message in the QTextCharFormat of the extra selection.
parent f995022a
......@@ -158,16 +158,14 @@ void QmlHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
QTextCursor tc(scriptEditor->document());
tc.setPosition(pos);
const unsigned lineNumber = tc.block().blockNumber() + 1;
// We only want to show F1 if the tooltip matches the help id
bool showF1 = true;
foreach (const QmlJS::DiagnosticMessage &m, scriptEditor->diagnosticMessages()) {
if (m.loc.startLine == lineNumber) {
m_toolTip = m.message;
foreach (const QTextEdit::ExtraSelection &sel, scriptEditor->extraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection)) {
if (pos >= sel.cursor.selectionStart() && pos <= sel.cursor.selectionEnd()) {
showF1 = false;
break;
m_toolTip = sel.format.toolTip();
}
}
......
......@@ -563,20 +563,16 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
QList<QTextEdit::ExtraSelection> selections;
QTextCharFormat errorFormat;
errorFormat.setUnderlineColor(Qt::red);
errorFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline);
QTextEdit::ExtraSelection sel;
m_diagnosticMessages = doc->diagnosticMessages();
const QList<DiagnosticMessage> diagnosticMessages = doc->diagnosticMessages();
foreach (const DiagnosticMessage &d, m_diagnosticMessages) {
int line = d.loc.startLine;
int column = d.loc.startColumn;
foreach (const DiagnosticMessage &d, diagnosticMessages) {
if (d.isWarning())
continue;
if (column == 0)
column = 1;
const int line = d.loc.startLine;
const int column = qMax(1U, d.loc.startColumn);
QTextCursor c(document()->findBlockByNumber(line - 1));
sel.cursor = c;
......@@ -587,7 +583,9 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
else
sel.cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
sel.format = errorFormat;
sel.format.setUnderlineColor(Qt::red);
sel.format.setUnderlineStyle(QTextCharFormat::WaveUnderline);
sel.format.setToolTip(d.message);
selections.append(sel);
}
......
......@@ -125,9 +125,6 @@ public:
QList<Declaration> declarations() const;
QStringList keywords() const;
QList<QmlJS::DiagnosticMessage> diagnosticMessages() const
{ return m_diagnosticMessages; }
virtual void unCommentSelection();
SemanticInfo semanticInfo() const { return m_semanticInfo; }
......@@ -178,7 +175,6 @@ private:
QList<Declaration> m_declarations; // ### remove me
QMap<QString, QList<QmlJS::AST::SourceLocation> > m_ids; // ### remove me
int m_idsRevision; // ### remove me
QList<QmlJS::DiagnosticMessage> m_diagnosticMessages; // ### remove me
QmlModelManagerInterface *m_modelManager;
QmlJS::TypeSystem *m_typeSystem;
QTextCharFormat m_occurrencesFormat;
......
Supports Markdown
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