Debian Codegraph @

spdxexp/extracts.go

raw symbols SCIP
1 package spdxexpscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/
2
3 import (
4 "mapsscip-go gomod github.com/golang/go/src go1.24 maps/"
5 "slicesscip-go gomod github.com/golang/go/src go1.24 slices/"
6 )
7
8 // ExtractLicenses extracts licenses from the given expression without duplicates.
9 // Returns an array of licenses or error if error occurs during processing.
10 func ExtractLicensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/ExtractLicenses().(expression string) ([]string, error) {
11 node, err := parsescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/parse().(expression)
12 if err != nil {
13 return nil, err
14 }
15
16 seen := map[string]struct{}{}
17 collectExtractedLicensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/collectExtractedLicenses().(node, seen)
18 return slicesscip-go gomod github.com/golang/go/src go1.24 slices/.Collectscip-go gomod github.com/golang/go/src go1.24 slices/Collect().(mapsscip-go gomod github.com/golang/go/src go1.24 maps/.Keysscip-go gomod github.com/golang/go/src go1.24 maps/Keys().(seen)), nil
19 }
20
21 func collectExtractedLicensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/collectExtractedLicenses().(n *nodescip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#, seen map[string]struct{}) {
22 if n == nil {
23 return
24 }
25
26 if n.isExpressionscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#isExpression().() {
27 collectExtractedLicensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/collectExtractedLicenses().(n.leftscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#left().(), seen)
28 collectExtractedLicensesscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/collectExtractedLicenses().(n.rightscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#right().(), seen)
29 return
30 }
31
32 reconstructed := n.reconstructedLicenseStringscip-go gomod github.com/github/go-spdx/v2 . `github.com/github/go-spdx/v2/spdxexp`/node#reconstructedLicenseString().()
33 if reconstructed == nil {
34 return
35 }
36
37 license := *reconstructed
38 if _, ok := seen[license]; ok {
39 return
40 }
41 seen[license] = struct{}{}
42 }