feat: add method chain autocomplete support#109
Open
abanchev wants to merge 7 commits intobobbylight:masterfrom
Open
feat: add method chain autocomplete support#109abanchev wants to merge 7 commits intobobbylight:masterfrom
abanchev wants to merge 7 commits intobobbylight:masterfrom
Conversation
- Add resolveChainType() to walk dotted prefixes through ClassFile metadata - Add findMethodReturnType() and findFieldType() with superclass chain walking - Add resolveLocalVarType() for local variable type resolution - Replace early-return restrictions with chain-aware resolution logic - Backwards compatible: single identifiers still use existing code path
The parent DefaultCompletionProvider.getAlreadyEnteredText() uses isValidChar() to scan backward, which excludes parentheses. This meant method chains like AudioEngine.sharedEngine().something only returned "." as the entered text, preventing chain resolution. The override scans backward through balanced parentheses so the full chain expression is captured and passed to the chain resolver.
…traction - 8 tests covering simple identifiers, method chains, nested parens, multi-arg, multi-level chains, prefix trimming, plain identifiers - Documents overload return type limitation in findMethodReturnType
findMethodReturnType now accepts an argCount parameter and matches it against MethodInfo.getParameterCount(). Arguments are counted from the call-site expression via countArguments(), which handles nested parentheses. This prevents incorrect type resolution when overloaded methods have different return types. Includes 6 new tests for countArguments covering empty, single, multi-arg, nested parens, and malformed input cases.
Track whether the last scanned token was a dot to distinguish method call parens (foo.bar().) from cast expression parens ((Cast)var.). When ')' follows identifier chars instead of a dot, stop scanning instead of treating the cast parens as part of the chain expression. Also adds tests for cast expression handling and parser verification that local variables with cast assignments inside for loops are correctly parsed.
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
AudioEngine.sharedEngine().playMusic()getAlreadyEnteredTextto scan backward through balanced parentheses so the full chain expression is capturedfindMethodReturnTypematches overloads by parameter count (not just name), preventing incorrect return type resolution when overloads have different return typescountArguments()helper that counts top-level comma-separated args with nested-paren awarenessHow it works
getAlreadyEnteredTextnow returns the full chain (e.g.,foo.bar(x).baz().) instead of stopping at)resolveChainTypesplits the prefix into segments, resolves each through ClassFile metadatafindMethodReturnType/findFieldTypewalk the superclass chain to find inherited membersresolveLocalVarTypehandles local variable type lookup for the first segmentWhat was previously broken
loadCompletionsForCaretPositionQualifiedhad two early-return restrictions rejecting any prefix with dots or non-identifier charactersgetAlreadyEnteredTextexcluded parentheses, sofoo.bar().only returned.Test plan
SourceCompletionProviderTestcovering:getAlreadyEnteredTextwith simple dots, method chains, nested parens, multi-arg, multi-level chainscountArgumentswith empty, single, multi-arg, nested, and malformed inputs