aboutsummaryrefslogtreecommitdiff
path: root/Scripts/normalize-zig-issues.pl
diff options
context:
space:
mode:
authorDavid Czihak <git@dcz.at>2026-05-10 19:21:33 +0200
committerDavid Czihak <git@dcz.at>2026-05-10 19:21:33 +0200
commitb80b9c1f82585677a7c042557576c41b1670d259 (patch)
tree9a741dfd7725205dba35b42bc6d5a6a7e084ced0 /Scripts/normalize-zig-issues.pl
parent33ea57ddd69f35f3f2db64a1a2d31b410ed7afb2 (diff)
Chore: Move extension bundle into Zig.novaextension/ subdirectory
Separates Nova extension resources from development-only items. Development items (ISSUES.md, vendor/, examples/) remain at the repo root. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'Scripts/normalize-zig-issues.pl')
-rw-r--r--Scripts/normalize-zig-issues.pl93
1 files changed, 0 insertions, 93 deletions
diff --git a/Scripts/normalize-zig-issues.pl b/Scripts/normalize-zig-issues.pl
deleted file mode 100644
index b6ff328..0000000
--- a/Scripts/normalize-zig-issues.pl
+++ /dev/null
@@ -1,93 +0,0 @@
-use strict;
-use warnings;
-$| = 1;
-
-my $base = $ENV{NOVA_ZIG_TASK_CWD} || $ENV{PWD} || "";
-my %file_cache = ();
-
-sub normalize_path {
- my ($path) = @_;
- return $path if $path =~ m{^/} || $path =~ m{^[A-Za-z]:[\/\\]};
-
- # The Zig compiler occasionally emits paths without a leading slash (e.g.
- # "Users/..." instead of "/Users/...") when traversing relative directories.
- # Detect known top-level directory names and restore the leading slash.
- if ($path =~ m{^(?:Users|private|opt|Library|System|usr|var|tmp|etc|home)/}) {
- return "/$path";
- }
-
- return $base eq "" ? $path : "$base/$path";
-}
-
-sub source_line_for_path {
- my ($path, $line_number) = @_;
- return undef if $line_number < 1;
-
- if (!exists $file_cache{$path}) {
- if (open my $fh, "<", $path) {
- my @lines = <$fh>;
- close $fh;
- $file_cache{$path} = \@lines;
- } else {
- $file_cache{$path} = undef;
- }
- }
-
- my $lines = $file_cache{$path};
- return undef if !defined $lines;
- return undef if $line_number > scalar(@$lines);
-
- my $line = $lines->[$line_number - 1];
- $line =~ s/\r?\n$//;
- return $line;
-}
-
-# Zig reports argument-count errors at the column of the opening parenthesis,
-# which causes Nova to underline the entire argument list. For method-call
-# expressions (receiver.method(...)), shift the column back to the start of
-# the callee identifier so only the call site itself is highlighted.
-sub adjusted_call_column {
- my ($source_line, $column) = @_;
- return $column if !defined $source_line || $column < 1;
-
- my $column_index = $column - 1;
- my $open_paren = index($source_line, "(", $column_index);
- return $column if $open_paren < 0;
-
- my $prefix = substr($source_line, 0, $open_paren);
- return $column if $prefix !~ /([A-Za-z_][A-Za-z0-9_]*)\s*$/;
-
- my $callee = $1;
- my $callee_index = rindex($prefix, $callee);
- return $column if $callee_index < 0;
-
- my $target_column = $callee_index + 1;
- return $column if $target_column <= $column;
-
- my $between = substr($source_line, $column_index, $target_column - $column);
- return $column if $between !~ /\./;
-
- return $target_column;
-}
-
-while (my $line = <STDIN>) {
- my $newline = $line =~ s/\r?\n$// ? "\n" : "";
-
- if ($line =~ m{^([^:\n]+\.zig):(\d+):(\d+):\s*(error|warning|note):\s*(.*)$}) {
- my ($path, $line_number, $column, $severity, $message) = ($1, $2, $3, $4, $5);
- my $normalized = normalize_path($path);
-
- if ($message =~ /\bexpected\b.*argument\(s\).*\bfound\b/i) {
- my $source_line = source_line_for_path($normalized, $line_number);
- $column = adjusted_call_column($source_line, $column);
- }
-
- $line = "$normalized:$line_number:$column: $severity: $message";
- } elsif ($line =~ m{^([^:\n]+\.zig):(\d+):(\d+):}) {
- my ($path, $line_number, $column) = ($1, $2, $3);
- my $normalized = normalize_path($path);
- $line =~ s{^[^:\n]+\.zig:\d+:\d+:}{$normalized:$line_number:$column:};
- }
-
- print $line, $newline;
-}