Skip to content

Commit 1b3ecf7

Browse files
Rename module highlight token (#16)
* Rename module highlight token * Fix CRLF in scanner lookahead
1 parent de3ec57 commit 1b3ecf7

File tree

9 files changed

+33
-30
lines changed

9 files changed

+33
-30
lines changed

queries/highlights.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@
6262
(float)
6363
] @number
6464

65-
(alias) @type
65+
(alias) @module
6666

6767
(call
6868
target: (dot
69-
left: (atom) @type))
69+
left: (atom) @module))
7070

7171
(char) @constant
7272

src/scanner.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ bool is_inline_whitespace(int32_t c) {
5656
}
5757

5858
bool is_newline(int32_t c) {
59-
return c == '\n';
59+
// Note: this implies \r\n is treated as two line breaks,
60+
// but in our case it's fine, since multiple line breaks
61+
// make no difference
62+
return c == '\n' || c == '\r';
6063
}
6164

6265
bool is_digit(int32_t c) {

test/highlight/anonymous.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343

4444
&Set.put(&1, &2)
4545
# <- operator
46-
# ^ type
46+
# ^ module
4747
# ^ operator
4848
# ^ function
4949
# ^ punctuation.bracket
@@ -55,7 +55,7 @@ end
5555
&( Set.put(&1, &1) )
5656
#<- operator
5757
#^ punctuation.bracket
58-
# ^ type
58+
# ^ module
5959
# ^ operator
6060
# ^ function
6161
# ^ punctuation.bracket

test/highlight/calls.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Path.expand("..", __DIR__)
2-
# ^ type
2+
# ^ module
33
# ^ operator
44
# ^ function
55
# ^ punctuation.bracket
@@ -35,7 +35,7 @@ hd([1,2])
3535
# ^ punctuation.bracket
3636

3737
Kernel.spawn(fn -> :ok end)
38-
# ^ type
38+
# ^ module
3939
# ^ operator
4040
# ^ function
4141
# ^ punctuation.bracket
@@ -46,20 +46,20 @@ Kernel.spawn(fn -> :ok end)
4646
# ^ punctuation.bracket
4747

4848
IO.ANSI.black
49-
# ^ type
49+
# ^ module
5050
# ^ operator
5151
# ^ function
5252

5353
Kernel.-(number)
54-
# ^ type
54+
# ^ module
5555
# ^ operator
5656
# ^ operator
5757
# ^ punctuation.bracket
5858
# ^ variable
5959
# ^ punctuation.bracket
6060

6161
Enum.map([1, 2], fn x ->
62-
# ^ type
62+
# ^ module
6363
# ^ operator
6464
# ^ function
6565
# ^ punctuation.bracket
@@ -81,7 +81,7 @@ end)
8181
# ^ punctuation.bracket
8282

8383
:erlang.abs(-1)
84-
# ^ type
84+
# ^ module
8585
# ^ operator
8686
# ^ function
8787
# ^ punctuation.bracket

test/highlight/data_structures.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,16 @@
160160

161161
%Long.Module.Name{name: "Silly"}
162162
# <- punctuation
163-
# ^ type
164-
# ^ type
163+
# ^ module
164+
# ^ module
165165
# ^ punctuation.bracket
166166
# ^ string.special.symbol
167167
# ^ string
168168
# ^ punctuation.bracket
169169

170170
%Long.Module.Name{s | height: {192, :cm}}
171171
# <- punctuation
172-
# ^ type
172+
# ^ module
173173
# ^ punctuation.bracket
174174
# ^ variable
175175
# ^ operator
@@ -185,7 +185,7 @@
185185
# ^ string
186186
# ^ punctuation.special
187187
# ^ punctuation
188-
# ^ type
188+
# ^ module
189189
# ^ punctuation.bracket
190190
# ^ variable
191191
# ^ operator

test/highlight/identifiers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ _018OP
55
# ^ comment.unused
66

77
A__0
8-
# ^ type
8+
# ^ module
99

1010
__MODULE__ ; __STACKTRACE__
1111
# ^ constant.builtin

test/highlight/kernel.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ end
139139

140140
raise RuntimeError, message: "This is not an error"
141141
# ^ keyword
142-
# ^ type
142+
# ^ module
143143
# ^ punctuation.delimiter
144144
# ^ string.special.symbol
145145
# ^ string
146146

147147
import Kernel, except: [spawn: 1, +: 2, /: 2, Unless: 2]
148148
# ^ keyword
149-
# ^ type
149+
# ^ module
150150
# ^ punctuation.delimiter
151151
# ^ string.special.symbol
152152
# ^ punctuation.bracket
@@ -165,11 +165,11 @@ import Kernel, except: [spawn: 1, +: 2, /: 2, Unless: 2]
165165

166166
alias Long.Module.Name, as: N0men123_and4
167167
# ^ keyword
168-
# ^ type
168+
# ^ module
169169
# ^ punctuation.delimiter
170170
# ^ string.special.symbol
171-
# ^ type
171+
# ^ module
172172

173173
use Bitwise
174174
# ^ keyword
175-
# ^ type
175+
# ^ module

test/highlight/module.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Long.Module.Name do
22
# ^ keyword
3-
# ^ type
4-
# ^ type
3+
# ^ module
4+
# ^ module
55
# ^ keyword
66

77
@moduledoc "Simple doc"
@@ -80,7 +80,7 @@ defmodule Long.Module.Name do
8080
# ^ attribute
8181
# ^ variable
8282
# ^ operator
83-
# ^ type
83+
# ^ module
8484
# ^ operator
8585
# ^ function
8686
# ^ punctuation.bracket
@@ -256,7 +256,7 @@ defmodule Long.Module.Name do
256256
# ^ punctuation.bracket
257257
# ^ punctuation.delimiter
258258
# ^ string.special.symbol
259-
# ^ type
259+
# ^ module
260260

261261
defmacro meta_function(name) do
262262
# ^ keyword
@@ -297,7 +297,7 @@ end
297297

298298
defprotocol Useless do
299299
# ^ keyword
300-
# ^ type
300+
# ^ module
301301
# ^ keyword
302302
def func(this)
303303
# ^ keyword
@@ -310,10 +310,10 @@ end
310310

311311
defimpl Useless, for: Atom do
312312
# ^ keyword
313-
# ^ type
313+
# ^ module
314314
# ^ punctuation.delimiter
315315
# ^ string.special.symbol
316-
# ^ type
316+
# ^ module
317317
# ^ keyword
318318
end
319319
# <- keyword

test/highlight/operators.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ y = true and false
7575
"hello" |> String.upcase |> String.downcase()
7676
# ^ string
7777
# ^ operator
78-
# ^ type
78+
# ^ module
7979
# ^ operator
8080
# ^ function
8181
# ^ operator
82-
# ^ type
82+
# ^ module
8383
# ^ operator
8484
# ^ function

0 commit comments

Comments
 (0)