Skip to content

Commit 58c3528

Browse files
authored
Support for @-syntax for attributes (#500)
Before: ![image](https://github.com/user-attachments/assets/2b54ad18-3bd8-45b0-874b-2bad954706af) After: ![image](https://github.com/user-attachments/assets/5d4fe1c9-42df-4c55-8680-3e4a66749595) Related issue dafny-lang/dafny#5795 @-attributes are now ready on Dafny, and they also have auto-complete from the language server. Having syntax hightlight will make them shine. I added a "visual regression test". It's unfortunate that they are not programmatically tested, but I hope that we will have semantic highlighting that will get rid of that issue.
1 parent 6d167f4 commit 58c3528

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/test/highlight/regression-highlight.dfy

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// This attribute should be colored
2+
@IsolateAssertions
3+
14
// Issue #386
25
method Test(thisNat: nat, dothis: nat) {
36
//^^^^ ^^^^ this should not be highlighted separatedly in blue

syntaxes/Dafny.tmLanguage

+43
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,49 @@
262262
<dict>
263263
<key>patterns</key>
264264
<array>
265+
<dict>
266+
<key>begin</key>
267+
<string>@([\w'\?]+)\(</string>
268+
<key>beginCaptures</key>
269+
<dict>
270+
<key>1</key>
271+
<dict>
272+
<key>name</key>
273+
<string>entity.other.attribute-name.dafny</string>
274+
</dict>
275+
</dict>
276+
<key>end</key>
277+
<string>\)</string>
278+
<key>name</key>
279+
<string>attribute</string>
280+
<key>patterns</key>
281+
<array>
282+
<dict>
283+
<key>include</key>
284+
<string>#code</string>
285+
</dict>
286+
</array>
287+
</dict>
288+
289+
<dict>
290+
<key>begin</key>
291+
<string>@([\w'\?]+)(?!\()</string>
292+
<key>beginCaptures</key>
293+
<dict>
294+
<key>1</key>
295+
<dict>
296+
<key>name</key>
297+
<string>entity.other.attribute-name.dafny</string>
298+
</dict>
299+
</dict>
300+
<key>end</key>
301+
<string>(?<=[\w'\?]+)</string>
302+
<key>name</key>
303+
<string>attribute</string>
304+
<key>patterns</key>
305+
<array>
306+
</array>
307+
</dict>
265308
<dict>
266309
<key>begin</key>
267310
<string>\{:(\w+)</string>

0 commit comments

Comments
 (0)