Commit b58e22f
authored
Improve the outline (#136)
This PR adds several changes to improve the current state of the outline
for multiple Java pieces of code. This will not only be reflected in the
outline panel, but also in the buffer symbols, which in my case, is what
I prefer to navigate across all the symbols in the current file. At the
beginning, my motivation was to solve an issue related to how the
methods were appearing in the sticky scroll, but this led me a rabbit
hole where I discovered that a lot more was missing in the outline,
namely the following:
Things that didn't appear in the outline before:
1. Constructors.
2. Any `class`, `interface`, `enum`, `record` and `annotation` (even if
nested) that had no modifiers (access and non-access).
3. Fields and methods that had no modifiers (access and non-access).
4. Static blocks.
5. The types of the fields and the return type of methods.
6. Enum declaration.
7. Enum constants.
8. Annotation type declaration.
9. Annotation type elements.
10. The constant fields of an interface.
11. The parameters of a record constructor.
And lastly, these changes have as consequence also the fixing of an
issue related to the sticky scroll. The purpose of the sticky scroll is
to give you context about the class and the method you are currently in,
which can be very useful in multiple scenarios. However, there was an
issue that when a method or class had an annotation, that annotation
would appear in the sticky scroll instead of the whole method
declaration, defeating the purpose of the sticky scroll.
This feature was recently
[introduced](zed-industries/zed#42242 (comment))
and can be enabled in `settings.json`:
```json
"sticky_scroll": {
"enabled": true
}
```
**Limitations I found**:
1. Currently, there's always a space after a parameter type in the outline. Even before these changes, when a method had parameters, even though the parameter types were not shown, there was a space left inside the parenthesis. After trying to solve this with no success, I'm very inclined to believe this is probably an issue on Zed's side.
2. For records, the constructor parameters appear at the top level in the outline. To nest them under the record declaration, we need the entire `record_declaration` marked as `@item`, but marking the entire `record_declaration` as `@item` causes the sticky scroll to show the annotation (because it includes the entire text range starting with any annotation that is present).
**Before**:
https://github.com/user-attachments/assets/ba836bc7-3259-4e2b-b100-ce0e57c88b67
**Now**:
https://github.com/user-attachments/assets/12604ee1-7631-4b75-a95f-a30aff87add81 parent cec444d commit b58e22f
1 file changed
+141
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
| 46 | + | |
45 | 47 | | |
46 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
47 | 106 | | |
48 | 107 | | |
49 | 108 | | |
| |||
57 | 116 | | |
58 | 117 | | |
59 | 118 | | |
60 | | - | |
| 119 | + | |
| 120 | + | |
61 | 121 | | |
62 | 122 | | |
63 | 123 | | |
64 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
65 | 175 | | |
66 | 176 | | |
67 | 177 | | |
| |||
73 | 183 | | |
74 | 184 | | |
75 | 185 | | |
76 | | - | |
| 186 | + | |
| 187 | + | |
77 | 188 | | |
78 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
0 commit comments