-
Notifications
You must be signed in to change notification settings - Fork 237
Mark type contents with meta.embedded scope #539
Conversation
microsoft/TypeScript-TmLanguage#537 VS Code uses the meta.embedded scope to mark sections of strings or comments as actually being code instead of string or comment content. This change adds the meta embedded scope to the contents of jsdoc types
grammars/jsdoc.cson
Outdated
@@ -508,7 +508,7 @@ | |||
'name': 'entity.name.type.instance.jsdoc' | |||
'1': | |||
'name': 'punctuation.definition.bracket.curly.begin.jsdoc' | |||
'contentName': 'entity.name.type.instance.jsdoc' | |||
'contentName': 'entity.name.type.instance.jsdoc.meta.embedded' |
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.
'name': 'entity.name.type.instance.jsdoc'
'contentName': 'meta.embedded.js'
grammars/jsdoc.cson
Outdated
@@ -508,7 +508,7 @@ | |||
'name': 'entity.name.type.instance.jsdoc' |
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.
Remove this capture
grammars/jsdoc.cson
Outdated
@@ -508,7 +508,7 @@ | |||
'name': 'entity.name.type.instance.jsdoc' | |||
'1': | |||
'name': 'punctuation.definition.bracket.curly.begin.jsdoc' | |||
'contentName': 'entity.name.type.instance.jsdoc' | |||
'contentName': 'entity.name.type.instance.jsdoc.meta.embedded' | |||
'end': '((}))\\s*|(?=\\*/)' | |||
'endCaptures': | |||
'1': |
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.
Remove this capture
grammars/jsdoc.cson
Outdated
@@ -508,7 +508,7 @@ | |||
'name': 'entity.name.type.instance.jsdoc' | |||
'1': | |||
'name': 'punctuation.definition.bracket.curly.begin.jsdoc' | |||
'contentName': 'entity.name.type.instance.jsdoc' | |||
'contentName': 'entity.name.type.instance.jsdoc.meta.embedded' | |||
'end': '((}))\\s*|(?=\\*/)' |
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.
'end': '(})|(?=\\*/)
@Alhadis is there something I'm missing with my review comments? |
Ok, I made the suggested change except for changing the |
I would prefer the solution listed here if possible, though this PR would still contain some nice scope fixes :). |
Nope, you've got it right. @mjbvz We really, really, really shouldn't remove the existing Example: /** "Doc-ish" comment line */
function(){
} |
@Alhadis Not sure I understand the part about removing scopes. The intent of this change is to add an additional |
Yes, I understand. The problem is that you're assigning these scopes with equal depth: E.g., TextMate's docs are quite elaborate on how the
So the author's example can be visualised as:
Whereas what you're doing is essentially this:
The key difference is in scope priority. Remember, the same definition of "scope" is used for two entirely seperate affairs: conveying semantic information, and syntax highlighting. You're concerned with the former, but the proposed changes are messing with the latter. What was that Edsger Dijkstra said about separation of concerns, again...? ;) @50Wliu I better take care of this. Both parties can be satisfied, but it takes a "text mate" to do it. 😜 I need to finish saving the trees first; |
I should also stress this grammar has violated TextMate scope-semantics dozens of times already, and the scopes chosen for JSDoc highlighting were sadly some of the worst. Unfortunately, what we have is what themes are using for highlighting (as well as GitHub), so we're kinda stuck with this for a while. This also includes themes which mistakenly highlight the |
Any updates on this? #541 does not address the same thing as this PR |
On my list to re-review. |
Sorry for the delay! Looking into this now. |
I am with @Alhadis that adding the |
@50Wliu We can use any |
@mjbvz It's a mistake to treat this as any sort or language, and it's only for the sake of maintainability that JSDoc's patterns have even been separated. Keep in mind this grammar has been stuck with incorrect scope choices for a very long time tgab |
I'm sorry, I pocketed my mobile while typing this, and my phone must have gotten impatient waiting for me to finish... 😓 *Keep in mind that this grammar has been stuck with incorrect scope choices for a very long time, and it's only recently that we've been reaching some sort of consistent and logical structure with relation to our scope choices. Glueing scopes to overcome a technical limitation (not to mention a rather arbitrary one) feels like a step backwards. I'll admit this grammar doesn't have the cleanest history when it comes to structure or semantics, but it's come a long way. |
@Alhadis I don't understand why this would be backwards step for the grammar though. In JSDocs, the type is a distinct part of the comment and it uses its own domain specific language. This proposed change seems like a great use case for the meta.embedded scope and I don't think the fact that is driven by our tooling needs makes the proposal less valid |
We added a way to explicitly override the token kind (string vs comment vs language) per scope in VS Code: microsoft/vscode@d74145e This accomplishes the same thing as using |
microsoft/TypeScript-TmLanguage#537
Description of the Change
VS Code uses the meta.embedded scope to mark sections of strings or comments as actually being code instead of string or comment content. This change adds the meta embedded scope to the contents of jsdoc types
Alternate Designs
Instead of modifying the existing
"contentName"
, it may be better to add a new scope formeta.embedded.line.js
. I wasn't able to figure out how to do this. Let me know if you have any suggestionsBenefits
Marker for what is code content with a jsdoc
Possible Drawbacks
Changes existing scopes
Applicable Issues
microsoft/TypeScript-TmLanguage#537