Commit 4507a2c
Fix namespace class definition lookup (Foo::Bar) (#128)
* Initial plan
* Add namespace reference detection for class definition lookup
- Modified possible_definitions to detect :: namespace separator
- Added namespace_reference? helper to check if context uses :: notation
- Updated project_definitions_for to search by path for namespaced names
- Added test cases for namespaced class lookup (Foo::Bar pattern)
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
* Improve namespace reference detection logic
- Use exclusive range for line_before_cursor (characters before cursor)
- Check pattern position relative to cursor more precisely
- Handle clicking anywhere in the namespaced class name
- Prevent false positives when pattern appears elsewhere on line
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
* Fix namespace reference detection to handle edge cases
- Search in reasonable range around cursor position
- Correctly handle multiple occurrences of pattern on same line
- Improve code formatting and documentation
- Validate pattern contains cursor position
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
* cops
* Simplify namespace_reference? to check uppercase letters
Instead of parsing line text to find :: separators, simply check if all
context parts start with uppercase letters. Class/module lookups always
start with uppercase, method calls never do.
This is much simpler and more elegant as suggested in code review.
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
Co-authored-by: Kurt Werle <kurt@CircleW.org>1 parent 9db7394 commit 4507a2c
3 files changed
Lines changed: 74 additions & 2 deletions
File tree
- lib/ruby_language_server
- spec/lib/ruby_language_server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
213 | 214 | | |
214 | 215 | | |
215 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
209 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
210 | 223 | | |
211 | 224 | | |
212 | 225 | | |
| |||
219 | 232 | | |
220 | 233 | | |
221 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
222 | 245 | | |
223 | 246 | | |
224 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
244 | 292 | | |
245 | 293 | | |
246 | 294 | | |
| |||
0 commit comments