From e320d749220693bd8211837c9421e7f01d0ce22e Mon Sep 17 00:00:00 2001 From: shivasurya Date: Sun, 23 Feb 2025 20:26:23 -0500 Subject: [PATCH] :rocket: finally db is ready and parsing with relationship is happening --- sourcecode-parser/model/member.go | 23 +---------------------- sourcecode-parser/tree/construct.go | 8 +++++--- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/sourcecode-parser/model/member.go b/sourcecode-parser/model/member.go index f8caf7b..b428245 100644 --- a/sourcecode-parser/model/member.go +++ b/sourcecode-parser/model/member.go @@ -208,20 +208,7 @@ func (m *Method) Insert(db *sql.DB) error { is_constructor, source_declaration ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)` - fmt.Println("Inserting method:", m.Name) - fmt.Println("Qualified Name:", m.QualifiedName) - fmt.Println("Return Type:", m.ReturnType) - fmt.Println("Parameters:", m.Parameters) - fmt.Println("Parameter Names:", m.ParameterNames) - fmt.Println("Visibility:", m.Visibility) - fmt.Println("Is Abstract:", m.IsAbstract) - fmt.Println("Is Strictfp:", m.IsStrictfp) - fmt.Println("Is Static:", m.IsStatic) - fmt.Println("Is Final:", m.IsFinal) - fmt.Println("Is Constructor:", m.IsConstructor) - fmt.Println("Source Declaration:", m.SourceDeclaration) - - s, err := db.Exec(query, + _, err := db.Exec(query, m.Name, m.QualifiedName, m.ReturnType, strings.Join(m.Parameters, ","), strings.Join(m.ParameterNames, ","), @@ -234,14 +221,6 @@ func (m *Method) Insert(db *sql.DB) error { return err } - lastInsertID, err := s.LastInsertId() - if err != nil { - log.Printf("Failed to get last insert ID: %v", err) - return err - } - - fmt.Printf("Inserted ID: %d", lastInsertID) - return nil } func (m *Method) Update(db *sql.DB) error { diff --git a/sourcecode-parser/tree/construct.go b/sourcecode-parser/tree/construct.go index f74c278..97a9f09 100644 --- a/sourcecode-parser/tree/construct.go +++ b/sourcecode-parser/tree/construct.go @@ -132,7 +132,7 @@ func readFile(path string) ([]byte, error) { func Initialize(directory string) []*model.TreeNode { treeHolder := []*model.TreeNode{} - storageNode := db.NewStorageNode("") + storageNode := db.NewStorageNode(directory) // record start time start := time.Now() @@ -238,9 +238,11 @@ func Initialize(directory string) []*model.TreeNode { close(progressChan) close(treeChan) - for _, method := range storageNode.MethodDecl { - utilities.Log("Method: ", method.ReturnType, " ", method.Name, " ", method.Parameters, " ", method.SourceDeclaration) + // TODO:bulk insert into db + for _, methodDeclaration := range storageNode.MethodDecl { + methodDeclaration.Insert(storageNode.DB) } + storageNode.DB.Close() end := time.Now() elapsed := end.Sub(start)