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:57:28 UTC
[couchdb-escodegen] reference refs/pull/153/head created (now
3aff017)
This is an automated email from the ASF dual-hosted git repository.
davisp pushed a change to reference refs/pull/153/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git.
at 3aff017 fix comment duplication
This reference includes the following new commits:
new 3aff017 fix comment duplication
The 1 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] 01/01: fix comment duplication
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/153/head
in repository https://gitbox.apache.org/repos/asf/couchdb-escodegen.git
commit 3aff017d939511e449e27fadcf6fcd704810633f
Author: Matt DuVall <md...@gmail.com>
AuthorDate: Wed Dec 18 00:27:42 2013 -0800
fix comment duplication
---
escodegen.js | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/escodegen.js b/escodegen.js
index 5be8063..dfb5810 100644
--- a/escodegen.js
+++ b/escodegen.js
@@ -675,7 +675,7 @@
}
function addCommentsToStatement(stmt, result) {
- var i, len, comment, save, tailingToStatement, specialBase, fragment;
+ var i, len, comment, save, tailingToStatement, specialBase, fragment, rangesAdded = {};
if (stmt.leadingComments && stmt.leadingComments.length > 0) {
save = result;
@@ -697,6 +697,7 @@
fragment.push('\n');
}
result.push(addIndent(fragment));
+ rangesAdded[comment.range.toString()] = 1;
}
result.push(addIndent(save));
@@ -707,24 +708,27 @@
specialBase = stringRepeat(' ', calculateSpaces(toSourceNode([base, result, indent]).toString()));
for (i = 0, len = stmt.trailingComments.length; i < len; ++i) {
comment = stmt.trailingComments[i];
- if (tailingToStatement) {
- // We assume target like following script
- //
- // var t = 20; /**
- // * This is comment of t
- // */
- if (i === 0) {
- // first case
- result = [result, indent];
+ if (rangesAdded[comment.range.toString()]) {
+ if (tailingToStatement) {
+
+ // We assume target like following script
+ //
+ // var t = 20; /**
+ // * This is comment of t
+ // */
+ if (i === 0) {
+ // first case
+ result = [result, indent];
+ } else {
+ result = [result, specialBase];
+ }
+ result.push(generateComment(comment, specialBase));
} else {
- result = [result, specialBase];
+ result = [result, addIndent(generateComment(comment))];
+ }
+ if (i !== len - 1 && !endsWithLineTerminator(toSourceNode(result).toString())) {
+ result = [result, '\n'];
}
- result.push(generateComment(comment, specialBase));
- } else {
- result = [result, addIndent(generateComment(comment))];
- }
- if (i !== len - 1 && !endsWithLineTerminator(toSourceNode(result).toString())) {
- result = [result, '\n'];
}
}
}