Skip to content

Commit

Permalink
feat: make generator quoting methods public (#7392)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
BeksOmega authored Aug 21, 2023
1 parent eebf19c commit a0301a2
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 14 deletions.
4 changes: 0 additions & 4 deletions core/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions generators/dart/dart_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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_);
Expand Down
2 changes: 0 additions & 2 deletions generators/javascript/javascript_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions generators/lua/lua_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '\\\\')
Expand All @@ -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_);
Expand Down
2 changes: 0 additions & 2 deletions generators/php/php_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '\\\\')
Expand All @@ -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_);
Expand Down
2 changes: 0 additions & 2 deletions generators/python/python_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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_);
Expand Down

0 comments on commit a0301a2

Please sign in to comment.