feat(completion): array callable method completion#188
Merged
Conversation
c6eb341 to
1305bed
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Add method name completion inside array callable strings. When the cursor is inside the method-name string of [Class::class, '|'] or [$obj, '|'], the LSP now offers method completions from the resolved class. Detection handles ::class constants, $this, typed variables, namespaced classes, whitespace variations, and unclosed strings. Completion reuses the standard member-completion builder so items have identical formatting to regular -> / :: member completions: label details, return type, deprecation tags, and data for lazy documentation resolve. Insert text is post-processed to strip snippet parentheses since we are inserting into a string literal. Works with both instance and static methods. Signed-off-by: Anders Jenbo <anders@jenbo.dk>
1305bed to
77bbdde
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add method name completion inside array callable strings. When the cursor is inside the method-name string of
[Class::class, '|']or[$obj, '|'], the LSP now offers method completions from the resolved class.Motivation
The array-callable navigation work (commit 21a0105) added go-to-definition, find-references, and rename for array callable method strings. This PR extends that with completion — the last missing piece for a full editing experience with array callables like
Route::get('/', [IndexPageController::class, 'indexPage']).What's included
Detection (
detect_array_callable_context)[Class::class, '|']and[$var, '|']patterns::classconstants,$this, typed variables, namespaced classes[$this, 'not a method'])Completion (
try_array_callable_completion)Class::class→ FQN resolution via use map / namespace / bare name$this→ enclosing classbuild_union_completion_itemsfrom the standard member-completion builder, so items have identical formatting to regular->/::completions:datafield for lazy documentation resolve (completionItem/resolve)insert_textsince we're inserting into a string literalIntegration
handle_completionbefore theInStringLiteralsuppression, alongside array shape and Eloquent string completionscompletion/mod.rswith module docs