forked from qt-creator/qt-creator
C++ editor: Highlight member variable
Highlight member variable when there is also enum value with the same name Task-number: QTCREATORBUG-7525 Change-Id: I0990844a20fdf9e87a807fde10708344b9c3497b Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
f1cec4629e
commit
7db3b660b6
@@ -787,7 +787,11 @@ void CheckSymbols::checkName(NameAST *ast, Scope *scope)
|
||||
}
|
||||
}
|
||||
} else if (maybeType(ast->name) || maybeStatic(ast->name)) {
|
||||
maybeAddTypeOrStatic(_context.lookup(ast->name, scope), ast);
|
||||
if (! maybeAddTypeOrStatic(_context.lookup(ast->name, scope), ast)) {
|
||||
// it can be a local variable
|
||||
if (maybeField(ast->name))
|
||||
maybeAddField(_context.lookup(ast->name, scope), ast);
|
||||
}
|
||||
} else if (maybeField(ast->name)) {
|
||||
maybeAddField(_context.lookup(ast->name, scope), ast);
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ private slots:
|
||||
void test_checksymbols_FunctionUse();
|
||||
void test_checksymbols_PseudoKeywordUse();
|
||||
void test_checksymbols_StaticUse();
|
||||
void test_checksymbols_VariableHasTheSameNameAsEnumUse();
|
||||
};
|
||||
|
||||
void tst_CheckSymbols::test_checksymbols_TypeUse()
|
||||
@@ -377,5 +378,35 @@ void tst_CheckSymbols::test_checksymbols_StaticUse()
|
||||
TestData::check(source, expectedUses);
|
||||
}
|
||||
|
||||
void tst_CheckSymbols::test_checksymbols_VariableHasTheSameNameAsEnumUse()
|
||||
{
|
||||
const QByteArray source =
|
||||
"struct Foo\n"
|
||||
"{\n"
|
||||
" enum E { bar, baz };\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct Boo\n"
|
||||
"{\n"
|
||||
" int foo;\n"
|
||||
" int bar;\n"
|
||||
" int baz;\n"
|
||||
"};\n"
|
||||
;
|
||||
const QList<Use> expectedUses = QList<Use>()
|
||||
<< Use(1, 8, 3, SemanticInfo::TypeUse)
|
||||
<< Use(3, 19, 3, SemanticInfo::EnumerationUse)
|
||||
<< Use(3, 14, 3, SemanticInfo::EnumerationUse)
|
||||
<< Use(3, 10, 1, SemanticInfo::TypeUse)
|
||||
<< Use(6, 8, 3, SemanticInfo::TypeUse)
|
||||
<< Use(8, 9, 3, SemanticInfo::FieldUse)
|
||||
<< Use(9, 9, 3, SemanticInfo::FieldUse)
|
||||
<< Use(10, 9, 3, SemanticInfo::FieldUse)
|
||||
;
|
||||
|
||||
TestData::check(source, expectedUses);
|
||||
}
|
||||
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_CheckSymbols)
|
||||
#include "tst_checksymbols.moc"
|
||||
|
||||
Reference in New Issue
Block a user