Skip to content

Commit

Permalink
🚀 finally db is ready and parsing with relationship is happening
Browse files Browse the repository at this point in the history
  • Loading branch information
shivasurya committed Feb 24, 2025
1 parent 4fc9c3b commit e320d74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
23 changes: 1 addition & 22 deletions sourcecode-parser/model/member.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ","),
Expand All @@ -234,14 +221,6 @@ func (m *Method) Insert(db *sql.DB) error {
return err
}

Check warning on line 222 in sourcecode-parser/model/member.go

View check run for this annotation

Codecov / codecov/patch

sourcecode-parser/model/member.go#L204-L222

Added lines #L204 - L222 were not covered by tests

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

Check warning on line 224 in sourcecode-parser/model/member.go

View check run for this annotation

Codecov / codecov/patch

sourcecode-parser/model/member.go#L224

Added line #L224 was not covered by tests
}
func (m *Method) Update(db *sql.DB) error {
Expand Down
8 changes: 5 additions & 3 deletions sourcecode-parser/tree/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e320d74

Please sign in to comment.