Commit c1efd3b
authored
feat: subscript access, setter methods, def self.method, heredoc fix (#21)
* feat: add subscript access, setter methods, def self.method, heredoc fix
Subscript expressions:
- arr[0], hash[:key], matrix[i][j] via SubscriptExpression
- Subscript assignment: arr[0] = 42, HASH[key] ||= []
Method definition improvements:
- Setter methods: def name=(val) ... end
- Class methods: def self.method(args) ... end (with and without parens)
Heredoc vs left-shift fix:
- Bare identifier heredocs (<<FILE) now reject non-whitespace after
the delimiter on the opening line, preventing <<File.expand_path()
from being misread as a heredoc
Real-world accuracy improvement:
- Devise: 98.0% → 99.1%
- All 7 repos above 95%
88 tests passing (5 new).
* fix: improve indentation deindent on end/else/elsif/rescue keywords
Indentation rules now check context.textAfter for closing keywords.
When typing `end`, `else`, `elsif`, `when`, `rescue`, `ensure` on a
new line inside a block, the line deindents to align with the opening
keyword (def, class, if, begin, etc.).
Previously the indent functions always added one unit regardless of
what was being typed, so `end` would stay indented until manually
adjusted.
* feat: restore hash symbol-key shorthand and fix indentation
Hash shorthand:
- {name: "Alice", age: 30} works again
- Moved Symbol from inline token to external tokenizer (symbolTokenizer)
to eliminate : vs Symbol overlap with Block in expressions
- colonOp handles : in ternary and hash shorthand contexts
- Same pattern as /, <, % external tokenizers
Indentation fix:
- Indent functions now check context.textAfter for closing keywords
- Typing `end`, `else`, `elsif`, `when`, `rescue`, `ensure` immediately
deindents to match the opening keyword
- After `end`, pressing enter starts at column 0 (not indented)
- Intermediate keywords (elsif, else, rescue) indent their bodies
89 tests passing.
* fix: rebuild indentation using indentService for incomplete code
The previous approach used indentNodeProp which depends on complete
parse tree nodes (MethodBody, ClassBody, etc.). These don't exist
while typing because the code is incomplete (no `end` yet).
New approach: text-based indentService that runs BEFORE tree-based
indentation. It checks the previous line's content:
- After def/class/module/if/while/etc. → indent one level
- After else/elsif/rescue/ensure/when → indent one level
- After end → stay at end's level
- On end/else/elsif/rescue/ensure → deindent to match opener
- Default → maintain previous line's indentation
Tree-based indentation (indentNodeProp) is kept only for bracket
delimited constructs ([], {}, ()) where delimitedIndent works well.
89 tests passing.
* fix: handle single-line forms and add comprehensive indent tests
Single-line forms like `class Foo; end`, `def foo; body; end`, and
endless methods `def foo(x) = x + 1` no longer incorrectly indent
the next line. Added 76 programmatic indentation tests covering
block openers, mid-block keywords, end alignment, nesting, modifier
forms, and real-world patterns. Also adds Tab key support and
Cmd+Shift+Enter for insert-line-above in the demo editor.
* feat: comprehensive indentation covering all 18 spec sections
Rewrote indent service to handle:
- Closing delimiters (}, ], )) via backward bracket scanning
- Continuation lines (trailing +, -, *, &&, ||, \, comma)
- Method chaining with leading dots (.bar, .baz)
- Assignment with block openers (x = if, x = case, @foo ||= begin)
- Chain-end detection: returns to base indent when chain/continuation ends
- Lambda/Proc blocks (-> (x) {, -> (x) do)
- Multi-line method def arguments
119 programmatic indent tests covering all 18 sections from the spec:
sections 1-8 (block openers, mid-block, end, delimiters, nesting,
modifiers, single-line), 9 (heredocs), 10 (continuations + chaining),
11 (lambdas), 12 (strings), 13 (assignment blocks), 14 (real-world),
15 (edge cases), 16 (when/in style), 17 (multi-line args), 18 (conditional assign).
* fix: Cmd+Shift+Enter inserts line with correct indentation
The insert-line-above keybinding now calculates the proper indent
level for the new line instead of always placing the cursor at
column 0. Also rebuilt demo bundle with latest indentation fixes.
* docs: update README with current test counts and remove fixed limitations
* chore: bump to 0.2.0, update accuracy benchmarks
Updated README with honest parse accuracy numbers from larger
real-world files (87.4% overall). Documented known limitations
from error pattern analysis. Bumped version to 0.2.0 for the
comprehensive indentation overhaul and edge case fixes.
* docs: add CHANGELOG for 0.1.0 and 0.2.01 parent 0342db2 commit c1efd3b
14 files changed
Lines changed: 923 additions & 98 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | | - | |
59 | | - | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
67 | | - | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
76 | 89 | | |
77 | 90 | | |
78 | 91 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
0 commit comments