TextEditor: Introduce some convenience text accessors in the editor

And adjust users.

Change-Id: I9329257cfa5f3298731deb07c2881bc37d9a051d
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-08-27 11:57:32 +02:00
parent d2c243464e
commit 2a5c602341
19 changed files with 111 additions and 104 deletions

View File

@@ -62,23 +62,15 @@ static void moveCursorToEndOfName(QTextCursor *tc)
// We cannot depend on this since CppEditor plugin code is internal and requires building the implementation files ourselves
CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor()
{
IEditor *editor = EditorManager::currentEditor();
TextEditor::BaseTextEditor *editor = TextEditor::BaseTextEditor::currentTextEditor();
if (!editor)
return 0;
TextEditor::BaseTextEditor *textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor);
if (!textEditor)
return 0;
TextEditor::BaseTextEditorWidget *editorWidget = textEditor->editorWidget();
if (!editorWidget)
return 0;
QTextCursor tc;
tc = editorWidget->textCursor();
QTextCursor tc = editor->textCursor();
int line = 0;
int column = 0;
const int pos = tc.position();
editorWidget->convertPosition(pos, &line, &column);
editor->convertPosition(pos, &line, &column);
const CPlusPlus::Snapshot &snapshot = CppTools::CppModelManagerInterface::instance()->snapshot();
CPlusPlus::Document::Ptr doc = snapshot.document(editor->document()->filePath());