File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,22 @@ type Class struct {
18
18
Repo string
19
19
}
20
20
21
- func (a * Class ) MatchName (str string ) bool {
22
- return a .Name == str || (strings .Contains (str , a .Name ) && strings .Contains (str , "Object" ))
21
+ func (c * Class ) MatchName (str string ) bool {
22
+ return c .Name == str || (strings .Contains (str , c .Name ) && strings .Contains (str , "Object" ))
23
23
}
24
24
25
- func (a * Class ) MatchBuiltInMethods (str string ) bool {
25
+ func (c * Class ) MatchBuiltInMethods (str string ) bool {
26
26
return strings .Contains (str , "builtin" ) && strings .Contains (str , "Methods" )
27
27
}
28
+
29
+ func (c * Class ) SetClassname (filepath string ) {
30
+ split_path := strings .Split (filepath , "/" )
31
+ filename := split_path [len (split_path )- 1 ]
32
+ filename_no_ext := strings .Replace (filename , ".go" , "" , - 1 )
33
+
34
+ name := ""
35
+ for _ , segment := range strings .Split (filename_no_ext , "_" ) {
36
+ name = name + strings .Title (segment )
37
+ }
38
+ c .Name = name
39
+ }
Original file line number Diff line number Diff line change @@ -33,12 +33,7 @@ func ClassesFromDir(dir string) []Class {
33
33
func classFromFile (filepath string ) Class {
34
34
allMethods := []Method {}
35
35
class := Class {}
36
-
37
- // Define class name
38
- split_path := strings .Split (filepath , "/" )
39
- filename := split_path [len (split_path )- 1 ]
40
- filename_no_ext := strings .Replace (filename , ".go" , "" , - 1 )
41
- class .Name = strings .Title (filename_no_ext )
36
+ class .SetClassname (filepath )
42
37
43
38
// Parse target file
44
39
fset := token .NewFileSet ()
You can’t perform that action at this time.
0 commit comments