Skip to content

Commit ef60300

Browse files
committed
Add LSP textDocument/documentHighlight support
Implements document highlight for all symbol types (fields, locals, params, constructors, functions, behaviours, classes) with integration tests covering 12 scenarios.
1 parent 0e6215e commit ef60300

File tree

8 files changed

+869
-4
lines changed

8 files changed

+869
-4
lines changed

.release-notes/5110.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Add LSP textDocument/documentHighlight support
2+
3+
The Pony language server now handles `textDocument/documentHighlight` requests. Placing the cursor on any symbol highlights all occurrences in the file, covering fields, locals, parameters, constructors, functions, behaviours, and type names.

tools/pony-lsp/language_server.pony

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ actor LanguageServer is (Notifier & RequestSender)
9191
this._channel.log(
9292
"\n\n<-\n" + r.json().string())
9393
match \exhaustive\ r.method
94+
| Methods.text_document().document_highlight() =>
95+
try
96+
let document_uri = _get_document_uri(r.params)?
97+
(_router.find_workspace(document_uri)
98+
as WorkspaceManager).document_highlight(document_uri, r)
99+
else
100+
this._channel.send(
101+
ResponseMessage.create(
102+
r.id,
103+
None,
104+
ResponseError(
105+
ErrorCodes.internal_error(),
106+
"[" + r.method + "] No workspace found for '" +
107+
r.json().string() + "'")
108+
)
109+
)
110+
end
94111
| Methods.text_document().definition() =>
95112
try
96113
let document_uri =
@@ -452,6 +469,7 @@ actor LanguageServer is (Notifier & RequestSender)
452469
.update(
453470
"capabilities",
454471
JsonObject
472+
.update("documentHighlightProvider", true)
455473
.update(
456474
"hoverProvider", true)
457475
.update(

tools/pony-lsp/methods.pony

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ primitive TextDocumentMethods
9191
fun did_save(): String val =>
9292
"textDocument/didSave"
9393

94+
fun document_highlight(): String val =>
95+
"textDocument/documentHighlight"
96+
9497
fun document_symbol(): String val =>
9598
"textDocument/documentSymbol"
9699

0 commit comments

Comments
 (0)