plantuml debug
This commit is contained in:
@@ -149,15 +149,46 @@ func (d *Workflow) ExtractFromPlantUML(plantUML multipart.File, request *tools.A
|
||||
},
|
||||
}
|
||||
graphVarName := map[string]graph.GraphItem{}
|
||||
scanner := bufio.NewScanner(plantUML)
|
||||
|
||||
// Collect all lines first to support look-ahead (comment on the line after
|
||||
// the declaration, as produced by ToPlantUML).
|
||||
scanner := bufio.NewScanner(plantUML)
|
||||
var lines []string
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return d, err
|
||||
}
|
||||
|
||||
for i, line := range lines {
|
||||
trimmed := strings.TrimSpace(line)
|
||||
|
||||
// Skip pure comment lines and PlantUML directives — they must never be
|
||||
// parsed as resource declarations or links. Without this guard, a comment
|
||||
// like "' source: http://my-server.com" would match the "-" link check.
|
||||
if strings.HasPrefix(trimmed, "'") ||
|
||||
strings.HasPrefix(trimmed, "!") ||
|
||||
strings.HasPrefix(trimmed, "@") ||
|
||||
trimmed == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// Build the parse line: if the current line has no inline comment and the
|
||||
// next line is a pure comment, append it so parsers receive one combined line.
|
||||
// Also handles the legacy inline-comment format unchanged.
|
||||
parseLine := line
|
||||
if !strings.Contains(line, "'") && i+1 < len(lines) {
|
||||
if next := strings.TrimSpace(lines[i+1]); strings.HasPrefix(next, "'") {
|
||||
parseLine = line + " " + next
|
||||
}
|
||||
}
|
||||
|
||||
for n, new := range resourceCatalog {
|
||||
if strings.Contains(line, n+"(") && !strings.Contains(line, "!procedure") { // should exclude declaration of type.
|
||||
if strings.Contains(line, n+"(") && !strings.Contains(line, "!procedure") && !strings.Contains(line, "!define") { // exclude macro declarations
|
||||
newRes := new()
|
||||
newRes.SetID(uuid.New().String())
|
||||
varName, graphItem, err := d.extractResourcePlantUML(line, newRes, n, request.PeerID)
|
||||
varName, graphItem, err := d.extractResourcePlantUML(parseLine, newRes, n, request.PeerID)
|
||||
fmt.Println(varName, graphItem, err)
|
||||
if err != nil {
|
||||
return d, err
|
||||
@@ -167,25 +198,25 @@ func (d *Workflow) ExtractFromPlantUML(plantUML multipart.File, request *tools.A
|
||||
}
|
||||
continue
|
||||
} else if strings.Contains(line, "-->") {
|
||||
err := d.extractLink(line, graphVarName, "-->", false)
|
||||
err := d.extractLink(parseLine, graphVarName, "-->", false)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
} else if strings.Contains(line, "<--") {
|
||||
err := d.extractLink(line, graphVarName, "<--", true)
|
||||
err := d.extractLink(parseLine, graphVarName, "<--", true)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
} else if strings.Contains(line, "--") {
|
||||
err := d.extractLink(line, graphVarName, "--", false)
|
||||
err := d.extractLink(parseLine, graphVarName, "--", false)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
} else if strings.Contains(line, "-") {
|
||||
err := d.extractLink(line, graphVarName, "-", false)
|
||||
err := d.extractLink(parseLine, graphVarName, "-", false)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
@@ -193,9 +224,6 @@ func (d *Workflow) ExtractFromPlantUML(plantUML multipart.File, request *tools.A
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return d, err
|
||||
}
|
||||
d.generateResource(d.GetResources(tools.DATA_RESOURCE), request)
|
||||
d.generateResource(d.GetResources(tools.PROCESSING_RESOURCE), request)
|
||||
d.generateResource(d.GetResources(tools.STORAGE_RESOURCE), request)
|
||||
|
||||
Reference in New Issue
Block a user