-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ensure method parameter tooltip/popup never occurs within strings or comments #2072
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible
x = \
" //"
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// some important thing in a comment...
This is NOT a comment.
@@ -63,6 +63,7 @@ mockedVSCode.SnippetString = vscodeMocks.vscMockExtHostedTypes.SnippetString; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
|
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
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.
All ok,
Do remember, #
is used only for single line comments.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#
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; |
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.
It is possible
x = \
" //"
- 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: