CppEditor: quick fix to generate getters and setters

This does not take namespaces on the implementation side
into account and does not properly position/indent things.

Task-number: QTCREATORBUG-1890
Change-Id: I779d12fefc79521bce38361729d4f66dada71147
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Erik Verbruggen
2013-01-23 15:41:15 +01:00
parent 794b41581b
commit 72db7a8f52
10 changed files with 462 additions and 26 deletions

View File

@@ -63,7 +63,7 @@ using namespace CppTools::Internal;
using namespace TextEditor;
using namespace Core;
struct TestData
struct TestCase
{
QByteArray srcText;
int pos;
@@ -72,7 +72,7 @@ struct TestData
QTextDocument *doc;
};
static QStringList getCompletions(TestData &data)
static QStringList getCompletions(TestCase &data)
{
QStringList completions;
@@ -96,7 +96,7 @@ static QStringList getCompletions(TestData &data)
return completions;
}
static void setup(TestData *data)
static void setup(TestCase *data)
{
data->pos = data->srcText.indexOf('@');
QVERIFY(data->pos != -1);
@@ -120,7 +120,7 @@ static void setup(TestData *data)
void CppToolsPlugin::test_completion_forward_declarations_present()
{
TestData data;
TestCase data;
data.srcText = "\n"
"class Foo\n"
"{\n"
@@ -154,7 +154,7 @@ void CppToolsPlugin::test_completion_forward_declarations_present()
void CppToolsPlugin::test_completion_inside_parentheses_c_style_conversion()
{
TestData data;
TestCase data;
data.srcText = "\n"
"class Base\n"
"{\n"
@@ -195,7 +195,7 @@ void CppToolsPlugin::test_completion_inside_parentheses_c_style_conversion()
void CppToolsPlugin::test_completion_inside_parentheses_cast_operator_conversion()
{
TestData data;
TestCase data;
data.srcText = "\n"
"class Base\n"
"{\n"
@@ -235,7 +235,7 @@ void CppToolsPlugin::test_completion_inside_parentheses_cast_operator_conversion
void CppToolsPlugin::test_completion_basic_1()
{
TestData data;
TestCase data;
data.srcText = "\n"
"class Foo\n"
"{\n"
@@ -275,7 +275,7 @@ void CppToolsPlugin::test_completion_basic_1()
void CppToolsPlugin::test_completion_template_1()
{
TestData data;
TestCase data;
data.srcText = "\n"
"template <class T>\n"
"class Foo\n"
@@ -311,7 +311,7 @@ void CppToolsPlugin::test_completion_template_1()
void CppToolsPlugin::test_completion_template_2()
{
TestData data;
TestCase data;
data.srcText = "\n"
"template <class T>\n"
"struct List\n"
@@ -346,7 +346,7 @@ void CppToolsPlugin::test_completion_template_2()
void CppToolsPlugin::test_completion_template_3()
{
TestData data;
TestCase data;
data.srcText = "\n"
"template <class T>\n"
"struct List\n"
@@ -381,7 +381,7 @@ void CppToolsPlugin::test_completion_template_3()
void CppToolsPlugin::test_completion_template_4()
{
TestData data;
TestCase data;
data.srcText = "\n"
"template <class T>\n"
"struct List\n"
@@ -417,7 +417,7 @@ void CppToolsPlugin::test_completion_template_4()
void CppToolsPlugin::test_completion_template_5()
{
TestData data;
TestCase data;
data.srcText = "\n"
"template <class T>\n"
"struct List\n"
@@ -453,7 +453,7 @@ void CppToolsPlugin::test_completion_template_5()
void CppToolsPlugin::test_completion_template_6()
{
TestData data;
TestCase data;
data.srcText = "\n"
"class Item\n"
"{\n"
@@ -493,7 +493,7 @@ void CppToolsPlugin::test_completion_template_6()
void CppToolsPlugin::test_completion_template_7()
{
TestData data;
TestCase data;
data.srcText = "\n"
"struct Test\n"
"{\n"
@@ -535,7 +535,7 @@ void CppToolsPlugin::test_completion_template_7()
void CppToolsPlugin::test_completion_type_of_pointer_is_typedef()
{
TestData data;
TestCase data;
data.srcText = "\n"
"typedef struct Foo\n"
"{\n"
@@ -566,7 +566,7 @@ void CppToolsPlugin::test_completion()
QFETCH(QByteArray, code);
QFETCH(QStringList, expectedCompletions);
TestData data;
TestCase data;
data.srcText = code;
setup(&data);
@@ -1207,7 +1207,7 @@ void CppToolsPlugin::test_completion_enclosing_template_class_data()
void CppToolsPlugin::test_completion_instantiate_nested_class_when_enclosing_is_template()
{
TestData data;
TestCase data;
data.srcText = "\n"
"struct Foo \n"
"{\n"
@@ -1247,7 +1247,7 @@ void CppToolsPlugin::test_completion_instantiate_nested_class_when_enclosing_is_
void CppToolsPlugin::test_completion_instantiate_nested_of_nested_class_when_enclosing_is_template()
{
TestData data;
TestCase data;
data.srcText = "\n"
"struct Foo \n"
"{\n"