Commit 6f3dc319 authored by Christian Kamm's avatar Christian Kamm
Browse files

C++ editor: Prefer to use extra selections to find diagnostics.

Change-Id: I5f1c6e29c8386018cfd4d45d8ee63fc3e24311f6
Reviewed-on: http://codereview.qt.nokia.com/3484

Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent 47789fb4
...@@ -109,7 +109,7 @@ void CppElementEvaluator::execute() ...@@ -109,7 +109,7 @@ void CppElementEvaluator::execute()
const int pos = m_tc.position(); const int pos = m_tc.position();
m_editor->convertPosition(pos, &line, &column); m_editor->convertPosition(pos, &line, &column);
checkDiagnosticMessage(doc, line); checkDiagnosticMessage(pos);
if (!matchIncludeFile(doc, line) && !matchMacroInUse(doc, pos)) { if (!matchIncludeFile(doc, line) && !matchMacroInUse(doc, pos)) {
CppTools::moveCursorToEndOfIdentifier(&m_tc); CppTools::moveCursorToEndOfIdentifier(&m_tc);
...@@ -130,12 +130,12 @@ void CppElementEvaluator::execute() ...@@ -130,12 +130,12 @@ void CppElementEvaluator::execute()
} }
} }
void CppElementEvaluator::checkDiagnosticMessage(const CPlusPlus::Document::Ptr &document, void CppElementEvaluator::checkDiagnosticMessage(int pos)
unsigned line)
{ {
foreach (const Document::DiagnosticMessage &m, document->diagnosticMessages()) { foreach (const QTextEdit::ExtraSelection &sel,
if (m.line() == line) { m_editor->extraSelections(TextEditor::BaseTextEditorWidget::CodeWarningsSelection)) {
m_diagnosis = m.text(); if (pos >= sel.cursor.selectionStart() && pos <= sel.cursor.selectionEnd()) {
m_diagnosis = sel.format.toolTip();
break; break;
} }
} }
......
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
private: private:
void clear(); void clear();
void checkDiagnosticMessage(const CPlusPlus::Document::Ptr &document, unsigned line); void checkDiagnosticMessage(int pos);
bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line); bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line);
bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos); bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos);
void handleLookupItemMatch(const CPlusPlus::Snapshot &snapshot, void handleLookupItemMatch(const CPlusPlus::Snapshot &snapshot,
......
...@@ -1084,6 +1084,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc) ...@@ -1084,6 +1084,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
} }
c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
sel.cursor = c; sel.cursor = c;
sel.format.setToolTip(m.text());
selections.append(sel); selections.append(sel);
} }
#endif #endif
......
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