Skip to content

Commit 0ae3ecb

Browse files
committed
Fix multiline jsdoc type highlightingFixes microsoft#27777
1 parent 4151e3e commit 0ae3ecb

14 files changed

Lines changed: 1351 additions & 63 deletions

extensions/javascript/syntaxes/JavaScript.tmLanguage.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5254,10 +5254,6 @@
52545254
},
52555255
"jsdoctype": {
52565256
"patterns": [
5257-
{
5258-
"name": "invalid.illegal.type.jsdoc",
5259-
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
5260-
},
52615257
{
52625258
"contentName": "entity.name.type.instance.jsdoc",
52635259
"begin": "\\G({)",

extensions/javascript/syntaxes/JavaScriptReact.tmLanguage.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5254,10 +5254,6 @@
52545254
},
52555255
"jsdoctype": {
52565256
"patterns": [
5257-
{
5258-
"name": "invalid.illegal.type.jsdoc",
5259-
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
5260-
},
52615257
{
52625258
"contentName": "entity.name.type.instance.jsdoc",
52635259
"begin": "\\G({)",

extensions/typescript-basics/build/update-grammars.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ function removeDom(grammar) {
1717
return grammar;
1818
}
1919

20+
function patchJsdoctype(grammar) {
21+
grammar.repository['jsdoctype'].patterns = grammar.repository['jsdoctype'].patterns.filter(pattern => {
22+
if (pattern.name && pattern.name.indexOf('illegal') >= -1) {
23+
return false;
24+
}
25+
return true;
26+
});
27+
return grammar;
28+
}
29+
30+
function patchGrammar(grammar) {
31+
return removeDom(patchJsdoctype(grammar));
32+
}
33+
2034
function adaptToJavaScript(grammar, replacementScope) {
2135
grammar.name = 'JavaScript (with React support)';
2236
grammar.fileTypes = ['.js', '.jsx', '.es6', '.mjs'];
@@ -44,7 +58,7 @@ function adaptToJavaScript(grammar, replacementScope) {
4458
}
4559

4660
var tsGrammarRepo = 'Microsoft/TypeScript-TmLanguage';
47-
updateGrammar.update(tsGrammarRepo, 'TypeScript.tmLanguage', './syntaxes/TypeScript.tmLanguage.json', grammar => removeDom(grammar));
48-
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', './syntaxes/TypeScriptReact.tmLanguage.json', grammar => removeDom(grammar));
49-
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScript.tmLanguage.json', grammar => adaptToJavaScript(removeDom(grammar), '.js'));
50-
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScriptReact.tmLanguage.json', grammar => adaptToJavaScript(removeDom(grammar), '.js.jsx'));
61+
updateGrammar.update(tsGrammarRepo, 'TypeScript.tmLanguage', './syntaxes/TypeScript.tmLanguage.json', grammar => patchGrammar(grammar));
62+
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', './syntaxes/TypeScriptReact.tmLanguage.json', grammar => patchGrammar(grammar));
63+
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScript.tmLanguage.json', grammar => adaptToJavaScript(patchGrammar(grammar), '.js'));
64+
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScriptReact.tmLanguage.json', grammar => adaptToJavaScript(patchGrammar(grammar), '.js.jsx'));

extensions/typescript-basics/package.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,8 @@
7979
}
8080
},
8181
{
82-
"scopeName": "documentation.markdown.injection",
83-
"path": "./syntaxes/MarkdownDocumentationInjection.tmLanguage.json",
84-
"injectTo": [
85-
"source.ts",
86-
"source.tsx",
87-
"source.js",
88-
"source.js.jsx"
89-
]
90-
},
91-
{
92-
"scopeName": "documentation.example.injection",
93-
"path": "./syntaxes/ExampleJsDoc.injection.tmLanguage.json",
82+
"scopeName": "documentation.injection",
83+
"path": "./syntaxes/jsdoc.injection.tmLanguage.json",
9484
"injectTo": [
9585
"source.ts",
9686
"source.tsx",

extensions/typescript-basics/syntaxes/MarkdownDocumentationInjection.tmLanguage.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

extensions/typescript-basics/syntaxes/TypeScript.tmLanguage.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5303,10 +5303,6 @@
53035303
},
53045304
"jsdoctype": {
53055305
"patterns": [
5306-
{
5307-
"name": "invalid.illegal.type.jsdoc",
5308-
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
5309-
},
53105306
{
53115307
"contentName": "entity.name.type.instance.jsdoc",
53125308
"begin": "\\G({)",

extensions/typescript-basics/syntaxes/TypeScriptReact.tmLanguage.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5254,10 +5254,6 @@
52545254
},
52555255
"jsdoctype": {
52565256
"patterns": [
5257-
{
5258-
"name": "invalid.illegal.type.jsdoc",
5259-
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
5260-
},
52615257
{
52625258
"contentName": "entity.name.type.instance.jsdoc",
52635259
"begin": "\\G({)",

extensions/typescript-basics/syntaxes/ExampleJsDoc.injection.tmLanguage.json renamed to extensions/typescript-basics/syntaxes/jsdoc.injection.tmLanguage.json

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,31 @@
22
"injectionSelector": "L:comment.block.documentation",
33
"patterns": [
44
{
5-
"include": "#example"
5+
"include": "#jsdocbody"
66
}
77
],
88
"repository": {
9+
"jsdocbody": {
10+
"begin": "(?<=/\\*\\*)([^*]|\\*(?!/))*$",
11+
"while": "(^|\\G)\\s*\\*(?!/)(?=([^*]|[*](?!/))*$)",
12+
"patterns": [
13+
{
14+
"include": "text.html.markdown#fenced_code_block"
15+
},
16+
{
17+
"include": "text.html.markdown#lists"
18+
},
19+
{
20+
"include": "#example"
21+
},
22+
{
23+
"include": "source.ts#docblock"
24+
},
25+
{
26+
"include": "text.html.markdown#inline"
27+
}
28+
]
29+
},
930
"example": {
1031
"begin": "((@)example)\\s+(?=([^*]|[*](?!/))*$).*$",
1132
"while": "(^|\\G)\\s(?!@)(?=([^*]|[*](?!/))*$)",
@@ -25,5 +46,5 @@
2546
]
2647
}
2748
},
28-
"scopeName": "documentation.example.injection"
49+
"scopeName": "documentation.injection"
2950
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @example
3+
* 1 + 1
4+
*
5+
* @other
6+
* not colored
7+
*/
8+
const a = 1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* **Bold**
3+
* ```js
4+
* 1 + code
5+
* ```
6+
*/
7+
const a = 1

0 commit comments

Comments
 (0)