CPlusPlus: Add toLink method to the Symbol

Basically move it from CppTools to CPlusPlus
to be able to use it there.

Change-Id: I0af80f93bdc029824397ceafdf940cb86c4382b0
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-02-02 12:52:07 +01:00
parent 31f1713c75
commit c020f2448b
9 changed files with 30 additions and 31 deletions

View File

@@ -246,7 +246,7 @@ void CppEditorOutline::gotoSymbolInEditor()
if (!symbol)
return;
const Utils::Link &link = CppTools::linkToSymbol(symbol);
const Utils::Link &link = symbol->toLink();
if (!link.hasValidTarget())
return;

View File

@@ -129,7 +129,7 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration)
}
tooltip = overview.prettyType(declaration->type(), qualifiedName);
link = CppTools::linkToSymbol(declaration);
link = declaration->toLink();
helpMark = name;
}

View File

@@ -355,7 +355,7 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
}
if (target) {
result = CppTools::linkToSymbol(target);
result = target->toLink();
unsigned startLine, startColumn, endLine, endColumn;
document->translationUnit()->getTokenStartPosition(name->firstToken(), &startLine,
@@ -762,7 +762,7 @@ Link FollowSymbolUnderCursor::findLink(
}
link = CppTools::linkToSymbol(def ? def : symbol);
link = (def ? def : symbol)->toLink();
link.linkTextStart = beginOfToken;
link.linkTextEnd = endOfToken;
return link;

View File

@@ -230,26 +230,6 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen
return 0;
}
Utils::Link linkToSymbol(Symbol *symbol)
{
if (!symbol)
return Utils::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 Utils::Link(filename, line, column);
}
QSharedPointer<CppCodeModelSettings> codeModelSettings()
{
return CppTools::Internal::CppToolsPlugin::instance()->codeModelSettings();

View File

@@ -58,8 +58,6 @@ bool CPPTOOLS_EXPORT isValidFirstIdentifierChar(const QChar &ch);
bool CPPTOOLS_EXPORT isValidIdentifierChar(const QChar &ch);
bool CPPTOOLS_EXPORT isValidIdentifier(const QString &s);
Utils::Link CPPTOOLS_EXPORT linkToSymbol(CPlusPlus::Symbol *symbol);
QString CPPTOOLS_EXPORT identifierUnderCursor(QTextCursor *cursor);
bool CPPTOOLS_EXPORT isOwnershipRAIIType(CPlusPlus::Symbol *symbol,

View File

@@ -173,7 +173,7 @@ private:
VirtualFunctionProposalItem *itemFromFunction(Function *func) const
{
const Utils::Link link = CppTools::linkToSymbol(maybeDefinitionFor(func));
const Utils::Link link = maybeDefinitionFor(func)->toLink();
QString text = m_overview.prettyName(LookupContext::fullyQualifiedName(func));
if (func->isPureVirtual())
text += QLatin1String(" = 0");