mirror of
https://github.com/google/blockly.git
synced 2025-12-15 13:50:08 +01:00
feat: make generator quoting methods public (#7392)
* feat: make quoting methods public * feat: add quote and multilineQuote methods * fix: update code generators to use new methods * chore: remove aliases * chore: revert changes to generators
This commit is contained in:
@@ -170,10 +170,6 @@ export class CodeGenerator {
|
||||
return codeString;
|
||||
}
|
||||
|
||||
// The following are some helpful functions which can be used by multiple
|
||||
|
||||
// languages.
|
||||
|
||||
/**
|
||||
* Prepend a common prefix onto each line of code.
|
||||
* Intended for indenting code or adding comment markers.
|
||||
|
||||
@@ -176,7 +176,6 @@ export class DartGenerator extends CodeGenerator {
|
||||
* Encode a string as a properly escaped Dart string, complete with quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} Dart string.
|
||||
* @protected
|
||||
*/
|
||||
quote_(string) {
|
||||
// Can't use goog.string.quote since $ must also be escaped.
|
||||
@@ -192,7 +191,6 @@ export class DartGenerator extends CodeGenerator {
|
||||
* quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} Dart string.
|
||||
* @protected
|
||||
*/
|
||||
multiline_quote_(string) {
|
||||
const lines = string.split(/\n/g).map(this.quote_);
|
||||
|
||||
@@ -206,7 +206,6 @@ export class JavascriptGenerator extends CodeGenerator {
|
||||
* quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} JavaScript string.
|
||||
* @protected
|
||||
*/
|
||||
quote_(string) {
|
||||
// Can't use goog.string.quote since Google's style guide recommends
|
||||
@@ -222,7 +221,6 @@ export class JavascriptGenerator extends CodeGenerator {
|
||||
* with quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} JavaScript string.
|
||||
* @protected
|
||||
*/
|
||||
multiline_quote_(string) {
|
||||
// Can't use goog.string.quote since Google's style guide recommends
|
||||
|
||||
@@ -149,7 +149,6 @@ export class LuaGenerator extends CodeGenerator {
|
||||
* quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} Lua string.
|
||||
* @protected
|
||||
*/
|
||||
quote_(string) {
|
||||
string = string.replace(/\\/g, '\\\\')
|
||||
@@ -163,7 +162,6 @@ export class LuaGenerator extends CodeGenerator {
|
||||
* quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} Lua string.
|
||||
* @protected
|
||||
*/
|
||||
multiline_quote_(string) {
|
||||
const lines = string.split(/\n/g).map(this.quote_);
|
||||
|
||||
@@ -184,7 +184,6 @@ export class PhpGenerator extends CodeGenerator {
|
||||
* quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} PHP string.
|
||||
* @protected
|
||||
*/
|
||||
quote_(string) {
|
||||
string = string.replace(/\\/g, '\\\\')
|
||||
@@ -198,7 +197,6 @@ export class PhpGenerator extends CodeGenerator {
|
||||
* quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} PHP string.
|
||||
* @protected
|
||||
*/
|
||||
multiline_quote_(string) {
|
||||
const lines = string.split(/\n/g).map(this.quote_);
|
||||
|
||||
@@ -228,7 +228,6 @@ export class PythonGenerator extends CodeGenerator {
|
||||
* Encode a string as a properly escaped Python string, complete with quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} Python string.
|
||||
* @protected
|
||||
*/
|
||||
quote_(string) {
|
||||
string = string.replace(/\\/g, '\\\\').replace(/\n/g, '\\\n');
|
||||
@@ -250,7 +249,6 @@ export class PythonGenerator extends CodeGenerator {
|
||||
* with quotes.
|
||||
* @param {string} string Text to encode.
|
||||
* @return {string} Python string.
|
||||
* @protected
|
||||
*/
|
||||
multiline_quote_(string) {
|
||||
const lines = string.split(/\n/g).map(this.quote_);
|
||||
|
||||
Reference in New Issue
Block a user