@@ -38,7 +38,9 @@ void checkHighlightings(llvm::StringRef Code) {
38
38
{HighlightingKind::Class, " Class" },
39
39
{HighlightingKind::Enum, " Enum" },
40
40
{HighlightingKind::Namespace, " Namespace" },
41
- {HighlightingKind::EnumConstant, " EnumConstant" }};
41
+ {HighlightingKind::EnumConstant, " EnumConstant" },
42
+ {HighlightingKind::Field, " Field" },
43
+ {HighlightingKind::Method, " Method" }};
42
44
std::vector<HighlightingToken> ExpectedTokens;
43
45
for (const auto &KindString : KindToString) {
44
46
std::vector<HighlightingToken> Toks = makeHighlightingTokens (
@@ -54,14 +56,14 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
54
56
const char *TestCases[] = {
55
57
R"cpp(
56
58
struct $Class[[AS]] {
57
- double SomeMember;
59
+ double $Field[[ SomeMember]] ;
58
60
};
59
61
struct {
60
62
} $Variable[[S]];
61
63
void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
62
64
auto $Variable[[VeryLongVariableName]] = 12312;
63
65
$Class[[AS]] $Variable[[AA]];
64
- auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
66
+ auto $Variable[[L]] = $Variable[[AA]].$Field[[ SomeMember]] + $Variable[[A]];
65
67
auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
66
68
$Variable[[FN]](12312);
67
69
}
@@ -73,27 +75,27 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
73
75
auto $Variable[[Bou]] = $Function[[Gah]];
74
76
}
75
77
struct $Class[[A]] {
76
- void $Function [[abc]]();
78
+ void $Method [[abc]]();
77
79
};
78
80
)cpp" ,
79
81
R"cpp(
80
82
namespace $Namespace[[abc]] {
81
83
template<typename T>
82
84
struct $Class[[A]] {
83
- T t ;
85
+ T $Field[[t]] ;
84
86
};
85
87
}
86
88
template<typename T>
87
89
struct $Class[[C]] : $Namespace[[abc]]::A<T> {
88
- typename T::A* D ;
90
+ typename T::A* $Field[[D]] ;
89
91
};
90
92
$Namespace[[abc]]::$Class[[A]]<int> $Variable[[AA]];
91
93
typedef $Namespace[[abc]]::$Class[[A]]<int> AAA;
92
94
struct $Class[[B]] {
93
95
$Class[[B]]();
94
96
~$Class[[B]]();
95
97
void operator<<($Class[[B]]);
96
- $Class[[AAA]] AA ;
98
+ $Class[[AAA]] $Field[[AA]] ;
97
99
};
98
100
$Class[[B]]::$Class[[B]]() {}
99
101
$Class[[B]]::~$Class[[B]]() {}
@@ -112,8 +114,8 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
112
114
$EnumConstant[[Hi]],
113
115
};
114
116
struct $Class[[A]] {
115
- $Enum[[E]] EEE;
116
- $Enum[[EE]] EEEE;
117
+ $Enum[[E]] $Field[[ EEE]] ;
118
+ $Enum[[EE]] $Field[[ EEEE]] ;
117
119
};
118
120
int $Variable[[I]] = $EnumConstant[[Hi]];
119
121
$Enum[[E]] $Variable[[L]] = $Enum[[E]]::$EnumConstant[[B]];
@@ -140,6 +142,30 @@ TEST(SemanticHighlighting, GetsCorrectTokens) {
140
142
$Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::$EnumConstant[[Hi]];
141
143
::$Namespace[[vwz]]::$Class[[A]] $Variable[[B]];
142
144
::$Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[BB]];
145
+ )cpp" ,
146
+ R"cpp(
147
+ struct $Class[[D]] {
148
+ double $Field[[C]];
149
+ };
150
+ struct $Class[[A]] {
151
+ double $Field[[B]];
152
+ $Class[[D]] $Field[[E]];
153
+ static double $Variable[[S]];
154
+ void $Method[[foo]]() {
155
+ $Field[[B]] = 123;
156
+ this->$Field[[B]] = 156;
157
+ this->$Method[[foo]]();
158
+ $Method[[foo]]();
159
+ $Variable[[S]] = 90.1;
160
+ }
161
+ };
162
+ void $Function[[foo]]() {
163
+ $Class[[A]] $Variable[[AA]];
164
+ $Variable[[AA]].$Field[[B]] += 2;
165
+ $Variable[[AA]].$Method[[foo]]();
166
+ $Variable[[AA]].$Field[[E]].$Field[[C]];
167
+ $Class[[A]]::$Variable[[S]] = 90;
168
+ }
143
169
)cpp" };
144
170
for (const auto &TestCase : TestCases) {
145
171
checkHighlightings (TestCase);
0 commit comments