From 4e43a596a91b79f6fdddfb76823bda6b86dd40b8 Mon Sep 17 00:00:00 2001 From: shivasurya Date: Mon, 3 Feb 2025 18:28:14 -0500 Subject: [PATCH] remove method name extraction logic --- sourcecode-parser/graph/construct.go | 62 ---------------------------- 1 file changed, 62 deletions(-) diff --git a/sourcecode-parser/graph/construct.go b/sourcecode-parser/graph/construct.go index aa7233a..59affeb 100644 --- a/sourcecode-parser/graph/construct.go +++ b/sourcecode-parser/graph/construct.go @@ -874,68 +874,6 @@ func buildGraphFromAST(node *sitter.Node, sourceCode []byte, currentContext *Nod buildGraphFromAST(child, sourceCode, currentContext, file, parentNode) } } - -//nolint:all -func extractMethodName(node *sitter.Node, sourceCode []byte, filepath string) (string, string) { - var methodID string - - // if the child node is method_declaration, extract method name, modifiers, parameters, and return type - var methodName string - var modifiers, parameters []string - - if node.Type() == "method_declaration" { - // Iterate over all children of the method_declaration node - for i := 0; i < int(node.ChildCount()); i++ { - child := node.Child(i) - switch child.Type() { - case "modifiers", "marker_annotation", "annotation": - // This child is a modifier or annotation, add its content to modifiers - modifiers = append(modifiers, child.Content(sourceCode)) //nolint:all - case "identifier": - // This child is the method name - methodName = child.Content(sourceCode) - case "formal_parameters": - // This child represents formal parameters; iterate through its children - for j := 0; j < int(child.NamedChildCount()); j++ { - param := child.NamedChild(j) - parameters = append(parameters, param.Content(sourceCode)) - } - } - } - } - - // check if type is method_invocation - // if the child node is method_invocation, extract method name - if node.Type() == "method_invocation" { - for j := 0; j < int(node.ChildCount()); j++ { - child := node.Child(j) - if child.Type() == "identifier" { - if methodName == "" { - methodName = child.Content(sourceCode) - } else { - methodName = methodName + "." + child.Content(sourceCode) - } - } - - argumentsNode := node.ChildByFieldName("argument_list") - // add data type of arguments list - if argumentsNode != nil { - for k := 0; k < int(argumentsNode.ChildCount()); k++ { - argument := argumentsNode.Child(k) - parameters = append(parameters, argument.Child(0).Content(sourceCode)) - } - } - - } - } - content := node.Content(sourceCode) - lineNumber := int(node.StartPoint().Row) + 1 - columnNumber := int(node.StartPoint().Column) + 1 - // convert to string and merge - content += " " + strconv.Itoa(lineNumber) + ":" + strconv.Itoa(columnNumber) - methodID = GenerateMethodID(methodName, parameters, filepath+"/"+content) - return methodName, methodID -} func getFiles(directory string) ([]string, error) { var files []string err := filepath.Walk(directory, func(path string, info os.FileInfo, err error) error {