Fix #65649 - fix injection patching in update-grammar.js
parent
b2ac8d2dcf
commit
509d693aa7
|
@ -4,17 +4,17 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var updateGrammar = require('../../../build/npm/update-grammar');
|
const updateGrammar = require('../../../build/npm/update-grammar');
|
||||||
|
|
||||||
function adaptInjectionScope(grammar) {
|
function adaptInjectionScope(grammar) {
|
||||||
// we're using the HTML grammar from https://github.com/textmate/html.tmbundle which has moved away from source.js.embedded.html
|
// we're using the HTML grammar from https://github.com/textmate/html.tmbundle which has moved away from source.js.embedded.html
|
||||||
let oldInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:text.html.php meta.tag, L:source.js.embedded.html";
|
const oldInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js.embedded.html - (meta.embedded.block.php | meta.embedded.line.php))";
|
||||||
let newInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:text.html.php meta.tag, L:text.html.php source.js";
|
const newInjectionKey = "text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php))";
|
||||||
|
|
||||||
var injections = grammar.injections;
|
const injections = grammar.injections;
|
||||||
var injection = injections[oldInjectionKey];
|
const injection = injections[oldInjectionKey];
|
||||||
if (!injections) {
|
if (!injection) {
|
||||||
throw new Error("Can not find PHP injection");
|
throw new Error("Can not find PHP injection to patch");
|
||||||
}
|
}
|
||||||
delete injections[oldInjectionKey];
|
delete injections[oldInjectionKey];
|
||||||
injections[newInjectionKey] = injection;
|
injections[newInjectionKey] = injection;
|
||||||
|
@ -37,4 +37,3 @@ function fixBadRegex(grammar) {
|
||||||
|
|
||||||
updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex);
|
updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex);
|
||||||
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', adaptInjectionScope);
|
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', adaptInjectionScope);
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,6 @@
|
||||||
"name": "PHP",
|
"name": "PHP",
|
||||||
"scopeName": "text.html.php",
|
"scopeName": "text.html.php",
|
||||||
"injections": {
|
"injections": {
|
||||||
"text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js.embedded.html - (meta.embedded.block.php | meta.embedded.line.php))": {
|
|
||||||
"patterns": [
|
|
||||||
{
|
|
||||||
"include": "#php-tag"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"L:source.php string.quoted.single.sql.php source.sql.embedded.php": {
|
"L:source.php string.quoted.single.sql.php source.sql.embedded.php": {
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
|
@ -115,6 +108,13 @@
|
||||||
"include": "source.php#interpolation_double_quoted"
|
"include": "source.php#interpolation_double_quoted"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"text.html.php - (meta.embedded | meta.tag), L:((text.html.php meta.tag) - (meta.embedded.block.php | meta.embedded.line.php)), L:(source.js - (meta.embedded.block.php | meta.embedded.line.php))": {
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"include": "#php-tag"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"patterns": [
|
"patterns": [
|
||||||
|
|
Loading…
Reference in New Issue