forked from qt-creator/qt-creator
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: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
1738ff64a6
commit
cc1b66f1cc
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user