From 7b0e2513bd388c975b4cb491b0356cb2a0805cd9 Mon Sep 17 00:00:00 2001 From: Raghu Rajagopalan Date: Sun, 27 Mar 2016 11:22:30 +0530 Subject: [PATCH] refactor fns in ast --- src/diagrams/gitGraph/gitGraphAst.js | 8 ++++---- src/diagrams/gitGraph/gitGraphParser.spec.js | 2 +- src/diagrams/gitGraph/parser/gitGraph.jison | 6 +++--- src/diagrams/gitGraph/parser/gitGraph.js | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/diagrams/gitGraph/gitGraphAst.js b/src/diagrams/gitGraph/gitGraphAst.js index 2259b9b36..5ba217d4e 100644 --- a/src/diagrams/gitGraph/gitGraphAst.js +++ b/src/diagrams/gitGraph/gitGraphAst.js @@ -16,7 +16,7 @@ function getId() { exports.setDirection = function(dir) { direction = dir; } -exports.pushCommit = function(msg) { +exports.commit = function(msg) { var commit = { id: getId(), message: msg, parent: head == null ? null : head.id}; @@ -26,12 +26,12 @@ exports.pushCommit = function(msg) { log.debug("in pushCommit"); } -exports.createBranch = function(name) { +exports.branch = function(name) { branches[name] = head != null ? head.id: null; log.debug("in createBranch"); } -exports.mergeBranch = function() { +exports.merge = function() { log.debug("in mergeBranch"); } @@ -41,7 +41,7 @@ exports.checkout = function(branch) { var id = branches[curBranch]; head = commits[id]; } -exports.reset = function () { +exports.clear = function () { commits = {}; head = null; branches = { "master" : head }; diff --git a/src/diagrams/gitGraph/gitGraphParser.spec.js b/src/diagrams/gitGraph/gitGraphParser.spec.js index 4f20d3b0c..c1a499ac9 100644 --- a/src/diagrams/gitGraph/gitGraphParser.spec.js +++ b/src/diagrams/gitGraph/gitGraphParser.spec.js @@ -4,7 +4,7 @@ describe('when parsing a gitGraph',function() { "use strict"; beforeEach(function () { parser.yy = ast; - parser.yy.reset(); + parser.yy.clear(); }); it('should handle a gitGraph defintion', function () { var str = 'gitGraph:\n' + diff --git a/src/diagrams/gitGraph/parser/gitGraph.jison b/src/diagrams/gitGraph/parser/gitGraph.jison index e21d7c0e7..fda4da867 100644 --- a/src/diagrams/gitGraph/parser/gitGraph.jison +++ b/src/diagrams/gitGraph/parser/gitGraph.jison @@ -57,10 +57,10 @@ line ; statement - : COMMIT commit_arg {yy.pushCommit($2)} - | BRANCH ID {yy.createBranch($2)} + : COMMIT commit_arg {yy.commit($2)} + | BRANCH ID {yy.branch($2)} | CHECKOUT ID {yy.checkout($2)} - | MERGE ID {yy.mergeBranch($2)} + | MERGE ID {yy.merge($2)} ; commit_arg diff --git a/src/diagrams/gitGraph/parser/gitGraph.js b/src/diagrams/gitGraph/parser/gitGraph.js index b223fe904..bb336afdc 100644 --- a/src/diagrams/gitGraph/parser/gitGraph.js +++ b/src/diagrams/gitGraph/parser/gitGraph.js @@ -101,16 +101,16 @@ case 5: this.$ =$$[$0-1] break; case 7: -yy.pushCommit($$[$0]) +yy.commit($$[$0]) break; case 8: -yy.createBranch($$[$0]) +yy.branch($$[$0]) break; case 9: yy.checkout($$[$0]) break; case 10: -yy.mergeBranch($$[$0]) +yy.merge($$[$0]) break; case 11: this.$ = ""