Skip to content

feat: add Go and Ruby language support#156

Merged
justrach merged 4 commits intomainfrom
feat/151-go-ruby-support
Apr 5, 2026
Merged

feat: add Go and Ruby language support#156
justrach merged 4 commits intomainfrom
feat/151-go-ruby-support

Conversation

@justrach
Copy link
Copy Markdown
Owner

@justrach justrach commented Apr 5, 2026

Summary

Fixes #151 — adds Go and Ruby language support.

Go

  • func definitions (including methods with receivers like func (r *Type) Name())
  • type struct/interface definitions
  • const/var declarations
  • import "path" statements
  • /* */ block comment tracking

Ruby

  • def method definitions
  • class/module definitions
  • require/require_relative imports
  • =begin/=end block comment tracking

Other

  • Added bundle/.bundle to skip_dirs for Ruby projects
  • Updated isCommentOrBlank for Ruby # and Go // comments

Tests

  • Go: func/type definitions + block comments
  • Ruby: class/module/def + =begin/=end comments
  • All existing tests pass

Files: src/explore.zig (+159 lines), src/tests.zig (+123 lines), src/watcher.zig (+2 lines)

Go parser (parseGoLine):
- func definitions (including methods with receivers)
- type struct/interface
- const/var declarations
- import statements (single-line with string literal)
- Block comment (/* */) tracking

Ruby parser (parseRubyLine):
- def method definitions
- class/module definitions
- require/require_relative imports
- =begin/=end block comment tracking
- # single-line comments

Also:
- Added bundle/.bundle to skip_dirs for Ruby projects
- 4 new tests: Go func/type, Ruby class/module/def, both comment styles

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@justrach justrach added the new_language New language support label Apr 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 5, 2026

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 654533 615820 -5.91% OK
codedb_changes 108402 111670 +3.01% OK
codedb_deps 30204 29029 -3.89% OK
codedb_edit 17444 16533 -5.22% OK
codedb_hot 162598 165478 +1.77% OK
codedb_outline 392269 396632 +1.11% OK
codedb_read 169157 168564 -0.35% OK
codedb_search 260237 254010 -2.39% OK
codedb_snapshot 3340696 3429566 +2.66% OK
codedb_status 28577 28389 -0.66% OK
codedb_symbol 64336 61924 -3.75% OK
codedb_tree 71396 74904 +4.91% OK
codedb_word 90625 94048 +3.78% OK

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cac9616ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1405 to +1407
} else if (startsWith(line, "import ")) {
if (extractStringLiteral(line)) |path| {
const import_copy = try a.dupe(u8, path);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Capture paths from Go import blocks

parseGoLine only appends to outline.imports when extractStringLiteral(line) succeeds on the same import ... line. In the common Go form import ( ... ), that opening line has no string literal, so none of the block’s imports are recorded and rebuildDepsFor receives an incomplete dependency list for typical multi-import files.

Useful? React with 👍 / 👎.

Comment on lines +1440 to +1442
if (startsWith(line, "def ")) {
if (extractIdent(line[4..])) |name| {
const name_copy = try a.dupe(u8, name);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse Ruby singleton method names correctly

The def branch in parseRubyLine extracts identifiers directly from line[4..], so declarations like def self.build are indexed as self (stopping at the dot) instead of build. This makes symbol indexing inaccurate for common Ruby class/singleton methods and breaks method-name based outline/search behavior.

Useful? React with 👍 / 👎.

1. Ruby =begin/=end must be at column 0 (use untrimmed line) — prevents
   indented =begin from tricking the parser into skipping real code
2. extractIdent capped at 256 chars — prevents CPU DoS on pathological
   files with 10MB identifiers
3. rebuildDepsFor filters imports containing ".." — prevents path
   traversal sequences from entering the dependency graph

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7fcc41945

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

src/explore.zig Outdated
Comment on lines +1389 to +1392
const kind: SymbolKind = if (std.mem.indexOf(u8, line, " struct") != null or std.mem.indexOf(u8, line, " interface") != null)
.struct_def
else
.constant;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Emit Go type declarations as type symbols

parseGoLine currently marks every type declaration that is not a struct/interface as .constant. In Go, declarations like type ID string or type HandlerFunc func(...) are still type definitions, so this misclassification makes kind-based outline/search results inaccurate for common files. Please emit a type-oriented kind (for example .type_alias) instead of .constant in this fallback branch.

Useful? React with 👍 / 👎.

src/explore.zig Outdated
fn parseRubyLine(self: *Explorer, line: []const u8, line_num: u32, outline: *FileOutline) !void {
const a = self.allocator;
if (startsWith(line, "def ")) {
if (extractIdent(line[4..])) |name| {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve Ruby method suffix punctuation

Ruby method names may legally end with ?, !, or = (for example valid?, save!, name=), but parseRubyLine delegates to extractIdent, which stops at non-alphanumeric characters and truncates those names. This causes symbol collisions and breaks exact method-name lookup for idiomatic Ruby code, so method parsing should retain these suffix characters.

Useful? React with 👍 / 👎.

…defs

P1: Go multi-line import blocks (import ( ... )) now parsed — each
    quoted path inside the block captured as an import
P2: Go type declarations all classified as struct_def (not constant)
P2: Ruby def self.method_name correctly extracts method_name, not "self"
P2: Ruby method suffixes ?, !, = preserved (extractRubyMethodName helper)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@justrach
Copy link
Copy Markdown
Owner Author

justrach commented Apr 5, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffc9e94ed0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

src/explore.zig Outdated
Comment on lines +267 to +269
if (std.mem.eql(u8, trimmed, ")")) {
in_go_import_block = false;
} else if (extractStringLiteral(trimmed)) |imp_path| {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Close Go import blocks when ')' has trailing comments

In the Go import-block state machine, the block is only closed when the trimmed line is exactly ")". Valid Go code often uses ) // ... on the closing line, and in that case in_go_import_block stays true, so every following line is treated as part of the import block and normal symbol parsing never resumes. This causes outlines/import graphs to silently drop functions, types, and variables for the remainder of the file whenever a trailing comment appears on the closing import parenthesis.

Useful? React with 👍 / 👎.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@justrach justrach merged commit 10573d7 into main Apr 5, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new_language New language support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add Ruby and Go language support

1 participant