diff options
author | Lorenz Haas <lykurg@gmail.com> | 2013-05-14 11:04:38 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-05-15 13:36:13 +0200 |
commit | 17a81ae1061a50e2d7184719ea20cc92a0d3a64c (patch) | |
tree | 16d4a48333b8983eac1ff2cb89d42bb5fa527b5c /src/plugins/cpptools/insertionpointlocator.cpp | |
parent | aa3aa7c455b80397c339aa49a49cf13afba453b9 (diff) |
CppTools: findMatchingDefinition handles const and volatile
Strict set to true, SymbolFinder::findMatchingDefinition will now also
check, if const and volatile matches.
Changed return type from 'Symbol *' to 'Function *' since only functions
are returned.
Change-Id: Ib55cb12b6c404e94fcefd0613b964e8caa425690
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cpptools/insertionpointlocator.cpp')
-rw-r--r-- | src/plugins/cpptools/insertionpointlocator.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/plugins/cpptools/insertionpointlocator.cpp b/src/plugins/cpptools/insertionpointlocator.cpp index 7bbcd3da7a..08d9722086 100644 --- a/src/plugins/cpptools/insertionpointlocator.cpp +++ b/src/plugins/cpptools/insertionpointlocator.cpp @@ -516,56 +516,44 @@ static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration, // find the declaration's definition CppTools::SymbolFinder symbolFinder; - Symbol *definition = symbolFinder.findMatchingDefinition(surroundingFunctionDecl, - changes.snapshot()); - if (!definition) + Function *definitionFunction = symbolFinder.findMatchingDefinition(surroundingFunctionDecl, + changes.snapshot()); + if (!definitionFunction) return noResult; unsigned line, column; if (suffix.isEmpty()) { - Function *definitionFunction = definition->asFunction(); - if (!definitionFunction) - return noResult; - - Document::Ptr targetDoc = changes.snapshot().document(QString::fromUtf8(definition->fileName())); + Document::Ptr targetDoc = changes.snapshot().document(QString::fromUtf8(definitionFunction->fileName())); if (!targetDoc) return noResult; targetDoc->translationUnit()->getPosition(definitionFunction->endOffset(), &line, &column); } else { // we don't have an offset to the start of the function definition, so we need to manually find it... - CppRefactoringFilePtr targetFile = changes.file(QString::fromUtf8(definition->fileName())); + CppRefactoringFilePtr targetFile = changes.file(QString::fromUtf8(definitionFunction->fileName())); if (!targetFile->isValid()) return noResult; FindFunctionDefinition finder(targetFile->cppDocument()->translationUnit()); - FunctionDefinitionAST *functionDefinition = finder(definition->line(), definition->column()); + FunctionDefinitionAST *functionDefinition = finder(definitionFunction->line(), definitionFunction->column()); if (!functionDefinition) return noResult; targetFile->cppDocument()->translationUnit()->getTokenStartPosition(functionDefinition->firstToken(), &line, &column); } - return InsertionLocation(QString::fromUtf8(definition->fileName()), prefix, suffix, line, column); + return InsertionLocation(QString::fromUtf8(definitionFunction->fileName()), prefix, suffix, line, column); } -QList<InsertionLocation> InsertionPointLocator::methodDefinition( - Declaration *declaration) const +QList<InsertionLocation> InsertionPointLocator::methodDefinition(Declaration *declaration) const { QList<InsertionLocation> result; if (!declaration) return result; CppTools::SymbolFinder symbolFinder; - if (Symbol *s = symbolFinder.findMatchingDefinition(declaration, - m_refactoringChanges.snapshot(), - true)) { - if (Function *f = s->asFunction()) { - if (f->isConst() == declaration->type().isConst() - && f->isVolatile() == declaration->type().isVolatile()) - return result; - } - } + if (symbolFinder.findMatchingDefinition(declaration, m_refactoringChanges.snapshot(), true)) + return result; const InsertionLocation location = nextToSurroundingDefinitions(declaration, m_refactoringChanges); if (location.isValid()) { |