Skip to content

Commit

Permalink
Treat all symbols with at least two dots as class names.
Browse files Browse the repository at this point in the history
  • Loading branch information
candid82 committed May 28, 2019
1 parent 484ea8e commit 3b42505
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"fmt"
"regexp"
"sort"
"strings"
"unsafe"
Expand Down Expand Up @@ -1610,14 +1611,14 @@ func isRecordConstructor(sym Symbol) bool {
return sym.ns == nil && (strings.HasPrefix(*sym.name, "->") || strings.HasPrefix(*sym.name, "map->"))
}

var fullClassNameRe = regexp.MustCompile(`.+\..+\..+`)

func isJavaSymbol(sym Symbol) bool {
s := *sym.name
if sym.ns != nil {
s = *sym.ns
}
return strings.HasPrefix(s, "java.") ||
strings.HasPrefix(s, "javax.") ||
strings.HasPrefix(s, "clojure.lang.")
return fullClassNameRe.MatchString(s)
}

func parseSymbol(obj Object, ctx *ParseContext) Expr {
Expand Down
8 changes: 8 additions & 0 deletions tests/linter/classnames/input.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(ns test.ns)

(defprotocol ITest
(x [this]))

(extend-protocol ITest
datomic.db.Db
(x [this] (println "do something")))
Empty file.

0 comments on commit 3b42505

Please sign in to comment.