Ensure method parameter tooltip/popup never occurs within strings or comments#2072
Ensure method parameter tooltip/popup never occurs within strings or comments#2072d3r3kk merged 8 commits intomicrosoft:masterfrom
Conversation
- issue microsoft#2057 - struggling with test framework & signature provider!
- incorporate Don's vscMock for SignatureHelp - completely revert changes I'd made to completionSource tests - create new 'pythonSignatureProvider' test suite
| if (position.character <= 0) { | ||
| return undefined; | ||
| } | ||
| const filename = document.fileName; |
There was a problem hiding this comment.
Not entirely clear why this block was here? Perhaps I'm missing something...
This code would skip processing for any line that begins with "[whitespace]//" which I believe is invalid for Python.
Please let me know if I should put this back (maybe embedded C-code within a .py file?).
There was a problem hiding this comment.
Yeah, that's true. However, the test here is for a line like this:
// some important thing in a comment...
or this:
// some comment...
...which isn't what Python would hold, I am certain.
(and the quotation marks in your example would fail the test I removed)
There was a problem hiding this comment.
// some important thing in a comment...
This is NOT a comment.
| mockedVSCode.EventEmitter = vscodeMocks.vscMock.EventEmitter; | ||
| mockedVSCode.ConfigurationTarget = vscodeMocks.vscMockExtHostedTypes.ConfigurationTarget; | ||
| mockedVSCode.StatusBarAlignment = vscodeMocks.vscMockExtHostedTypes.StatusBarAlignment; | ||
| mockedVSCode.SignatureHelp = vscodeMocks.vscMockExtHostedTypes.SignatureHelp; |
There was a problem hiding this comment.
@DonJayamanne you rock so hard. I love that I was able to add this mock so easily.
Codecov Report
@@ Coverage Diff @@
## master #2072 +/- ##
==========================================
- Coverage 79.89% 79.79% -0.11%
==========================================
Files 307 307
Lines 14064 14083 +19
Branches 2494 2499 +5
==========================================
Hits 11237 11237
- Misses 2815 2834 +19
Partials 12 12
Continue to review full report at Codecov.
|
| if (offset > 1) { | ||
| // In case position is at the every end of the comment or unterminated string | ||
| index = tokens.getItemContaining(offset - 1); | ||
| index = tokens.getItemContaining(offset - 2); |
There was a problem hiding this comment.
I am having difficulty understanding this one. The given comment is misleading a bit - the test only looks for tokens that are of type TokenType.Comment, but in Python I don't think there is an end to a comment (like there is in Cx languages) - isn't it just # -> everything to EOL for comments in Python? Or is there a special <# ... #> style syntax?
There was a problem hiding this comment.
# is a single line comment token.
We use """ or ''' for multilines
Let me if that answers your question.
If that's ok, then I can approve this PR.
There was a problem hiding this comment.
Totally answers my question... so removing this block here was the right move I would think.
I'm actually writing a few more tests for the 'isInsideStringOrComment' at the moment, I'll see if those multi-line strings are handled properly or not.
...sorry - responded to the wrong thing. Blaming my tired brain.
- make it 1-based (was 0-based)
DonJayamanne
left a comment
There was a problem hiding this comment.
All ok,
Do remember, # is used only for single line comments.
| if (offset > 1) { | ||
| // In case position is at the every end of the comment or unterminated string | ||
| index = tokens.getItemContaining(offset - 1); | ||
| index = tokens.getItemContaining(offset - 2); |
There was a problem hiding this comment.
# is a single line comment token.
We use """ or ''' for multilines
Let me if that answers your question.
If that's ok, then I can approve this PR.
| if (position.character <= 0) { | ||
| return undefined; | ||
| } | ||
| const filename = document.fileName; |
- determine whether or not cursors are in a string or comment
- previously expecting signatures within a string - this no longer occurs
|
@DonJayamanne so based on the tests that were in place before I began this work, it appears that the signature was expected within a string. Was that the correct way for the extension to be? Or would the new behaviour (never showing function signatures within comments or strings, ever) be correct?
|
Fixes #2057
This pull request: