CppTools: Move function to BuiltinEditorDocumentProcessor

It's only needed there.

Change-Id: Id12aa9d0fdf50b3292316426587677f79a09a9e9
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-12-15 12:09:32 +01:00
parent beb977dc8a
commit cbdcd1e4a7
3 changed files with 43 additions and 51 deletions

View File

@@ -33,13 +33,7 @@
#include "cppmodelmanager.h"
#include "editordocumenthandle.h"
#include <texteditor/fontsettings.h>
#include <texteditor/quickfix.h>
#include <texteditor/texteditorsettings.h>
#include <utils/qtcassert.h>
#include <QTextBlock>
namespace CppTools {
@@ -55,7 +49,6 @@ BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(
TextEditor::TextDocument *document)
: m_baseTextDocument(document)
{
QTC_CHECK(document);
}
BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor()
@@ -81,46 +74,6 @@ BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &fil
return 0;
}
QList<QTextEdit::ExtraSelection> BaseEditorDocumentProcessor::toTextEditorSelections(
const QList<CPlusPlus::Document::DiagnosticMessage> &diagnostics,
QTextDocument *textDocument)
{
const TextEditor::FontSettings &fontSettings = TextEditor::TextEditorSettings::instance()->fontSettings();
QTextCharFormat warningFormat = fontSettings.toTextCharFormat(TextEditor::C_WARNING);
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
QList<QTextEdit::ExtraSelection> result;
foreach (const CPlusPlus::Document::DiagnosticMessage &m, diagnostics) {
QTextEdit::ExtraSelection sel;
if (m.isWarning())
sel.format = warningFormat;
else
sel.format = errorFormat;
QTextCursor c(textDocument->findBlockByNumber(m.line() - 1));
const QString text = c.block().text();
const int startPos = m.column() > 0 ? m.column() - 1 : 0;
if (m.length() > 0 && startPos + m.length() <= (unsigned)text.size()) {
c.setPosition(c.position() + startPos);
c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, m.length());
} else {
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(m.text());
result.append(sel);
}
return result;
}
void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future,
BaseEditorDocumentParser::Ptr parser,
BaseEditorDocumentParser::InMemoryInfo info)