This repository has been archived by the owner on Jul 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Introduce the ObjectAttributeCompletionProvider
module
#654
Merged
Conversation
This file contains 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
…the 'LiquidFixer' modules
…e the providers API from 'completions(content, cursor)' to 'completions(relative_path, line, col)'
charlespwd
reviewed
Nov 9, 2022
lib/theme_check/language_server/completion_providers/object_attribute_completion_provider.rb
Outdated
Show resolved
Hide resolved
mgmanzella
reviewed
Nov 10, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolute 🔥!! only question i have is the same one CP raised here
Poitrin
approved these changes
Nov 14, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, I just found some stuff during tophatting :)
Poitrin
reviewed
Nov 14, 2022
lib/theme_check/language_server/completion_providers/object_completion_provider.rb
Outdated
Show resolved
Hide resolved
lib/theme_check/language_server/completion_providers/object_completion_provider.rb
Outdated
Show resolved
Hide resolved
implement `completions(context)` instead of `completions(relative_path, line, col)` to DRY IO calls
mgmanzella
approved these changes
Nov 16, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🚀 🚀
- Introduce scope support the in the `AssignmentsFinder` with the `TolerantParser` - Introduce support to variables defined in iteration statements - Fix documentation format
* Add file at desired location * Read data from JSON file * Update built_in_liquid_objects.json
charlespwd
reviewed
Nov 25, 2022
charlespwd
reviewed
Nov 25, 2022
lib/theme_check/language_server/variable_lookup_finder/assignments_finder.rb
Outdated
Show resolved
Hide resolved
charlespwd
reviewed
Nov 25, 2022
lib/theme_check/language_server/variable_lookup_finder/assignments_finder.rb
Outdated
Show resolved
Hide resolved
charlespwd
reviewed
Nov 25, 2022
lib/theme_check/language_server/variable_lookup_finder/assignments_finder.rb
Outdated
Show resolved
Hide resolved
charlespwd
reviewed
Nov 25, 2022
lib/theme_check/language_server/variable_lookup_finder/tolerant_parser.rb
Outdated
Show resolved
Hide resolved
charlespwd
reviewed
Nov 25, 2022
lib/theme_check/language_server/completion_providers/object_attribute_completion_provider.rb
Outdated
Show resolved
Hide resolved
charlespwd
approved these changes
Nov 25, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :) 🔥 🔥 🔥
- Use a single instance of `CompletionContext` on all providers - Remove variable from all parent scopes when it is defined in a block - Extra visitor and node handler from `AssignmentsFinder` - Remove `index!` in favor of an alternative - Introduce documentation for `TolerantBlockBody` - Rename `ObjectAttributeCompletionProvider#property_doc` to `[...]#property_to_completion`
mgmanzella
added a commit
that referenced
this pull request
Dec 9, 2022
* Define the domain for the `theme-liquid-docs` files (#643) * Introduce the `ObjectAttributeCompletionProvider` module (#654) * Download theme-liquid-docs on package deploy or while running theme-check (#661) * Download theme-liquid-docs on package deploy * Add data fixtures to test downloading theme-liquid-docs * Introduce the `AssignmentsCompletionProvider` to suggest variables (#667) * Refresh theme-liquid-docs on theme-check startup (#671) * Add async download in SourceManager#refresh and mechanism to notify SourceIndex liquid schema is out of date * Tests for SourceIndex state classes and SourceManager#refresh, create helper for shared stubs * Cleanup -- fix test dir name to source_index, aggr requires * Remove class method mock (Net::HTTP.any_instance), affects other tests * Change SourceIndex#local_path to #local_path! to indicate danger, fix syntax of filename const * Suggest filters compatible with the object type (#669) ### WHY are these changes introduced? Fixes #658 ### WHAT is this pull request doing? 1. Adds logic to `FilterCompletionProvider` to… - determine the type of the variable/literal (string, number, array, …) sitting before the filter separator ("input type") - suggest filters that match the specific input type, and filters whose input type is _variable_ (i.e. for more than 1 specific type, e.g. ` | default`) 2. Displays deprecated filters too, so that users can still see the filter they wanted to use. Co-authored-by: Morisa Manzella <[email protected]> Co-authored-by: Julien Poitrin <[email protected]> Co-authored-by: Julien Poitrin <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Overview
The goal of this PR is fixing #642* and introducing new intelligent code completion capabilities on Theme Check.
I recommend reviewing this PR by following the sections below. I've split it into meaningful commits to approach each module individually and clarify its purpose.
Steps to review
1. Minor adjustments
2. Setup our new code completion tools
variable_lookup_finder/constants
module to hold some regexes (they will be used in the future commits)LiquidFixer
AssignmentsFinder
moduleassign
occurrencesAssignmentsFinder
shouldn't index variables when it can't infer the proper type #655VariableLookupFinder
to use theAssignmentsFinder
and theLiquidFixer
modulesVariableLookupFinder
can follow variables and get their types based on assignments3. Improve our code completion suggestions
CompletionEngine
works as an aggregator of all completion providers (each completion provider extendsCompletionProvider
)CompletionProvider
main method fromcompletions(content, cursor)
tocompletions(relative_path, line, col)
content
, which wasthe current tokena subset of the file)4. The new
ObjectAttributeCompletionProvider
providerVariableLookupFinder
implementation to provide intelligent code completion for attributes5. TODO
Steps to 🎩
shopify theme init
* I've been calling the features introduced by this PR as "type inference" in #642 issue. But, I've decided to break that concept into sub-components into this PR to clarify what each phase means.