Skip to content

Commit 9edbeae

Browse files
committed
Implement textDocument/documentHighlight
1 parent a532ccd commit 9edbeae

7 files changed

Lines changed: 882 additions & 1 deletion

File tree

docs/ARCHITECTURE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ src/
109109
├── references/
110110
│ ├── mod.rs # Find References handler: same-file and cross-file symbol scanning
111111
│ └── tests.rs # Unit tests for find-references
112+
├── highlight/
113+
│ └── mod.rs # Document highlighting: same-file symbol occurrence highlighting
112114
├── diagnostics/
113115
│ ├── mod.rs # Diagnostic collection and publishing (skips vendor files)
114116
│ ├── deprecated.rs # @deprecated usage diagnostics (strikethrough)
@@ -122,6 +124,7 @@ tests/
122124
├── hover.rs # Hover integration tests
123125
├── signature_help.rs # Signature help integration tests
124126
├── implementation.rs # Go-to-implementation integration tests
127+
├── document_highlight.rs # Document highlighting integration tests
125128
├── docblock_*.rs # Docblock parsing and type tests
126129
├── parser.rs # PHP parser / AST extraction tests
127130
├── composer.rs # Composer integration tests

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- **Find References.** "Find All References" locates every usage of a symbol across the project. Supports classes, interfaces, traits, enums, methods, properties, constants, functions, and variables. Variable references are scoped to the enclosing function or closure. Cross-file scanning lazily indexes user files on demand (vendor and stub files are excluded, matching PhpStorm's behaviour). The workspace walk respects `.gitignore` rules, so generated/cached directories (blade cache, Symfony `var/cache/`, `node_modules/`, etc.) are automatically skipped.
1313
- **`#[Deprecated]` attribute support.** PHPantom now reads the `#[Deprecated]` attribute used by phpstorm-stubs (~362 elements) in addition to docblock `@deprecated` tags. The `reason` and `since` fields appear in hover, completion strikethrough, and deprecation diagnostics. When both a docblock tag and an attribute are present, the docblock message takes priority. Works on classes, interfaces, traits, enums, methods, properties, constants, and standalone functions.
1414
- **Deprecation diagnostics for variable member access.** Calling a deprecated method or accessing a deprecated property through a variable (e.g. `$svc->oldMethod()`) now produces a strikethrough diagnostic. Previously only `self::`, `static::`, `$this->`, and explicit class name accesses were checked.
15+
- **Document highlighting.** Placing the cursor on a symbol highlights all other occurrences in the current file. Variables are scoped to their enclosing function or closure. Assignment targets, parameters, foreach bindings, and catch variables are marked as writes; all other occurrences are reads. Class names, members, functions, and constants highlight file-wide.
1516

1617
### Changed
1718

docs/todo.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ Each one removes a reason someone might look elsewhere.
7676

7777
| # | Item | Effort | Domain | Doc Link |
7878
|---|---|---|---|---|
79-
| 18 | Document Highlighting (`textDocument/documentHighlight`) | Low | LSP Features | [lsp-features.md §2](todo/lsp-features.md#2-document-highlighting-textdocumentdocumenthighlight) |
8079
| 19 | Document Symbols (`textDocument/documentSymbol`) | Low | LSP Features | [lsp-features.md §4](todo/lsp-features.md#4-document-symbols-textdocumentdocumentsymbol) |
8180
| 20 | Workspace Symbols (`workspace/symbol`) | Low-Medium | LSP Features | [lsp-features.md §5](todo/lsp-features.md#5-workspace-symbols-workspacesymbol) |
8281
| 21 | Folding Ranges (`textDocument/foldingRange`) | Low | LSP Features | [lsp-features.md §12](todo/lsp-features.md#12-folding-ranges-textdocumentfoldingrange) |

0 commit comments

Comments
 (0)