src/nodes/constants.js in prettier-0.21.0 vs src/nodes/constants.js in prettier-0.22.0
- old
+ new
@@ -1,25 +1,43 @@
const { concat, group, indent, join, softline } = require("../prettier");
-const { first, makeCall, prefix } = require("../utils");
+const { makeCall } = require("../utils");
+function printConstPath(path, opts, print) {
+ return join("::", path.map(print, "body"));
+}
+
+function printConstRef(path, opts, print) {
+ return path.call(print, "body", 0);
+}
+
+function printDefined(path, opts, print) {
+ return group(
+ concat([
+ "defined?(",
+ indent(concat([softline, path.call(print, "body", 0)])),
+ concat([softline, ")"])
+ ])
+ );
+}
+
+function printField(path, opts, print) {
+ return group(
+ concat([
+ path.call(print, "body", 0),
+ concat([makeCall(path, opts, print), path.call(print, "body", 2)])
+ ])
+ );
+}
+
+function printTopConst(path, opts, print) {
+ return concat(["::", path.call(print, "body", 0)]);
+}
+
module.exports = {
- const_path_field: (path, opts, print) => join("::", path.map(print, "body")),
- const_path_ref: (path, opts, print) => join("::", path.map(print, "body")),
- const_ref: first,
- defined: (path, opts, print) =>
- group(
- concat([
- "defined?(",
- indent(concat([softline, path.call(print, "body", 0)])),
- concat([softline, ")"])
- ])
- ),
- field: (path, opts, print) =>
- group(
- concat([
- path.call(print, "body", 0),
- concat([makeCall(path, opts, print), path.call(print, "body", 2)])
- ])
- ),
- top_const_field: prefix("::"),
- top_const_ref: prefix("::")
+ const_path_field: printConstPath,
+ const_path_ref: printConstPath,
+ const_ref: printConstRef,
+ defined: printDefined,
+ field: printField,
+ top_const_field: printTopConst,
+ top_const_ref: printTopConst
};