Skip to content

Commit

Permalink
#931 Reformatting for compliacne with code standard
Browse files Browse the repository at this point in the history
  • Loading branch information
knsv committed Sep 12, 2019
1 parent 34de311 commit f9b30bd
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 423 deletions.
81 changes: 40 additions & 41 deletions src/diagrams/class/classDb.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { logger } from '../../logger';

import { logger } from '../../logger'

let relations = []
let classes = {}
let relations = [];
let classes = {};

/**
* Function called by parser when a node definition has been found.
Expand All @@ -11,75 +10,75 @@ let classes = {}
* @param type
* @param style
*/
export const addClass = function (id) {
export const addClass = function(id) {
if (typeof classes[id] === 'undefined') {
classes[id] = {
id: id,
methods: [],
members: []
}
};
}
}
};

export const clear = function () {
relations = []
classes = {}
}
export const clear = function() {
relations = [];
classes = {};
};

export const getClass = function (id) {
return classes[id]
}
export const getClasses = function () {
return classes
}
export const getClass = function(id) {
return classes[id];
};
export const getClasses = function() {
return classes;
};

export const getRelations = function () {
return relations
}
export const getRelations = function() {
return relations;
};

export const addRelation = function (relation) {
logger.debug('Adding relation: ' + JSON.stringify(relation))
addClass(relation.id1)
addClass(relation.id2)
relations.push(relation)
}
export const addRelation = function(relation) {
logger.debug('Adding relation: ' + JSON.stringify(relation));
addClass(relation.id1);
addClass(relation.id2);
relations.push(relation);
};

export const addMember = function (className, member) {
const theClass = classes[className]
export const addMember = function(className, member) {
const theClass = classes[className];
if (typeof member === 'string') {
if (member.substr(-1) === ')') {
theClass.methods.push(member)
theClass.methods.push(member);
} else {
theClass.members.push(member)
theClass.members.push(member);
}
}
}
};

export const addMembers = function (className, MembersArr) {
export const addMembers = function(className, MembersArr) {
if (Array.isArray(MembersArr)) {
MembersArr.forEach(member => addMember(className, member))
MembersArr.forEach(member => addMember(className, member));
}
}
};

export const cleanupLabel = function (label) {
export const cleanupLabel = function(label) {
if (label.substring(0, 1) === ':') {
return label.substr(2).trim()
return label.substr(2).trim();
} else {
return label.trim()
return label.trim();
}
}
};

export const lineType = {
LINE: 0,
DOTTED_LINE: 1
}
};

export const relationType = {
AGGREGATION: 0,
EXTENSION: 1,
COMPOSITION: 2,
DEPENDENCY: 3
}
};

export default {
addClass,
Expand All @@ -93,4 +92,4 @@ export default {
cleanupLabel,
lineType,
relationType
}
};
Loading

0 comments on commit f9b30bd

Please sign in to comment.