forked from qt-creator/qt-creator
CppEditor: Return on invalid code in ExtractLiteralAsParameter::match
No declarator was provided but we assumed one. Task-number: QTCREATORBUG-12853 Change-Id: I5faf96b63f39aff43c0165f7277345737e53f191 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
committed by
Eike Ziller
parent
be3dbd2699
commit
a01f6cadf4
@@ -201,13 +201,14 @@ private slots:
|
||||
void test_quickfix_ExtractLiteralAsParameter_typeDeduction();
|
||||
void test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles();
|
||||
void test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles();
|
||||
void test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode();
|
||||
|
||||
void test_quickfix_InsertVirtualMethods_data();
|
||||
void test_quickfix_InsertVirtualMethods();
|
||||
void test_quickfix_InsertVirtualMethods_implementationFile();
|
||||
void test_quickfix_InsertVirtualMethods_BaseClassInNamespace();
|
||||
|
||||
// tests for "Include Hiererchy"
|
||||
// tests for "Include Hierarchy"
|
||||
void test_includehierarchy_data();
|
||||
void test_includehierarchy();
|
||||
|
||||
|
||||
@@ -3614,3 +3614,21 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_sep
|
||||
ExtractLiteralAsParameter factory;
|
||||
QuickFixTestCase(testFiles, &factory);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode()
|
||||
{
|
||||
QList<QuickFixTestDocument::Ptr> testFiles;
|
||||
QByteArray original;
|
||||
QByteArray expected;
|
||||
|
||||
original =
|
||||
"T(\"test\")\n"
|
||||
"{\n"
|
||||
" const int i = @14;\n"
|
||||
"}\n";
|
||||
expected = original;
|
||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
ExtractLiteralAsParameter factory;
|
||||
QuickFixTestCase(testFiles, &factory);
|
||||
}
|
||||
|
||||
@@ -3884,13 +3884,15 @@ void ExtractLiteralAsParameter::match(const CppQuickFixInterface &interface,
|
||||
return;
|
||||
}
|
||||
|
||||
FunctionDeclaratorAST *functionDeclarator
|
||||
= function->declarator->postfix_declarator_list->value->asFunctionDeclarator();
|
||||
if (functionDeclarator
|
||||
&& functionDeclarator->parameter_declaration_clause
|
||||
&& functionDeclarator->parameter_declaration_clause->dot_dot_dot_token) {
|
||||
// Do not handle functions with ellipsis parameter.
|
||||
PostfixDeclaratorListAST * const declaratorList = function->declarator->postfix_declarator_list;
|
||||
if (!declaratorList)
|
||||
return;
|
||||
if (FunctionDeclaratorAST *declarator = declaratorList->value->asFunctionDeclarator()) {
|
||||
if (declarator->parameter_declaration_clause
|
||||
&& declarator->parameter_declaration_clause->dot_dot_dot_token) {
|
||||
// Do not handle functions with ellipsis parameter.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const int priority = path.size() - 1;
|
||||
|
||||
Reference in New Issue
Block a user