Commit cfd3b561 authored by Nikolai Kosjar's avatar Nikolai Kosjar

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: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent f0826649
...@@ -592,26 +592,6 @@ void CppEditorWidget::slotCodeStyleSettingsChanged(const QVariant &) ...@@ -592,26 +592,6 @@ void CppEditorWidget::slotCodeStyleSettingsChanged(const QVariant &)
formatter.invalidateCache(document()); 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, void CppEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo,
bool updateUseSelectionSynchronously) bool updateUseSelectionSynchronously)
{ {
......
...@@ -35,10 +35,8 @@ ...@@ -35,10 +35,8 @@
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <QScopedPointer> #include <QScopedPointer>
namespace CPlusPlus { class Symbol; }
namespace CppTools { class SemanticInfo; } namespace CppTools { class SemanticInfo; }
namespace CppEditor { namespace CppEditor {
...@@ -62,9 +60,6 @@ class CppEditorWidget : public TextEditor::TextEditorWidget ...@@ -62,9 +60,6 @@ class CppEditorWidget : public TextEditor::TextEditorWidget
{ {
Q_OBJECT Q_OBJECT
public:
static Link linkToSymbol(CPlusPlus::Symbol *symbol);
public: public:
CppEditorWidget(); CppEditorWidget();
~CppEditorWidget(); ~CppEditorWidget();
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "cppeditorplugin.h" #include "cppeditorplugin.h"
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolsreuse.h>
#include <cplusplus/OverviewModel.h> #include <cplusplus/OverviewModel.h>
#include <utils/treeviewcombobox.h> #include <utils/treeviewcombobox.h>
...@@ -253,7 +254,7 @@ void CppEditorOutline::gotoSymbolInEditor() ...@@ -253,7 +254,7 @@ void CppEditorOutline::gotoSymbolInEditor()
if (!symbol) if (!symbol)
return; return;
const TextEditor::TextEditorWidget::Link &link = CppEditorWidget::linkToSymbol(symbol); const TextEditor::TextEditorWidget::Link &link = CppTools::linkToSymbol(symbol);
if (!link.hasValidTarget()) if (!link.hasValidTarget())
return; return;
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include "cppelementevaluator.h" #include "cppelementevaluator.h"
#include "cppeditor.h"
#include <cpptools/cpptoolsreuse.h> #include <cpptools/cpptoolsreuse.h>
#include <cpptools/typehierarchybuilder.h> #include <cpptools/typehierarchybuilder.h>
...@@ -302,7 +300,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration) ...@@ -302,7 +300,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration)
} }
tooltip = overview.prettyType(declaration->type(), qualifiedName); tooltip = overview.prettyType(declaration->type(), qualifiedName);
link = CppEditorWidget::linkToSymbol(declaration); link = CppTools::linkToSymbol(declaration);
helpMark = name; helpMark = name;
} }
......
...@@ -366,7 +366,7 @@ CppEditorWidget::Link attemptFuncDeclDef(const QTextCursor &cursor, ...@@ -366,7 +366,7 @@ CppEditorWidget::Link attemptFuncDeclDef(const QTextCursor &cursor,
} }
if (target) { if (target) {
result = CppEditorWidget::linkToSymbol(target); result = CppTools::linkToSymbol(target);
unsigned startLine, startColumn, endLine, endColumn; unsigned startLine, startColumn, endLine, endColumn;
document->translationUnit()->getTokenStartPosition(name->firstToken(), &startLine, document->translationUnit()->getTokenStartPosition(name->firstToken(), &startLine,
...@@ -714,7 +714,7 @@ TextEditorWidget::Link FollowSymbolUnderCursor::findLink(const QTextCursor &curs ...@@ -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.linkTextStart = beginOfToken;
link.linkTextEnd = endOfToken; link.linkTextEnd = endOfToken;
return link; return link;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "cppvirtualfunctionassistprovider.h" #include "cppvirtualfunctionassistprovider.h"
#include "cppeditor.h"
#include "cppeditorconstants.h" #include "cppeditorconstants.h"
#include "cppvirtualfunctionproposalitem.h" #include "cppvirtualfunctionproposalitem.h"
...@@ -41,6 +40,7 @@ ...@@ -41,6 +40,7 @@
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <cpptools/cpptoolsreuse.h>
#include <cpptools/functionutils.h> #include <cpptools/functionutils.h>
#include <cpptools/symbolfinder.h> #include <cpptools/symbolfinder.h>
#include <cpptools/typehierarchybuilder.h> #include <cpptools/typehierarchybuilder.h>
...@@ -132,7 +132,8 @@ public: ...@@ -132,7 +132,8 @@ public:
{ {
QTC_ASSERT(m_params.function, return 0); 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", hintItem->setText(QCoreApplication::translate("VirtualFunctionsAssistProcessor",
"...searching overrides")); "...searching overrides"));
hintItem->setOrder(-1000); hintItem->setOrder(-1000);
...@@ -179,7 +180,8 @@ private: ...@@ -179,7 +180,8 @@ private:
AssistProposalItem *itemFromFunction(Function *func) const 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)); QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(func));
if (func->isPureVirtual()) if (func->isPureVirtual())
text += QLatin1String(" = 0"); text += QLatin1String(" = 0");
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <cplusplus/Symbols.h> #include <cplusplus/Symbols.h>
#include <cplusplus/TypeOfExpression.h> #include <cplusplus/TypeOfExpression.h>
#include <QSharedPointer> #include <QSharedPointer>
#include <QTextCursor> #include <QTextCursor>
......
...@@ -227,4 +227,26 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen ...@@ -227,4 +227,26 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen
return 0; 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 } // CppTools
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "cpptools_global.h" #include "cpptools_global.h"
#include <texteditor/texteditor.h>
#include <cplusplus/CppDocument.h> #include <cplusplus/CppDocument.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
...@@ -59,6 +61,8 @@ bool CPPTOOLS_EXPORT isValidFirstIdentifierChar(const QChar &ch); ...@@ -59,6 +61,8 @@ bool CPPTOOLS_EXPORT isValidFirstIdentifierChar(const QChar &ch);
bool CPPTOOLS_EXPORT isValidIdentifierChar(const QChar &ch); bool CPPTOOLS_EXPORT isValidIdentifierChar(const QChar &ch);
bool CPPTOOLS_EXPORT isValidIdentifier(const QString &s); bool CPPTOOLS_EXPORT isValidIdentifier(const QString &s);
TextEditor::TextEditorWidget::Link CPPTOOLS_EXPORT linkToSymbol(CPlusPlus::Symbol *symbol);
QString CPPTOOLS_EXPORT identifierUnderCursor(QTextCursor *cursor); QString CPPTOOLS_EXPORT identifierUnderCursor(QTextCursor *cursor);
bool CPPTOOLS_EXPORT isOwnershipRAIIType(CPlusPlus::Symbol *symbol, bool CPPTOOLS_EXPORT isOwnershipRAIIType(CPlusPlus::Symbol *symbol,
......
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