Skip to content

Commit

Permalink
chore: remove aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
BeksOmega committed Aug 16, 2023
1 parent 00f4bb4 commit b4d17c4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 40 deletions.
10 changes: 2 additions & 8 deletions generators/dart/dart_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class DartGenerator extends CodeGenerator {
* @param {string} string Text to encode.
* @return {string} Dart string.
*/
quote(string) {
quote_(string) {
// Can't use goog.string.quote since $ must also be escaped.
string = string.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\\n')
Expand All @@ -186,25 +186,19 @@ export class DartGenerator extends CodeGenerator {
return '\'' + string + '\'';
}

/** Alias for the `quote` method. Use `quote` instead. */
quote_ = this.quote;

/**
* Encode a string as a properly escaped multiline Dart string, complete with
* quotes.
* @param {string} string Text to encode.
* @return {string} Dart string.
*/
multilineQuote(string) {
multiline_quote_(string) {
const lines = string.split(/\n/g).map(this.quote_);
// Join with the following, plus a newline:
// + '\n' +
return lines.join(' + \'\\n\' + \n');
}

/** Alias for the `multilineQuote` method. Use `multilineQuote` instead. */
multiline_quote_ = this.multilineQuote;

/**
* Common tasks for generating Dart from blocks.
* Handles comments for the specified block and any connected value blocks.
Expand Down
10 changes: 2 additions & 8 deletions generators/javascript/javascript_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export class JavascriptGenerator extends CodeGenerator {
* @param {string} string Text to encode.
* @return {string} JavaScript string.
*/
quote(string) {
quote_(string) {
// Can't use goog.string.quote since Google's style guide recommends
// JS string literals use single quotes.
string = string.replace(/\\/g, '\\\\')
Expand All @@ -216,25 +216,19 @@ export class JavascriptGenerator extends CodeGenerator {
return '\'' + string + '\'';
}

/** Alias for the `quote` method. Use `quote` instead. */
quote_ = this.quote;

/**
* Encode a string as a properly escaped multiline JavaScript string, complete
* with quotes.
* @param {string} string Text to encode.
* @return {string} JavaScript string.
*/
multilineQuote(string) {
multiline_quote_(string) {
// Can't use goog.string.quote since Google's style guide recommends
// JS string literals use single quotes.
const lines = string.split(/\n/g).map(this.quote_);
return lines.join(' + \'\\n\' +\n');
}

/** Alias for the `multilineQuote` method. Use `multilineQuote` instead. */
multiline_quote_ = this.multilineQuote;

/**
* Common tasks for generating JavaScript from blocks.
* Handles comments for the specified block and any connected value blocks.
Expand Down
10 changes: 2 additions & 8 deletions generators/lua/lua_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,26 @@ export class LuaGenerator extends CodeGenerator {
* @param {string} string Text to encode.
* @return {string} Lua string.
*/
quote(string) {
quote_(string) {
string = string.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\\n')
.replace(/'/g, '\\\'');
return '\'' + string + '\'';
};

/** Alias for the `quote` method. Use `quote` instead. */
quote_ = this.quote;

/**
* Encode a string as a properly escaped multiline Lua string, complete with
* quotes.
* @param {string} string Text to encode.
* @return {string} Lua string.
*/
multilineQuote(string) {
multiline_quote_(string) {
const lines = string.split(/\n/g).map(this.quote_);
// Join with the following, plus a newline:
// .. '\n' ..
return lines.join(' .. \'\\n\' ..\n');
};

/** Alias for the `multilineQuote` method. Use `multilineQuote` instead. */
multiline_quote_ = this.multilineQuote;

/**
* Common tasks for generating Lua from blocks.
* Handles comments for the specified block and any connected value blocks.
Expand Down
10 changes: 2 additions & 8 deletions generators/php/php_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,33 +185,27 @@ export class PhpGenerator extends CodeGenerator {
* @param {string} string Text to encode.
* @return {string} PHP string.
*/
quote(string) {
quote_(string) {
string = string.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\\n')
.replace(/'/g, '\\\'');
return '\'' + string + '\'';
};

/** Alias for the `quote` method. Use `quote` instead. */
quote_ = this.quote;

/**
* Encode a string as a properly escaped multiline PHP string, complete with
* quotes.
* @param {string} string Text to encode.
* @return {string} PHP string.
*/
multilineQuote(string) {
multiline_quote_(string) {
const lines = string.split(/\n/g).map(this.quote_);
// Join with the following, plus a newline:
// . "\n" .
// Newline escaping only works in double-quoted strings.
return lines.join(' . \"\\n\" .\n');
};

/** Alias for the `multilineQuote` method. Use `multilineQuote` instead. */
multiline_quote_ = this.multilineQuote;

/**
* Common tasks for generating PHP from blocks.
* Handles comments for the specified block and any connected value blocks.
Expand Down
10 changes: 2 additions & 8 deletions generators/python/python_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class PythonGenerator extends CodeGenerator {
* @param {string} string Text to encode.
* @return {string} Python string.
*/
quote(string) {
quote_(string) {
string = string.replace(/\\/g, '\\\\').replace(/\n/g, '\\\n');

// Follow the CPython behaviour of repr() for a non-byte string.
Expand All @@ -244,25 +244,19 @@ export class PythonGenerator extends CodeGenerator {
return quote + string + quote;
}

/** Alias for the `quote` method. Use `quote` instead. */
quote_ = this.quote;

/**
* Encode a string as a properly escaped multiline Python string, complete
* with quotes.
* @param {string} string Text to encode.
* @return {string} Python string.
*/
multilineQuote(string) {
multiline_quote_(string) {
const lines = string.split(/\n/g).map(this.quote_);
// Join with the following, plus a newline:
// + '\n' +
return lines.join(' + \'\\n\' + \n');
}

/** Alias for the `multilineQuote` method. Use `multilineQuote` instead. */
multiline_quote_ = this.multilineQuote;

/**
* Common tasks for generating Python from blocks.
* Handles comments for the specified block and any connected value blocks.
Expand Down

0 comments on commit b4d17c4

Please sign in to comment.