Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80648778
CodeNode.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 1, 21:24
Size
1 KB
Mime Type
text/x-c++
Expires
Tue, Sep 3, 21:24 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20403939
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
CodeNode.js
View Options
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const getNumberOfLines = require("./helpers").getNumberOfLines;
const getUnfinishedLine = require("./helpers").getUnfinishedLine;
class CodeNode {
constructor(generatedCode) {
this.generatedCode = generatedCode;
}
clone() {
return new CodeNode(this.generatedCode);
}
getGeneratedCode() {
return this.generatedCode;
}
getMappings(mappingsContext) {
const lines = getNumberOfLines(this.generatedCode);
const mapping = Array(lines+1).join(";");
if(lines > 0) {
mappingsContext.unfinishedGeneratedLine = getUnfinishedLine(this.generatedCode);
if(mappingsContext.unfinishedGeneratedLine > 0) {
return mapping + "A";
} else {
return mapping;
}
} else {
const prevUnfinished = mappingsContext.unfinishedGeneratedLine;
mappingsContext.unfinishedGeneratedLine += getUnfinishedLine(this.generatedCode);
if(prevUnfinished === 0 && mappingsContext.unfinishedGeneratedLine > 0) {
return "A";
} else {
return "";
}
}
}
addGeneratedCode(generatedCode) {
this.generatedCode += generatedCode;
}
mapGeneratedCode(fn) {
const generatedCode = fn(this.generatedCode);
return new CodeNode(generatedCode);
}
getNormalizedNodes() {
return [this];
}
merge(otherNode) {
if(otherNode instanceof CodeNode) {
this.generatedCode += otherNode.generatedCode;
return this;
}
return false;
}
}
module.exports = CodeNode;
Event Timeline
Log In to Comment