-
Notifications
You must be signed in to change notification settings - Fork 17
/
language.go
103 lines (86 loc) · 2.36 KB
/
language.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package gazelle
import (
"aspect.build/cli/gazelle/common/git"
jvm_maven "github.com/bazel-contrib/rules_jvm/java/gazelle/private/maven"
"github.com/bazelbuild/bazel-gazelle/config"
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/bazelbuild/bazel-gazelle/language"
"github.com/bazelbuild/bazel-gazelle/resolve"
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/emirpasic/gods/sets/treeset"
)
const LanguageName = "kotlin"
const (
KtJvmLibrary = "kt_jvm_library"
KtJvmBinary = "kt_jvm_binary"
RulesKotlinRepositoryName = "io_bazel_rules_kotlin"
)
var sourceRuleKinds = treeset.NewWithStringComparator(KtJvmLibrary)
type Java_PackageName struct {
Name string
}
type Java_MavenResolver interface {
Resolve(pkg Java_PackageName) (label.Label, error)
}
// The Gazelle extension for TypeScript rules.
// TypeScript satisfies the language.Language interface including the
// Configurer and Resolver types.
type kotlinLang struct {
config.Configurer
resolve.Resolver
// Ignore configurations for the workspace.
gitignore *git.GitIgnore
// TODO: extend rules_jvm extension instead of duplicating?
mavenResolver *jvm_maven.Resolver
}
// NewLanguage initializes a new TypeScript that satisfies the language.Language
// interface. This is the entrypoint for the extension initialization.
func NewLanguage() language.Language {
l := &kotlinLang{
gitignore: git.NewGitIgnore(),
}
l.Configurer = NewConfigurer(l)
l.Resolver = NewResolver(l)
return l
}
var kotlinKinds = map[string]rule.KindInfo{
KtJvmLibrary: {
MatchAny: false,
NonEmptyAttrs: map[string]bool{
"srcs": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
KtJvmBinary: {
MatchAny: false,
NonEmptyAttrs: map[string]bool{
"srcs": true,
"main_class": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{},
ResolveAttrs: map[string]bool{},
},
}
var kotlinLoads = []rule.LoadInfo{
{
Name: "@" + RulesKotlinRepositoryName + "//kotlin:jvm.bzl",
Symbols: []string{
KtJvmLibrary,
KtJvmBinary,
},
},
}
func (*kotlinLang) Kinds() map[string]rule.KindInfo {
return kotlinKinds
}
func (*kotlinLang) Loads() []rule.LoadInfo {
return kotlinLoads
}
func (*kotlinLang) Fix(c *config.Config, f *rule.File) {}