utils/Changeset: use jshint

This commit is contained in:
booo 2011-12-22 13:36:01 +01:00
parent 6985b93013
commit c26c45309a

View file

@ -66,7 +66,7 @@ exports.newLen = function (cs) {
exports.opIterator = function (opsStr, optStartIndex) { exports.opIterator = function (opsStr, optStartIndex) {
//print(opsStr); //print(opsStr);
var regex = /((?:\*[0-9a-z]+)*)(?:\|([0-9a-z]+))?([-+=])([0-9a-z]+)|\?|/g; var regex = /((?:\*[0-9a-z]+)*)(?:\|([0-9a-z]+))?([\-+=])([0-9a-z]+)|\?|/g;
var startIndex = (optStartIndex || 0); var startIndex = (optStartIndex || 0);
var curIndex = startIndex; var curIndex = startIndex;
var prevIndex = curIndex; var prevIndex = curIndex;
@ -195,13 +195,11 @@ exports.checkRep = function (cs) {
exports.assert(oldPos < oldLen, oldPos, " >= ", oldLen, " in ", cs); exports.assert(oldPos < oldLen, oldPos, " >= ", oldLen, " in ", cs);
break; break;
case '+': case '+':
{
calcNewLen += o.chars; calcNewLen += o.chars;
numInserted += o.chars; numInserted += o.chars;
exports.assert(calcNewLen < newLen, calcNewLen, " >= ", newLen, " in ", cs); exports.assert(calcNewLen < newLen, calcNewLen, " >= ", newLen, " in ", cs);
break; break;
} }
}
assem.append(o); assem.append(o);
} }
@ -216,7 +214,7 @@ exports.checkRep = function (cs) {
exports.assert(normalized == cs, normalized, ' != ', cs); exports.assert(normalized == cs, normalized, ' != ', cs);
return cs; return cs;
} };
exports.smartOpAssembler = function () { exports.smartOpAssembler = function () {
// Like opAssembler but able to produce conforming exportss // Like opAssembler but able to produce conforming exportss
@ -387,7 +385,7 @@ if (_opt) {
bufOp.chars += bufOpAdditionalCharsAfterNewline + op.chars; bufOp.chars += bufOpAdditionalCharsAfterNewline + op.chars;
bufOp.lines += op.lines; bufOp.lines += op.lines;
bufOpAdditionalCharsAfterNewline = 0; bufOpAdditionalCharsAfterNewline = 0;
} else if (bufOp.lines == 0) { } else if (bufOp.lines === 0) {
// both bufOp and op are in-line // both bufOp and op are in-line
bufOp.chars += op.chars; bufOp.chars += op.chars;
} else { } else {
@ -667,13 +665,13 @@ exports.textLinesMutator = function (lines) {
enterSplice(); enterSplice();
} }
function nextKLinesText(k) { var nextKLinesText = function nextKLinesText(k) {
var m = curSplice[0] + curSplice[1]; var m = curSplice[0] + curSplice[1];
return lines_slice(m, m + k).join(''); return lines_slice(m, m + k).join('');
} };
if (isCurLineInSplice()) { if (isCurLineInSplice()) {
//print(curCol); //print(curCol);
if (curCol == 0) { if (curCol === 0) {
removed = curSplice[curSplice.length - 1]; removed = curSplice[curSplice.length - 1];
// print("FOO"); // case foo // print("FOO"); // case foo
curSplice.length--; curSplice.length--;
@ -719,6 +717,7 @@ exports.textLinesMutator = function (lines) {
if (!inSplice) { if (!inSplice) {
enterSplice(); enterSplice();
} }
var sline;
if (L) { if (L) {
var newLines = exports.splitTextLines(text); var newLines = exports.splitTextLines(text);
if (isCurLineInSplice()) { if (isCurLineInSplice()) {
@ -729,7 +728,7 @@ exports.textLinesMutator = function (lines) {
//curLine += newLines.length; //curLine += newLines.length;
//} //}
//else { //else {
var sline = curSplice.length - 1; sline = curSplice.length - 1;
var theLine = curSplice[sline]; var theLine = curSplice[sline];
var lineCol = curCol; var lineCol = curCol;
curSplice[sline] = theLine.substring(0, lineCol) + newLines[0]; curSplice[sline] = theLine.substring(0, lineCol) + newLines[0];
@ -745,7 +744,7 @@ exports.textLinesMutator = function (lines) {
curLine += newLines.length; curLine += newLines.length;
} }
} else { } else {
var sline = putCurLineInSplice(); sline = putCurLineInSplice();
curSplice[sline] = curSplice[sline].substring(0, curCol) + text + curSplice[sline].substring(curCol); curSplice[sline] = curSplice[sline].substring(0, curCol) + text + curSplice[sline].substring(curCol);
curCol += text.length; curCol += text.length;
} }
@ -949,7 +948,6 @@ exports._slicerZipperFunc = function (attOp, csOp, opOut, pool) {
} else { } else {
switch (csOp.opcode) { switch (csOp.opcode) {
case '-': case '-':
{
if (csOp.chars <= attOp.chars) { if (csOp.chars <= attOp.chars) {
// delete or delete part // delete or delete part
if (attOp.opcode == '=') { if (attOp.opcode == '=') {
@ -977,16 +975,12 @@ exports._slicerZipperFunc = function (attOp, csOp, opOut, pool) {
attOp.opcode = ''; attOp.opcode = '';
} }
break; break;
}
case '+': case '+':
{
// insert // insert
exports.copyOp(csOp, opOut); exports.copyOp(csOp, opOut);
csOp.opcode = ''; csOp.opcode = '';
break; break;
}
case '=': case '=':
{
if (csOp.chars <= attOp.chars) { if (csOp.chars <= attOp.chars) {
// keep or keep part // keep or keep part
opOut.opcode = attOp.opcode; opOut.opcode = attOp.opcode;
@ -1010,15 +1004,12 @@ exports._slicerZipperFunc = function (attOp, csOp, opOut, pool) {
csOp.lines -= attOp.lines; csOp.lines -= attOp.lines;
} }
break; break;
}
case '': case '':
{
exports.copyOp(attOp, opOut); exports.copyOp(attOp, opOut);
attOp.opcode = ''; attOp.opcode = '';
break; break;
} }
} }
}
}; };
exports.applyToAttribution = function (cs, astr, pool) { exports.applyToAttribution = function (cs, astr, pool) {
@ -1470,7 +1461,7 @@ exports.appendATextToAssembler = function (atext, assem) {
}; };
exports.prepareForWire = function (cs, pool) { exports.prepareForWire = function (cs, pool) {
var newPool = AttributePoolFactory.createAttributePool();; var newPool = AttributePoolFactory.createAttributePool();
var newCs = exports.moveOpsToNewPool(cs, pool, newPool); var newCs = exports.moveOpsToNewPool(cs, pool, newPool);
return { return {
translated: newCs, translated: newCs,
@ -1480,7 +1471,7 @@ exports.prepareForWire = function (cs, pool) {
exports.isIdentity = function (cs) { exports.isIdentity = function (cs) {
var unpacked = exports.unpack(cs); var unpacked = exports.unpack(cs);
return unpacked.ops == "" && unpacked.oldLen == unpacked.newLen; return unpacked.ops === "" && unpacked.oldLen == unpacked.newLen;
}; };
exports.opAttributeValue = function (op, key, pool) { exports.opAttributeValue = function (op, key, pool) {