Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support textDocument/prepareRename & textDocument/documentHighlight, improve accuracy of reference finding #732

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5471e1f
feat: support textDocument/prepareRename & textDocument/documentHighl…
4teapo Aug 8, 2024
fbaf1a7
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Aug 9, 2024
7d214c1
Disallow finding references and renaming properties of globals
4teapo Aug 9, 2024
594819d
Remove TODO
4teapo Aug 9, 2024
30819f5
Generalize disallowing renaming of properties in globals
4teapo Aug 9, 2024
baacb8e
Update changelog, get rid of unused variable
4teapo Aug 9, 2024
3ddd71f
Add type check to prepareRename
4teapo Aug 9, 2024
7183abb
Merge branch 'main' into improve-zed-support-and-references
4teapo Aug 10, 2024
d3dff9a
Merge branch 'main' into improve-zed-support-and-references
4teapo Aug 10, 2024
a0c9ba5
Add tests & improvements
4teapo Aug 12, 2024
6edb7fc
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Aug 14, 2024
2500772
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Aug 15, 2024
db128df
Merge branch 'main' into improve-zed-support-and-references
4teapo Aug 22, 2024
fe34d3f
Merge branch 'main' into improve-zed-support-and-references
4teapo Aug 28, 2024
1ddfcab
Merge branch 'main' into improve-zed-support-and-references
4teapo Sep 5, 2024
6d76d2b
Merge branch 'main' into improve-zed-support-and-references
4teapo Sep 12, 2024
6c3a4d8
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Sep 19, 2024
3fcb2f4
Add some more test cases
4teapo Sep 19, 2024
402f723
Merge branch 'main' into improve-zed-support-and-references
4teapo Sep 20, 2024
3304607
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Sep 23, 2024
3f1ebb8
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Oct 4, 2024
97e87e1
Merge branch 'main' into improve-zed-support-and-references
4teapo Oct 6, 2024
1bc72b3
Merge branch 'JohnnyMorganz:main' into improve-zed-support-and-refere…
4teapo Oct 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added

- Added support for the prepare rename request
- Added support for document highlighting

### Fixed

- Fixed property references in assignments not being found (i.e. `bar` in `foo.bar = baz` wouldn't be recognized as a reference to `foo.bar`)
4teapo marked this conversation as resolved.
Show resolved Hide resolved
- Fixed references to required files in types prefixes not being accurate with variable shadowing or separate scopes

## [1.33.1] - 2024-10-05

### Changed
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ target_sources(Luau.LanguageServer PRIVATE
src/platform/roblox/RobloxStudioPlugin.cpp
src/operations/Diagnostics.cpp
src/operations/Completion.cpp
src/operations/DocumentHighlight.cpp
src/operations/DocumentSymbol.cpp
src/operations/DocumentLink.cpp
src/operations/ColorProvider.cpp
Expand Down Expand Up @@ -83,6 +84,8 @@ target_sources(Luau.LanguageServer.Test PRIVATE
tests/SemanticTokens.test.cpp
tests/Sourcemap.test.cpp
tests/References.test.cpp
tests/DocumentHighlight.test.cpp
tests/PrepareRename.test.cpp
tests/Rename.test.cpp
tests/ColorProvider.test.cpp
tests/LuauExt.test.cpp
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Install the binary and run `luau-lsp --help` for more information.
- [x] Go To Definition
- [x] Go To Type Definition
- [x] Find References
- [x] Document Highlight
- [x] Document Link
- [x] Document Symbol
- [x] Color Provider
Expand All @@ -87,7 +88,6 @@ They can be investigated at a later time:
- [ ] Go To Declaration (do not apply)
- [ ] Go To Implementation (do not apply)
- [ ] Code Lens (not necessary)
- [ ] Document Highlight (not necessary - editor highlighting is sufficient)
- [ ] Selection Range (not necessary - editor selection is sufficient)
- [ ] Inline Value (applies for debuggers only)
- [ ] Moniker
Expand Down
12 changes: 11 additions & 1 deletion src/LanguageServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ lsp::ServerCapabilities LanguageServer::getServerCapabilities()
capabilities.implementationProvider = false; // TODO: does this apply to Luau?
// Find References Provider
capabilities.referencesProvider = true;
// Document Highlight Provider
capabilities.documentHighlightProvider = true;
// Document Symbol Provider
capabilities.documentSymbolProvider = true;
// Color Provider
Expand All @@ -82,7 +84,7 @@ lsp::ServerCapabilities LanguageServer::getServerCapabilities()
// Code Action Provider
capabilities.codeActionProvider = {std::vector<lsp::CodeActionKind>{lsp::CodeActionKind::SourceOrganizeImports}, /* resolveProvider: */ false};
// Rename Provider
capabilities.renameProvider = true;
capabilities.renameProvider = {true};
// Folding Range Provider
capabilities.foldingRangeProvider = true;
// Inlay Hint Provider
Expand Down Expand Up @@ -163,6 +165,14 @@ void LanguageServer::onRequest(const id_type& id, const std::string& method, std
{
response = rename(JSON_REQUIRED_PARAMS(baseParams, "textDocument/rename"));
}
else if (method == "textDocument/prepareRename")
{
response = prepareRename(JSON_REQUIRED_PARAMS(baseParams, "textDocument/prepareRename"));
}
else if (method == "textDocument/documentHighlight")
{
response = documentHighlight(JSON_REQUIRED_PARAMS(baseParams, "textDocument/documentHighlight"));
}
else if (method == "textDocument/documentSymbol")
{
response = documentSymbol(JSON_REQUIRED_PARAMS(baseParams, "textDocument/documentSymbol"));
Expand Down
Loading
Loading