mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-13 14:09:06 -05:00
Preserve newlines and indentation for binary expressions when possible.
This commit is contained in:
@@ -3045,13 +3045,54 @@ module ts {
|
||||
}
|
||||
else {
|
||||
emit(node.left);
|
||||
if (node.operatorToken.kind !== SyntaxKind.CommaToken) write(" ");
|
||||
|
||||
if (node.operatorToken.kind !== SyntaxKind.CommaToken) {
|
||||
write(" ");
|
||||
}
|
||||
|
||||
write(tokenToString(node.operatorToken.kind));
|
||||
write(" ");
|
||||
|
||||
var operatorEnd = getLineAndCharacterOfPosition(currentSourceFile, node.operatorToken.end);
|
||||
var rightStart = getLineAndCharacterOfPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.right.pos));
|
||||
|
||||
var ondifferentLine = operatorEnd.line !== rightStart.line;
|
||||
if (ondifferentLine) {
|
||||
var exprStart = getLineAndCharacterOfPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
var firstCharOfExpr = getFirstNonWhitespaceCharacter(exprStart.line);
|
||||
var shouldIndent = rightStart.character > firstCharOfExpr;
|
||||
|
||||
if (shouldIndent) {
|
||||
increaseIndent();
|
||||
}
|
||||
|
||||
writeLine();
|
||||
}
|
||||
else {
|
||||
write(" ");
|
||||
}
|
||||
|
||||
emit(node.right);
|
||||
|
||||
if (shouldIndent) {
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFirstNonWhitespaceCharacter(line: number): number {
|
||||
var lineStart = getLineStarts(currentSourceFile)[line];
|
||||
var text = currentSourceFile.text;
|
||||
|
||||
for (var i = lineStart; i < text.length; i++) {
|
||||
var ch = text.charCodeAt(i);
|
||||
if (!isWhiteSpace(text.charCodeAt(i)) || isLineBreak(ch)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i - lineStart;
|
||||
}
|
||||
|
||||
function emitConditionalExpression(node: ConditionalExpression) {
|
||||
emit(node.condition);
|
||||
write(" ? ");
|
||||
|
||||
@@ -1998,7 +1998,8 @@ function delint(sourceFile) {
|
||||
if (ifStatement.thenStatement.kind !== 172 /* Block */) {
|
||||
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 172 /* Block */ && ifStatement.elseStatement.kind !== 176 /* IfStatement */) {
|
||||
if (ifStatement.elseStatement &&
|
||||
ifStatement.elseStatement.kind !== 172 /* Block */ && ifStatement.elseStatement.kind !== 176 /* IfStatement */) {
|
||||
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -12,6 +12,8 @@ obj[Symbol.foo];
|
||||
|
||||
//// [ES5SymbolProperty1.js]
|
||||
var Symbol;
|
||||
var obj = (_a = {}, _a[Symbol.foo] = 0, _a);
|
||||
var obj = (_a = {}, _a[Symbol.foo] =
|
||||
0,
|
||||
_a);
|
||||
obj[Symbol.foo];
|
||||
var _a;
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
var v = { [yield]: foo }
|
||||
|
||||
//// [FunctionDeclaration8_es6.js]
|
||||
var v = (_a = {}, _a[yield] = foo, _a);
|
||||
var v = (_a = {}, _a[yield] =
|
||||
foo,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -5,6 +5,8 @@ function * foo() {
|
||||
|
||||
//// [FunctionDeclaration9_es6.js]
|
||||
function foo() {
|
||||
var v = (_a = {}, _a[] = foo, _a);
|
||||
var v = (_a = {}, _a[] =
|
||||
foo,
|
||||
_a);
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
var v = { *[foo()]() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments5_es6.js]
|
||||
var v = (_a = {}, _a[foo()] = function () { }, _a);
|
||||
var v = (_a = {}, _a[foo()] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -37,7 +37,9 @@ y
|
||||
//// [asiArith.js]
|
||||
var x = 1;
|
||||
var y = 1;
|
||||
var z = x + + +y;
|
||||
var z = x +
|
||||
+ +y;
|
||||
var a = 1;
|
||||
var b = 1;
|
||||
var c = x - - -y;
|
||||
var c = x -
|
||||
- -y;
|
||||
|
||||
@@ -20,5 +20,6 @@ var v = {
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, _a);
|
||||
var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -32,5 +32,6 @@ var v = (_a = {}, _a[s] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a["hello " + a + " bye"] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a);
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -7,6 +7,8 @@ function foo() {
|
||||
|
||||
//// [computedPropertyNames18_ES5.js]
|
||||
function foo() {
|
||||
var obj = (_a = {}, _a[this.bar] = 0, _a);
|
||||
var obj = (_a = {}, _a[this.bar] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ module M {
|
||||
//// [computedPropertyNames19_ES5.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var obj = (_a = {}, _a[this.bar] = 0, _a);
|
||||
var obj = (_a = {}, _a[this.bar] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
})(M || (M = {}));
|
||||
|
||||
@@ -7,5 +7,6 @@ var v = {
|
||||
//// [computedPropertyNames1_ES5.js]
|
||||
var v = (_a = {}, _a[0 + 1] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a);
|
||||
}, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -4,5 +4,7 @@ var obj = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNames20_ES5.js]
|
||||
var obj = (_a = {}, _a[this.bar] = 0, _a);
|
||||
var obj = (_a = {}, _a[this.bar] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -13,7 +13,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var obj = (_a = {}, _a[this.bar()] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[this.bar()] = function () { },
|
||||
_a);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -15,7 +15,9 @@ var C = (function () {
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[(_a = {}, _a[this.bar()] = 1, _a)[0]] = function () { };
|
||||
C.prototype[(_a = {}, _a[this.bar()] =
|
||||
1,
|
||||
_a)[0]] = function () { };
|
||||
return C;
|
||||
})();
|
||||
var _a;
|
||||
|
||||
@@ -34,7 +34,8 @@ var C = (function (_super) {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { },
|
||||
_a);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -34,7 +34,9 @@ var C = (function (_super) {
|
||||
}
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
C.prototype[(_a = {}, _a[super.bar.call(this)] = 1, _a)[0]] = function () { };
|
||||
C.prototype[(_a = {}, _a[super.bar.call(this)] =
|
||||
1,
|
||||
_a)[0]] = function () { };
|
||||
return C;
|
||||
})(Base);
|
||||
var _a;
|
||||
|
||||
@@ -26,7 +26,8 @@ var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.call(this);
|
||||
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
}
|
||||
return C;
|
||||
|
||||
@@ -17,7 +17,8 @@ var C = (function () {
|
||||
C.prototype.bar = function () {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = (_a = {}, _a[_this.bar()] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[_this.bar()] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
});
|
||||
return 0;
|
||||
|
||||
@@ -32,7 +32,8 @@ var C = (function (_super) {
|
||||
function C() {
|
||||
_super.call(this);
|
||||
(function () {
|
||||
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ var C = (function (_super) {
|
||||
C.prototype.foo = function () {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
});
|
||||
return 0;
|
||||
|
||||
@@ -17,7 +17,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var obj = (_a = {}, _a[foo()] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[foo()] = function () { },
|
||||
_a);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,8 @@ var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.bar = function () {
|
||||
var obj = (_a = {}, _a[foo()] = function () { }, _a);
|
||||
var obj = (_a = {}, _a[foo()] = function () { },
|
||||
_a);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -4,5 +4,7 @@ var o = {
|
||||
};
|
||||
|
||||
//// [computedPropertyNames46_ES5.js]
|
||||
var o = (_a = {}, _a["" || 0] = 0, _a);
|
||||
var o = (_a = {}, _a["" || 0] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -14,5 +14,7 @@ var E2;
|
||||
(function (E2) {
|
||||
E2[E2["x"] = 0] = "x";
|
||||
})(E2 || (E2 = {}));
|
||||
var o = (_a = {}, _a[0 /* x */ || 0 /* x */] = 0, _a);
|
||||
var o = (_a = {}, _a[0 /* x */ || 0 /* x */] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -23,7 +23,13 @@ var E;
|
||||
E[E["x"] = 0] = "x";
|
||||
})(E || (E = {}));
|
||||
var a;
|
||||
extractIndexer((_a = {}, _a[a] = "", _a)); // Should return string
|
||||
extractIndexer((_b = {}, _b[0 /* x */] = "", _b)); // Should return string
|
||||
extractIndexer((_c = {}, _c["" || 0] = "", _c)); // Should return any (widened form of undefined)
|
||||
extractIndexer((_a = {}, _a[a] =
|
||||
"",
|
||||
_a)); // Should return string
|
||||
extractIndexer((_b = {}, _b[0 /* x */] =
|
||||
"",
|
||||
_b)); // Should return string
|
||||
extractIndexer((_c = {}, _c["" || 0] =
|
||||
"",
|
||||
_c)); // Should return any (widened form of undefined)
|
||||
var _a, _b, _c;
|
||||
|
||||
@@ -28,7 +28,8 @@ var x = {
|
||||
//// [computedPropertyNames49_ES5.js]
|
||||
var x = (_a = {
|
||||
p1: 10
|
||||
}, _a.p1 = 10, _a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
}, _a.p1 =
|
||||
10, _a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
throw 10;
|
||||
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
return 10;
|
||||
@@ -39,5 +40,7 @@ var x = (_a = {
|
||||
if (1 == 1) {
|
||||
return 10;
|
||||
}
|
||||
}, enumerable: true, configurable: true }), _a.p2 = 20, _a);
|
||||
}, enumerable: true, configurable: true }), _a.p2 =
|
||||
20,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -20,5 +20,17 @@ var v = {
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var v = (_a = {}, _a[s] = 0, _a[n] = n, _a[s + s] = 1, _a[s + n] = 2, _a[+s] = s, _a[""] = 0, _a[0] = 0, _a[a] = 1, _a[true] = 0, _a["hello bye"] = 0, _a["hello " + a + " bye"] = 0, _a);
|
||||
var v = (_a = {}, _a[s] =
|
||||
0, _a[n] =
|
||||
n, _a[s + s] =
|
||||
1, _a[s + n] =
|
||||
2, _a[+s] =
|
||||
s, _a[""] =
|
||||
0, _a[0] =
|
||||
0, _a[a] =
|
||||
1, _a[true] =
|
||||
0, _a["hello bye"] =
|
||||
0, _a["hello " + a + " bye"] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -33,7 +33,8 @@ var x = (_a = {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
}, _a.p1 = 10, _a.foo = Object.defineProperty({ get: function () {
|
||||
}, _a.p1 =
|
||||
10, _a.foo = Object.defineProperty({ get: function () {
|
||||
if (1 == 1) {
|
||||
return 10;
|
||||
}
|
||||
@@ -44,5 +45,7 @@ var x = (_a = {
|
||||
throw 10;
|
||||
}, enumerable: true, configurable: true }), _a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
return 10;
|
||||
}, enumerable: true, configurable: true }), _a.p2 = 20, _a);
|
||||
}, enumerable: true, configurable: true }), _a.p2 =
|
||||
20,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -11,5 +11,12 @@ var v = {
|
||||
|
||||
//// [computedPropertyNames5_ES5.js]
|
||||
var b;
|
||||
var v = (_a = {}, _a[b] = 0, _a[true] = 1, _a[[]] = 0, _a[{}] = 0, _a[undefined] = undefined, _a[null] = null, _a);
|
||||
var v = (_a = {}, _a[b] =
|
||||
0, _a[true] =
|
||||
1, _a[[]] =
|
||||
0, _a[{}] =
|
||||
0, _a[undefined] =
|
||||
undefined, _a[null] =
|
||||
null,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -12,5 +12,9 @@ var v = {
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var v = (_a = {}, _a[p1] = 0, _a[p2] = 1, _a[p3] = 2, _a);
|
||||
var v = (_a = {}, _a[p1] =
|
||||
0, _a[p2] =
|
||||
1, _a[p3] =
|
||||
2,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -11,5 +11,7 @@ var E;
|
||||
(function (E) {
|
||||
E[E["member"] = 0] = "member";
|
||||
})(E || (E = {}));
|
||||
var v = (_a = {}, _a[0 /* member */] = 0, _a);
|
||||
var v = (_a = {}, _a[0 /* member */] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -12,6 +12,9 @@ function f<T, U extends string>() {
|
||||
function f() {
|
||||
var t;
|
||||
var u;
|
||||
var v = (_a = {}, _a[t] = 0, _a[u] = 1, _a);
|
||||
var v = (_a = {}, _a[t] =
|
||||
0, _a[u] =
|
||||
1,
|
||||
_a);
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -12,5 +12,9 @@ var v = {
|
||||
|
||||
//// [computedPropertyNames9_ES5.js]
|
||||
function f(x) { }
|
||||
var v = (_a = {}, _a[f("")] = 0, _a[f(0)] = 0, _a[f(true)] = 0, _a);
|
||||
var v = (_a = {}, _a[f("")] =
|
||||
0, _a[f(0)] =
|
||||
0, _a[f(true)] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -9,5 +9,8 @@ var o: I = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesContextualType10_ES5.js]
|
||||
var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, _a);
|
||||
var o = (_a = {}, _a[+"foo"] =
|
||||
"", _a[+"bar"] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -12,5 +12,7 @@ var o: I = {
|
||||
//// [computedPropertyNamesContextualType1_ES5.js]
|
||||
var o = (_a = {}, _a["" + 0] = function (y) {
|
||||
return y.length;
|
||||
}, _a["" + 1] = function (y) { return y.length; }, _a);
|
||||
}, _a["" + 1] =
|
||||
function (y) { return y.length; },
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -12,5 +12,7 @@ var o: I = {
|
||||
//// [computedPropertyNamesContextualType2_ES5.js]
|
||||
var o = (_a = {}, _a[+"foo"] = function (y) {
|
||||
return y.length;
|
||||
}, _a[+"bar"] = function (y) { return y.length; }, _a);
|
||||
}, _a[+"bar"] =
|
||||
function (y) { return y.length; },
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -11,5 +11,7 @@ var o: I = {
|
||||
//// [computedPropertyNamesContextualType3_ES5.js]
|
||||
var o = (_a = {}, _a[+"foo"] = function (y) {
|
||||
return y.length;
|
||||
}, _a[+"bar"] = function (y) { return y.length; }, _a);
|
||||
}, _a[+"bar"] =
|
||||
function (y) { return y.length; },
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -10,5 +10,8 @@ var o: I = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesContextualType4_ES5.js]
|
||||
var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = 0, _a);
|
||||
var o = (_a = {}, _a["" + "foo"] =
|
||||
"", _a["" + "bar"] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -10,5 +10,8 @@ var o: I = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesContextualType5_ES5.js]
|
||||
var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, _a);
|
||||
var o = (_a = {}, _a[+"foo"] =
|
||||
"", _a[+"bar"] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -17,5 +17,11 @@ foo({
|
||||
foo((_a = {
|
||||
p: "",
|
||||
0: function () { }
|
||||
}, _a.p = "", _a[0] = function () { }, _a["hi" + "bye"] = true, _a[0 + 1] = 0, _a[+"hi"] = [0], _a));
|
||||
}, _a.p =
|
||||
"", _a[0] =
|
||||
function () { }, _a["hi" + "bye"] =
|
||||
true, _a[0 + 1] =
|
||||
0, _a[+"hi"] =
|
||||
[0],
|
||||
_a));
|
||||
var _a;
|
||||
|
||||
@@ -17,5 +17,11 @@ foo({
|
||||
foo((_a = {
|
||||
p: "",
|
||||
0: function () { }
|
||||
}, _a.p = "", _a[0] = function () { }, _a["hi" + "bye"] = true, _a[0 + 1] = 0, _a[+"hi"] = [0], _a));
|
||||
}, _a.p =
|
||||
"", _a[0] =
|
||||
function () { }, _a["hi" + "bye"] =
|
||||
true, _a[0 + 1] =
|
||||
0, _a[+"hi"] =
|
||||
[0],
|
||||
_a));
|
||||
var _a;
|
||||
|
||||
@@ -10,5 +10,8 @@ var o: I = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesContextualType8_ES5.js]
|
||||
var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = 0, _a);
|
||||
var o = (_a = {}, _a["" + "foo"] =
|
||||
"", _a["" + "bar"] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -10,5 +10,8 @@ var o: I = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesContextualType9_ES5.js]
|
||||
var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, _a);
|
||||
var o = (_a = {}, _a[+"foo"] =
|
||||
"", _a[+"bar"] =
|
||||
0,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -7,9 +7,11 @@ var v = {
|
||||
}
|
||||
|
||||
//// [computedPropertyNamesDeclarationEmit5_ES5.js]
|
||||
var v = (_a = {}, _a["" + ""] = 0, _a["" + ""] = function () { }, _a["" + ""] = Object.defineProperty({ get: function () {
|
||||
var v = (_a = {}, _a["" + ""] =
|
||||
0, _a["" + ""] = function () { }, _a["" + ""] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }), _a);
|
||||
}, enumerable: true, configurable: true }), _a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }),
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ var v = {
|
||||
//// [computedPropertyNamesSourceMap2_ES5.js]
|
||||
var v = (_a = {}, _a["hello"] = function () {
|
||||
debugger;
|
||||
}, _a);
|
||||
},
|
||||
_a);
|
||||
var _a;
|
||||
//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
|
||||
@@ -1,2 +1,2 @@
|
||||
//// [computedPropertyNamesSourceMap2_ES5.js.map]
|
||||
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA,EACA,EAAA,CACK,OAAO,CAFA,GAAA;IAGA,QAAQ,CAAC;AACb,CAAC,AAJA,EACA,EAAA,AADA,CAKA,CAAA;IAJD,EAAA"}
|
||||
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,AADA,CACA,EAAA,GADA,EAAA,EACA,EAAA,CACK,OAAO,CAFA,GAAA;IAGA,QAAQ,CAAC;AACb,CAAC,AAJA;AACA,EAAA,AADA,CAKA,CAAA;IAJD,EAAA"}
|
||||
@@ -95,16 +95,11 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts
|
||||
2 >Emitted(2, 13) Source(3, 17) + SourceIndex(0)
|
||||
3 >Emitted(2, 14) Source(3, 18) + SourceIndex(0)
|
||||
---
|
||||
>>>}, _a);
|
||||
>>>},
|
||||
1 >
|
||||
2 >^
|
||||
3 >
|
||||
4 > ^^
|
||||
5 > ^^
|
||||
6 >
|
||||
7 > ^
|
||||
8 > ^
|
||||
9 > ^->
|
||||
4 > ^^^^->
|
||||
1 >!!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
|
||||
1 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(1, 33) Source(0, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 1) Source(4, 5) + SourceIndex(0) nameIndex (-1)
|
||||
1 >
|
||||
@@ -115,42 +110,50 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts
|
||||
3 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 5) Source(3, 21) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 2) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
|
||||
3 >
|
||||
4 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 13) Source(3, 29) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 4) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
4 >
|
||||
5 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 14) Source(3, 30) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 6) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
5 >
|
||||
6 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
6 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 1) Source(4, 17) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 6) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
|
||||
6 >
|
||||
7 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
7 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(4, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 7) Source(5, 2) + SourceIndex(0) nameIndex (-1)
|
||||
7 >
|
||||
8 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
|
||||
8 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(3, 8) Source(5, 2) + SourceIndex(0) nameIndex (-1)
|
||||
8 >
|
||||
1 >Emitted(3, 1) Source(4, 5) + SourceIndex(0)
|
||||
2 >Emitted(3, 2) Source(4, 6) + SourceIndex(0)
|
||||
3 >Emitted(3, 2) Source(0, NaN) + SourceIndex(0)
|
||||
4 >Emitted(3, 4) Source(1, 1) + SourceIndex(0)
|
||||
5 >Emitted(3, 6) Source(1, 1) + SourceIndex(0)
|
||||
6 >Emitted(3, 6) Source(0, NaN) + SourceIndex(0)
|
||||
7 >Emitted(3, 7) Source(5, 2) + SourceIndex(0)
|
||||
8 >Emitted(3, 8) Source(5, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>_a);
|
||||
1->
|
||||
2 >^^
|
||||
3 >
|
||||
4 > ^
|
||||
5 > ^
|
||||
6 > ^^^^->
|
||||
1->!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 13) Source(3, 29) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 1) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
1->
|
||||
2 >!!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
2 >!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(2, 14) Source(3, 30) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 3) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
2 >
|
||||
3 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
3 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 1) Source(4, 17) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 3) Source(0, NaN) + SourceIndex(0) nameIndex (-1)
|
||||
3 >
|
||||
4 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
4 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(4, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 4) Source(5, 2) + SourceIndex(0) nameIndex (-1)
|
||||
4 >
|
||||
5 > !!^^ !!^^ There was decoding error in the sourcemap at this location: Invalid sourceLine found
|
||||
5 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(5, 2) + SourceIndex(0) nameIndex (-1)
|
||||
5 >
|
||||
1->Emitted(4, 1) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(4, 3) Source(1, 1) + SourceIndex(0)
|
||||
3 >Emitted(4, 3) Source(0, NaN) + SourceIndex(0)
|
||||
4 >Emitted(4, 4) Source(5, 2) + SourceIndex(0)
|
||||
5 >Emitted(4, 5) Source(5, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>var _a;
|
||||
1->^^^^
|
||||
2 > ^^
|
||||
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
|
||||
1->!!^^ !!^^ There was decoding error in the sourcemap at this location: Unsupported Error Format: No entries after emitted column
|
||||
1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
1->!!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 2) Source(0, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 5) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
1->
|
||||
2 > !!^^ !!^^ The decoded span from sourcemap's mapping entry does not match what was encoded for this span:
|
||||
2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(3, 4) Source(1, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(4, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
2 > !!^^ !!^^ Decoded span from sourcemap's mappings entry: Emitted(4, 1) Source(1, 18) + SourceIndex(0) nameIndex (-1) Span encoded by the emitter:Emitted(5, 7) Source(1, 1) + SourceIndex(0) nameIndex (-1)
|
||||
2 >
|
||||
1->Emitted(4, 5) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(4, 7) Source(1, 1) + SourceIndex(0)
|
||||
1->Emitted(5, 5) Source(1, 1) + SourceIndex(0)
|
||||
2 >Emitted(5, 7) Source(1, 1) + SourceIndex(0)
|
||||
---
|
||||
!!!! **** There are more source map entries in the sourceMap's mapping than what was encoded
|
||||
!!!! **** Remaining decoded string: ,EAAA,AADA,CAKA,CAAA;IAJD,EAAA
|
||||
|
||||
@@ -314,10 +314,12 @@ var TypeScriptAllInOne;
|
||||
Program.prototype.if = function (retValue) {
|
||||
if (retValue === void 0) { retValue = != 0; }
|
||||
return 1;
|
||||
^ retValue;
|
||||
^
|
||||
retValue;
|
||||
bfs.TYPES();
|
||||
if (retValue != 0) {
|
||||
return 1 && ;
|
||||
return 1 &&
|
||||
;
|
||||
}
|
||||
retValue = bfs.OPERATOR;
|
||||
' );;
|
||||
@@ -348,7 +350,8 @@ var BasicFeatures = (function () {
|
||||
BasicFeatures.prototype.VARIABLES = function () {
|
||||
var local = Number.MAX_VALUE;
|
||||
var min = Number.MIN_VALUE;
|
||||
var inf = Number.NEGATIVE_INFINITY - ;
|
||||
var inf = Number.NEGATIVE_INFINITY -
|
||||
;
|
||||
var nan = Number.NaN;
|
||||
var undef = undefined;
|
||||
var _\uD4A5\u7204\uC316, uE59F = local;
|
||||
@@ -357,7 +360,8 @@ var BasicFeatures = (function () {
|
||||
var local6 = local5 instanceof fs.File;
|
||||
var hex = 0xBADC0DE, Hex = 0XDEADBEEF;
|
||||
var float = 6.02e23, float2 = 6.02E-23;
|
||||
var char = 'c', \u0066 = '\u0066', hexchar = '\x42' != ;
|
||||
var char = 'c', \u0066 = '\u0066', hexchar = '\x42' !=
|
||||
;
|
||||
var quoted = '"', quoted2 = "'";
|
||||
var reg = /\w*/;
|
||||
var objLit = { "var": number = 42, equals: function (x) {
|
||||
@@ -366,7 +370,8 @@ var BasicFeatures = (function () {
|
||||
var weekday = 0 /* Monday */;
|
||||
var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday;
|
||||
//
|
||||
var any = 0 ^= ;
|
||||
var any = 0 ^=
|
||||
;
|
||||
var bool = 0;
|
||||
var declare = 0;
|
||||
var constructor = 0;
|
||||
@@ -382,7 +387,8 @@ var BasicFeatures = (function () {
|
||||
var public = 0;
|
||||
var set = 0;
|
||||
var static = 0;
|
||||
var string = 0 / > ;
|
||||
var string = 0 / >
|
||||
;
|
||||
var yield = 0;
|
||||
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
|
||||
return 0;
|
||||
@@ -545,7 +551,8 @@ while ()
|
||||
: string, ;
|
||||
rest: string[];
|
||||
{
|
||||
& public;
|
||||
&
|
||||
public;
|
||||
DefaultValue(value ? : string = "Hello");
|
||||
{ }
|
||||
}
|
||||
|
||||
@@ -436,22 +436,38 @@ exports.tests = (function () {
|
||||
}));
|
||||
// File pattern matching tests
|
||||
testRunner.addTest(new TestCase("Check text file match", function () {
|
||||
return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") && FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") && FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js"));
|
||||
return (FileManager.FileBuffer.isTextFile("C:\\somedir\\readme.txt") &&
|
||||
FileManager.FileBuffer.isTextFile("C:\\spaces path\\myapp.str") &&
|
||||
FileManager.FileBuffer.isTextFile("C:\\somedir\\code.js"));
|
||||
}));
|
||||
testRunner.addTest(new TestCase("Check makefile match", function () {
|
||||
return FileManager.FileBuffer.isTextFile("C:\\some dir\\makefile");
|
||||
}));
|
||||
testRunner.addTest(new TestCase("Check binary file doesn't match", function () {
|
||||
return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") && !FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll"));
|
||||
return (!FileManager.FileBuffer.isTextFile("C:\\somedir\\app.exe") &&
|
||||
!FileManager.FileBuffer.isTextFile("C:\\somedir\\my lib.dll"));
|
||||
}));
|
||||
// Command-line parameter tests
|
||||
testRunner.addTest(new TestCase("Check App defaults", function () {
|
||||
var app = new App.App([]);
|
||||
return (app.fixLines === false && app.recurse === true && app.lineEndings === "CRLF" && app.matchPattern === undefined && app.rootDirectory === ".\\" && app.encodings[0] === "ascii" && app.encodings[1] === "utf8nobom");
|
||||
return (app.fixLines === false &&
|
||||
app.recurse === true &&
|
||||
app.lineEndings === "CRLF" &&
|
||||
app.matchPattern === undefined &&
|
||||
app.rootDirectory === ".\\" &&
|
||||
app.encodings[0] === "ascii" &&
|
||||
app.encodings[1] === "utf8nobom");
|
||||
}));
|
||||
testRunner.addTest(new TestCase("Check App params", function () {
|
||||
var app = new App.App(["-dir=C:\\test dir", "-lineEndings=LF", "-encodings=utf16be,ascii", "-recurse=false", "-fixlines"]);
|
||||
return (app.fixLines === true && app.lineEndings === "LF" && app.recurse === false && app.matchPattern === undefined && app.rootDirectory === "C:\\test dir" && app.encodings[0] === "utf16be" && app.encodings[1] === "ascii" && app.encodings.length === 2);
|
||||
return (app.fixLines === true &&
|
||||
app.lineEndings === "LF" &&
|
||||
app.recurse === false &&
|
||||
app.matchPattern === undefined &&
|
||||
app.rootDirectory === "C:\\test dir" &&
|
||||
app.encodings[0] === "utf16be" &&
|
||||
app.encodings[1] === "ascii" &&
|
||||
app.encodings.length === 2);
|
||||
}));
|
||||
// File BOM detection tests
|
||||
testRunner.addTest(new TestCase("Check encoding detection no BOM", function () {
|
||||
|
||||
@@ -43,7 +43,10 @@ function testcase() {
|
||||
var one = 1;
|
||||
var _float = -(4 / 3);
|
||||
var a = new Array(false, undefined, null, "0", obj, -1.3333333333333, "str", -0, true, +0, one, 1, 0, false, _float, -(4 / 3));
|
||||
if (a.indexOf(-(4 / 3)) === 14 && a.indexOf(0) === 7 && a.indexOf(-0) === 7 && a.indexOf(1) === 10) {
|
||||
if (a.indexOf(-(4 / 3)) === 14 &&
|
||||
a.indexOf(0) === 7 &&
|
||||
a.indexOf(-0) === 7 &&
|
||||
a.indexOf(1) === 10) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
var v = { [e]: 1 };
|
||||
|
||||
//// [parserES5ComputedPropertyName2.js]
|
||||
var v = (_a = {}, _a[e] = 1, _a);
|
||||
var v = (_a = {}, _a[e] =
|
||||
1,
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
var v = { [e]() { } };
|
||||
|
||||
//// [parserES5ComputedPropertyName3.js]
|
||||
var v = (_a = {}, _a[e] = function () { }, _a);
|
||||
var v = (_a = {}, _a[e] = function () { },
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
var v = { get [e]() { } };
|
||||
|
||||
//// [parserES5ComputedPropertyName4.js]
|
||||
var v = (_a = {}, _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }), _a);
|
||||
var v = (_a = {}, _a[e] = Object.defineProperty({ get: function () { }, enumerable: true, configurable: true }),
|
||||
_a);
|
||||
var _a;
|
||||
|
||||
@@ -6,6 +6,7 @@ function f() {
|
||||
|
||||
//// [parserErrorRecovery_Block1.js]
|
||||
function f() {
|
||||
1 + ;
|
||||
1 +
|
||||
;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ switch (e) {
|
||||
//// [parserErrorRecovery_SwitchStatement1.js]
|
||||
switch (e) {
|
||||
case 1:
|
||||
1 + ;
|
||||
1 +
|
||||
;
|
||||
case 2:
|
||||
1 + ;
|
||||
1 +
|
||||
;
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity10.js]
|
||||
1 >>> 2;
|
||||
1 >>>
|
||||
2;
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
= 2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity14.js]
|
||||
1 >> ;
|
||||
1 >>
|
||||
;
|
||||
2;
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity15.js]
|
||||
1 >>= 2;
|
||||
1 >>=
|
||||
2;
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
= 2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity19.js]
|
||||
1 >>> ;
|
||||
1 >>>
|
||||
;
|
||||
2;
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity20.js]
|
||||
1 >>>= 2;
|
||||
1 >>>=
|
||||
2;
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
> 2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity4.js]
|
||||
1 > > 2;
|
||||
1 >
|
||||
> 2;
|
||||
|
||||
@@ -5,4 +5,5 @@
|
||||
2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity5.js]
|
||||
1 >> 2;
|
||||
1 >>
|
||||
2;
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
> 2;
|
||||
|
||||
//// [parserGreaterThanTokenAmbiguity9.js]
|
||||
1 >> > 2;
|
||||
1 >>
|
||||
> 2;
|
||||
|
||||
@@ -813,7 +813,8 @@ var TypeScript;
|
||||
else {
|
||||
var tokenInfo = lookupToken(this.tokenId);
|
||||
if (tokenInfo != undefined) {
|
||||
if ((tokenInfo.unopNodeType != NodeType.None) || (tokenInfo.binopNodeType != NodeType.None)) {
|
||||
if ((tokenInfo.unopNodeType != NodeType.None) ||
|
||||
(tokenInfo.binopNodeType != NodeType.None)) {
|
||||
return 2 /* Operator */;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2496,7 +2496,8 @@ var TypeScript;
|
||||
if (context.parser !== null) {
|
||||
context.parser.getSourceLineCol(lineCol, this.minChar);
|
||||
context.parser.getSourceLineCol(limLineCol, this.limChar);
|
||||
context.write("(" + lineCol.line + "," + lineCol.col + ")--" + "(" + limLineCol.line + "," + limLineCol.col + "): ");
|
||||
context.write("(" + lineCol.line + "," + lineCol.col + ")--" +
|
||||
"(" + limLineCol.line + "," + limLineCol.col + "): ");
|
||||
}
|
||||
var lab = this.printLabel();
|
||||
if (hasFlag(this.flags, ASTFlags.Error)) {
|
||||
@@ -4093,13 +4094,16 @@ var TypeScript;
|
||||
var target = cond.target;
|
||||
if (target.nodeType == NodeType.Dot) {
|
||||
var binex = target;
|
||||
if ((binex.operand1.nodeType == NodeType.Name) && (this.obj.nodeType == NodeType.Name) && (binex.operand1.actualText == this.obj.actualText)) {
|
||||
if ((binex.operand1.nodeType == NodeType.Name) &&
|
||||
(this.obj.nodeType == NodeType.Name) &&
|
||||
(binex.operand1.actualText == this.obj.actualText)) {
|
||||
var prop = binex.operand2;
|
||||
if (prop.actualText == "hasOwnProperty") {
|
||||
var args = cond.arguments;
|
||||
if ((args !== null) && (args.members.length == 1)) {
|
||||
var arg = args.members[0];
|
||||
if ((arg.nodeType == NodeType.Name) && (this.lval.nodeType == NodeType.Name)) {
|
||||
if ((arg.nodeType == NodeType.Name) &&
|
||||
(this.lval.nodeType == NodeType.Name)) {
|
||||
if ((this.lval.actualText) == arg.actualText) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -658,167 +658,288 @@ var TypeScript;
|
||||
AstPath.prototype.isNameOfClass = function () {
|
||||
if (this.ast() === null || this.parent() === null)
|
||||
return false;
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) && (this.parent().nodeType === TypeScript.NodeType.ClassDeclaration) && (this.parent().name === this.ast());
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) &&
|
||||
(this.parent().nodeType === TypeScript.NodeType.ClassDeclaration) &&
|
||||
(this.parent().name === this.ast());
|
||||
};
|
||||
AstPath.prototype.isNameOfInterface = function () {
|
||||
if (this.ast() === null || this.parent() === null)
|
||||
return false;
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) && (this.parent().nodeType === TypeScript.NodeType.InterfaceDeclaration) && (this.parent().name === this.ast());
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) &&
|
||||
(this.parent().nodeType === TypeScript.NodeType.InterfaceDeclaration) &&
|
||||
(this.parent().name === this.ast());
|
||||
};
|
||||
AstPath.prototype.isNameOfArgument = function () {
|
||||
if (this.ast() === null || this.parent() === null)
|
||||
return false;
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) && (this.parent().nodeType === TypeScript.NodeType.ArgDecl) && (this.parent().id === this.ast());
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) &&
|
||||
(this.parent().nodeType === TypeScript.NodeType.ArgDecl) &&
|
||||
(this.parent().id === this.ast());
|
||||
};
|
||||
AstPath.prototype.isNameOfVariable = function () {
|
||||
if (this.ast() === null || this.parent() === null)
|
||||
return false;
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) && (this.parent().nodeType === TypeScript.NodeType.VarDecl) && (this.parent().id === this.ast());
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) &&
|
||||
(this.parent().nodeType === TypeScript.NodeType.VarDecl) &&
|
||||
(this.parent().id === this.ast());
|
||||
};
|
||||
AstPath.prototype.isNameOfModule = function () {
|
||||
if (this.ast() === null || this.parent() === null)
|
||||
return false;
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) && (this.parent().nodeType === TypeScript.NodeType.ModuleDeclaration) && (this.parent().name === this.ast());
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) &&
|
||||
(this.parent().nodeType === TypeScript.NodeType.ModuleDeclaration) &&
|
||||
(this.parent().name === this.ast());
|
||||
};
|
||||
AstPath.prototype.isNameOfFunction = function () {
|
||||
if (this.ast() === null || this.parent() === null)
|
||||
return false;
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) && (this.parent().nodeType === TypeScript.NodeType.FuncDecl) && (this.parent().name === this.ast());
|
||||
return (this.ast().nodeType === TypeScript.NodeType.Name) &&
|
||||
(this.parent().nodeType === TypeScript.NodeType.FuncDecl) &&
|
||||
(this.parent().name === this.ast());
|
||||
};
|
||||
AstPath.prototype.isChildOfScript = function () {
|
||||
var ast = lastOf(this.asts);
|
||||
return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.Script;
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top] === ast &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.Script;
|
||||
};
|
||||
AstPath.prototype.isChildOfModule = function () {
|
||||
var ast = lastOf(this.asts);
|
||||
return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.ModuleDeclaration;
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top] === ast &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.ModuleDeclaration;
|
||||
};
|
||||
AstPath.prototype.isChildOfClass = function () {
|
||||
var ast = lastOf(this.asts);
|
||||
return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.ClassDeclaration;
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top] === ast &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.ClassDeclaration;
|
||||
};
|
||||
AstPath.prototype.isArgumentOfClassConstructor = function () {
|
||||
var ast = lastOf(this.asts);
|
||||
return this.count() >= 5 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 3].nodeType === TypeScript.NodeType.List && this.asts[this.top - 4].nodeType === TypeScript.NodeType.ClassDeclaration && (this.asts[this.top - 2].isConstructor) && (this.asts[this.top - 2].arguments === this.asts[this.top - 1]) && (this.asts[this.top - 4].constructorDecl === this.asts[this.top - 2]);
|
||||
return this.count() >= 5 &&
|
||||
this.asts[this.top] === ast &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.FuncDecl &&
|
||||
this.asts[this.top - 3].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 4].nodeType === TypeScript.NodeType.ClassDeclaration &&
|
||||
(this.asts[this.top - 2].isConstructor) &&
|
||||
(this.asts[this.top - 2].arguments === this.asts[this.top - 1]) &&
|
||||
(this.asts[this.top - 4].constructorDecl === this.asts[this.top - 2]);
|
||||
};
|
||||
AstPath.prototype.isChildOfInterface = function () {
|
||||
var ast = lastOf(this.asts);
|
||||
return this.count() >= 3 && this.asts[this.top] === ast && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.InterfaceDeclaration;
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top] === ast &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.InterfaceDeclaration;
|
||||
};
|
||||
AstPath.prototype.isTopLevelImplicitModule = function () {
|
||||
return this.count() >= 1 && this.asts[this.top].nodeType === TypeScript.NodeType.ModuleDeclaration && TypeScript.hasFlag(this.asts[this.top].modFlags, TypeScript.ModuleFlags.IsWholeFile);
|
||||
return this.count() >= 1 &&
|
||||
this.asts[this.top].nodeType === TypeScript.NodeType.ModuleDeclaration &&
|
||||
TypeScript.hasFlag(this.asts[this.top].modFlags, TypeScript.ModuleFlags.IsWholeFile);
|
||||
};
|
||||
AstPath.prototype.isBodyOfTopLevelImplicitModule = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ModuleDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0] && TypeScript.hasFlag(this.asts[this.top - 1].modFlags, TypeScript.ModuleFlags.IsWholeFile);
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ModuleDeclaration &&
|
||||
this.asts[this.top - 1].members == this.asts[this.top - 0] &&
|
||||
TypeScript.hasFlag(this.asts[this.top - 1].modFlags, TypeScript.ModuleFlags.IsWholeFile);
|
||||
};
|
||||
AstPath.prototype.isBodyOfScript = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Script && this.asts[this.top - 1].bod == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Script &&
|
||||
this.asts[this.top - 1].bod == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfSwitch = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Switch && this.asts[this.top - 1].caseList == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Switch &&
|
||||
this.asts[this.top - 1].caseList == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfModule = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ModuleDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ModuleDeclaration &&
|
||||
this.asts[this.top - 1].members == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfClass = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ClassDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ClassDeclaration &&
|
||||
this.asts[this.top - 1].members == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfFunction = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 1].bod == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.FuncDecl &&
|
||||
this.asts[this.top - 1].bod == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfInterface = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.InterfaceDeclaration && this.asts[this.top - 1].members == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.InterfaceDeclaration &&
|
||||
this.asts[this.top - 1].members == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfBlock = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Block && this.asts[this.top - 1].statements == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Block &&
|
||||
this.asts[this.top - 1].statements == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfFor = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.For && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.For &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfCase = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Case && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Case &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfTry = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Try && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Try &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfCatch = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Catch && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Catch &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfDoWhile = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.DoWhile && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.DoWhile &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfWhile = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.While && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.While &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfForIn = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ForIn && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ForIn &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfWith = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.With && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.With &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfFinally = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Finally && this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Finally &&
|
||||
this.asts[this.top - 1].body == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isCaseOfSwitch = function () {
|
||||
return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript.NodeType.Switch && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].caseList == this.asts[this.top - 1];
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.Switch &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].caseList == this.asts[this.top - 1];
|
||||
};
|
||||
AstPath.prototype.isDefaultCaseOfSwitch = function () {
|
||||
return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript.NodeType.Switch && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].caseList == this.asts[this.top - 1] && this.asts[this.top - 2].defaultCase == this.asts[this.top - 0];
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.Switch &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].caseList == this.asts[this.top - 1] &&
|
||||
this.asts[this.top - 2].defaultCase == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isListOfObjectLit = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ObjectLit &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].operand == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfObjectLit = function () {
|
||||
return this.isListOfObjectLit();
|
||||
};
|
||||
AstPath.prototype.isEmptyListOfObjectLit = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0] && this.asts[this.top - 0].members.length == 0;
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ObjectLit &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].operand == this.asts[this.top - 0] &&
|
||||
this.asts[this.top - 0].members.length == 0;
|
||||
};
|
||||
AstPath.prototype.isMemberOfObjectLit = function () {
|
||||
return this.count() >= 3 && this.asts[this.top - 2].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 0].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 2].operand == this.asts[this.top - 1];
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.ObjectLit &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.Member &&
|
||||
this.asts[this.top - 2].operand == this.asts[this.top - 1];
|
||||
};
|
||||
AstPath.prototype.isNameOfMemberOfObjectLit = function () {
|
||||
return this.count() >= 4 && this.asts[this.top - 3].nodeType === TypeScript.NodeType.ObjectLit && this.asts[this.top - 2].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 0].nodeType === TypeScript.NodeType.Name && this.asts[this.top - 3].operand == this.asts[this.top - 2];
|
||||
return this.count() >= 4 &&
|
||||
this.asts[this.top - 3].nodeType === TypeScript.NodeType.ObjectLit &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.Name &&
|
||||
this.asts[this.top - 3].operand == this.asts[this.top - 2];
|
||||
};
|
||||
AstPath.prototype.isListOfArrayLit = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.ArrayLit && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].operand == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.ArrayLit &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].operand == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isTargetOfMember = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 1].operand1 === this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member &&
|
||||
this.asts[this.top - 1].operand1 === this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isMemberOfMember = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member && this.asts[this.top - 1].operand2 === this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Member &&
|
||||
this.asts[this.top - 1].operand2 === this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isItemOfList = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List;
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List;
|
||||
//(<Tools.ASTList>this.asts[this.top - 1]).operand2 === this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isThenOfIf = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.If && this.asts[this.top - 1].thenBod == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.If &&
|
||||
this.asts[this.top - 1].thenBod == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isElseOfIf = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.If && this.asts[this.top - 1].elseBod == this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.If &&
|
||||
this.asts[this.top - 1].elseBod == this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isBodyOfDefaultCase = function () {
|
||||
return this.isBodyOfCase();
|
||||
};
|
||||
AstPath.prototype.isSingleStatementList = function () {
|
||||
return this.count() >= 1 && this.asts[this.top].nodeType === TypeScript.NodeType.List && this.asts[this.top].members.length === 1;
|
||||
return this.count() >= 1 &&
|
||||
this.asts[this.top].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top].members.length === 1;
|
||||
};
|
||||
AstPath.prototype.isArgumentListOfFunction = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 1].arguments === this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.FuncDecl &&
|
||||
this.asts[this.top - 1].arguments === this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isArgumentOfFunction = function () {
|
||||
return this.count() >= 3 && this.asts[this.top - 1].nodeType === TypeScript.NodeType.List && this.asts[this.top - 2].nodeType === TypeScript.NodeType.FuncDecl && this.asts[this.top - 2].arguments === this.asts[this.top - 1];
|
||||
return this.count() >= 3 &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 2].nodeType === TypeScript.NodeType.FuncDecl &&
|
||||
this.asts[this.top - 2].arguments === this.asts[this.top - 1];
|
||||
};
|
||||
AstPath.prototype.isArgumentListOfCall = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.Call && this.asts[this.top - 1].arguments === this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.Call &&
|
||||
this.asts[this.top - 1].arguments === this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isArgumentListOfNew = function () {
|
||||
return this.count() >= 2 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.List && this.asts[this.top - 1].nodeType === TypeScript.NodeType.New && this.asts[this.top - 1].arguments === this.asts[this.top - 0];
|
||||
return this.count() >= 2 &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.List &&
|
||||
this.asts[this.top - 1].nodeType === TypeScript.NodeType.New &&
|
||||
this.asts[this.top - 1].arguments === this.asts[this.top - 0];
|
||||
};
|
||||
AstPath.prototype.isSynthesizedBlock = function () {
|
||||
return this.count() >= 1 && this.asts[this.top - 0].nodeType === TypeScript.NodeType.Block && this.asts[this.top - 0].isStatementBlock === false;
|
||||
return this.count() >= 1 &&
|
||||
this.asts[this.top - 0].nodeType === TypeScript.NodeType.Block &&
|
||||
this.asts[this.top - 0].isStatementBlock === false;
|
||||
};
|
||||
return AstPath;
|
||||
})();
|
||||
@@ -879,7 +1000,9 @@ var TypeScript;
|
||||
// bar
|
||||
// 0123
|
||||
// If "position == 3", the caret is at the "right" of the "r" character, which should be considered valid
|
||||
var inclusive = hasFlag(options, 1 /* EdgeInclusive */) || cur.nodeType === TypeScript.NodeType.Name || pos === script.limChar; // Special "EOF" case
|
||||
var inclusive = hasFlag(options, 1 /* EdgeInclusive */) ||
|
||||
cur.nodeType === TypeScript.NodeType.Name ||
|
||||
pos === script.limChar; // Special "EOF" case
|
||||
var minChar = cur.minChar;
|
||||
var limChar = cur.limChar + (inclusive ? 1 : 0);
|
||||
if (pos >= minChar && pos < limChar) {
|
||||
|
||||
@@ -329,7 +329,8 @@ var TypeScript;
|
||||
// is has not been fully re-parsed yet.
|
||||
if (ast.nodeType == NodeType.Script && context.pos > limChar)
|
||||
limChar = context.pos;
|
||||
if ((minChar <= context.pos) && (limChar >= context.pos)) {
|
||||
if ((minChar <= context.pos) &&
|
||||
(limChar >= context.pos)) {
|
||||
switch (ast.nodeType) {
|
||||
case NodeType.Script:
|
||||
var script = ast;
|
||||
|
||||
@@ -1053,7 +1053,8 @@ var TypeScript;
|
||||
if (isExported) {
|
||||
typeSymbol.flags |= SymbolFlags.Exported;
|
||||
}
|
||||
if ((context.scopeChain.moduleDecl) || (context.scopeChain.container == context.checker.gloMod)) {
|
||||
if ((context.scopeChain.moduleDecl) ||
|
||||
(context.scopeChain.container == context.checker.gloMod)) {
|
||||
typeSymbol.flags |= SymbolFlags.ModuleMember;
|
||||
}
|
||||
moduleDecl.mod = modType;
|
||||
@@ -1079,7 +1080,11 @@ var TypeScript;
|
||||
// REVIEW-CLASSES
|
||||
if (!typeSymbol) {
|
||||
var valTypeSymbol = scopeChain.scope.findLocal(className, false, false);
|
||||
if (valTypeSymbol && valTypeSymbol.isType() && valTypeSymbol.declAST && valTypeSymbol.declAST.nodeType == NodeType.FuncDecl && valTypeSymbol.declAST.isSignature()) {
|
||||
if (valTypeSymbol &&
|
||||
valTypeSymbol.isType() &&
|
||||
valTypeSymbol.declAST &&
|
||||
valTypeSymbol.declAST.nodeType == NodeType.FuncDecl &&
|
||||
valTypeSymbol.declAST.isSignature()) {
|
||||
typeSymbol = valTypeSymbol;
|
||||
foundValSymbol = true;
|
||||
if (isExported) {
|
||||
@@ -1233,7 +1238,10 @@ var TypeScript;
|
||||
if (context.scopeChain.moduleDecl) {
|
||||
context.scopeChain.moduleDecl.recordNonInterface();
|
||||
}
|
||||
if (isProperty || isExported || (context.scopeChain.container == context.checker.gloMod) || context.scopeChain.moduleDecl) {
|
||||
if (isProperty ||
|
||||
isExported ||
|
||||
(context.scopeChain.container == context.checker.gloMod) ||
|
||||
context.scopeChain.moduleDecl) {
|
||||
if (isAmbient) {
|
||||
var existingSym = scopeChain.scope.findLocal(varDecl.id.text, false, false);
|
||||
if (existingSym) {
|
||||
@@ -1254,7 +1262,8 @@ var TypeScript;
|
||||
}
|
||||
field.symbol = fieldSymbol;
|
||||
fieldSymbol.declAST = ast;
|
||||
if ((context.scopeChain.moduleDecl) || (context.scopeChain.container == context.checker.gloMod)) {
|
||||
if ((context.scopeChain.moduleDecl) ||
|
||||
(context.scopeChain.container == context.checker.gloMod)) {
|
||||
fieldSymbol.flags |= SymbolFlags.ModuleMember;
|
||||
fieldSymbol.declModule = context.scopeChain.moduleDecl;
|
||||
}
|
||||
@@ -1305,7 +1314,12 @@ var TypeScript;
|
||||
// If the parent is the constructor, and this isn't an instance method, skip it.
|
||||
// That way, we'll set the type during scope assignment, and can be sure that the
|
||||
// function will be placed in the constructor-local scope
|
||||
if (!funcDecl.isConstructor && containerSym && containerSym.declAST && containerSym.declAST.nodeType == NodeType.FuncDecl && containerSym.declAST.isConstructor && !funcDecl.isMethod()) {
|
||||
if (!funcDecl.isConstructor &&
|
||||
containerSym &&
|
||||
containerSym.declAST &&
|
||||
containerSym.declAST.nodeType == NodeType.FuncDecl &&
|
||||
containerSym.declAST.isConstructor &&
|
||||
!funcDecl.isMethod()) {
|
||||
return go;
|
||||
}
|
||||
// Interfaces and overloads
|
||||
@@ -1394,7 +1408,14 @@ var TypeScript;
|
||||
}
|
||||
}
|
||||
// REVIEW: Move this check into the typecheck phase? It's only being run over properties...
|
||||
if (fgSym && !fgSym.isAccessor() && fgSym.type && fgSym.type.construct && fgSym.type.construct.signatures != [] && (fgSym.type.construct.signatures[0].declAST == null || !hasFlag(fgSym.type.construct.signatures[0].declAST.fncFlags, FncFlags.Ambient)) && !funcDecl.isConstructor) {
|
||||
if (fgSym &&
|
||||
!fgSym.isAccessor() &&
|
||||
fgSym.type &&
|
||||
fgSym.type.construct &&
|
||||
fgSym.type.construct.signatures != [] &&
|
||||
(fgSym.type.construct.signatures[0].declAST == null ||
|
||||
!hasFlag(fgSym.type.construct.signatures[0].declAST.fncFlags, FncFlags.Ambient)) &&
|
||||
!funcDecl.isConstructor) {
|
||||
context.checker.errorReporter.simpleError(funcDecl, "Functions may not have class overloads");
|
||||
}
|
||||
if (fgSym && !(fgSym.kind() == SymbolKind.Type) && funcDecl.isMethod() && !funcDecl.isAccessor() && !funcDecl.isConstructor) {
|
||||
|
||||
@@ -632,7 +632,8 @@ var TypeScript;
|
||||
// the enclosing scope
|
||||
// REVIEW: Some twisted logic here - this needs to be cleaned up once old classes are removed
|
||||
// - if it's a new class, always use the contained scope, since we initialize the constructor scope below
|
||||
if (context.scopeChain.thisType && (!funcDecl.isConstructor || hasFlag(funcDecl.fncFlags, FncFlags.ClassMethod))) {
|
||||
if (context.scopeChain.thisType &&
|
||||
(!funcDecl.isConstructor || hasFlag(funcDecl.fncFlags, FncFlags.ClassMethod))) {
|
||||
var instType = context.scopeChain.thisType;
|
||||
if (!(instType.typeFlags & TypeFlags.IsClass) && !hasFlag(funcDecl.fncFlags, FncFlags.ClassMethod)) {
|
||||
if (!funcDecl.isMethod() || isStatic) {
|
||||
@@ -644,7 +645,10 @@ var TypeScript;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (context.scopeChain.previous.scope.container && context.scopeChain.previous.scope.container.declAST && context.scopeChain.previous.scope.container.declAST.nodeType == NodeType.FuncDecl && context.scopeChain.previous.scope.container.declAST.isConstructor) {
|
||||
if (context.scopeChain.previous.scope.container &&
|
||||
context.scopeChain.previous.scope.container.declAST &&
|
||||
context.scopeChain.previous.scope.container.declAST.nodeType == NodeType.FuncDecl &&
|
||||
context.scopeChain.previous.scope.container.declAST.isConstructor) {
|
||||
// if the parent is the class constructor, use the constructor scope
|
||||
parentScope = instType.constructorScope;
|
||||
}
|
||||
@@ -681,7 +685,12 @@ var TypeScript;
|
||||
outerFnc.innerStaticFuncs[outerFnc.innerStaticFuncs.length] = funcDecl;
|
||||
}
|
||||
else {
|
||||
if (!funcDecl.isConstructor && container && container.declAST && container.declAST.nodeType == NodeType.FuncDecl && container.declAST.isConstructor && !funcDecl.isMethod()) {
|
||||
if (!funcDecl.isConstructor &&
|
||||
container &&
|
||||
container.declAST &&
|
||||
container.declAST.nodeType == NodeType.FuncDecl &&
|
||||
container.declAST.isConstructor &&
|
||||
!funcDecl.isMethod()) {
|
||||
funcScope = context.scopeChain.thisType.constructorScope; //locals;
|
||||
}
|
||||
else {
|
||||
@@ -702,7 +711,11 @@ var TypeScript;
|
||||
}
|
||||
context.typeFlow.checker.createFunctionSignature(funcDecl, container, funcScope, fgSym, fgSym == null);
|
||||
// it's a getter or setter for a class property
|
||||
if (!funcDecl.accessorSymbol && (funcDecl.fncFlags & FncFlags.ClassMethod) && container && ((!fgSym || fgSym.declAST.nodeType != NodeType.FuncDecl) && funcDecl.isAccessor()) || (fgSym && fgSym.isAccessor())) {
|
||||
if (!funcDecl.accessorSymbol &&
|
||||
(funcDecl.fncFlags & FncFlags.ClassMethod) &&
|
||||
container &&
|
||||
((!fgSym || fgSym.declAST.nodeType != NodeType.FuncDecl) && funcDecl.isAccessor()) ||
|
||||
(fgSym && fgSym.isAccessor())) {
|
||||
funcDecl.accessorSymbol = context.typeFlow.checker.createAccessorSymbol(funcDecl, fgSym, container.getType(), (funcDecl.isMethod() && isStatic), true, funcScope, container);
|
||||
}
|
||||
funcDecl.type.symbol.flags |= SymbolFlags.TypeSetDuringScopeAssignment;
|
||||
|
||||
@@ -778,7 +778,10 @@ var Formatting;
|
||||
}
|
||||
Indenter.prototype.GetIndentationEdits = function (token, nextToken, node, sameLineIndent) {
|
||||
if (this.logger.information()) {
|
||||
this.logger.log("GetIndentationEdits(" + "t1=[" + token.Span.startPosition() + "," + token.Span.endPosition() + "], " + "t2=[" + (nextToken == null ? "null" : (nextToken.Span.startPosition() + "," + nextToken.Span.endPosition())) + "]" + ")");
|
||||
this.logger.log("GetIndentationEdits(" +
|
||||
"t1=[" + token.Span.startPosition() + "," + token.Span.endPosition() + "], " +
|
||||
"t2=[" + (nextToken == null ? "null" : (nextToken.Span.startPosition() + "," + nextToken.Span.endPosition())) + "]" +
|
||||
")");
|
||||
}
|
||||
var result = this.GetIndentationEditsWorker(token, nextToken, node, sameLineIndent);
|
||||
if (this.logger.information()) {
|
||||
@@ -938,7 +941,8 @@ var Formatting;
|
||||
};
|
||||
Indenter.prototype.GetSpecialCaseIndentationForLCurly = function (node) {
|
||||
var indentationInfo = null;
|
||||
if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkFncDecl || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneThen || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneElse) {
|
||||
if (node.AuthorNode.Details.Kind == AuthorParseNodeKind.apnkFncDecl ||
|
||||
node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneThen || node.AuthorNode.EdgeLabel == AuthorParseNodeEdge.apneElse) {
|
||||
// flushed with the node (function & if)
|
||||
indentationInfo = node.GetNodeStartLineIndentation(this);
|
||||
return indentationInfo;
|
||||
@@ -1233,7 +1237,8 @@ var Formatting;
|
||||
// Get the parent that is really on a different line from the self node
|
||||
var startNodeLineNumber = this.snapshot.GetLineNumberFromPosition(tree.StartNodeSelf.AuthorNode.Details.StartOffset);
|
||||
parent = tree.StartNodeSelf.Parent;
|
||||
while (parent != null && startNodeLineNumber == this.snapshot.GetLineNumberFromPosition(parent.AuthorNode.Details.StartOffset)) {
|
||||
while (parent != null &&
|
||||
startNodeLineNumber == this.snapshot.GetLineNumberFromPosition(parent.AuthorNode.Details.StartOffset)) {
|
||||
parent = parent.Parent;
|
||||
}
|
||||
}
|
||||
@@ -1331,7 +1336,8 @@ var Formatting;
|
||||
}
|
||||
};
|
||||
Indenter.prototype.IsMultiLineString = function (token) {
|
||||
return token.tokenID === TypeScript.TokenID.StringLiteral && this.snapshot.GetLineNumberFromPosition(token.Span.endPosition()) > this.snapshot.GetLineNumberFromPosition(token.Span.startPosition());
|
||||
return token.tokenID === TypeScript.TokenID.StringLiteral &&
|
||||
this.snapshot.GetLineNumberFromPosition(token.Span.endPosition()) > this.snapshot.GetLineNumberFromPosition(token.Span.startPosition());
|
||||
};
|
||||
return Indenter;
|
||||
})();
|
||||
|
||||
@@ -11,6 +11,9 @@ var y: {
|
||||
|
||||
//// [privateIndexer2.js]
|
||||
// private indexers not allowed
|
||||
var x = (_a = {}, _a[x] = string, _a.string = , _a);
|
||||
var x = (_a = {}, _a[x] =
|
||||
string, _a.string =
|
||||
,
|
||||
_a);
|
||||
var y;
|
||||
var _a;
|
||||
|
||||
@@ -33,7 +33,9 @@ var CharacterInfo = (function () {
|
||||
return c >= CharacterCodes._0 && c <= CharacterCodes._9;
|
||||
};
|
||||
CharacterInfo.isHexDigit = function (c) {
|
||||
return isDecimalDigit(c) || (c >= CharacterCodes.A && c <= CharacterCodes.F) || (c >= CharacterCodes.a && c <= CharacterCodes.f);
|
||||
return isDecimalDigit(c) ||
|
||||
(c >= CharacterCodes.A && c <= CharacterCodes.F) ||
|
||||
(c >= CharacterCodes.a && c <= CharacterCodes.f);
|
||||
};
|
||||
CharacterInfo.hexValue = function (c) {
|
||||
Debug.assert(isHexDigit(c));
|
||||
|
||||
@@ -110,6 +110,7 @@ function C(a, b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
C.prototype = { a: 0, b: 0, C1M1: function (c, d) {
|
||||
return (this.a + c) + (this.b + d);
|
||||
} };
|
||||
C.prototype =
|
||||
{ a: 0, b: 0, C1M1: function (c, d) {
|
||||
return (this.a + c) + (this.b + d);
|
||||
} };
|
||||
|
||||
@@ -5,4 +5,7 @@ var x = `abc${0}abc` === `abc` ||
|
||||
"abc0abc" !== `abc${0}abc`;
|
||||
|
||||
//// [templateStringInEqualityChecks.js]
|
||||
var x = "abc" + 0 + "abc" === "abc" || "abc" !== "abc" + 0 + "abc" && "abc" + 0 + "abc" == "abc0abc" && "abc0abc" !== "abc" + 0 + "abc";
|
||||
var x = "abc" + 0 + "abc" === "abc" ||
|
||||
"abc" !== "abc" + 0 + "abc" &&
|
||||
"abc" + 0 + "abc" == "abc0abc" &&
|
||||
"abc0abc" !== "abc" + 0 + "abc";
|
||||
|
||||
@@ -5,4 +5,7 @@ var x = `abc${0}abc` === `abc` ||
|
||||
"abc0abc" !== `abc${0}abc`;
|
||||
|
||||
//// [templateStringInEqualityChecksES6.js]
|
||||
var x = `abc${0}abc` === `abc` || `abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc`;
|
||||
var x = `abc${0}abc` === `abc` ||
|
||||
`abc` !== `abc${0}abc` &&
|
||||
`abc${0}abc` == "abc0abc" &&
|
||||
"abc0abc" !== `abc${0}abc`;
|
||||
|
||||
@@ -120,8 +120,11 @@ var B = (function () {
|
||||
this.prop1 = this;
|
||||
this.prop2 = function () { return _this; };
|
||||
this.prop3 = function () { return function () { return function () { return function () { return _this; }; }; }; };
|
||||
this.prop4 = ' ' + function () {
|
||||
} + ' ' + (function () { return function () { return function () { return _this; }; }; });
|
||||
this.prop4 = ' ' +
|
||||
function () {
|
||||
} +
|
||||
' ' +
|
||||
(function () { return function () { return function () { return _this; }; }; });
|
||||
this.prop5 = {
|
||||
a: function () {
|
||||
return _this;
|
||||
|
||||
@@ -142,7 +142,8 @@ function foo7(x) {
|
||||
}
|
||||
function foo8(x) {
|
||||
var b;
|
||||
return typeof x === "string" ? x === "hello" : ((b = x) && (typeof x === "boolean" ? x // boolean
|
||||
return typeof x === "string" ? x === "hello" : ((b = x) &&
|
||||
(typeof x === "boolean" ? x // boolean
|
||||
: x == 10)); // number
|
||||
}
|
||||
function foo9(x) {
|
||||
|
||||
@@ -240,7 +240,9 @@ var ts;
|
||||
this.flags = flags;
|
||||
}
|
||||
Property.prototype.equals = function (other) {
|
||||
return this.name === other.name && this.flags === other.flags && this.type.equals(other.type);
|
||||
return this.name === other.name &&
|
||||
this.flags === other.flags &&
|
||||
this.type.equals(other.type);
|
||||
};
|
||||
return Property;
|
||||
})(Symbol);
|
||||
@@ -258,10 +260,14 @@ var ts;
|
||||
this.returnType = returnType;
|
||||
}
|
||||
Signature.prototype.equalsNoReturn = function (other) {
|
||||
return this.parameters.length === other.parameters.length && this.typeParameters.length === other.typeParameters.length && arrayEquals(this.parameters, other.parameters) && arrayEquals(this.typeParameters, other.typeParameters);
|
||||
return this.parameters.length === other.parameters.length &&
|
||||
this.typeParameters.length === other.typeParameters.length &&
|
||||
arrayEquals(this.parameters, other.parameters) &&
|
||||
arrayEquals(this.typeParameters, other.typeParameters);
|
||||
};
|
||||
Signature.prototype.equals = function (other) {
|
||||
return this.equalsNoReturn(other) && this.returnType.equals(other.returnType);
|
||||
return this.equalsNoReturn(other) &&
|
||||
this.returnType.equals(other.returnType);
|
||||
};
|
||||
return Signature;
|
||||
})(Symbol);
|
||||
@@ -274,7 +280,9 @@ var ts;
|
||||
this.flags = flags;
|
||||
}
|
||||
Parameter.prototype.equals = function (other) {
|
||||
return this.name === other.name && this.flags === other.flags && this.type.equals(other.type);
|
||||
return this.name === other.name &&
|
||||
this.flags === other.flags &&
|
||||
this.type.equals(other.type);
|
||||
};
|
||||
return Parameter;
|
||||
})(Symbol);
|
||||
|
||||
Reference in New Issue
Block a user