Commit e0725277 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Erik Verbruggen
Browse files

CppEditor: Remove CppEditorWidget dependency of CanonicalSymbol



Change-Id: I3c42d9df93756d9f85682465b9661d7e75ffa71e
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7c21f2ec
......@@ -29,23 +29,22 @@
#include "cppcanonicalsymbol.h"
#include "cppeditor.h"
#include <cpptools/cpptoolsreuse.h>
#include <texteditor/convenience.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <QTextCursor>
#include <QTextDocument>
using namespace CPlusPlus;
namespace CppEditor {
namespace Internal {
CanonicalSymbol::CanonicalSymbol(CppEditorWidget *editor,
const Document::Ptr &document,
CanonicalSymbol::CanonicalSymbol(const Document::Ptr &document,
const Snapshot &snapshot)
: m_editorWidget(editor),
m_document(document),
: m_document(document),
m_snapshot(snapshot)
{
m_typeOfExpression.init(document, snapshot);
......@@ -64,11 +63,11 @@ Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString
QTextCursor tc = cursor;
int line, column;
m_editorWidget->convertPosition(tc.position(), &line, &column);
TextEditor::Convenience::convertPosition(cursor.document(), tc.position(), &line, &column);
++column; // 1-based line and 1-based column
int pos = tc.position();
QTextDocument *textDocument = m_editorWidget->document();
QTextDocument *textDocument = cursor.document();
if (!CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
if (!(pos > 0 && CppTools::isValidIdentifierChar(textDocument->characterAt(pos - 1))))
return 0;
......
......@@ -39,13 +39,10 @@ QT_FORWARD_DECLARE_CLASS(QTextCursor)
namespace CppEditor {
namespace Internal {
class CppEditorWidget;
class CanonicalSymbol
{
public:
CanonicalSymbol(CppEditorWidget *editorWidget,
const CPlusPlus::Document::Ptr &document,
CanonicalSymbol(const CPlusPlus::Document::Ptr &document,
const CPlusPlus::Snapshot &snapshot);
const CPlusPlus::LookupContext &context() const;
......@@ -61,8 +58,6 @@ public:
CPlusPlus::TypeOfExpression &typeOfExpression);
private:
CppEditorWidget *m_editorWidget;
CPlusPlus::Document::Ptr m_document;
CPlusPlus::Snapshot m_snapshot;
CPlusPlus::TypeOfExpression m_typeOfExpression;
......
......@@ -309,7 +309,7 @@ void CppEditorWidget::findUsages()
if (const Macro *macro = CppTools::findCanonicalMacro(textCursor(), info.doc)) {
d->m_modelManager->findMacroUsages(*macro);
} else {
CanonicalSymbol cs(this, info.doc, info.snapshot);
CanonicalSymbol cs(info.doc, info.snapshot);
Symbol *canonicalSymbol = cs(textCursor());
if (canonicalSymbol)
d->m_modelManager->findUsages(canonicalSymbol, cs.context());
......@@ -328,7 +328,7 @@ void CppEditorWidget::renameUsages(const QString &replacement)
if (const Macro *macro = CppTools::findCanonicalMacro(textCursor(), info.doc)) {
d->m_modelManager->renameMacroUsages(*macro, replacement);
} else {
CanonicalSymbol cs(this, info.doc, info.snapshot);
CanonicalSymbol cs(info.doc, info.snapshot);
if (Symbol *canonicalSymbol = cs(textCursor()))
if (canonicalSymbol->identifier() != 0)
d->m_modelManager->renameUsages(canonicalSymbol, cs.context(), replacement);
......@@ -429,7 +429,7 @@ void CppEditorWidget::markSymbols(const QTextCursor &tc, const SemanticInfo &inf
setExtraSelections(CodeSemanticsSelection, selections);
} else {
CanonicalSymbol cs(this, info.doc, info.snapshot);
CanonicalSymbol cs(info.doc, info.snapshot);
QString expression;
if (Scope *scope = cs.getScopeAndExpression(tc, &expression)) {
if (d->m_referencesWatcher)
......
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