-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser_ts_java.go
More file actions
46 lines (35 loc) · 958 Bytes
/
parser_ts_java.go
File metadata and controls
46 lines (35 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//go:build !notreesitter
package repomap
import (
"unsafe"
tree_sitter "github.com/tree-sitter/go-tree-sitter"
tree_sitter_java "github.com/tree-sitter/tree-sitter-java/bindings/go"
)
func registerTSJava() {
registerTS("java",
func() *tree_sitter.Language {
return tree_sitter.NewLanguage(unsafe.Pointer(tree_sitter_java.Language()))
},
tsQueryJava, tsQueryJavaImports,
)
}
// tsQueryJava finds classes, interfaces, enums, records, and methods.
const tsQueryJava = `
(class_declaration
name: (identifier) @name) @type
(interface_declaration
name: (identifier) @name) @type
(enum_declaration
name: (identifier) @name) @type
(record_declaration
name: (identifier) @name) @type
(method_declaration
name: (identifier) @name) @type
(constructor_declaration
name: (identifier) @name) @type
`
// tsQueryJavaImports finds import declarations.
const tsQueryJavaImports = `
(import_declaration
path: (scoped_identifier) @path)
`