Commit ab9846a9 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Joerg Bornemann

CppEditor: findLinkAt() delegates to FollowSymbolUnderCursor

Moves functionality of CPPEditorWidget::findLinkAt into a newly created
class FollowSymbolUnderCursor. This slim downs cppeditor.cpp a bit and
makes Follow Symbol Under Cursor more easily testable.

Change-Id: I106c7fbfc6869dd13c75381fbe87c90dc88998a7
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
parent 64c17eab
This diff is collapsed.
......@@ -120,6 +120,7 @@ public:
bool openLink(const Link &link, bool inNextSplit) { return openCppEditorAt(link, inNextSplit); }
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
static QString identifierUnderCursor(QTextCursor *macroCursor);
static QVector<TextEditor::TextStyle> highlighterFormatCategories();
......@@ -188,8 +189,6 @@ private Q_SLOTS:
private:
void markSymbols(const QTextCursor &tc, const CppTools::SemanticInfo &info);
bool sortedOutline() const;
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol,
const CPlusPlus::Snapshot &snapshot) const;
TextEditor::ITextEditor *openCppEditorAt(const QString &fileName, int line,
int column = 0);
......@@ -205,14 +204,7 @@ private:
Q_SLOT void abortDeclDefLink();
Link attemptFuncDeclDef(const QTextCursor &cursor,
const CPlusPlus::Document::Ptr &doc,
CPlusPlus::Snapshot snapshot) const;
Link findLinkAt(const QTextCursor &, bool resolveTarget = true);
Link findMacroLink(const QByteArray &name) const;
Link findMacroLink(const QByteArray &name, CPlusPlus::Document::Ptr doc,
const CPlusPlus::Snapshot &snapshot, QSet<QString> *processed) const;
QString identifierUnderCursor(QTextCursor *macroCursor) const;
bool openCppEditorAt(const Link &, bool inNextSplit = false);
QModelIndex indexForPosition(int line, int column,
......
......@@ -9,16 +9,17 @@ HEADERS += cppeditorplugin.h \
cppeditor.h \
cppelementevaluator.h \
cppfilewizard.h \
cppfollowsymbolundercursor.h
cppfunctiondecldeflink.h \
cpphighlighter.h \
cpphighlighterfactory.h \
cpphighlighter.h \
cpphoverhandler.h \
cppoutline.h \
cppquickfixassistant.h \
cppquickfixes.h \
cppquickfix.h \
cppsnippetprovider.h \
cpptypehierarchy.h
cpptypehierarchy.h \
SOURCES += cppeditorplugin.cpp \
cppautocompleter.cpp \
......@@ -26,6 +27,7 @@ SOURCES += cppeditorplugin.cpp \
cppeditor.cpp \
cppelementevaluator.cpp \
cppfilewizard.cpp \
cppfollowsymbolundercursor.cpp
cppfunctiondecldeflink.cpp \
cpphighlighter.cpp \
cpphighlighterfactory.cpp \
......@@ -35,7 +37,7 @@ SOURCES += cppeditorplugin.cpp \
cppquickfix.cpp \
cppquickfixes.cpp \
cppsnippetprovider.cpp \
cpptypehierarchy.cpp
cpptypehierarchy.cpp \
RESOURCES += cppeditor.qrc
......
......@@ -30,12 +30,14 @@ QtcPlugin {
"cppelementevaluator.h",
"cppfilewizard.cpp",
"cppfilewizard.h",
"cppfollowsymbolundercursor.cpp",
"cppfollowsymbolundercursor.h",
"cppfunctiondecldeflink.cpp",
"cppfunctiondecldeflink.h",
"cpphighlighter.cpp",
"cpphighlighter.h",
"cpphighlighterfactory.cpp",
"cpphighlighterfactory.h",
"cpphighlighter.h",
"cpphoverhandler.cpp",
"cpphoverhandler.h",
"cppoutline.cpp",
......@@ -61,7 +63,7 @@ QtcPlugin {
"cppquickfix_test_utils.cpp",
"cppquickfix_test_utils.h",
"fileandtokenactions_test.cpp",
"followsymbol_switchmethoddecldef_test.cpp"
"followsymbol_switchmethoddecldef_test.cpp",
]
cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
......
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPFOLLOWSYMBOLUNDERCURSOR_H
#define CPPFOLLOWSYMBOLUNDERCURSOR_H
#include <cplusplus/CppDocument.h>
#include <texteditor/basetexteditor.h>
#include <QTextCursor>
namespace CppTools { class SymbolFinder; }
namespace CppEditor {
namespace Internal {
class CPPEditorWidget;
class FollowSymbolUnderCursor
{
public:
typedef TextEditor::BaseTextEditorWidget::Link Link;
// Ownership of widget and symbolFinder is *not* transferred.
FollowSymbolUnderCursor(CPPEditorWidget *widget, const QTextCursor &cursor, bool resolveTarget,
const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
CppTools::SymbolFinder *symbolFinder);
Link findLink();
private:
Link attemptFuncDeclDef(const QTextCursor &cursor);
CPlusPlus::Symbol *findDefinition(CPlusPlus::Symbol *symbol,
const CPlusPlus::Snapshot &snapshot) const;
private:
CppEditor::Internal::CPPEditorWidget *m_widget;
const QTextCursor m_cursor;
const bool m_resolveTarget;
CPlusPlus::Snapshot m_snapshot;
CPlusPlus::Document::Ptr m_document; // from SemanticInfo, i.e. with AST
CppTools::SymbolFinder *m_symbolFinder;
};
} // namespace Internal
} // namespace CppEditor
#endif // CPPFOLLOWSYMBOLUNDERCURSOR_H
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