diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 02:28:09 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 02:49:36 -0300 |
| commit | 148e48dd9b8cd7e66aa1521daa49a64852b1650e (patch) | |
| tree | edf3c1ca188018164a0713917ca0e336cecd14cd /core/dump.zig | |
| parent | 1ce3bcb6178b720058518a12e45f25769be7d39c (diff) | |
| download | pardes-148e48dd9b8cd7e66aa1521daa49a64852b1650e.tar.gz pardes-148e48dd9b8cd7e66aa1521daa49a64852b1650e.zip | |
syntax, Query, Pick, Names, Band, Stream, File, colors: the Symbols picker grouped by kind, a kind mark on each row (UX DESIGN N, binding; the user: "The lsp symbols should be more organized: types first then functions then fields and the rest (and some indicator to tell the kind)", "For the symbols picker"): the rows are the file's own parse's, as before, now from a symbol walk of their own (syntax.zig `SymbolWalk`, in the same walk of the tree as the sticky headers' declarations, which keep theirs: contextFromTree), by one kind table a grammar (`symbol_rules`: Zig, C, C++, Rust, Go, Python, JavaScript, Java, C#, Kotlin, Scala, Ruby, PHP, bash, Haskell, OCaml, Erlang, Elixir, Clojure, Fortran, Ada, Pascal, PowerShell; JSON, CSS, HTML, Markdown and Typst have no declarations to list), each node's kind as given or found where its grammar cannot say it (Zig's `const S = struct`, `error{...}`, `@This()`, `@Type(...)` a type and `@import(...)` a module, JavaScript's `const f = () => ...` a function, C's declaration a function where a declarator is one's and a const where `const` says so, a Python class's or Kotlin's binding a field in a type); fields and consts are listed now (the sticky headers' declarations had neither), a function's consts and vars never (its locals), each named in the types, functions and modules it is in (`Counts.lines`, `torque.Parser.Parse`; an anonymous struct's members in its owner's, a Rust `impl S`'s in `S`, no row of its own); a row is `t Counts = struct`: its kind's mark (t type, f function, m field, c const, v var, n module, · other), its qualified name, two blanks and what its name's line says after the name (its body's `{`, a trailing `,` or `;` dropped), its line the dim meta at the right end (Band's); the mark in the keyword's ink (colors.Roles.kind, the theme's keyword pushed to 4.5:1 on every tag ground and the selection, as the key ink is), the qualifier and the words after the name dim; with the field empty the rows are types, functions, fields, then the rest (consts, vars, modules, other as one group), each in the text's order; typed, they stay grouped and are scored within each group (Names: `Cand.group`, `before` orders by it, then by `better`), the cursor starts on the best match wherever its group puts it (Names.bestRow, Pick.toBest: after a key, when the parse lands, and following the best while the rest are scored), and the count says where it is; the name alone is matched (`u8` in a signature matches nothing); no header rows: every row is a symbol, ordinary text, and C-q keeps them in a +Search with the mark a word; the query pane's `Symbols` rows the same (Query.gather), its current the best; the parse's answer carries the symbols beside the declarations (Stream.Batch.symbols, an input every replica takes), ContextCache keeps both for the revision (derived, made again at a load), and every producer makes both (the worker, a sticky header's refresh, a load), so a text at a revision has the same symbols everywhere; syntax.zig's tests ran in no test program (core-test's filter `syntax context nested` matched nothing on the base): core/root.zig imports it now, and its 34 pass; RUN (TEST FIRST): syntax.zig "syntax symbols: a Zig file's types, functions, fields and the rest ...", "... C, C++, Rust, Go, Python and JavaScript by their kind tables ...", "... every kind table names nodes of its grammar ..." (23 tables), Pick.zig "Symbols (UX DESIGN N): a Zig file's rows types, functions, fields, then the rest ... the mark in the keyword's ink, the qualifier and the rest dim", "Symbols (UX DESIGN N3): typed, the rows stay grouped ... the cursor starts on the best match ...; the name alone is matched, never the signature", "Symbols (UX DESIGN N): a C++ file's rows ...", "Symbols: every row is ordinary text ..."; on the base the rows were ` 2 pub const Counts = struct {` in the text's order, no mark, no field, the cursor on the first row; core-test -Dtest-filter=ymbols 18/18, core-test 1135/1308 (173 skipped); the stack's suites, the dump fuzz, the soak and the pictures are on the change after this one
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/dump.zig')
| -rw-r--r-- | core/dump.zig | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/dump.zig b/core/dump.zig index 2dde9c8c..663ee083 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -1379,7 +1379,7 @@ test "restored syntax context caches are rebuilt from the text rather than loade const f = &pane.file.?; const declarations = try p.tree_sitter_gpa.alloc(pardes.syntax.ContextDeclaration, 1); @memset(std.mem.sliceAsBytes(declarations), 0); - f.context.replace(p.tree_sitter_gpa, declarations, f.revision); + f.context.replace(p.tree_sitter_gpa, .{ .declarations = declarations }, f.revision); // Older builds persisted these two fields; the schema reader must skip them too. const OldFile = struct { path: []const u8, @@ -1405,13 +1405,14 @@ test "restored syntax context caches are rebuilt from the text rather than loade defer gpa.free(bytes); const q = try load(gpa, opts, bytes, null); defer q.deinit(); - // This build's: the revision kept, the declarations parsed again from - // the text, with the syntax allocator. - const want = try pardes.syntax.contextDeclarations(syntax_gpa.allocator(), f.path, f.content); - defer syntax_gpa.allocator().free(want); + // This build's: the revision kept, the declarations and the symbols + // parsed again from the text, with the syntax allocator. + var want = try pardes.syntax.context(syntax_gpa.allocator(), f.path, f.content); + defer want.deinit(syntax_gpa.allocator()); for (q.panes) |slot| if (slot) |restored| if (restored.file) |file| { try std.testing.expectEqual(f.context.revision, file.context.revision); - try std.testing.expectEqualSlices(pardes.syntax.ContextDeclaration, want, file.context.declarations); + try std.testing.expectEqualSlices(pardes.syntax.ContextDeclaration, want.declarations, file.context.declarations); + try std.testing.expectEqualSlices(pardes.syntax.Symbol, want.symbols, file.context.symbols); }; } |
