Skip to content

feat(golang): Go type definitions parsing (PR-04)#523

Merged
shivasurya merged 2 commits into
mainfrom
shiva/golang-pr04-types
Feb 15, 2026
Merged

feat(golang): Go type definitions parsing (PR-04)#523
shivasurya merged 2 commits into
mainfrom
shiva/golang-pr04-types

Conversation

@shivasurya
Copy link
Copy Markdown
Owner

Summary

  • Add TypeInfo struct and ParseTypeDeclaration in graph/golang/types.go to extract type information from Go type_declaration AST nodes
  • Handle struct definitions (with fields via ExtractStructFields), interface definitions (with methods via ExtractInterfaceMethods), type aliases/named types, and grouped declarations (type ( A int; B string ))
  • Add dispatcher parseGoTypeDeclaration in parser_golang.go that converts TypeInfo into graph.Node with correct types (struct_definition, interface, type_alias) and SourceLocation byte ranges
  • Fill type_declaration stub in parser.go

Test plan

  • go build ./... compiles without errors
  • go vet ./... clean
  • All existing tests pass (go test ./graph/...) — no regressions
  • New tests in types_test.go: struct with fields, embedded types, empty struct, unexported struct, struct with tags, interfaces with methods, interfaces with embedded, unexported interface, named type, function type alias, slice type, true alias (=), unexported alias, grouped declarations, grouped mixed types
  • ParseTypeDeclaration 100% coverage, parseTypeAlias 100% coverage
  • parseTypeSpec 87.5% coverage (remaining gap is defensive nil guard unreachable via tree-sitter)

🤖 Generated with Claude Code

@shivasurya shivasurya added the enhancement New feature or request label Feb 14, 2026
@shivasurya shivasurya self-assigned this Feb 14, 2026
@safedep
Copy link
Copy Markdown

safedep Bot commented Feb 14, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 90.36145% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.97%. Comparing base (b2882ff) to head (e87e9c4).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sast-engine/graph/parser_golang.go 83.33% 5 Missing ⚠️
sast-engine/graph/golang/types.go 94.11% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #523      +/-   ##
==========================================
+ Coverage   82.93%   82.97%   +0.04%     
==========================================
  Files         125      126       +1     
  Lines       14540    14623      +83     
==========================================
+ Hits        12059    12134      +75     
- Misses       2027     2034       +7     
- Partials      454      455       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shivasurya shivasurya changed the title feat: Go type definitions parsing (structs, interfaces, aliases) feat(golang): Go type definitions parsing (PR-04) Feb 14, 2026
Copy link
Copy Markdown
Owner Author

shivasurya commented Feb 15, 2026

Merge activity

  • Feb 15, 4:00 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 15, 4:05 AM UTC: Graphite rebased this pull request as part of a merge.
  • Feb 15, 4:06 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya changed the base branch from shiva/golang-pr03-declarations to graphite-base/523 February 15, 2026 04:03
@shivasurya shivasurya changed the base branch from graphite-base/523 to main February 15, 2026 04:04
shivasurya and others added 2 commits February 15, 2026 04:05
Add TypeInfo extraction from Go type_declaration AST nodes, handling
struct definitions with fields, interface definitions with methods,
type aliases, and grouped declarations. Dispatcher creates CodeGraph
nodes with correct types and SourceLocation byte ranges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that generic Go types (type Set[T comparable] struct{}) are
parsed correctly: name extracted, type params ignored, struct/interface/
alias kind detected. Covers single param, multiple params, generic
interface, generic slice alias, and unexported generic struct.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@shivasurya shivasurya force-pushed the shiva/golang-pr04-types branch from f03617d to e87e9c4 Compare February 15, 2026 04:05
@github-actions
Copy link
Copy Markdown

Code Pathfinder Security Scan

Pass Critical High Medium Low Info

No security issues detected.

Metric Value
Files Scanned 4
Rules 38

Powered by Code Pathfinder

@shivasurya shivasurya merged commit f581b39 into main Feb 15, 2026
5 checks passed
@shivasurya shivasurya deleted the shiva/golang-pr04-types branch February 15, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant