Skip to content

Commit

Permalink
refactor isFile to canPrint in type node
Browse files Browse the repository at this point in the history
  • Loading branch information
Angry-Potato committed Jul 19, 2019
1 parent 6f548ce commit 18b9b52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const nodes = {
[NODE_TYPES.FUNCTION_CALL]: require(`./nodes/${NODE_TYPES.FUNCTION_CALL}`)
};

const isInteger = node => node.form == "INT";

const isOperator = node => node.token;

const isFunctionCall = node => node.expr && node.typeArgs && node.args;
Expand Down Expand Up @@ -77,7 +75,7 @@ const assignType = node => {
return { ...node, astType: NODE_TYPES.STRING };
} else if (nodes[NODE_TYPES.TYPE].canPrint(node)) {
return { ...node, astType: NODE_TYPES.TYPE };
} else if (isInteger(node)) {
} else if (nodes[NODE_TYPES.INTEGER].canPrint(node)) {
return { ...node, astType: NODE_TYPES.INTEGER };
} else if (isOperator(node)) {
return { ...node, astType: NODE_TYPES.OPERATOR };
Expand Down
9 changes: 6 additions & 3 deletions src/nodes/integer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const {
}
} = require("prettier");

module.exports = (path, opts, print) => {
const node = path.getValue();
return node.value;
module.exports = {
canPrint: node => node.form == "INT",
print: (path, opts, print) => {
const node = path.getValue();
return node.value;
}
};

0 comments on commit 18b9b52

Please sign in to comment.