Skip to content

Commit f1d127a

Browse files
committed
slightly improve preprocessor #569
1 parent b159c5e commit f1d127a

4 files changed

Lines changed: 35 additions & 12 deletions

File tree

autogenerated/cpp.embedded.macro.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

autogenerated/cpp.tmLanguage.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"endCaptures": { },
8888
"patterns": [
8989
{ "include": "#attributes_context" },
90-
{ "include": "#string_context" }
90+
{ "include": "#string_context" },
91+
{ "include": "#ever_present_context" }
9192
]
9293
},
9394
{
@@ -113,7 +114,8 @@
113114
"match": "(?<!\\w)(?:[a-zA-Z_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))(?:[a-zA-Z0-9_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))*(?!\\w)",
114115
"name": "entity.other.attribute.$0.cpp"
115116
},
116-
{ "include": "#number_literal" }
117+
{ "include": "#number_literal" },
118+
{ "include": "#ever_present_context" }
117119
]
118120
},
119121
"alignas_operator": {
@@ -1068,7 +1070,8 @@
10681070
"endCaptures": { },
10691071
"patterns": [
10701072
{ "include": "#attributes_context" },
1071-
{ "include": "#string_context" }
1073+
{ "include": "#string_context" },
1074+
{ "include": "#ever_present_context" }
10721075
]
10731076
},
10741077
{
@@ -1094,7 +1097,8 @@
10941097
"match": "(?<!\\w)(?:[a-zA-Z_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))(?:[a-zA-Z0-9_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))*(?!\\w)",
10951098
"name": "entity.other.attribute.$0.cpp"
10961099
},
1097-
{ "include": "#number_literal" }
1100+
{ "include": "#number_literal" },
1101+
{ "include": "#ever_present_context" }
10981102
]
10991103
},
11001104
"curly_initializer": {
@@ -2640,7 +2644,8 @@
26402644
"endCaptures": { },
26412645
"patterns": [
26422646
{ "include": "#attributes_context" },
2643-
{ "include": "#string_context" }
2647+
{ "include": "#string_context" },
2648+
{ "include": "#ever_present_context" }
26442649
]
26452650
},
26462651
{
@@ -2666,7 +2671,8 @@
26662671
"match": "(?<!\\w)(?:[a-zA-Z_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))(?:[a-zA-Z0-9_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))*(?!\\w)",
26672672
"name": "entity.other.attribute.$0.cpp"
26682673
},
2669-
{ "include": "#number_literal" }
2674+
{ "include": "#number_literal" },
2675+
{ "include": "#ever_present_context" }
26702676
]
26712677
},
26722678
"goto_statement": {
@@ -3285,7 +3291,8 @@
32853291
"endCaptures": { },
32863292
"patterns": [
32873293
{ "include": "#attributes_context" },
3288-
{ "include": "#string_context" }
3294+
{ "include": "#string_context" },
3295+
{ "include": "#ever_present_context" }
32893296
]
32903297
},
32913298
{
@@ -3311,7 +3318,8 @@
33113318
"match": "(?<!\\w)(?:[a-zA-Z_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))(?:[a-zA-Z0-9_]|(?:\\\\u[0-9a-fA-F]{4}|\\\\U[0-9a-fA-F]{8}))*(?!\\w)",
33123319
"name": "entity.other.attribute.$0.cpp"
33133320
},
3314-
{ "include": "#number_literal" }
3321+
{ "include": "#number_literal" },
3322+
{ "include": "#ever_present_context" }
33153323
]
33163324
},
33173325
"namespace_alias": {
@@ -4641,7 +4649,8 @@
46414649
"7": { "name": "comment.block.cpp" },
46424650
"8": { "name": "comment.block.cpp punctuation.definition.comment.end.cpp" }
46434651
}
4644-
}
4652+
},
4653+
{ "include": "#ever_present_context" }
46454654
]
46464655
},
46474656
"parameter_class": {
@@ -5032,7 +5041,8 @@
50325041
"8": { "name": "comment.block.cpp punctuation.definition.comment.end.cpp" }
50335042
}
50345043
},
5035-
{ "include": "#evaluation_context" }
5044+
{ "include": "#evaluation_context" },
5045+
{ "include": "#ever_present_context" }
50365046
]
50375047
},
50385048
"parameter_struct": {

language_examples/#569.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
int func1(int); // highlighted correctly
4+
5+
#ifdef FOO
6+
[[
7+
#endif
8+
9+
int func2(int); // not highlighted

main/main.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
591591
includes: [
592592
:attributes_context,
593593
:string_context,
594+
:ever_present_context,
594595
],
595596
),
596597
Pattern.new(match: /using/, tag_as: "keyword.other.using.directive").then(@spaces).then(
@@ -605,6 +606,7 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
605606
),
606607
Pattern.new(match: variable_name, tag_as: "entity.other.attribute.$match"),
607608
:number_literal,
609+
:ever_present_context,
608610
]
609611
)
610612
end
@@ -1780,7 +1782,8 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
17801782
:template_call_range,
17811783
# # tag the reference and dereference operator
17821784
ref_deref[],
1783-
:evaluation_context # this is part of the #282 workaround
1785+
:evaluation_context, # this is part of the #282 workaround
1786+
:ever_present_context,
17841787
]
17851788
)
17861789
grammar[:parameter] = PatternRange.new(
@@ -1880,6 +1883,7 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
18801883
:template_call_range,
18811884
# tag the reference and dereference operator
18821885
ref_deref[],
1886+
:ever_present_context,
18831887
]
18841888
)
18851889
#

0 commit comments

Comments
 (0)