C++ editor: Highlighting static variables

Fix highlighting, find usages, marking for static variables.

Task-number: QTCREATORBUG-6822
Change-Id: I0c97c93c6c1024550907eec3820496df22a94e85
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Przemyslaw Gorszkowski
2013-01-29 13:18:08 +01:00
committed by Nikolai Kosjar
parent 8bb0134c50
commit 7fcc52bf47
4 changed files with 101 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ private Q_SLOTS:
void lambdaCaptureByReference();
void shadowedNames_1();
void shadowedNames_2();
void staticVariables();
// Qt keywords
void qproperty_1();
@@ -257,6 +258,52 @@ void tst_FindUsages::shadowedNames_2()
QCOMPARE(findUsages.usages().size(), 3);
}
void tst_FindUsages::staticVariables()
{
const QByteArray src = "\n"
"struct Outer\n"
"{\n"
" static int Foo;\n"
" struct Inner\n"
" {\n"
" Outer *outer;\n"
" void foo();\n"
" };\n"
"};\n"
"\n"
"int Outer::Foo = 42;\n"
"\n"
"void Outer::Inner::foo()\n"
"{\n"
" Foo = 7;\n"
" Outer::Foo = 7;\n"
" outer->Foo = 7;\n"
"}\n"
;
Document::Ptr doc = Document::create("staticVariables");
doc->setUtf8Source(src);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 3U);
Snapshot snapshot;
snapshot.insert(doc);
Class *c = doc->globalSymbolAt(0)->asClass();
QVERIFY(c);
QCOMPARE(c->name()->identifier()->chars(), "Outer");
QCOMPARE(c->memberCount(), 2U);
Declaration *d = c->memberAt(0)->asDeclaration();
QVERIFY(d);
QCOMPARE(d->name()->identifier()->chars(), "Foo");
FindUsages findUsages(src, doc, snapshot);
findUsages(d);
QCOMPARE(findUsages.usages().size(), 5);
}
#if 0
@interface Clazz {} +(void)method:(int)arg; @end
@implementation Clazz +(void)method:(int)arg {