From 045287eccff6880c368a669e7487a29520ca32c4 Mon Sep 17 00:00:00 2001 From: DmitriyLewen Date: Wed, 17 Jan 2024 12:42:01 +0600 Subject: [PATCH] feat(pom): add line number definition for pomDependency --- pkg/java/pom/parse.go | 19 +++++++++++++++++++ pkg/java/pom/pom.go | 1 + 2 files changed, 20 insertions(+) diff --git a/pkg/java/pom/parse.go b/pkg/java/pom/parse.go index 9e8fe900..11d37b8b 100644 --- a/pkg/java/pom/parse.go +++ b/pkg/java/pom/parse.go @@ -642,3 +642,22 @@ func parsePom(r io.Reader) (*pomXML, error) { } return parsed, nil } + +func (deps *pomDependencies) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + *deps = pomDependencies{} + for { + var dep pomDependency + err := d.Decode(&dep) + if err == io.EOF { + break + } else if err != nil { + return err + } + + endLine, _ := d.InputPos() + dep.endLine = endLine + + (*deps).Dependency = append((*deps).Dependency, dep) + } + return nil +} diff --git a/pkg/java/pom/pom.go b/pkg/java/pom/pom.go index bec7ab31..acd02e23 100644 --- a/pkg/java/pom/pom.go +++ b/pkg/java/pom/pom.go @@ -184,6 +184,7 @@ type pomDependency struct { Scope string `xml:"scope"` Optional bool `xml:"optional"` Exclusions pomExclusions `xml:"exclusions"` + endLine int } type pomExclusions struct {