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

Add better autocomplete patch to playground #498

Merged
merged 4 commits into from
Oct 22, 2023

Conversation

u9g
Copy link
Contributor

@u9g u9g commented Oct 19, 2023

With this patch, you can autocomplete directives (with some accuracy based on the preceding field's type) and you can autocomplete fields.

Comment on lines 10 to 11
+const edgeDirectives = new Set(['fold', 'recurse', 'optional', 'transform'])
+const propertyDirectives = new Set(['filter', 'tag', 'output', 'transform'])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this prevent us from doing something like:

{
    Root {
        edge @fold @transform(op: "count") @filter(op: ">", value: ["$zero"]) @output @tag {
            # ... other stuff
        }
        # ... other stuff
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won’t prevent it, but we will not autocomplete properties after transform yet, that seems like it will be much more involved to add, although it can be explored.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a user started typing @filter after a @transform on an edge, will it continue the completion from there?

Imagine they are here:

{ Root { edge @fold @transform(op: "count") @fil

Will it autocomplete @filter and its arguments?

If yes, that's great and let's merge this. If not, we should maybe add all the possible directives that could appear on edges here instead — it's not great if the autocomplete suggests broken code, but it might be worse if it pretends to not understand completely valid code...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it will not, I removed the edge filtering code for now and just left a comment about this case.

@obi1kenobi obi1kenobi merged commit 6e30499 into obi1kenobi:main Oct 22, 2023
19 checks passed
@u9g u9g deleted the better-autocomplete branch October 22, 2023 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants