@dekobon/tree-sitter-groovy 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/grammar.js +752 -154
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/@dekobon+tree-sitter-groovy.node +0 -0
- package/prebuilds/linux-x64/@dekobon+tree-sitter-groovy.node +0 -0
- package/prebuilds/win32-x64/@dekobon+tree-sitter-groovy.node +0 -0
- package/queries/groovy/highlights.scm +10 -4
- package/queries/groovy/locals.scm +7 -0
- package/queries/groovy/tags.scm +32 -0
- package/src/grammar.json +1881 -439
- package/src/node-types.json +673 -1
- package/src/parser.c +195459 -140150
- package/src/scanner.c +391 -10
- package/tree-sitter.json +2 -1
package/README.md
CHANGED
|
@@ -166,6 +166,48 @@ These are documented in detail in
|
|
|
166
166
|
as `a + b` rather than splitting into two statements. Idiomatic
|
|
167
167
|
Groovy places continuation operators at the end of the previous
|
|
168
168
|
line.
|
|
169
|
+
- **A `{` after `new T(...)` is always an anonymous class body** --
|
|
170
|
+
Groovy instead calls a closure on the new object when the `{`
|
|
171
|
+
starts a later line (outside parentheses and brackets) or cannot be
|
|
172
|
+
a class body, so `new ArrayList()\n{ list.add(1) }` and
|
|
173
|
+
`new T() { x -> x }` get an `ERROR` inside a `class_body`. Write
|
|
174
|
+
`new ArrayList().call { ... }` to keep the call.
|
|
175
|
+
- **A `{ ... }` straight after a field with no initializer is an
|
|
176
|
+
instance initializer block** -- `int x { ... }` parses with no
|
|
177
|
+
`ERROR`. A record's compact constructor (`public Name { ... }`),
|
|
178
|
+
which is unsupported, takes the same reading. After a field *with*
|
|
179
|
+
an initializer a next-line `{` is that expression's trailing
|
|
180
|
+
closure, as in Groovy: end the field with `;` to get an
|
|
181
|
+
initializer block.
|
|
182
|
+
- **`sealed` and `trait` are keywords where a class member can
|
|
183
|
+
start** -- a field named `sealed` or `trait` is an `ERROR` when it
|
|
184
|
+
follows a modifier (`private boolean sealed`) or opens the member
|
|
185
|
+
(`static trait = 1`). `boolean sealed` and `String trait`, with no
|
|
186
|
+
modifier, parse, and so does an enum constant with either name
|
|
187
|
+
(`enum E { trait, sealed }`).
|
|
188
|
+
`record` is not affected: it is a keyword only directly before a
|
|
189
|
+
record header (`record Name(`), so `private Record record` and
|
|
190
|
+
`record.key()` parse.
|
|
191
|
+
- **A member after an enum's trailing comma must start with a
|
|
192
|
+
modifier, `def` or a keyword** -- Groovy up to 4.x takes any member
|
|
193
|
+
there. `A,` followed by `String x` or by `E() { }` is an `ERROR`
|
|
194
|
+
(#97).
|
|
195
|
+
- **Parameter modifiers have one order** -- annotations, then `final`,
|
|
196
|
+
then `def`, `var` or a type. `def String x`, `final @A x` and a
|
|
197
|
+
varargs parameter with no type (`... xs`) are an `ERROR` (#98).
|
|
198
|
+
- **A line break does not end a statement** -- a newline is whitespace
|
|
199
|
+
to the grammar. Most code is unaffected, because the next token
|
|
200
|
+
cannot continue the statement. Known cases that read wrongly with no
|
|
201
|
+
`ERROR`: a bare name followed by a literal on the next line is one
|
|
202
|
+
parenthesis-free call (#90); a field with a modifier and no type
|
|
203
|
+
followed by a typed method is a typed field and a constructor (#96);
|
|
204
|
+
and inside brackets, `(a)` followed by a line that starts with `-`,
|
|
205
|
+
`+` or `(` is not the cast Groovy reads (#99).
|
|
206
|
+
- **A method with modifiers and no return type is a constructor** --
|
|
207
|
+
`static f() { }` in a class body is a `constructor_declaration`,
|
|
208
|
+
and `abstract m()` is an `ERROR` (#91).
|
|
209
|
+
- **Annotations come before modifiers** -- `private @Autowired Foo
|
|
210
|
+
foo` and `public @interface X { }` are an `ERROR` (#92).
|
|
169
211
|
|
|
170
212
|
## Contributing
|
|
171
213
|
|