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