You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/18 17:59:38 UTC

[couchdb-escodegen] reference refs/pull/299/head created (now b28ea81)

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a change to reference refs/pull/299/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git.


      at b28ea81  Remove trailing space

This reference includes the following new commits:

     new 3d8f672  Add support for inline comments
     new 7f7ad83  Removed an obsolete export of addInlineComment
     new 034650a  Fix broken indentation
     new b28ea81  Remove trailing space

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[couchdb-escodegen] 03/04: Fix broken indentation

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to reference refs/pull/299/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git

commit 034650add3d2570b87dd7da7bcaadbe76c2ca902
Author: gadisn <ga...@users.noreply.github.com>
AuthorDate: Tue Jun 7 08:56:04 2016 +0300

    Fix broken indentation
    
    Indentation got broken with the introduction of inline comments
---
 escodegen.js | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/escodegen.js b/escodegen.js
index 2c02192..8f9b2a5 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -664,7 +664,7 @@
         return '/*' + comment.value + '*/';
     }
 
-    function addInlineComment(stmt, result) {
+    function addInlineComment(stmt, result, bAddIndent) {
         if (stmt.inlineComments) {
             for (var i = 0; i < stmt.inlineComments.length; i++) {
                 var comment = stmt.inlineComments[i];
@@ -685,8 +685,14 @@
                     result.splice(2 + i, 0, generateComment(comment));
                 }
             }
-        }
-        return result;
+            return result;
+        } else {
+            if (bAddIndent) {
+		return addIndent(result);
+            } else {
+		return result;
+            }
+        }        
     }
 
     function addComments(stmt, result) {
@@ -752,11 +758,11 @@
             }
 
             // Add inline comments after the leading comments were added
-            result.push(addInlineComment(stmt, save));
+            result.push(addInlineComment(stmt, save, true));
         }
         else {
           // Add inline comments
-          result = addInlineComment(stmt, result);
+          result = addInlineComment(stmt, result, false);
         }
 
         if (stmt.trailingComments) {


[couchdb-escodegen] 01/04: Add support for inline comments

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to reference refs/pull/299/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git

commit 3d8f67262318bb880b58b525f6f90587688d1fe8
Author: gadisn <ga...@users.noreply.github.com>
AuthorDate: Sun Jun 5 17:49:12 2016 +0300

    Add support for inline comments
    
    In regard to issue #206 ("Attach comment to an empty object"):
    
    I have an initial modification of attachComments() and addComments() which supports comments in empty object/block.
    
    I've called them inline comments, and they are attached to the node which represents the empty object/block (i.e. ObjectExpression/BlockStatement).
---
 escodegen.js | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/escodegen.js b/escodegen.js
index 30132a8..988a889 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -664,6 +664,31 @@
         return '/*' + comment.value + '*/';
     }
 
+    function addInlineComment(stmt, result) {
+        if (stmt.inlineComments) {
+            for (var i = 0; i < stmt.inlineComments.length; i++) {
+                var comment = stmt.inlineComments[i];
+                // For object, replace '{}' in result with empty array
+                if (stmt.type === Syntax.ObjectExpression) {
+                    if (!isArray(result)) {
+                        result = [];
+                        result.push("{");
+                        result.push("\n");
+                        result.push(generateComment(comment));
+                        result.push("}");
+                    } else {
+                        // Add in index 2: index 0 is '{', index 1 is newline
+                        result.splice(2 + i, 0, generateComment(comment));
+                    }
+                } else if (stmt.type === Syntax.BlockStatement) {
+					// Add in index 2: index 0 is '{', index 1 is newline (see definition of BlockStatement)
+                    result.splice(2 + i, 0, generateComment(comment));
+                }
+            }
+        }
+        return result;
+    }
+
     function addComments(stmt, result) {
         var i, len, comment, save, tailingToStatement, specialBase, fragment,
             extRange, range, prevRange, prefix, infix, suffix, count;
@@ -726,7 +751,12 @@
                 }
             }
 
-            result.push(addIndent(save));
+            // Add inline comments after the leading comments were added
+            result.push(addInlineComment(stmt, save));
+        }
+        else {
+          // Add inline comments
+          result = addInlineComment(stmt, result);
         }
 
         if (stmt.trailingComments) {
@@ -2554,5 +2584,6 @@
     exports.browser = false;
     exports.FORMAT_MINIFY = FORMAT_MINIFY;
     exports.FORMAT_DEFAULTS = FORMAT_DEFAULTS;
+    exports._addInlineComment = addInlineComment
 }());
 /* vim: set sw=4 ts=4 et tw=80 : */


[couchdb-escodegen] 04/04: Remove trailing space

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to reference refs/pull/299/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git

commit b28ea813afb8217409c12c200be2bbd40085d4b0
Author: gadisn <ga...@users.noreply.github.com>
AuthorDate: Tue Jun 7 10:18:32 2016 +0300

    Remove trailing space
---
 escodegen.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/escodegen.js b/escodegen.js
index 8f9b2a5..6ef7cce 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -692,7 +692,7 @@
             } else {
 		return result;
             }
-        }        
+        }
     }
 
     function addComments(stmt, result) {


[couchdb-escodegen] 02/04: Removed an obsolete export of addInlineComment

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to reference refs/pull/299/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git

commit 7f7ad83dbd0fbaafb6549e663a35997671942198
Author: gadisn <ga...@users.noreply.github.com>
AuthorDate: Mon Jun 6 09:14:22 2016 +0300

    Removed an obsolete export of addInlineComment
---
 escodegen.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/escodegen.js b/escodegen.js
index 988a889..2c02192 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -2584,6 +2584,5 @@
     exports.browser = false;
     exports.FORMAT_MINIFY = FORMAT_MINIFY;
     exports.FORMAT_DEFAULTS = FORMAT_DEFAULTS;
-    exports._addInlineComment = addInlineComment
 }());
 /* vim: set sw=4 ts=4 et tw=80 : */