diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-06-06 11:52:09 -0400 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2014-06-12 17:02:52 +0200 |
commit | a6e04c363f5d9fe5d84528c8e921989d8d6121e0 (patch) | |
tree | 19b8ea509e37735b2b483772246a96bf1b195108 /src/plugins/cpptools/cpphighlightingsupportinternal.cpp | |
parent | fc7f5ba364fb7a09a1038faf0f8c35b20c955810 (diff) | |
download | qt-creator-a6e04c363f5d9fe5d84528c8e921989d8d6121e0.tar.gz |
CppTools: CppHighlightingSupport takes a BaseTextDocument
...instead an ITextEditor.
The ITextEditor was only used to access the file path and QTextDocument
via the BaseTextEditorWidget.
Change-Id: Idef2b8162b992fe3718e16e2a046e2ff214846f2
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cpphighlightingsupportinternal.cpp')
-rw-r--r-- | src/plugins/cpptools/cpphighlightingsupportinternal.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/cpptools/cpphighlightingsupportinternal.cpp b/src/plugins/cpptools/cpphighlightingsupportinternal.cpp index 29bf316082..26dc9cf253 100644 --- a/src/plugins/cpptools/cpphighlightingsupportinternal.cpp +++ b/src/plugins/cpptools/cpphighlightingsupportinternal.cpp @@ -32,7 +32,8 @@ #include "cppchecksymbols.h" #include "cpptoolsreuse.h" -#include <texteditor/itexteditor.h> +#include <texteditor/basetextdocument.h> +#include <texteditor/convenience.h> #include <cplusplus/SimpleLexer.h> @@ -40,8 +41,9 @@ using namespace CPlusPlus; using namespace CppTools; using namespace CppTools::Internal; -CppHighlightingSupportInternal::CppHighlightingSupportInternal(TextEditor::ITextEditor *editor) - : CppHighlightingSupport(editor) +CppHighlightingSupportInternal::CppHighlightingSupportInternal( + TextEditor::BaseTextDocument *baseTextDocument) + : CppHighlightingSupport(baseTextDocument) { } @@ -56,10 +58,14 @@ QFuture<TextEditor::HighlightingResult> CppHighlightingSupportInternal::highligh typedef TextEditor::HighlightingResult Result; QList<Result> macroUses; + QTextDocument *textDocument = baseTextDocument()->document(); + using TextEditor::Convenience::convertPosition; + // Get macro definitions foreach (const CPlusPlus::Macro& macro, doc->definedMacros()) { int line, column; - editor()->convertPosition(macro.utf16CharOffset(), &line, &column); + convertPosition(textDocument, macro.utf16CharOffset(), &line, &column); + ++column; //Highlighting starts at (column-1) --> compensate here Result use(line, column, macro.nameToQString().size(), MacroUse); macroUses.append(use); @@ -86,7 +92,7 @@ QFuture<TextEditor::HighlightingResult> CppHighlightingSupportInternal::highligh continue; int line, column; - editor()->convertPosition(macro.utf16charsBegin(), &line, &column); + convertPosition(textDocument, macro.utf16charsBegin(), &line, &column); ++column; //Highlighting starts at (column-1) --> compensate here Result use(line, column, name.size(), MacroUse); macroUses.append(use); |