prettier-plugin-apex
Advanced tools
Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6
@@ -0,0 +0,0 @@ #!/usr/bin/env node |
@@ -0,0 +0,0 @@ #!/usr/bin/env node |
@@ -0,2 +1,13 @@ | ||
## 1.0.0-alpha.6 | ||
- Fix formatting for trailing comments at the end of block statements ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/12)). | ||
- Fix issue in which comments right before semi colon are not printed ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/11)). | ||
- Assert that all comments have been printed out in the formatted code. | ||
- Fix long expressions not breaking into multi lines ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/16)). | ||
## 1.0.0-alpha.5 | ||
- Fix `apex-ast-serializer` executables not having their execute bits set on *nix ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/10)). | ||
## 1.0.0-alpha.4 | ||
- Support `WITH SECURITY_ENFORCED` in SOQL ([issue](https://github.com/dangmai/prettier-plugin-apex/issues/9)). | ||
@@ -3,0 +14,0 @@ - Fix `npm scripts` pointing to old files. |
@@ -0,0 +0,0 @@ Copyright (c) 2018 Dang Mai |
{ | ||
"name": "prettier-plugin-apex", | ||
"version": "1.0.0-alpha.5", | ||
"version": "1.0.0-alpha.6", | ||
"description": "Salesforce Apex plugin for Prettier", | ||
@@ -33,9 +33,9 @@ "main": "src/index.js", | ||
"devDependencies": { | ||
"eslint": "^5.9.0", | ||
"eslint": "^5.15.1", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"jest": "^23.6.0", | ||
"prettier": "^1.15.0" | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"jest": "^24.1.0", | ||
"prettier": "^1.16.4" | ||
}, | ||
@@ -49,4 +49,4 @@ "peerDependencies": { | ||
"wait-on": "^3.2.0", | ||
"yargs": "^12.0.5" | ||
"yargs": "^13.2.1" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # Prettier Apex [![Build Status](https://travis-ci.org/dangmai/prettier-plugin-apex.svg)](https://travis-ci.org/dangmai/prettier-plugin-apex) |
@@ -7,3 +7,3 @@ /* eslint no-param-reassign: 0, no-plusplus: 0, no-else-return: 0, consistent-return: 0 */ | ||
const { concat, hardline } = prettier.doc.builders; | ||
const { concat, lineSuffix, hardline } = prettier.doc.builders; | ||
const { skipWhitespace } = prettier.util; | ||
@@ -214,5 +214,14 @@ const childNodesCacheKey = require("private").makeUniqueKey(); | ||
} else if (pn) { | ||
// No contest: we have a trailing comment. | ||
breakTies(tiesToBreak, sourceCode); | ||
addTrailingComment(pn, comment); | ||
if (en && en["@class"] === apexNames.BLOCK_STATEMENT && !fn) { | ||
// Special case: this is a trailing comment in a block statement | ||
breakTies(tiesToBreak, sourceCode); | ||
// Our algorithm for attaching comment generally attaches the comment | ||
// to the last node, however we want to attach this comment to the last | ||
// statement node instead. | ||
addTrailingComment(en.stmnts[en.stmnts.length - 1], comment); | ||
} else { | ||
// No contest: we have a trailing comment. | ||
breakTies(tiesToBreak, sourceCode); | ||
addTrailingComment(pn, comment); | ||
} | ||
} else if (fn) { | ||
@@ -234,2 +243,3 @@ // No contest: we have a leading comment. | ||
comments.forEach(comment => { | ||
comment.printed = false; | ||
// These node references were useful for breaking ties, but we | ||
@@ -269,2 +279,3 @@ // don't need them anymore, and they create cycles in the AST that | ||
} | ||
comment.printed = true; | ||
return concat(parts); | ||
@@ -286,6 +297,3 @@ } | ||
if (leadingSpace.length > 0 && numberOfNewLines === 0) { | ||
// If the leading space contains no newlines, then we add at most 1 space | ||
parts.push(" "); | ||
} else if (numberOfNewLines > 0) { | ||
if (numberOfNewLines > 0) { | ||
// If the leading space contains newlines, then add at most 2 new lines | ||
@@ -295,4 +303,21 @@ const numberOfNewLinesToInsert = Math.min(numberOfNewLines, 2); | ||
} | ||
parts.push(print(commentPath)); | ||
if (comment["@class"] === apexNames.INLINE_COMMENT) { | ||
// When we print trailing inline comments, we have to make sure that nothing | ||
// else is printed after it (e.g. a semicolon), so we'll use lineSuffix | ||
// from prettier to buffer the output | ||
if (leadingSpace.length > 0 && numberOfNewLines === 0) { | ||
parts.push(lineSuffix(concat([" ", print(commentPath)]))); | ||
} else { | ||
parts.push(lineSuffix(print(commentPath))); | ||
} | ||
} else { | ||
// Handling block comment, which does not need lineSuffix | ||
if (leadingSpace.length > 0 && numberOfNewLines === 0) { | ||
// If the leading space contains no newlines, then we add at most 1 space | ||
parts.push(" "); | ||
} | ||
parts.push(print(commentPath)); | ||
} | ||
comment.printed = true; | ||
return concat(parts); | ||
@@ -347,2 +372,12 @@ } | ||
trailingParts.push(printTrailingComment(commentPath, options, print)); | ||
} else if (!leading && !trailing) { | ||
// Dangling comments | ||
// Note: in this statement `Integer a = 1 /* Comment */;` | ||
// the comment is considered dangling, since jorje considers the literal | ||
// number 1 node to end after the comment | ||
trailingParts.push(printTrailingComment(commentPath, options, print)); | ||
} else { | ||
throw new Error( | ||
"Comment is not printed because we cannot determine its property. Please submit a bug report with your code sample", | ||
); | ||
} | ||
@@ -349,0 +384,0 @@ }, "apexComments"); |
@@ -0,0 +0,0 @@ #!/usr/bin/env node |
@@ -0,0 +0,0 @@ const parse = require("./parser"); |
@@ -0,0 +0,0 @@ const { argv } = require("yargs"); |
@@ -0,0 +0,0 @@ const { spawn } = require("child_process"); |
@@ -0,0 +0,0 @@ /* eslint no-param-reassign:0 */ |
@@ -0,0 +0,0 @@ const values = { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3269
11731967
+ Addedansi-regex@4.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedcliui@5.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedemoji-regex@7.0.3(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedstring-width@3.1.0(transitive)
+ Addedstrip-ansi@5.2.0(transitive)
+ Addedwrap-ansi@5.1.0(transitive)
+ Addedyargs@13.3.2(transitive)
+ Addedyargs-parser@13.1.2(transitive)
- Removedansi-regex@2.1.13.0.1(transitive)
- Removedcliui@4.1.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcross-spawn@6.0.6(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedexeca@1.0.0(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedinvert-kv@2.0.0(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedlcid@2.0.0(transitive)
- Removedmap-age-cleaner@0.1.3(transitive)
- Removedmem@4.3.0(transitive)
- Removedmimic-fn@2.1.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedos-locale@3.1.0(transitive)
- Removedp-defer@1.0.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-is-promise@2.1.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstring-width@1.0.22.1.1(transitive)
- Removedstrip-ansi@3.0.14.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyargs@12.0.5(transitive)
- Removedyargs-parser@11.1.1(transitive)
Updatedyargs@^13.2.1