UNPKG

1.13 kBJavaScriptView Raw
1/**
2 * Holds mapping between source position of element (method/branch) and the index in generated file.
3 * @param sourceFilepath
4 * @constructor
5 */
6function SourcePositionMapper(sourceFilepath) {
7 this.sourceFilePath= sourceFilepath;
8 this.methods = {};
9 this.branches = {};
10}
11
12SourcePositionMapper.prototype.addMethod = function(sourcePosition, index){
13 this.methods[sourcePosition] = index;
14}
15
16SourcePositionMapper.prototype.addBranch = function(sourcePosition, index){
17 this.branches[sourcePosition] = index;
18}
19
20SourcePositionMapper.prototype.getMethodIndex = function (sourcePosition){
21 return this.methods[sourcePosition] != null ? this.methods[sourcePosition] : -1;
22}
23
24SourcePositionMapper.prototype.getBranchIndex = function (sourcePosition){
25 return this.branches[sourcePosition] != null ? this.branches[sourcePosition] : -1;
26}
27
28SourcePositionMapper.prototype.getMethodsPosition = function () {
29 return Object.keys(this.methods) || [];
30}
31
32SourcePositionMapper.prototype.getBranchesPosition = function () {
33 return Object.keys(this.branches) || [];
34}
35
36module.exports = SourcePositionMapper;
\No newline at end of file