forked from qt-creator/qt-creator
CppEditor: Move CppEditorWidget::linkToSymbol to CppTools
* Cuts direct dependency to CPlusPlus from cppeditor.h, but cppfunctiondecldeflink.h still pulls it in. * Cuts direct dependency to cppeditor.h from cppvirtualfunctionassistprovider.cpp, but it still depends on cppeditorconstants.h. * Cuts direct dependency to cppeditor.h from cppelementevaluator.cpp. The long-term goal is to make the CppEditor independent from concrete code model backends. Change-Id: I291ee0d0da5fc5ed1a839a763fe7be11dcf7a6fb Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
@@ -592,26 +592,6 @@ void CppEditorWidget::slotCodeStyleSettingsChanged(const QVariant &)
|
||||
formatter.invalidateCache(document());
|
||||
}
|
||||
|
||||
CppEditorWidget::Link CppEditorWidget::linkToSymbol(CPlusPlus::Symbol *symbol)
|
||||
{
|
||||
if (!symbol)
|
||||
return Link();
|
||||
|
||||
const QString filename = QString::fromUtf8(symbol->fileName(),
|
||||
symbol->fileNameLength());
|
||||
|
||||
unsigned line = symbol->line();
|
||||
unsigned column = symbol->column();
|
||||
|
||||
if (column)
|
||||
--column;
|
||||
|
||||
if (symbol->isGenerated())
|
||||
column = 0;
|
||||
|
||||
return Link(filename, line, column);
|
||||
}
|
||||
|
||||
void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
|
||||
bool updateUseSelectionSynchronously)
|
||||
{
|
||||
|
@@ -35,10 +35,8 @@
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace CPlusPlus { class Symbol; }
|
||||
namespace CppTools { class SemanticInfo; }
|
||||
|
||||
namespace CppEditor {
|
||||
@@ -62,9 +60,6 @@ class CppEditorWidget : public TextEditor::TextEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
|
||||
|
||||
public:
|
||||
CppEditorWidget();
|
||||
~CppEditorWidget();
|
||||
|
@@ -34,6 +34,7 @@
|
||||
#include "cppeditorplugin.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
|
||||
#include <cplusplus/OverviewModel.h>
|
||||
#include <utils/treeviewcombobox.h>
|
||||
@@ -253,7 +254,7 @@ void CppEditorOutline::gotoSymbolInEditor()
|
||||
if (!symbol)
|
||||
return;
|
||||
|
||||
const TextEditor::TextEditorWidget::Link &link = CppEditorWidget::linkToSymbol(symbol);
|
||||
const TextEditor::TextEditorWidget::Link &link = CppTools::linkToSymbol(symbol);
|
||||
if (!link.hasValidTarget())
|
||||
return;
|
||||
|
||||
|
@@ -30,8 +30,6 @@
|
||||
|
||||
#include "cppelementevaluator.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <cpptools/typehierarchybuilder.h>
|
||||
|
||||
@@ -302,7 +300,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration)
|
||||
}
|
||||
|
||||
tooltip = overview.prettyType(declaration->type(), qualifiedName);
|
||||
link = CppEditorWidget::linkToSymbol(declaration);
|
||||
link = CppTools::linkToSymbol(declaration);
|
||||
helpMark = name;
|
||||
}
|
||||
|
||||
|
@@ -366,7 +366,7 @@ CppEditorWidget::Link attemptFuncDeclDef(const QTextCursor &cursor,
|
||||
}
|
||||
|
||||
if (target) {
|
||||
result = CppEditorWidget::linkToSymbol(target);
|
||||
result = CppTools::linkToSymbol(target);
|
||||
|
||||
unsigned startLine, startColumn, endLine, endColumn;
|
||||
document->translationUnit()->getTokenStartPosition(name->firstToken(), &startLine,
|
||||
@@ -714,7 +714,7 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs
|
||||
|
||||
}
|
||||
|
||||
link = m_widget->linkToSymbol(def ? def : symbol);
|
||||
link = CppTools::linkToSymbol(def ? def : symbol);
|
||||
link.linkTextStart = beginOfToken;
|
||||
link.linkTextEnd = endOfToken;
|
||||
return link;
|
||||
|
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "cppvirtualfunctionassistprovider.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppvirtualfunctionproposalitem.h"
|
||||
|
||||
@@ -41,6 +40,7 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <cpptools/functionutils.h>
|
||||
#include <cpptools/symbolfinder.h>
|
||||
#include <cpptools/typehierarchybuilder.h>
|
||||
@@ -132,7 +132,8 @@ public:
|
||||
{
|
||||
QTC_ASSERT(m_params.function, return 0);
|
||||
|
||||
AssistProposalItem *hintItem = new VirtualFunctionProposalItem(CppEditorWidget::Link());
|
||||
AssistProposalItem *hintItem
|
||||
= new VirtualFunctionProposalItem(TextEditor::TextEditorWidget::Link());
|
||||
hintItem->setText(QCoreApplication::translate("VirtualFunctionsAssistProcessor",
|
||||
"...searching overrides"));
|
||||
hintItem->setOrder(-1000);
|
||||
@@ -179,7 +180,8 @@ private:
|
||||
|
||||
AssistProposalItem *itemFromFunction(Function *func) const
|
||||
{
|
||||
const CppEditorWidget::Link link = CppEditorWidget::linkToSymbol(maybeDefinitionFor(func));
|
||||
const TextEditor::TextEditorWidget::Link link
|
||||
= CppTools::linkToSymbol(maybeDefinitionFor(func));
|
||||
QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(func));
|
||||
if (func->isPureVirtual())
|
||||
text += QLatin1String(" = 0");
|
||||
|
@@ -37,7 +37,6 @@
|
||||
#include <cplusplus/Symbols.h>
|
||||
#include <cplusplus/TypeOfExpression.h>
|
||||
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QTextCursor>
|
||||
|
||||
|
@@ -227,4 +227,26 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen
|
||||
return 0;
|
||||
}
|
||||
|
||||
TextEditor::TextEditorWidget::Link linkToSymbol(Symbol *symbol)
|
||||
{
|
||||
typedef TextEditor::TextEditorWidget::Link Link;
|
||||
|
||||
if (!symbol)
|
||||
return Link();
|
||||
|
||||
const QString filename = QString::fromUtf8(symbol->fileName(),
|
||||
symbol->fileNameLength());
|
||||
|
||||
unsigned line = symbol->line();
|
||||
unsigned column = symbol->column();
|
||||
|
||||
if (column)
|
||||
--column;
|
||||
|
||||
if (symbol->isGenerated())
|
||||
column = 0;
|
||||
|
||||
return Link(filename, line, column);
|
||||
}
|
||||
|
||||
} // CppTools
|
||||
|
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -59,6 +61,8 @@ bool CPPTOOLS_EXPORT isValidFirstIdentifierChar(const QChar &ch);
|
||||
bool CPPTOOLS_EXPORT isValidIdentifierChar(const QChar &ch);
|
||||
bool CPPTOOLS_EXPORT isValidIdentifier(const QString &s);
|
||||
|
||||
TextEditor::TextEditorWidget::Link CPPTOOLS_EXPORT linkToSymbol(CPlusPlus::Symbol *symbol);
|
||||
|
||||
QString CPPTOOLS_EXPORT identifierUnderCursor(QTextCursor *cursor);
|
||||
|
||||
bool CPPTOOLS_EXPORT isOwnershipRAIIType(CPlusPlus::Symbol *symbol,
|
||||
|
Reference in New Issue
Block a user