Add context-aware autocomplete for QueryDescendants selectors#1368
Draft
JohnnyMorganz wants to merge 1 commit intomainfrom
Draft
Add context-aware autocomplete for QueryDescendants selectors#1368JohnnyMorganz wants to merge 1 commit intomainfrom
JohnnyMorganz wants to merge 1 commit intomainfrom
Conversation
Commit 6b87442 added magic type narrowing for QueryDescendants but no autocomplete support. This adds context-aware completions that understand the CSS-like selector syntax and provide appropriate suggestions based on cursor position within the selector string. Completion contexts: - Class names after combinators (>, >>), commas, parentheses, or spaces - Pseudo-classes (:not, :has) after colons, with snippet parentheses - Property names inside brackets ([...]), scoped to the preceding class - No completions after . or # (tags/names have no LSP data) Implementation: - Attach "QuerySelector" tag to QueryDescendants in RobloxLuauExt.cpp - Add detectSelectorContext() to parse selector content up to cursor - Add findPrecedingClassName() for bracket property completions - Extract getPropertiesOfType() to deduplicate with "Properties" handler - Token-level textEdit replaces only the current token, not the full string - Pseudo-class entries tagged "SelectorPseudoClass" for snippet post-processing - Register [, (, ,, > as completion trigger characters, suppressed outside QuerySelector context - Pseudo-class completions include documentation strings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
TODO: We now trigger a lot of completion for common punctuation. Is this a performance concern? Maybe we need to scope it down to just ClassNames.
A lot of roblox specific details are leaking into the generic Completion.cpp, can we improve this?
Summary
Instance:QueryDescendants("...")selector stringsCompletion Contexts
>,>>,,, space:not,has) with snippet parentheses[...].or#Implementation Details
RobloxLuauExt.cpp: Attaches"QuerySelector"tag toQueryDescendantsRobloxCompletion.cpp: Selector context parser (detectSelectorContext,findPrecedingClassName) and"QuerySelector"handler incompletionCallback. Extracts sharedgetPropertiesOfType()helper to deduplicate with existing"Properties"handlerCompletion.cpp: Computes string content up to cursor for context detection; token-leveltextEditreplaces only the current token instead of the full string; pseudo-class entries get snippet parentheses and documentationLanguageServer.cpp: Registers[,(,,,>as completion trigger characters, suppressed outside QuerySelector contextTest plan
--new-solver🤖 Generated with Claude Code