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

#constructors are missing from completion items #104

Open
mattmasson opened this issue Aug 13, 2021 · 2 comments
Open

#constructors are missing from completion items #104

mattmasson opened this issue Aug 13, 2021 · 2 comments
Assignees

Comments

@mattmasson
Copy link
Member

  1. Start a new PQ editor window
  2. type # (and Ctrl+Space to force suggestions)
  3. Receive no suggstions
@JordanBoltonMN
Copy link
Contributor

The inspection operates on a parser state and the tokens generated by the lexer. The problem with # is that there isn't a token for an isolated hash character. We don't have a way to provably know if we should or shouldn't include those constructors. I'm tempted to put the logic in the provider level since we would have access to the raw text and position coordinates.

@ninmonkey
Copy link
Contributor

I'm tempted to put the logic in the provider level since we would have access to the raw text and position coordinates.

Does the provider level mean completions that come from vscode-powerquery rather than the LanguageServer itself?

Check out the "possibly low impact ideas".

Potentially low impact ideas

The inspection operates on a parser state and the tokens generated by the lexer. The problem with # is that there isn't a token for an isolated hash character. We don't have a way to provably know if we should or shouldn't include those constructors.

foo = #<cursor>

Are you saying the crux of the issue is parsing an incomplete AST,
You cannot determine whether # is going to be a quoted-identifier verses a one of the global identifiers like #duration ?

If yes, could you try this?

1 Can you complete for this specific case? If the user types #<char>

If the first char is not # but the second char is not any of: " or ! or \s
Is that enough to make it non-ambiguous to complete?

[  a =  #d<complete>
   c = 3
]

regex and test data: https://regex101.com/r/UKHMH8/4

(?x-i)
# I replaced escaped literals with codepoints 
# to simplify additional escapes in regex
    (?<=\B) # Maybe required if you don't have it as a token
        # starts with '#'
        \x23
        # is not followed by '"' or '!' or whitespace
        [^\x22\x21\s]
   .*?\b
# context: <https://github.com/microsoft/vscode-powerquery/issues/104>
# test cases: <https://regex101.com/r/UKHMH8/4>  

2 Change sort order for the built in ctor identifiers to be higher?

Example: If you start with a non # prefix like dur<complete>, constructors do show up, but they are sorted low on the list.

image

Is there a debug tool to rule out user settings?

for idea #2 I wanted to verify whether that sort order was the actually coming from the extension -- rather than vcode user settings or the LS.

Is there a dev tool or logger to test whether the extension/LS is giving that sort order?
To rule out user's completion settings, because there's a bunch of them. Ie: Interactions could be complex

I'm not confident that a blank vscode profile without extensions would still be deterministic enough to test. History, and code locations can affect rank order.


Extra Details and Test Cases

It does complete when

The problem with # is that there isn't a token for an isolated hash character

Working: partial matches dur<complete>

image

[ a = dur<complete> , b = 2 ]

Working: evaluates as global?

image

[   a = <cursor>
    b = 2
]

same thing on a single line

[ a = <cursor> b = 3 ]

I think that version is showing every global symbol

Broke: when using comma

image

[   a = <cursor>,
    b = 2
]

I used the phrases broke or bug for simplicity, they may be correct behaviors.

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

No branches or pull requests

3 participants