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
Enable completions inside parenthesized expressions #1221
Conversation
Is there a plan for intellisense for outside parenthesis? What about intellisense without a closed parenthesis (Error hints that you should probably insert the missing
Additionally, I think parenthesis should be blocked inside
|
@TarunSunkaraneni
This is a good find. We should open an issue and track this as a bug.
With this PR you now get a "missing )" error.
These two cases are not syntactically valid. The first line doesn't work because we don't support single-line array. For the second one, I think the parser already handles it correctly, and it feels hacky to me to treat it as a special case. |
I think in general we do have a problem with how we handle un-closed parentheses, braces and brackets. c# intellisense continues to function even if you don't close whatever symbol was opened, so I think we will need to do the same in the future regardless. (Requires a bit change to the parser recovery logic.) For dot property access completions on parenthesized expressions, we are missing the logic to flow the "declared type" through those types of syntax nodes. It should light up once that's fixed. |
@@ -70,7 +70,7 @@ module './main.bicep' = if | |||
|
|||
module './main.bicep' = if ( | |||
//@[7:21) [BCP096 (Error)] Expected a module identifier at this location. |'./main.bicep'| | |||
//@[28:28) [BCP009 (Error)] Expected a literal value, an array, an object, a parenthesized expression, or a function call at this location. || | |||
//@[28:28) [BCP018 (Error)] Expected the ")" character at this location. || |
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.
) [](start = 42, length = 1)
That's actually confusing. The original error message was correct.
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.
Will try to tweak the error recovery logic to restore the original error message.
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.
@majastrz I tried several ways and the one works best is to change the type of CloseParen
from Token
to SyntaxBase
in order to call WithRecovery
. With this change the original error message is restored, and one bonus side effect is that we now have completions inside an un-closed parenthesized expression (...
😄
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.
Makes sense. The SyntaxBase approach is what we've done in other places too.
In reply to: 552174602 [](ancestors = 552174602)
Codecov Report
@@ Coverage Diff @@
## main #1221 +/- ##
==========================================
+ Coverage 94.48% 95.03% +0.54%
==========================================
Files 338 334 -4
Lines 16987 16853 -134
Branches 14 0 -14
==========================================
- Hits 16050 16016 -34
+ Misses 937 837 -100
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Awesome!
Added error recovery for parenthesized expressions. After the change
()
is parsed as aParenthesizedExpression
(withOpenParen=(
,Expression=SkippedTriviaSyntax
, andCloseParen=)
) rather than aSkippedTriviaSyntax
. The existing completion handling logic is good enough to trigger completions inside an incompleteParenthesizedExpression
.Closes #1223.