feat: HCL/Terraform + R language support, telemetry fix (#108, #215, #216)#257
Conversation
…ng (#108, #215, #216) - #216: add missing php/ruby/hcl/r entries to telemetry writeLanguages array - #108: add HCL language support — resource, data, module, variable, output, provider, locals, terraform blocks; .tf/.tfvars/.hcl detection; #//* block comment handling; .terragrunt-cache in skip_dirs - #215: add R language support — function assignment (<-/=), setClass/setRefClass, library/require imports; .r/.R detection; # comment handling - 10 new tests covering all HCL and R parser paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Benchmark Regression ReportThreshold: 10.00%
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b25d92f270
ℹ️ 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".
| hcl, | ||
| r, |
There was a problem hiding this comment.
Preserve Language enum values used in snapshot serialization
Inserting .hcl and .r here shifts the numeric values of existing variants (markdown/json/yaml/unknown), but snapshot persistence stores Language as raw enum bytes (@intFromEnum when writing and intToEnum when reading in snapshot.zig) without a migration path, so pre-upgrade snapshots will silently deserialize to the wrong language tags after this change. Because the loader accepts older snapshots, this causes incorrect language metadata in restored outlines; new variants should be appended (or explicit discriminants/versioned migration should be used).
Useful? React with 👍 / 👎.
| errdefer a.free(name_copy); | ||
| const detail_copy = try a.dupe(u8, line); | ||
| errdefer a.free(detail_copy); | ||
| try outline.symbols.append(a, .{ .name = name_copy, .kind = .struct_def, .line_start = line_num, .line_end = line_num, .detail = detail_copy }); |
There was a problem hiding this comment.
Compute line_end for HCL block symbols
HCL resource/data/locals/terraform entries are emitted as .struct_def, but computeSymbolEnds only expands block ranges for the existing brace-language set and does not include .hcl, so these symbols keep line_end == line_start. In practice, symbol body and enclosing-symbol queries on .tf/.hcl files will return only the declaration line instead of the full block.
Useful? React with 👍 / 👎.
| if (std.mem.indexOf(u8, line, "<- function(") != null or std.mem.indexOf(u8, line, "= function(") != null) { | ||
| const assign_pos = std.mem.indexOf(u8, line, "<-") orelse std.mem.indexOf(u8, line, "=") orelse return; |
There was a problem hiding this comment.
Anchor R function parsing to top-level assignments
This condition matches = function( anywhere in the line, then splits at the first =; common R calls like lapply(x, FUN = function(...) ...) are therefore misindexed as top-level function definitions with invalid names (e.g. lapply(x, FUN). Restricting detection to lines where a standalone identifier is directly assigned to function( would avoid these false symbols.
Useful? React with 👍 / 👎.
Summary
writeLanguagesarray — names now match Language enum order exactlyresource,data,module,variable,output,provider,locals,terraformblock parsing;.tf/.tfvars/.hcldetection;#/////* */comment handling;.terragrunt-cacheadded toskip_dirsname <- function()/name = function()assignment,setClass()/setRefClass()class defs,library()/require()imports;.r/.Rdetection;#comment handlingTest plan
zig build test— exit 0)codedb_outlineon a.tffile returns resource/variable/output symbolscodedb_outlineon an.Rfile returns function/class/import symbols🤖 Generated with Claude Code