Skip to content

Commit bf54586

Browse files
Use constructor names for unqualified imported values (#120)
1 parent 5efbe4f commit bf54586

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

grammar.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@ module.exports = grammar({
9393
optional(seq("as", field("alias", $.identifier)))
9494
),
9595
seq(
96-
optional("type"),
96+
"type",
9797
field("name", $.type_identifier),
9898
optional(seq("as", field("alias", $.type_identifier)))
99+
),
100+
seq(
101+
field("name", $.constructor_name),
102+
optional(seq("as", field("alias", $.constructor_name)))
99103
)
100104
),
101105

test/corpus/imports.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import a.{b}
2121
import a/b.{c, d}
2222
import a/b.{c as d, e}
2323
import a/b.{c, D as E}
24+
import a/b.{A as B, type C as D}
2425

2526
--------------------------------------------------------------------------------
2627

@@ -50,6 +51,15 @@ import a/b.{c, D as E}
5051
imports: (unqualified_imports
5152
(unqualified_import
5253
name: (identifier))
54+
(unqualified_import
55+
name: (constructor_name)
56+
alias: (constructor_name))))
57+
(import
58+
module: (module)
59+
imports: (unqualified_imports
60+
(unqualified_import
61+
name: (constructor_name)
62+
alias: (constructor_name))
5363
(unqualified_import
5464
name: (type_identifier)
5565
alias: (type_identifier)))))
@@ -61,6 +71,7 @@ Aliased imports
6171
import a/b.{c as d} as e
6272
import animal/cat as kitty
6373
import animal.{Cat as Kitty} as a
74+
import animal.{type Cat as Kitty} as a
6475
import animal.{}
6576

6677
--------------------------------------------------------------------------------
@@ -76,6 +87,13 @@ import animal.{}
7687
(import
7788
module: (module)
7889
alias: (identifier))
90+
(import
91+
module: (module)
92+
imports: (unqualified_imports
93+
(unqualified_import
94+
name: (constructor_name)
95+
alias: (constructor_name)))
96+
alias: (identifier))
7997
(import
8098
module: (module)
8199
imports: (unqualified_imports

test/corpus/whole_files.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub fn negate(bool: Bool) -> Bool {
161161
module: (module)
162162
imports: (unqualified_imports
163163
(unqualified_import
164-
name: (type_identifier))))
164+
name: (constructor_name))))
165165
(statement_comment)
166166
(statement_comment)
167167
(statement_comment)
@@ -234,7 +234,7 @@ fn foo(a,) {
234234
(module)
235235
(unqualified_imports
236236
(unqualified_import
237-
(type_identifier))))
237+
(constructor_name))))
238238
(constant
239239
(identifier)
240240
(tuple_type

test/tags/frame.gleam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import gleam/option.{Option, Some, None}
1+
import gleam/option.{type Option, Some, None}
22
// ^ reference.module
3-
// ^ reference.type
4-
// ^ reference.type
5-
// ^ reference.type
3+
// ^ reference.type
4+
// ^ reference.constructor
5+
// ^ reference.constructor
66
import gleam/bit_builder
77
// ^ reference.module
88

0 commit comments

Comments
 (0)