UNPKG

@gkotulski/doc_preprocessing

Version:
60 lines (49 loc) 1.32 kB
var {PreprocessorInstruction, TYPE} = require("./preprocessorInstruction") const log = require("./log.js") class PreprocessorRef extends PreprocessorInstruction { constructor() { super() this.content = "" this._id = "" this._filePath = "" } getType() { return TYPE.REF } set ID(inID) { this._id = inID } get ID() { return this._id } set filePath(inFilePath) { this._filePath = inFilePath } get filePath() { return this._filePath } resolve(inContent) { this.content = inContent.substr(this._start, this._end - this._start) } } class REFManager { constructor() { this._ref = new Map() } push(inRef) { if(!this._ref.has(inRef.ID)) { this._ref.set(inRef.ID, inRef) } else { log.show(log.MESSAGE.WARNING, "The reference \'" + inRef.ID + "\' located in " + inRef.filePath + " is already used in " + this._ref.get(inRef.ID).filePath) } } getContentFromID(inID) { if(this._ref.has(inID)) { return {content:this._ref.get(inID).content, error:true} } return {content:"",error:false}; } } exports.PreprocessorRef = PreprocessorRef exports.REFManager = REFManager