Skip to content

Commit

Permalink
Fix multiline jsdoc type highlightingFixes #27777
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Apr 11, 2019
1 parent 4151e3e commit 0ae3ecb
Show file tree
Hide file tree
Showing 14 changed files with 1,351 additions and 63 deletions.
4 changes: 0 additions & 4 deletions extensions/javascript/syntaxes/JavaScript.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -5254,10 +5254,6 @@
},
"jsdoctype": {
"patterns": [
{
"name": "invalid.illegal.type.jsdoc",
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
},
{
"contentName": "entity.name.type.instance.jsdoc",
"begin": "\\G({)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5254,10 +5254,6 @@
},
"jsdoctype": {
"patterns": [
{
"name": "invalid.illegal.type.jsdoc",
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
},
{
"contentName": "entity.name.type.instance.jsdoc",
"begin": "\\G({)",
Expand Down
22 changes: 18 additions & 4 deletions extensions/typescript-basics/build/update-grammars.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ function removeDom(grammar) {
return grammar;
}

function patchJsdoctype(grammar) {
grammar.repository['jsdoctype'].patterns = grammar.repository['jsdoctype'].patterns.filter(pattern => {
if (pattern.name && pattern.name.indexOf('illegal') >= -1) {
return false;
}
return true;
});
return grammar;
}

function patchGrammar(grammar) {
return removeDom(patchJsdoctype(grammar));
}

function adaptToJavaScript(grammar, replacementScope) {
grammar.name = 'JavaScript (with React support)';
grammar.fileTypes = ['.js', '.jsx', '.es6', '.mjs'];
Expand Down Expand Up @@ -44,7 +58,7 @@ function adaptToJavaScript(grammar, replacementScope) {
}

var tsGrammarRepo = 'Microsoft/TypeScript-TmLanguage';
updateGrammar.update(tsGrammarRepo, 'TypeScript.tmLanguage', './syntaxes/TypeScript.tmLanguage.json', grammar => removeDom(grammar));
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', './syntaxes/TypeScriptReact.tmLanguage.json', grammar => removeDom(grammar));
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScript.tmLanguage.json', grammar => adaptToJavaScript(removeDom(grammar), '.js'));
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScriptReact.tmLanguage.json', grammar => adaptToJavaScript(removeDom(grammar), '.js.jsx'));
updateGrammar.update(tsGrammarRepo, 'TypeScript.tmLanguage', './syntaxes/TypeScript.tmLanguage.json', grammar => patchGrammar(grammar));
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', './syntaxes/TypeScriptReact.tmLanguage.json', grammar => patchGrammar(grammar));
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScript.tmLanguage.json', grammar => adaptToJavaScript(patchGrammar(grammar), '.js'));
updateGrammar.update(tsGrammarRepo, 'TypeScriptReact.tmLanguage', '../javascript/syntaxes/JavaScriptReact.tmLanguage.json', grammar => adaptToJavaScript(patchGrammar(grammar), '.js.jsx'));
14 changes: 2 additions & 12 deletions extensions/typescript-basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,8 @@
}
},
{
"scopeName": "documentation.markdown.injection",
"path": "./syntaxes/MarkdownDocumentationInjection.tmLanguage.json",
"injectTo": [
"source.ts",
"source.tsx",
"source.js",
"source.js.jsx"
]
},
{
"scopeName": "documentation.example.injection",
"path": "./syntaxes/ExampleJsDoc.injection.tmLanguage.json",
"scopeName": "documentation.injection",
"path": "./syntaxes/jsdoc.injection.tmLanguage.json",
"injectTo": [
"source.ts",
"source.tsx",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5303,10 +5303,6 @@
},
"jsdoctype": {
"patterns": [
{
"name": "invalid.illegal.type.jsdoc",
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
},
{
"contentName": "entity.name.type.instance.jsdoc",
"begin": "\\G({)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5254,10 +5254,6 @@
},
"jsdoctype": {
"patterns": [
{
"name": "invalid.illegal.type.jsdoc",
"match": "\\G{(?:[^}*]|\\*[^/}])+$"
},
{
"contentName": "entity.name.type.instance.jsdoc",
"begin": "\\G({)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,31 @@
"injectionSelector": "L:comment.block.documentation",
"patterns": [
{
"include": "#example"
"include": "#jsdocbody"
}
],
"repository": {
"jsdocbody": {
"begin": "(?<=/\\*\\*)([^*]|\\*(?!/))*$",
"while": "(^|\\G)\\s*\\*(?!/)(?=([^*]|[*](?!/))*$)",
"patterns": [
{
"include": "text.html.markdown#fenced_code_block"
},
{
"include": "text.html.markdown#lists"
},
{
"include": "#example"
},
{
"include": "source.ts#docblock"
},
{
"include": "text.html.markdown#inline"
}
]
},
"example": {
"begin": "((@)example)\\s+(?=([^*]|[*](?!/))*$).*$",
"while": "(^|\\G)\\s(?!@)(?=([^*]|[*](?!/))*$)",
Expand All @@ -25,5 +46,5 @@
]
}
},
"scopeName": "documentation.example.injection"
"scopeName": "documentation.injection"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @example
* 1 + 1
*
* @other
* not colored
*/
const a = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* **Bold**
* ```js
* 1 + code
* ```
*/
const a = 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @typedef {{
* id: number,
* fn: !Function,
* context: (!Object|undefined)
* }}
* @private
*/
goog.dom.animationFrame.Task_;


/**
* @typedef {{
* measureTask: goog.dom.animationFrame.Task_,
* mutateTask: goog.dom.animationFrame.Task_,
* state: (!Object|undefined),
* args: (!Array|undefined),
* isScheduled: boolean
* }}
* @private
*/
goog.dom.animationFrame.TaskSet_;
Loading

0 comments on commit 0ae3ecb

Please sign in to comment.