Skip to content

Commit 852c3a3

Browse files
committed
add some basic support for kotlin
1 parent 61cd9ad commit 852c3a3

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

pkg/comments/comments_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,17 @@ func TestPHPFiles(t *testing.T) {
6161
t.Fail()
6262
}
6363
}
64+
65+
func TestKotlinFiles(t *testing.T) {
66+
var comments Comments
67+
err := SearchDir("testdata/kotlin", func(comment *Comment) {
68+
comments = append(comments, comment)
69+
})
70+
if err != nil {
71+
t.Fatal(err)
72+
}
73+
74+
if len(comments) != 2 {
75+
t.Fail()
76+
}
77+
}

pkg/comments/languages.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type Language string
4141

4242
// LanguageParseOptions keeps track of source languages and their corresponding comment options
4343
var LanguageParseOptions map[Language]*lege.ParseOptions = map[Language]*lege.ParseOptions{
44+
// TODO this map should probably be sorted in some reasonable way - alphabetically?
4445
"Go": CStyleCommentOptions,
4546
"Java": CStyleCommentOptions,
4647
"C": CStyleCommentOptions,
@@ -59,8 +60,8 @@ var LanguageParseOptions map[Language]*lege.ParseOptions = map[Language]*lege.Pa
5960
"Common Lisp": LispStyleCommentOptions,
6061
"Emacs Lisp": LispStyleCommentOptions,
6162
"R": HashStyleCommentOptions,
62-
6363
// TODO Currently, the underlying pkg that does the parsing/plucking (lege) doesn't properly support precedance
6464
// so lines beginning with /// or //! will be picked up by this start // and include a / or ! preceding the comment
65-
"Rust": {Boundaries: []lege.Boundary{{Start: "///", End: "\n"}, {Start: "//!", End: "\n"}, {Start: "//", End: "\n"}}},
65+
"Rust": {Boundaries: []lege.Boundary{{Start: "///", End: "\n"}, {Start: "//!", End: "\n"}, {Start: "//", End: "\n"}}},
66+
"Kotlin": CStyleCommentOptions,
6667
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// this is a comment
2+
fun main() {
3+
println("Hello world!")
4+
/*
5+
Here's another comment
6+
*/
7+
}

0 commit comments

Comments
 (0)