Commit cc1b66f1 authored by Lorenz Haas's avatar Lorenz Haas Committed by Erik Verbruggen
Browse files

CppTools: Open InsertionPointLocator::methodDefinition for symbols



Remove restricted use of declarations and add an option to define if
SymbolFinder should be used to find a matching definition for symbol.

Change-Id: If5cf5b11926e116766dd60dd3726b4fcf2e1c9f5
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 1738ff64
......@@ -363,7 +363,7 @@ public:
: ASTVisitor(translationUnit)
{}
void operator()(Declaration *decl, unsigned *line, unsigned *column)
void operator()(Symbol *decl, unsigned *line, unsigned *column)
{
// default to end of file
_bestToken.maybeSet(-1, translationUnit()->ast()->lastToken());
......@@ -470,7 +470,7 @@ static Declaration *isNonVirtualFunctionDeclaration(Symbol *s)
return declaration;
}
static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration, const CppRefactoringChanges &changes)
static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration, const CppRefactoringChanges &changes)
{
InsertionLocation noResult;
Class *klass = declaration->enclosingClass();
......@@ -545,15 +545,18 @@ static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration,
return InsertionLocation(QString::fromUtf8(definitionFunction->fileName()), prefix, suffix, line, column);
}
QList<InsertionLocation> InsertionPointLocator::methodDefinition(Declaration *declaration) const
QList<InsertionLocation> InsertionPointLocator::methodDefinition(Symbol *declaration,
bool useSymbolFinder) const
{
QList<InsertionLocation> result;
if (!declaration)
return result;
CppTools::SymbolFinder symbolFinder;
if (symbolFinder.findMatchingDefinition(declaration, m_refactoringChanges.snapshot(), true))
return result;
if (useSymbolFinder) {
CppTools::SymbolFinder symbolFinder;
if (symbolFinder.findMatchingDefinition(declaration, m_refactoringChanges.snapshot(), true))
return result;
}
const InsertionLocation location = nextToSurroundingDefinitions(declaration, m_refactoringChanges);
if (location.isValid()) {
......
......@@ -98,7 +98,8 @@ public:
const CPlusPlus::Class *clazz,
AccessSpec xsSpec) const;
QList<InsertionLocation> methodDefinition(CPlusPlus::Declaration *declaration) const;
QList<InsertionLocation> methodDefinition(CPlusPlus::Symbol *declaration,
bool useSymbolFinder = true) const;
private:
CppRefactoringChanges m_refactoringChanges;
......
Supports Markdown
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