Skip to content

Commit

Permalink
chore: update tree sitter
Browse files Browse the repository at this point in the history
  • Loading branch information
didroe committed Jun 10, 2024
1 parent ada6cfa commit c68b480
Show file tree
Hide file tree
Showing 55 changed files with 11,926 additions and 13,729 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/schollz/progressbar/v3 v3.14.4
github.com/shirou/gopsutil/v3 v3.24.5
github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8
github.com/smacker/go-tree-sitter v0.0.0-20240514083259-c5d1f3f5f99e
github.com/stretchr/testify v1.9.0
github.com/tangzero/inflector v1.0.0
github.com/weppos/publicsuffix-go v0.30.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8 h1:DxgjlvWYsb80WEN2Zv3WqJFAg2DKjUQJO6URGdf1x6Y=
github.com/smacker/go-tree-sitter v0.0.0-20230720070738-0d0a9f78d8f8/go.mod h1:q99oHDsbP0xRwmn7Vmob8gbSMNyvJ83OauXPSuHQuKE=
github.com/smacker/go-tree-sitter v0.0.0-20240514083259-c5d1f3f5f99e h1:nOtrYzQNgRipVsrOkYpVU/ZMDS3/+78It68cPBPKy8A=
github.com/smacker/go-tree-sitter v0.0.0-20240514083259-c5d1f3f5f99e/go.mod h1:q99oHDsbP0xRwmn7Vmob8gbSMNyvJ83OauXPSuHQuKE=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
Expand Down
7 changes: 6 additions & 1 deletion pkg/detectors/csharp/csharp.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,18 @@ func annotate(tree *parser.Tree) error {

return tree.Annotate(func(node *parser.Node, value *values.Value) {
switch node.Type() {
case "interpolated_string_text", "interpolated_verbatim_string_text":
case "interpolated_string_text",
"interpolated_verbatim_string_text",
"string_content",
"string_literal_content":
value.AppendString(node.Content())

return
case "interpolation":
value.Append(node.FirstChild().Value())

return
case "interpolation_start":
return
case "binary_expression":
if node.FirstUnnamedChild().Content() == "+" {
Expand Down
3 changes: 2 additions & 1 deletion pkg/detectors/csharp/datatype/datatype.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ func discoverFunctions(tree *parser.Tree, datatypes map[parser.NodeID]*schemadat

parent := functionNameNode.Parent()

functionTypeNode := parent.ChildByFieldName("type")
functionTypeNode := parent.ChildByFieldName("returns")

functionType := ""
functionTextType := ""
if functionTypeNode != nil {
Expand Down
60 changes: 33 additions & 27 deletions pkg/detectors/dependencies/ivy/ivy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,51 @@ var language = xml.GetLanguage()

var query = `
(element
(_
(tag_name) @helper_module
(STag
(Name) @helper_module
(#match? @helper_module "^module$")
(attribute
(attribute_name) @helper_organisation
(Attribute
(Name) @helper_organisation
(#match? @helper_organisation "^organisation$")
(attribute_value) @param_organisation_name
(AttValue) @param_organisation_name
)
(attribute
(attribute_name) @helper_organisation_name
(Attribute
(Name) @helper_organisation_name
(#match? @helper_organisation_name "^name$")
(attribute_value) @param_module_name
(AttValue) @param_module_name
)
)
(element
(_
(tag_name) @helper_revision
(#match? @helper_revision "^revision$")
(attribute
(attribute_name) @helper_revision_name
(#match? @helper_revision_name "^name$")
(attribute_value) @param_version
)
)
)
(content
(element
(STag
(Name) @helper_revision
(#match? @helper_revision "^revision$")
(Attribute
(Name) @helper_revision_name
(#match? @helper_revision_name "^name$")
(AttValue) @param_version
)
)
)
)
)
`

var queryDependencies = parser.QueryMustCompile(language, fmt.Sprintf(`
(document
(element
(element
(start_tag
(tag_name) @helper_dependencies
(#match? @helper_dependencies "^dependencies$")
)
%s
)
(content
(element
(STag
(Name) @helper_dependencies
(#match? @helper_dependencies "^dependencies$")
)
(content
%s
)
)
)
)
)
`, query))
Expand Down
22 changes: 11 additions & 11 deletions pkg/detectors/dependencies/package-config/package-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ var language = xml.GetLanguage()
var queryDependencies = parser.QueryMustCompile(language, `
(element
(_
(tag_name) @helper_package
(Name) @helper_package
(#match? @helper_package "^package$")
(attribute
(attribute_name) @helper_id
(#match? @helper_id "^id$")
(attribute_value) @param_dependency
)
(attribute
(attribute_name) @helper_version
(#match? @helper_version "^version$")
(attribute_value) @param_version
)
(Attribute
(Name) @helper_id
(#match? @helper_id "^id$")
(AttValue) @param_dependency
)
(Attribute
(Name) @helper_version
(#match? @helper_version "^version$")
(AttValue) @param_version
)
)
)
`)
Expand Down
45 changes: 25 additions & 20 deletions pkg/detectors/dependencies/pom-xml/pom-xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ var language = xml.GetLanguage()

var queryDependencies = parser.QueryMustCompile(language, `
(element
(start_tag
(tag_name) @helper_dependency
(STag
(Name) @helper_dependency
(#match? @helper_dependency "^dependency$")
)
) @param_dependency
Expand All @@ -41,32 +41,37 @@ func Discover(f *file.FileInfo) (report *depsbase.DiscoveredDependency) {
for i := 0; i < dependencyNode.ChildCount(); i++ {
child := dependencyNode.Child(i)

if child.Type() != "element" {
if child.Type() != "content" {
continue
}

tag := ""
tagContent := ""

for j := 0; j < child.ChildCount(); j++ {
elementChild := child.Child(j)

if elementChild.Type() == "start_tag" {
tag = elementChild.Child(0).Content()
childElement := child.Child(j)
if childElement.Type() != "element" {
continue
}

if elementChild.Type() == "text" {
tagContent = elementChild.Content()
tag := ""
tagContent := ""

for k := 0; k < childElement.ChildCount(); k++ {
subElement := childElement.Child(k)
switch subElement.Type() {
case "STag":
tag = subElement.Child(0).Content()
case "content":
tagContent += subElement.Content()
}
}
}

switch tag {
case "groupId":
groupId = tagContent
case "artifactId":
artifactId = tagContent
case "version":
version = tagContent
switch tag {
case "groupId":
groupId = tagContent
case "artifactId":
artifactId = tagContent
case "version":
version = tagContent
}
}
}

Expand Down
Loading

0 comments on commit c68b480

Please sign in to comment.