Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support interfaces #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions dotmaker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// tags2uml
// Copyright 2014 ruben2020 https://github.com/ruben2020/
// Copyright 2014 ruben2020 https://github.com/ruben2020/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,7 +73,7 @@ for _, value := range classmap {
for inti := range intlst {
if intlst[inti] == value.id {continue}
if idpairs[createPairOfIds(intlst[inti], value.id)] == 99 {continue}
outs = append(outs, buildArrowLine(intlst[inti], value.id, "none"))
outs = append(outs, buildArrowLine(intlst[inti], value.id, "vee", "back"))
idpairs[createPairOfIds(intlst[inti], value.id)] = 99
}
}
Expand Down Expand Up @@ -109,15 +109,18 @@ func createPairOfIds(id1 int, id2 int) string {
return strings.Join(outs, "")
}

func buildArrowLine(id1 int, id2 int, arrowtype string) string {
func buildArrowLine(id1 int, id2 int, arrowtype string, dir string) string {
var outs []string
outs = append(outs, "n")
outs = append(outs, strconv.Itoa(id1))
outs = append(outs, " -> n")
outs = append(outs, strconv.Itoa(id2))
outs = append(outs, " [arrowhead=\"")
outs = append(outs, arrowtype)
outs = append(outs, "\"];\n")
outs = append(outs, "\"")
outs = append(outs, ", dir=")
outs = append(outs, dir)
outs = append(outs, "];\n")
return strings.Join(outs, "")
}

Expand Down
40 changes: 33 additions & 7 deletions tagsparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ import "regexp"
import "strings"


func getFileName(input string) string {
endPos := strings.LastIndex(input, ".")
if (endPos < 0) {
endPos = len(input)
}
beginPos := 0
for i := endPos - 1; i >= 0; i-- {
r := input[i]
if (r < 'a' || r > 'z') && (r < 'A' || r > 'Z') {
beginPos = i
break
}
}
return input[beginPos+1:endPos]
}


func parseClass(fn string) {

file, err := os.Open(fn)
Expand All @@ -31,13 +48,21 @@ if err != nil {
}

scanner := bufio.NewScanner(file)
re := regexp.MustCompile(`^([A-Za-z0-9_]+)\t([^\t]+)\t([^\t]+)\tclass`)
re := regexp.MustCompile(`^([A-Za-z0-9_]+)\t([^\t]+)\t([^\t]+)\t(class|interface)`)
re2 := regexp.MustCompile(`inherits:([A-Za-z0-9_\:,]+)`)
for scanner.Scan() {
match := re.FindStringSubmatch(scanner.Text())
if len(match) != 0 {
newclass := classinfo_st{}
newclass.name = match[1]
filepath := match[2]
filebasename := getFileName(filepath)
if (newclass.name != filebasename) {
newclass.name = filebasename + "." + match[1]
} else {
newclass.name = match[1]
}

match2 := re2.FindStringSubmatch(scanner.Text())
if len(match2) != 0 {
newclass.parents = strings.Split(match2[1], ",")
Expand Down Expand Up @@ -65,7 +90,7 @@ if err != nil {
scanner := bufio.NewScanner(file)
re := regexp.MustCompile(`^([A-Za-z0-9_]+)\t([^\t]+)\t([^\t]+)\t([A-Za-z]+)`)
rea := regexp.MustCompile(`access:([A-Za-z0-9_]+)`)
rec := regexp.MustCompile(`class:([A-Za-z0-9_\.]+)`)
rec := regexp.MustCompile(`(interface|class):([A-Za-z0-9_\.]+)`)
rel := regexp.MustCompile(`language:([A-Za-z0-9_\#]+)`)
ret := regexp.MustCompile(`\/\^([ ]*)([A-Za-z0-9_\.]+)([^A-Za-z0-9_]+)(.*)\$\/`)
for scanner.Scan() {
Expand All @@ -74,11 +99,12 @@ for scanner.Scan() {
matchc := rec.FindStringSubmatch(scanner.Text())
ci := classinfo_st{}
var cn string
if (len(matchc) != 0) {cn = matchc[1]}
cnsep := strings.LastIndex(cn, ".")
if (cnsep != -1) {
cn = cn[cnsep+1:]
}
if (len(matchc) != 0) {cn = matchc[2]}

//cnsep := strings.LastIndex(cn, ".")
//if (cnsep != -1) {
//cn = cn[cnsep+1:]
//}
if (len(cn) != 0) {ci = classmap[cn]}
if (len(ci.name) == 0) {continue}
matcha := rea.FindStringSubmatch(scanner.Text())
Expand Down