CppEditor: InsertDefFromDecl: Hide when definition already exists

"Add Definition Inside/Outside Class" was wrongly shown when there was
already an definition outside the class.

Change-Id: I6409080c6a1a3abdd4511f7db14ecb4f63458411
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Lorenz Haas
2013-05-14 11:10:15 +02:00
committed by Nikolai Kosjar
parent 17a81ae106
commit d25c5f35ca
3 changed files with 23 additions and 0 deletions

View File

@@ -2621,6 +2621,13 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
const QString cppFileName = correspondingHeaderOrSource(
interface->fileName(), &isHeaderFile);
// Check if there is already a definition
CppTools::SymbolFinder symbolFinder;
if (symbolFinder.findMatchingDefinition(decl, interface->snapshot(),
true)) {
return;
}
// Insert Position: Implementation File
if (isHeaderFile && !cppFileName.isEmpty()) {
CppRefactoringChanges refactoring(interface->snapshot());