lint harness, disablow control flow analysis because buggy
This commit is contained in:
parent
cbe2f3df64
commit
3fe379ce52
|
@ -7,6 +7,264 @@ namespace ts {
|
|||
return isExternalModule(sourceFile) || isDeclarationFile(sourceFile);
|
||||
}
|
||||
|
||||
type DependencyGroup = Array<ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration>;
|
||||
|
||||
let entities: Map<number> = {
|
||||
"quot": 0x0022,
|
||||
"amp": 0x0026,
|
||||
"apos": 0x0027,
|
||||
"lt": 0x003C,
|
||||
"gt": 0x003E,
|
||||
"nbsp": 0x00A0,
|
||||
"iexcl": 0x00A1,
|
||||
"cent": 0x00A2,
|
||||
"pound": 0x00A3,
|
||||
"curren": 0x00A4,
|
||||
"yen": 0x00A5,
|
||||
"brvbar": 0x00A6,
|
||||
"sect": 0x00A7,
|
||||
"uml": 0x00A8,
|
||||
"copy": 0x00A9,
|
||||
"ordf": 0x00AA,
|
||||
"laquo": 0x00AB,
|
||||
"not": 0x00AC,
|
||||
"shy": 0x00AD,
|
||||
"reg": 0x00AE,
|
||||
"macr": 0x00AF,
|
||||
"deg": 0x00B0,
|
||||
"plusmn": 0x00B1,
|
||||
"sup2": 0x00B2,
|
||||
"sup3": 0x00B3,
|
||||
"acute": 0x00B4,
|
||||
"micro": 0x00B5,
|
||||
"para": 0x00B6,
|
||||
"middot": 0x00B7,
|
||||
"cedil": 0x00B8,
|
||||
"sup1": 0x00B9,
|
||||
"ordm": 0x00BA,
|
||||
"raquo": 0x00BB,
|
||||
"frac14": 0x00BC,
|
||||
"frac12": 0x00BD,
|
||||
"frac34": 0x00BE,
|
||||
"iquest": 0x00BF,
|
||||
"Agrave": 0x00C0,
|
||||
"Aacute": 0x00C1,
|
||||
"Acirc": 0x00C2,
|
||||
"Atilde": 0x00C3,
|
||||
"Auml": 0x00C4,
|
||||
"Aring": 0x00C5,
|
||||
"AElig": 0x00C6,
|
||||
"Ccedil": 0x00C7,
|
||||
"Egrave": 0x00C8,
|
||||
"Eacute": 0x00C9,
|
||||
"Ecirc": 0x00CA,
|
||||
"Euml": 0x00CB,
|
||||
"Igrave": 0x00CC,
|
||||
"Iacute": 0x00CD,
|
||||
"Icirc": 0x00CE,
|
||||
"Iuml": 0x00CF,
|
||||
"ETH": 0x00D0,
|
||||
"Ntilde": 0x00D1,
|
||||
"Ograve": 0x00D2,
|
||||
"Oacute": 0x00D3,
|
||||
"Ocirc": 0x00D4,
|
||||
"Otilde": 0x00D5,
|
||||
"Ouml": 0x00D6,
|
||||
"times": 0x00D7,
|
||||
"Oslash": 0x00D8,
|
||||
"Ugrave": 0x00D9,
|
||||
"Uacute": 0x00DA,
|
||||
"Ucirc": 0x00DB,
|
||||
"Uuml": 0x00DC,
|
||||
"Yacute": 0x00DD,
|
||||
"THORN": 0x00DE,
|
||||
"szlig": 0x00DF,
|
||||
"agrave": 0x00E0,
|
||||
"aacute": 0x00E1,
|
||||
"acirc": 0x00E2,
|
||||
"atilde": 0x00E3,
|
||||
"auml": 0x00E4,
|
||||
"aring": 0x00E5,
|
||||
"aelig": 0x00E6,
|
||||
"ccedil": 0x00E7,
|
||||
"egrave": 0x00E8,
|
||||
"eacute": 0x00E9,
|
||||
"ecirc": 0x00EA,
|
||||
"euml": 0x00EB,
|
||||
"igrave": 0x00EC,
|
||||
"iacute": 0x00ED,
|
||||
"icirc": 0x00EE,
|
||||
"iuml": 0x00EF,
|
||||
"eth": 0x00F0,
|
||||
"ntilde": 0x00F1,
|
||||
"ograve": 0x00F2,
|
||||
"oacute": 0x00F3,
|
||||
"ocirc": 0x00F4,
|
||||
"otilde": 0x00F5,
|
||||
"ouml": 0x00F6,
|
||||
"divide": 0x00F7,
|
||||
"oslash": 0x00F8,
|
||||
"ugrave": 0x00F9,
|
||||
"uacute": 0x00FA,
|
||||
"ucirc": 0x00FB,
|
||||
"uuml": 0x00FC,
|
||||
"yacute": 0x00FD,
|
||||
"thorn": 0x00FE,
|
||||
"yuml": 0x00FF,
|
||||
"OElig": 0x0152,
|
||||
"oelig": 0x0153,
|
||||
"Scaron": 0x0160,
|
||||
"scaron": 0x0161,
|
||||
"Yuml": 0x0178,
|
||||
"fnof": 0x0192,
|
||||
"circ": 0x02C6,
|
||||
"tilde": 0x02DC,
|
||||
"Alpha": 0x0391,
|
||||
"Beta": 0x0392,
|
||||
"Gamma": 0x0393,
|
||||
"Delta": 0x0394,
|
||||
"Epsilon": 0x0395,
|
||||
"Zeta": 0x0396,
|
||||
"Eta": 0x0397,
|
||||
"Theta": 0x0398,
|
||||
"Iota": 0x0399,
|
||||
"Kappa": 0x039A,
|
||||
"Lambda": 0x039B,
|
||||
"Mu": 0x039C,
|
||||
"Nu": 0x039D,
|
||||
"Xi": 0x039E,
|
||||
"Omicron": 0x039F,
|
||||
"Pi": 0x03A0,
|
||||
"Rho": 0x03A1,
|
||||
"Sigma": 0x03A3,
|
||||
"Tau": 0x03A4,
|
||||
"Upsilon": 0x03A5,
|
||||
"Phi": 0x03A6,
|
||||
"Chi": 0x03A7,
|
||||
"Psi": 0x03A8,
|
||||
"Omega": 0x03A9,
|
||||
"alpha": 0x03B1,
|
||||
"beta": 0x03B2,
|
||||
"gamma": 0x03B3,
|
||||
"delta": 0x03B4,
|
||||
"epsilon": 0x03B5,
|
||||
"zeta": 0x03B6,
|
||||
"eta": 0x03B7,
|
||||
"theta": 0x03B8,
|
||||
"iota": 0x03B9,
|
||||
"kappa": 0x03BA,
|
||||
"lambda": 0x03BB,
|
||||
"mu": 0x03BC,
|
||||
"nu": 0x03BD,
|
||||
"xi": 0x03BE,
|
||||
"omicron": 0x03BF,
|
||||
"pi": 0x03C0,
|
||||
"rho": 0x03C1,
|
||||
"sigmaf": 0x03C2,
|
||||
"sigma": 0x03C3,
|
||||
"tau": 0x03C4,
|
||||
"upsilon": 0x03C5,
|
||||
"phi": 0x03C6,
|
||||
"chi": 0x03C7,
|
||||
"psi": 0x03C8,
|
||||
"omega": 0x03C9,
|
||||
"thetasym": 0x03D1,
|
||||
"upsih": 0x03D2,
|
||||
"piv": 0x03D6,
|
||||
"ensp": 0x2002,
|
||||
"emsp": 0x2003,
|
||||
"thinsp": 0x2009,
|
||||
"zwnj": 0x200C,
|
||||
"zwj": 0x200D,
|
||||
"lrm": 0x200E,
|
||||
"rlm": 0x200F,
|
||||
"ndash": 0x2013,
|
||||
"mdash": 0x2014,
|
||||
"lsquo": 0x2018,
|
||||
"rsquo": 0x2019,
|
||||
"sbquo": 0x201A,
|
||||
"ldquo": 0x201C,
|
||||
"rdquo": 0x201D,
|
||||
"bdquo": 0x201E,
|
||||
"dagger": 0x2020,
|
||||
"Dagger": 0x2021,
|
||||
"bull": 0x2022,
|
||||
"hellip": 0x2026,
|
||||
"permil": 0x2030,
|
||||
"prime": 0x2032,
|
||||
"Prime": 0x2033,
|
||||
"lsaquo": 0x2039,
|
||||
"rsaquo": 0x203A,
|
||||
"oline": 0x203E,
|
||||
"frasl": 0x2044,
|
||||
"euro": 0x20AC,
|
||||
"image": 0x2111,
|
||||
"weierp": 0x2118,
|
||||
"real": 0x211C,
|
||||
"trade": 0x2122,
|
||||
"alefsym": 0x2135,
|
||||
"larr": 0x2190,
|
||||
"uarr": 0x2191,
|
||||
"rarr": 0x2192,
|
||||
"darr": 0x2193,
|
||||
"harr": 0x2194,
|
||||
"crarr": 0x21B5,
|
||||
"lArr": 0x21D0,
|
||||
"uArr": 0x21D1,
|
||||
"rArr": 0x21D2,
|
||||
"dArr": 0x21D3,
|
||||
"hArr": 0x21D4,
|
||||
"forall": 0x2200,
|
||||
"part": 0x2202,
|
||||
"exist": 0x2203,
|
||||
"empty": 0x2205,
|
||||
"nabla": 0x2207,
|
||||
"isin": 0x2208,
|
||||
"notin": 0x2209,
|
||||
"ni": 0x220B,
|
||||
"prod": 0x220F,
|
||||
"sum": 0x2211,
|
||||
"minus": 0x2212,
|
||||
"lowast": 0x2217,
|
||||
"radic": 0x221A,
|
||||
"prop": 0x221D,
|
||||
"infin": 0x221E,
|
||||
"ang": 0x2220,
|
||||
"and": 0x2227,
|
||||
"or": 0x2228,
|
||||
"cap": 0x2229,
|
||||
"cup": 0x222A,
|
||||
"int": 0x222B,
|
||||
"there4": 0x2234,
|
||||
"sim": 0x223C,
|
||||
"cong": 0x2245,
|
||||
"asymp": 0x2248,
|
||||
"ne": 0x2260,
|
||||
"equiv": 0x2261,
|
||||
"le": 0x2264,
|
||||
"ge": 0x2265,
|
||||
"sub": 0x2282,
|
||||
"sup": 0x2283,
|
||||
"nsub": 0x2284,
|
||||
"sube": 0x2286,
|
||||
"supe": 0x2287,
|
||||
"oplus": 0x2295,
|
||||
"otimes": 0x2297,
|
||||
"perp": 0x22A5,
|
||||
"sdot": 0x22C5,
|
||||
"lceil": 0x2308,
|
||||
"rceil": 0x2309,
|
||||
"lfloor": 0x230A,
|
||||
"rfloor": 0x230B,
|
||||
"lang": 0x2329,
|
||||
"rang": 0x232A,
|
||||
"loz": 0x25CA,
|
||||
"spades": 0x2660,
|
||||
"clubs": 0x2663,
|
||||
"hearts": 0x2665,
|
||||
"diams": 0x2666
|
||||
};
|
||||
|
||||
// Flags enum to track count of temp variables and a few dedicated names
|
||||
const enum TempFlags {
|
||||
Auto = 0x00000000, // No preferred name
|
||||
|
@ -189,7 +447,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
|
||||
/** If removeComments is true, no leading-comments needed to be emitted **/
|
||||
let emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos: number) { } : emitLeadingCommentsOfPositionWorker;
|
||||
|
||||
|
||||
let moduleEmitDelegates: Map<(node: SourceFile, startIndex: number) => void> = {
|
||||
[ModuleKind.ES6]: emitES6Module,
|
||||
[ModuleKind.AMD]: emitAMDModule,
|
||||
|
@ -695,7 +953,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function emitNodeWithCommentsAndWithSourcemap(node: Node) {
|
||||
emitNodeConsideringCommentsOption(node, emitNodeWithSourceMap);
|
||||
}
|
||||
|
@ -1190,7 +1448,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
|
||||
function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) {
|
||||
let syntheticReactRef = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
syntheticReactRef.text = 'React';
|
||||
syntheticReactRef.text = "React";
|
||||
syntheticReactRef.parent = openingNode;
|
||||
|
||||
// Call React.createElement(tag, ...
|
||||
|
@ -1525,8 +1783,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
else if (declaration.kind === SyntaxKind.ImportSpecifier) {
|
||||
// Identifier references named import
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>declaration.parent.parent.parent));
|
||||
var name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name;
|
||||
var identifier = getSourceTextOfNodeFromSourceFile(currentSourceFile, name);
|
||||
let name = (<ImportSpecifier>declaration).propertyName || (<ImportSpecifier>declaration).name;
|
||||
let identifier = getSourceTextOfNodeFromSourceFile(currentSourceFile, name);
|
||||
if (languageVersion === ScriptTarget.ES3 && identifier === "default") {
|
||||
write(`["default"]`);
|
||||
}
|
||||
|
@ -2069,15 +2327,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function tryGetConstEnumValue(node: Node): number {
|
||||
if (compilerOptions.isolatedModules) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.ElementAccessExpression
|
||||
|
||||
return node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.ElementAccessExpression
|
||||
? resolver.getConstantValue(<PropertyAccessExpression | ElementAccessExpression>node)
|
||||
: undefined
|
||||
: undefined;
|
||||
}
|
||||
|
||||
// Returns 'true' if the code was actually indented, false otherwise.
|
||||
|
@ -3147,7 +3405,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
if (modulekind === ModuleKind.System) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) {
|
||||
for (let specifier of exportSpecifiers[name.text]) {
|
||||
writeLine();
|
||||
|
@ -3162,14 +3420,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function emitExportSpecifierInSystemModule(specifier: ExportSpecifier): void {
|
||||
Debug.assert(modulekind === ModuleKind.System);
|
||||
|
||||
if (!resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) && !resolver.isValueAliasDeclaration(specifier) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
writeLine();
|
||||
emitStart(specifier.name);
|
||||
write(`${exportFunctionForFile}("`);
|
||||
|
@ -5402,14 +5660,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
emitExportMemberAssignments(<Identifier>node.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Some bundlers (SystemJS builder) sometimes want to rename dependencies.
|
||||
* Here we check if alternative name was provided for a given moduleName and return it if possible.
|
||||
*/
|
||||
function tryRenameExternalModule(moduleName: LiteralExpression): string {
|
||||
if (currentSourceFile.renamedDependencies && hasProperty(currentSourceFile.renamedDependencies, moduleName.text)) {
|
||||
return `"${currentSourceFile.renamedDependencies[moduleName.text]}"`
|
||||
return `"${currentSourceFile.renamedDependencies[moduleName.text]}"`;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -5731,7 +5989,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
emitContainingModuleName(node);
|
||||
if (languageVersion === ScriptTarget.ES3) {
|
||||
write("[\"default\"] = ");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
write(".default = ");
|
||||
}
|
||||
emit(node.expression);
|
||||
|
@ -5824,7 +6083,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
function getExternalModuleNameText(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string {
|
||||
let moduleName = getExternalModuleName(importNode);
|
||||
if (moduleName.kind === SyntaxKind.StringLiteral) {
|
||||
return tryRenameExternalModule(<LiteralExpression>moduleName) || getLiteralText(<LiteralExpression>moduleName);
|
||||
return tryRenameExternalModule(<LiteralExpression>moduleName) || getLiteralText(<LiteralExpression>moduleName);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
|
@ -6226,7 +6485,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
|
||||
function emitSetters(exportStarFunction: string, dependencyGroups: DependencyGroup[]) {
|
||||
write("setters:[");
|
||||
|
||||
|
||||
for (let i = 0; i < dependencyGroups.length; ++i) {
|
||||
if (i !== 0) {
|
||||
write(",");
|
||||
|
@ -6234,17 +6493,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
|
||||
|
||||
let group = dependencyGroups[i];
|
||||
|
||||
|
||||
// derive a unique name for parameter from the first named entry in the group
|
||||
let parameterName = makeUniqueName(forEach(group, getLocalNameForExternalImport) || "");
|
||||
write(`function (${parameterName}) {`);
|
||||
increaseIndent();
|
||||
|
||||
for(let entry of group) {
|
||||
|
||||
for (let entry of group) {
|
||||
let importVariableName = getLocalNameForExternalImport(entry) || "";
|
||||
|
||||
|
||||
switch (entry.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
if (!(<ImportDeclaration>entry).importClause) {
|
||||
|
@ -6280,7 +6539,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
write(",");
|
||||
writeLine();
|
||||
}
|
||||
|
||||
|
||||
let e = (<ExportDeclaration>entry).exportClause.elements[i];
|
||||
write(`"`);
|
||||
emitNodeWithCommentsAndWithoutSourcemap(e.name);
|
||||
|
@ -6290,7 +6549,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("});")
|
||||
write("});");
|
||||
}
|
||||
else {
|
||||
writeLine();
|
||||
|
@ -6325,7 +6584,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
// - import declarations are not emitted since they are already handled in setters
|
||||
// - export declarations with module specifiers are not emitted since they were already written in setters
|
||||
// - export declarations without module specifiers are emitted preserving the order
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
continue;
|
||||
case SyntaxKind.ExportDeclaration:
|
||||
|
@ -6345,15 +6604,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
default:
|
||||
writeLine();
|
||||
emit(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("}"); // execute
|
||||
}
|
||||
|
||||
type DependencyGroup = Array<ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration>;
|
||||
|
||||
|
||||
function emitSystemModule(node: SourceFile, startIndex: number): void {
|
||||
collectExternalModuleInfo(node);
|
||||
// System modules has the following shape
|
||||
|
@ -6373,7 +6630,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
write(`"${node.moduleName}", `);
|
||||
}
|
||||
write("[");
|
||||
|
||||
|
||||
let groupIndices: Map<number> = {};
|
||||
let dependencyGroups: DependencyGroup[] = [];
|
||||
|
||||
|
@ -6393,7 +6650,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
if (i !== 0) {
|
||||
write(", ");
|
||||
}
|
||||
|
||||
|
||||
write(text);
|
||||
}
|
||||
write(`], function(${exportFunctionForFile}) {`);
|
||||
|
@ -7104,7 +7361,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
if (compilerOptions.removeComments) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let leadingComments: CommentRange[];
|
||||
if (isEmittedNode) {
|
||||
leadingComments = getLeadingCommentsToEmit(node);
|
||||
|
@ -7237,7 +7494,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function emitShebang() {
|
||||
let shebang = getShebang(currentSourceFile.text);
|
||||
if (shebang) {
|
||||
|
@ -7254,260 +7511,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var entities: Map<number> = {
|
||||
"quot": 0x0022,
|
||||
"amp": 0x0026,
|
||||
"apos": 0x0027,
|
||||
"lt": 0x003C,
|
||||
"gt": 0x003E,
|
||||
"nbsp": 0x00A0,
|
||||
"iexcl": 0x00A1,
|
||||
"cent": 0x00A2,
|
||||
"pound": 0x00A3,
|
||||
"curren": 0x00A4,
|
||||
"yen": 0x00A5,
|
||||
"brvbar": 0x00A6,
|
||||
"sect": 0x00A7,
|
||||
"uml": 0x00A8,
|
||||
"copy": 0x00A9,
|
||||
"ordf": 0x00AA,
|
||||
"laquo": 0x00AB,
|
||||
"not": 0x00AC,
|
||||
"shy": 0x00AD,
|
||||
"reg": 0x00AE,
|
||||
"macr": 0x00AF,
|
||||
"deg": 0x00B0,
|
||||
"plusmn": 0x00B1,
|
||||
"sup2": 0x00B2,
|
||||
"sup3": 0x00B3,
|
||||
"acute": 0x00B4,
|
||||
"micro": 0x00B5,
|
||||
"para": 0x00B6,
|
||||
"middot": 0x00B7,
|
||||
"cedil": 0x00B8,
|
||||
"sup1": 0x00B9,
|
||||
"ordm": 0x00BA,
|
||||
"raquo": 0x00BB,
|
||||
"frac14": 0x00BC,
|
||||
"frac12": 0x00BD,
|
||||
"frac34": 0x00BE,
|
||||
"iquest": 0x00BF,
|
||||
"Agrave": 0x00C0,
|
||||
"Aacute": 0x00C1,
|
||||
"Acirc": 0x00C2,
|
||||
"Atilde": 0x00C3,
|
||||
"Auml": 0x00C4,
|
||||
"Aring": 0x00C5,
|
||||
"AElig": 0x00C6,
|
||||
"Ccedil": 0x00C7,
|
||||
"Egrave": 0x00C8,
|
||||
"Eacute": 0x00C9,
|
||||
"Ecirc": 0x00CA,
|
||||
"Euml": 0x00CB,
|
||||
"Igrave": 0x00CC,
|
||||
"Iacute": 0x00CD,
|
||||
"Icirc": 0x00CE,
|
||||
"Iuml": 0x00CF,
|
||||
"ETH": 0x00D0,
|
||||
"Ntilde": 0x00D1,
|
||||
"Ograve": 0x00D2,
|
||||
"Oacute": 0x00D3,
|
||||
"Ocirc": 0x00D4,
|
||||
"Otilde": 0x00D5,
|
||||
"Ouml": 0x00D6,
|
||||
"times": 0x00D7,
|
||||
"Oslash": 0x00D8,
|
||||
"Ugrave": 0x00D9,
|
||||
"Uacute": 0x00DA,
|
||||
"Ucirc": 0x00DB,
|
||||
"Uuml": 0x00DC,
|
||||
"Yacute": 0x00DD,
|
||||
"THORN": 0x00DE,
|
||||
"szlig": 0x00DF,
|
||||
"agrave": 0x00E0,
|
||||
"aacute": 0x00E1,
|
||||
"acirc": 0x00E2,
|
||||
"atilde": 0x00E3,
|
||||
"auml": 0x00E4,
|
||||
"aring": 0x00E5,
|
||||
"aelig": 0x00E6,
|
||||
"ccedil": 0x00E7,
|
||||
"egrave": 0x00E8,
|
||||
"eacute": 0x00E9,
|
||||
"ecirc": 0x00EA,
|
||||
"euml": 0x00EB,
|
||||
"igrave": 0x00EC,
|
||||
"iacute": 0x00ED,
|
||||
"icirc": 0x00EE,
|
||||
"iuml": 0x00EF,
|
||||
"eth": 0x00F0,
|
||||
"ntilde": 0x00F1,
|
||||
"ograve": 0x00F2,
|
||||
"oacute": 0x00F3,
|
||||
"ocirc": 0x00F4,
|
||||
"otilde": 0x00F5,
|
||||
"ouml": 0x00F6,
|
||||
"divide": 0x00F7,
|
||||
"oslash": 0x00F8,
|
||||
"ugrave": 0x00F9,
|
||||
"uacute": 0x00FA,
|
||||
"ucirc": 0x00FB,
|
||||
"uuml": 0x00FC,
|
||||
"yacute": 0x00FD,
|
||||
"thorn": 0x00FE,
|
||||
"yuml": 0x00FF,
|
||||
"OElig": 0x0152,
|
||||
"oelig": 0x0153,
|
||||
"Scaron": 0x0160,
|
||||
"scaron": 0x0161,
|
||||
"Yuml": 0x0178,
|
||||
"fnof": 0x0192,
|
||||
"circ": 0x02C6,
|
||||
"tilde": 0x02DC,
|
||||
"Alpha": 0x0391,
|
||||
"Beta": 0x0392,
|
||||
"Gamma": 0x0393,
|
||||
"Delta": 0x0394,
|
||||
"Epsilon": 0x0395,
|
||||
"Zeta": 0x0396,
|
||||
"Eta": 0x0397,
|
||||
"Theta": 0x0398,
|
||||
"Iota": 0x0399,
|
||||
"Kappa": 0x039A,
|
||||
"Lambda": 0x039B,
|
||||
"Mu": 0x039C,
|
||||
"Nu": 0x039D,
|
||||
"Xi": 0x039E,
|
||||
"Omicron": 0x039F,
|
||||
"Pi": 0x03A0,
|
||||
"Rho": 0x03A1,
|
||||
"Sigma": 0x03A3,
|
||||
"Tau": 0x03A4,
|
||||
"Upsilon": 0x03A5,
|
||||
"Phi": 0x03A6,
|
||||
"Chi": 0x03A7,
|
||||
"Psi": 0x03A8,
|
||||
"Omega": 0x03A9,
|
||||
"alpha": 0x03B1,
|
||||
"beta": 0x03B2,
|
||||
"gamma": 0x03B3,
|
||||
"delta": 0x03B4,
|
||||
"epsilon": 0x03B5,
|
||||
"zeta": 0x03B6,
|
||||
"eta": 0x03B7,
|
||||
"theta": 0x03B8,
|
||||
"iota": 0x03B9,
|
||||
"kappa": 0x03BA,
|
||||
"lambda": 0x03BB,
|
||||
"mu": 0x03BC,
|
||||
"nu": 0x03BD,
|
||||
"xi": 0x03BE,
|
||||
"omicron": 0x03BF,
|
||||
"pi": 0x03C0,
|
||||
"rho": 0x03C1,
|
||||
"sigmaf": 0x03C2,
|
||||
"sigma": 0x03C3,
|
||||
"tau": 0x03C4,
|
||||
"upsilon": 0x03C5,
|
||||
"phi": 0x03C6,
|
||||
"chi": 0x03C7,
|
||||
"psi": 0x03C8,
|
||||
"omega": 0x03C9,
|
||||
"thetasym": 0x03D1,
|
||||
"upsih": 0x03D2,
|
||||
"piv": 0x03D6,
|
||||
"ensp": 0x2002,
|
||||
"emsp": 0x2003,
|
||||
"thinsp": 0x2009,
|
||||
"zwnj": 0x200C,
|
||||
"zwj": 0x200D,
|
||||
"lrm": 0x200E,
|
||||
"rlm": 0x200F,
|
||||
"ndash": 0x2013,
|
||||
"mdash": 0x2014,
|
||||
"lsquo": 0x2018,
|
||||
"rsquo": 0x2019,
|
||||
"sbquo": 0x201A,
|
||||
"ldquo": 0x201C,
|
||||
"rdquo": 0x201D,
|
||||
"bdquo": 0x201E,
|
||||
"dagger": 0x2020,
|
||||
"Dagger": 0x2021,
|
||||
"bull": 0x2022,
|
||||
"hellip": 0x2026,
|
||||
"permil": 0x2030,
|
||||
"prime": 0x2032,
|
||||
"Prime": 0x2033,
|
||||
"lsaquo": 0x2039,
|
||||
"rsaquo": 0x203A,
|
||||
"oline": 0x203E,
|
||||
"frasl": 0x2044,
|
||||
"euro": 0x20AC,
|
||||
"image": 0x2111,
|
||||
"weierp": 0x2118,
|
||||
"real": 0x211C,
|
||||
"trade": 0x2122,
|
||||
"alefsym": 0x2135,
|
||||
"larr": 0x2190,
|
||||
"uarr": 0x2191,
|
||||
"rarr": 0x2192,
|
||||
"darr": 0x2193,
|
||||
"harr": 0x2194,
|
||||
"crarr": 0x21B5,
|
||||
"lArr": 0x21D0,
|
||||
"uArr": 0x21D1,
|
||||
"rArr": 0x21D2,
|
||||
"dArr": 0x21D3,
|
||||
"hArr": 0x21D4,
|
||||
"forall": 0x2200,
|
||||
"part": 0x2202,
|
||||
"exist": 0x2203,
|
||||
"empty": 0x2205,
|
||||
"nabla": 0x2207,
|
||||
"isin": 0x2208,
|
||||
"notin": 0x2209,
|
||||
"ni": 0x220B,
|
||||
"prod": 0x220F,
|
||||
"sum": 0x2211,
|
||||
"minus": 0x2212,
|
||||
"lowast": 0x2217,
|
||||
"radic": 0x221A,
|
||||
"prop": 0x221D,
|
||||
"infin": 0x221E,
|
||||
"ang": 0x2220,
|
||||
"and": 0x2227,
|
||||
"or": 0x2228,
|
||||
"cap": 0x2229,
|
||||
"cup": 0x222A,
|
||||
"int": 0x222B,
|
||||
"there4": 0x2234,
|
||||
"sim": 0x223C,
|
||||
"cong": 0x2245,
|
||||
"asymp": 0x2248,
|
||||
"ne": 0x2260,
|
||||
"equiv": 0x2261,
|
||||
"le": 0x2264,
|
||||
"ge": 0x2265,
|
||||
"sub": 0x2282,
|
||||
"sup": 0x2283,
|
||||
"nsub": 0x2284,
|
||||
"sube": 0x2286,
|
||||
"supe": 0x2287,
|
||||
"oplus": 0x2295,
|
||||
"otimes": 0x2297,
|
||||
"perp": 0x22A5,
|
||||
"sdot": 0x22C5,
|
||||
"lceil": 0x2308,
|
||||
"rceil": 0x2309,
|
||||
"lfloor": 0x230A,
|
||||
"rfloor": 0x230B,
|
||||
"lang": 0x2329,
|
||||
"rang": 0x232A,
|
||||
"loz": 0x25CA,
|
||||
"spades": 0x2660,
|
||||
"clubs": 0x2663,
|
||||
"hearts": 0x2665,
|
||||
"diams": 0x2666
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/// <reference path="harness.ts" />
|
||||
/// <reference path="runnerbase.ts" />
|
||||
/// <reference path="typeWriter.ts" />
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
const enum CompilerTestType {
|
||||
Conformance,
|
||||
|
@ -32,7 +33,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
}
|
||||
else if (testType === CompilerTestType.Test262) {
|
||||
this.testSuiteName = "test262";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.testSuiteName = "compiler"; // default to this for historical reasons
|
||||
}
|
||||
this.basePath += "/" + this.testSuiteName;
|
||||
|
@ -82,7 +84,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
otherFiles.push({ unitName: rootDir + unit.name, content: unit.content });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
toBeCompiled = units.map(unit => {
|
||||
return { unitName: rootDir + unit.name, content: unit.content };
|
||||
});
|
||||
|
@ -193,7 +196,8 @@ class CompilerBaselineRunner extends RunnerBase {
|
|||
|
||||
if (jsCode.length > 0) {
|
||||
return tsCode + "\r\n\r\n" + jsCode;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
/// <reference path="harnessLanguageService.ts" />
|
||||
/// <reference path="harness.ts" />
|
||||
/// <reference path="fourslashRunner.ts" />
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
module FourSlash {
|
||||
namespace FourSlash {
|
||||
ts.disableIncrementalParsing = false;
|
||||
|
||||
// Represents a parsed source file with metadata
|
||||
|
@ -258,7 +259,8 @@ module FourSlash {
|
|||
this.inputFiles[file.fileName] = file.content;
|
||||
if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference] === "true") {
|
||||
startResolveFileRef = file;
|
||||
} else if (startResolveFileRef) {
|
||||
}
|
||||
else if (startResolveFileRef) {
|
||||
// If entry point for resolving file references is already specified, report duplication error
|
||||
throw new Error("There exists a Fourslash file which has resolveReference flag specified; remove duplicated resolveReference flag");
|
||||
}
|
||||
|
@ -361,7 +363,8 @@ module FourSlash {
|
|||
this.currentCaretPosition = Math.min(this.currentCaretPosition, this.getFileContent(this.activeFile.fileName).length);
|
||||
if (count > 0) {
|
||||
this.scenarioActions.push(`<MoveCaretRight NumberOfChars="${count}" />`);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.scenarioActions.push(`<MoveCaretLeft NumberOfChars="${-count}" />`);
|
||||
}
|
||||
}
|
||||
|
@ -436,7 +439,8 @@ module FourSlash {
|
|||
predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false;
|
||||
};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) {
|
||||
return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false;
|
||||
};
|
||||
|
@ -476,7 +480,8 @@ module FourSlash {
|
|||
private printErrorLog(expectErrors: boolean, errors: ts.Diagnostic[]) {
|
||||
if (expectErrors) {
|
||||
Harness.IO.log("Expected error not found. Error list is:");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Harness.IO.log("Unexpected error(s) found. Error list is:");
|
||||
}
|
||||
|
||||
|
@ -549,10 +554,12 @@ module FourSlash {
|
|||
if (negative) {
|
||||
this.verifyMemberListIsEmpty(false);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.scenarioActions.push("<ShowCompletionList />");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.scenarioActions.push("<ShowCompletionList />");
|
||||
this.scenarioActions.push(`<VerifyCompletionItemsCount Count="${expectedCount}" ${(negative ? "ExpectsFailure=\"true\" " : "")}/>`);
|
||||
}
|
||||
|
@ -595,14 +602,16 @@ module FourSlash {
|
|||
public verifyMemberListIsEmpty(negative: boolean) {
|
||||
if (negative) {
|
||||
this.scenarioActions.push("<ShowCompletionList />");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.scenarioActions.push("<ShowCompletionList ExpectsFailure=\"true\" />");
|
||||
}
|
||||
|
||||
let members = this.getMemberListAtCaret();
|
||||
if ((!members || members.entries.length === 0) && negative) {
|
||||
this.raiseError("Member list is empty at Caret");
|
||||
} else if ((members && members.entries.length !== 0) && !negative) {
|
||||
}
|
||||
else if ((members && members.entries.length !== 0) && !negative) {
|
||||
|
||||
let errorMsg = "\n" + "Member List contains: [" + members.entries[0].name;
|
||||
for (let i = 1; i < members.entries.length; i++) {
|
||||
|
@ -639,7 +648,8 @@ module FourSlash {
|
|||
|
||||
if ((completions && !completions.isNewIdentifierLocation) && !negative) {
|
||||
this.raiseError("Expected builder completion entry");
|
||||
} else if ((completions && completions.isNewIdentifierLocation) && negative) {
|
||||
}
|
||||
else if ((completions && completions.isNewIdentifierLocation) && negative) {
|
||||
this.raiseError("Un-expected builder completion entry");
|
||||
}
|
||||
}
|
||||
|
@ -832,7 +842,8 @@ module FourSlash {
|
|||
if (expectedDocumentation != undefined) {
|
||||
assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment"));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (expectedText !== undefined) {
|
||||
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
|
||||
}
|
||||
|
@ -1014,7 +1025,8 @@ module FourSlash {
|
|||
if (!actual) {
|
||||
this.raiseError("Expected signature help to be present, but it wasn't");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (actual) {
|
||||
this.raiseError(`Expected no signature help, but got "${JSON.stringify(actual)}"`);
|
||||
}
|
||||
|
@ -1371,7 +1383,8 @@ module FourSlash {
|
|||
public type(text: string) {
|
||||
if (text === "") {
|
||||
this.taoInvalidReason = "Test used empty-insert workaround.";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.scenarioActions.push(`<InsertText><![CDATA[${text}]]></InsertText>`);
|
||||
}
|
||||
|
||||
|
@ -1398,7 +1411,8 @@ module FourSlash {
|
|||
if (ch === "(" || ch === ",") {
|
||||
/* Signature help*/
|
||||
this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset);
|
||||
} else if (prevChar === " " && /A-Za-z_/.test(ch)) {
|
||||
}
|
||||
else if (prevChar === " " && /A-Za-z_/.test(ch)) {
|
||||
/* Completions */
|
||||
this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset);
|
||||
}
|
||||
|
@ -1547,7 +1561,8 @@ module FourSlash {
|
|||
if (marker.position < limChar) {
|
||||
// Marker is inside the edit - mark it as invalidated (?)
|
||||
marker.position = -1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Move marker back/forward by the appropriate amount
|
||||
marker.position += (minChar - limChar) + text.length;
|
||||
}
|
||||
|
@ -1568,7 +1583,8 @@ module FourSlash {
|
|||
public goToDefinition(definitionIndex: number) {
|
||||
if (definitionIndex === 0) {
|
||||
this.scenarioActions.push("<GoToDefinition />");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.taoInvalidReason = "GoToDefinition not supported for non-zero definition indices";
|
||||
}
|
||||
|
||||
|
@ -1650,7 +1666,8 @@ module FourSlash {
|
|||
if (negative) {
|
||||
assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
|
||||
assert.notEqual(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
|
||||
assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
|
||||
}
|
||||
|
@ -1897,22 +1914,22 @@ module FourSlash {
|
|||
|
||||
if (expected === undefined) {
|
||||
if (actual) {
|
||||
this.raiseError(name + ' failed - expected no template but got {newText: \"' + actual.newText + '\" caretOffset: ' + actual.caretOffset + '}');
|
||||
this.raiseError(name + " failed - expected no template but got {newText: \"" + actual.newText + "\" caretOffset: " + actual.caretOffset + "}");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (actual === undefined) {
|
||||
this.raiseError(name + ' failed - expected the template {newText: \"' + actual.newText + '\" caretOffset: ' + actual.caretOffset + '} but got nothing instead');
|
||||
this.raiseError(name + " failed - expected the template {newText: \"" + actual.newText + "\" caretOffset: " + actual.caretOffset + "} but got nothing instead");
|
||||
}
|
||||
|
||||
if (actual.newText !== expected.newText) {
|
||||
this.raiseError(name + ' failed - expected insertion:\n' + this.clarifyNewlines(expected.newText) + '\nactual insertion:\n' + this.clarifyNewlines(actual.newText));
|
||||
this.raiseError(name + " failed - expected insertion:\n" + this.clarifyNewlines(expected.newText) + "\nactual insertion:\n" + this.clarifyNewlines(actual.newText));
|
||||
}
|
||||
|
||||
if (actual.caretOffset !== expected.caretOffset) {
|
||||
this.raiseError(name + ' failed - expected caretOffset: ' + expected.caretOffset + ',\nactual caretOffset:' + actual.caretOffset);
|
||||
this.raiseError(name + " failed - expected caretOffset: " + expected.caretOffset + ",\nactual caretOffset:" + actual.caretOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1936,9 +1953,11 @@ module FourSlash {
|
|||
let actualMatchPosition = -1;
|
||||
if (bracePosition === actual[0].start) {
|
||||
actualMatchPosition = actual[1].start;
|
||||
} else if (bracePosition === actual[1].start) {
|
||||
}
|
||||
else if (bracePosition === actual[1].start) {
|
||||
actualMatchPosition = actual[0].start;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.raiseError(`verifyMatchingBracePosition failed - could not find the brace position: ${bracePosition} in the returned list: (${actual[0].start},${ts.textSpanEnd(actual[0])}) and (${actual[1].start},${ts.textSpanEnd(actual[1])})`);
|
||||
}
|
||||
|
||||
|
@ -2108,7 +2127,7 @@ module FourSlash {
|
|||
let occurrences = this.getOccurrencesAtCurrentPosition();
|
||||
|
||||
if (!occurrences || occurrences.length === 0) {
|
||||
this.raiseError('verifyOccurrencesAtPositionListContains failed - found 0 references, expected at least one.');
|
||||
this.raiseError("verifyOccurrencesAtPositionListContains failed - found 0 references, expected at least one.");
|
||||
}
|
||||
|
||||
for (let occurrence of occurrences) {
|
||||
|
@ -2140,12 +2159,12 @@ module FourSlash {
|
|||
}
|
||||
|
||||
public verifyDocumentHighlightsAtPositionListContains(fileName: string, start: number, end: number, fileNamesToSearch: string[], kind?: string) {
|
||||
this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListContains NYI';
|
||||
this.taoInvalidReason = "verifyDocumentHighlightsAtPositionListContains NYI";
|
||||
|
||||
let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch);
|
||||
|
||||
if (!documentHighlights || documentHighlights.length === 0) {
|
||||
this.raiseError('verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one.');
|
||||
this.raiseError("verifyDocumentHighlightsAtPositionListContains failed - found 0 highlights, expected at least one.");
|
||||
}
|
||||
|
||||
for (let documentHighlight of documentHighlights) {
|
||||
|
@ -2168,15 +2187,15 @@ module FourSlash {
|
|||
}
|
||||
|
||||
public verifyDocumentHighlightsAtPositionListCount(expectedCount: number, fileNamesToSearch: string[]) {
|
||||
this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListCount NYI';
|
||||
this.taoInvalidReason = "verifyDocumentHighlightsAtPositionListCount NYI";
|
||||
|
||||
let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch);
|
||||
let actualCount = documentHighlights
|
||||
? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0)
|
||||
let actualCount = documentHighlights
|
||||
? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0)
|
||||
: 0;
|
||||
|
||||
if (expectedCount !== actualCount) {
|
||||
this.raiseError('verifyDocumentHighlightsAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount);
|
||||
this.raiseError("verifyDocumentHighlightsAtPositionListCount failed - actual: " + actualCount + ", expected:" + expectedCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2250,10 +2269,12 @@ module FourSlash {
|
|||
let index = <number>indexOrName;
|
||||
if (index >= this.testData.files.length) {
|
||||
throw new Error(`File index (${index}) in openFile was out of range. There are only ${this.testData.files.length} files in this test.`);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = this.testData.files[index];
|
||||
}
|
||||
} else if (typeof indexOrName === "string") {
|
||||
}
|
||||
else if (typeof indexOrName === "string") {
|
||||
let name = <string>indexOrName;
|
||||
|
||||
// names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName
|
||||
|
@ -2276,7 +2297,8 @@ module FourSlash {
|
|||
if (!foundIt) {
|
||||
throw new Error(`No test file named "${name}" exists. Available file names are: ${availableNames.join(", ")}`);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new Error("Unknown argument type");
|
||||
}
|
||||
|
||||
|
@ -2294,7 +2316,8 @@ module FourSlash {
|
|||
let markerNames: string[] = [];
|
||||
for (let m in this.testData.markerPositions) markerNames.push(m);
|
||||
throw new Error(`Unknown marker "${markerName}" Available markers: ${markerNames.map(m => "\"" + m + "\"").join(", ")}`);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return markerPos;
|
||||
}
|
||||
}
|
||||
|
@ -2439,13 +2462,15 @@ module FourSlash {
|
|||
// Append to the current subfile content, inserting a newline needed
|
||||
if (currentFileContent === null) {
|
||||
currentFileContent = "";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// End-of-line
|
||||
currentFileContent = currentFileContent + "\n";
|
||||
}
|
||||
|
||||
currentFileContent = currentFileContent + line.substr(4);
|
||||
} else if (line.substr(0, 2) === "//") {
|
||||
}
|
||||
else if (line.substr(0, 2) === "//") {
|
||||
// Comment line, check for global/file @options and record them
|
||||
let match = optionRegex.exec(line.substr(2));
|
||||
if (match) {
|
||||
|
@ -2475,17 +2500,20 @@ module FourSlash {
|
|||
|
||||
currentFileName = basePath + "/" + match[2];
|
||||
currentFileOptions[match[1]] = match[2];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Add other fileMetadata flag
|
||||
currentFileOptions[match[1]] = match[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: should be '==='?
|
||||
} else if (line == "" || lineLength === 0) {
|
||||
}
|
||||
else if (line == "" || lineLength === 0) {
|
||||
// Previously blank lines between fourslash content caused it to be considered as 2 files,
|
||||
// Remove this behavior since it just causes errors now
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Empty line or code line, terminate current subfile if there is one
|
||||
if (currentFileContent) {
|
||||
let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges);
|
||||
|
@ -2555,7 +2583,8 @@ module FourSlash {
|
|||
try {
|
||||
// Attempt to parse the marker value as JSON
|
||||
markerValue = JSON.parse("{ " + text + " }");
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
reportError(fileName, location.sourceLine, location.sourceColumn, "Unable to parse marker text " + e.message);
|
||||
}
|
||||
|
||||
|
@ -2591,7 +2620,8 @@ module FourSlash {
|
|||
let message = "Marker '" + name + "' is duplicated in the source file contents.";
|
||||
reportError(marker.fileName, location.sourceLine, location.sourceColumn, message);
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
markerMap[name] = marker;
|
||||
markers.push(marker);
|
||||
return marker;
|
||||
|
@ -2605,7 +2635,7 @@ module FourSlash {
|
|||
let validMarkerChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_";
|
||||
|
||||
/// The file content (minus metacharacters) so far
|
||||
let output: string = "";
|
||||
let output = "";
|
||||
|
||||
/// The current marker (or maybe multi-line comment?) we're parsing, possibly
|
||||
let openMarker: ILocationInformation = null;
|
||||
|
@ -2617,22 +2647,23 @@ module FourSlash {
|
|||
let localRanges: Range[] = [];
|
||||
|
||||
/// The latest position of the start of an unflushed plain text area
|
||||
let lastNormalCharPosition: number = 0;
|
||||
let lastNormalCharPosition = 0;
|
||||
|
||||
/// The total number of metacharacters removed from the file (so far)
|
||||
let difference: number = 0;
|
||||
let difference = 0;
|
||||
|
||||
/// The fourslash file state object we are generating
|
||||
let state: State = State.none;
|
||||
|
||||
/// Current position data
|
||||
let line: number = 1;
|
||||
let column: number = 1;
|
||||
let line = 1;
|
||||
let column = 1;
|
||||
|
||||
let flush = (lastSafeCharIndex: number) => {
|
||||
if (lastSafeCharIndex === undefined) {
|
||||
output = output + content.substr(lastNormalCharPosition);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
output = output + content.substr(lastNormalCharPosition, lastSafeCharIndex - lastNormalCharPosition);
|
||||
}
|
||||
};
|
||||
|
@ -2655,7 +2686,8 @@ module FourSlash {
|
|||
flush(i - 1);
|
||||
lastNormalCharPosition = i + 1;
|
||||
difference += 2;
|
||||
} else if (previousChar === "|" && currentChar === "]") {
|
||||
}
|
||||
else if (previousChar === "|" && currentChar === "]") {
|
||||
// found a range end
|
||||
let rangeStart = openRanges.pop();
|
||||
if (!rangeStart) {
|
||||
|
@ -2674,7 +2706,8 @@ module FourSlash {
|
|||
flush(i - 1);
|
||||
lastNormalCharPosition = i + 1;
|
||||
difference += 2;
|
||||
} else if (previousChar === "/" && currentChar === "*") {
|
||||
}
|
||||
else if (previousChar === "/" && currentChar === "*") {
|
||||
// found a possible marker start
|
||||
state = State.inSlashStarMarker;
|
||||
openMarker = {
|
||||
|
@ -2683,7 +2716,8 @@ module FourSlash {
|
|||
sourceLine: line,
|
||||
sourceColumn: column,
|
||||
};
|
||||
} else if (previousChar === "{" && currentChar === "|") {
|
||||
}
|
||||
else if (previousChar === "{" && currentChar === "|") {
|
||||
// found an object marker start
|
||||
state = State.inObjectMarker;
|
||||
openMarker = {
|
||||
|
@ -2736,10 +2770,12 @@ module FourSlash {
|
|||
// Reset the state
|
||||
openMarker = null;
|
||||
state = State.none;
|
||||
} else if (validMarkerChars.indexOf(currentChar) < 0) {
|
||||
}
|
||||
else if (validMarkerChars.indexOf(currentChar) < 0) {
|
||||
if (currentChar === "*" && i < content.length - 1 && content.charAt(i + 1) === "/") {
|
||||
// The marker is about to be closed, ignore the 'invalid' char
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// We've hit a non-valid marker character, so we were actually in a block comment
|
||||
// Bail out the text we've gathered so far back into the output
|
||||
flush(i);
|
||||
|
@ -2755,7 +2791,8 @@ module FourSlash {
|
|||
if (currentChar === "\n" && previousChar === "\r") {
|
||||
// Ignore trailing \n after a \r
|
||||
continue;
|
||||
} else if (currentChar === "\n" || currentChar === "\r") {
|
||||
}
|
||||
else if (currentChar === "\n" || currentChar === "\r") {
|
||||
line++;
|
||||
column = 1;
|
||||
continue;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
///<reference path="fourslash.ts" />
|
||||
///<reference path="harness.ts"/>
|
||||
///<reference path="runnerbase.ts" />
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
const enum FourSlashTestType {
|
||||
Native,
|
||||
|
@ -25,8 +26,8 @@ class FourSlashRunner extends RunnerBase {
|
|||
this.testSuiteName = "fourslash-shims";
|
||||
break;
|
||||
case FourSlashTestType.ShimsWithPreprocess:
|
||||
this.basePath = 'tests/cases/fourslash/shims-pp';
|
||||
this.testSuiteName = 'fourslash-shims-pp';
|
||||
this.basePath = "tests/cases/fourslash/shims-pp";
|
||||
this.testSuiteName = "fourslash-shims-pp";
|
||||
break;
|
||||
case FourSlashTestType.Server:
|
||||
this.basePath = "tests/cases/fourslash/server";
|
||||
|
@ -87,7 +88,8 @@ class FourSlashRunner extends RunnerBase {
|
|||
FourSlash.xmlData.forEach(xml => {
|
||||
if (xml.invalidReason !== null) {
|
||||
lines.push("<!-- Skipped " + xml.originalName + ", reason: " + xml.invalidReason + " -->");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lines.push(" <Scenario Name=\"" + xml.originalName + "\">");
|
||||
xml.actions.forEach(action => {
|
||||
lines.push(" " + action);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
/// <reference path="external\chai.d.ts"/>
|
||||
/// <reference path="sourceMapRecorder.ts"/>
|
||||
/// <reference path="runnerbase.ts"/>
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
// Block scoped definitions work poorly for global variables, temporarily enable var
|
||||
/* tslint:disable:no-var-keyword */
|
||||
|
@ -35,7 +36,7 @@ declare var __dirname: string; // Node-specific
|
|||
var global = <any>Function("return this").call(null);
|
||||
/* tslint:enable:no-var-keyword */
|
||||
|
||||
module Utils {
|
||||
namespace Utils {
|
||||
// Setup some globals based on the current environment
|
||||
export const enum ExecutionEnvironment {
|
||||
Node,
|
||||
|
@ -54,17 +55,17 @@ module Utils {
|
|||
return ExecutionEnvironment.Node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export let currentExecutionEnvironment = getExecutionEnvironment();
|
||||
|
||||
const Buffer: BufferConstructor = currentExecutionEnvironment !== ExecutionEnvironment.Browser
|
||||
? require("buffer").Buffer
|
||||
const Buffer: BufferConstructor = currentExecutionEnvironment !== ExecutionEnvironment.Browser
|
||||
? require("buffer").Buffer
|
||||
: undefined;
|
||||
|
||||
export function encodeString(s: string): string {
|
||||
return Buffer ? (new Buffer(s)).toString("utf8") : s;
|
||||
}
|
||||
|
||||
|
||||
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
|
||||
let environment = getExecutionEnvironment();
|
||||
switch (environment) {
|
||||
|
@ -76,7 +77,8 @@ module Utils {
|
|||
let vm = require("vm");
|
||||
if (nodeContext) {
|
||||
vm.runInNewContext(fileContents, nodeContext, fileName);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
vm.runInThisContext(fileContents, fileName);
|
||||
}
|
||||
break;
|
||||
|
@ -126,7 +128,8 @@ module Utils {
|
|||
let cachedResult = cache[key];
|
||||
if (cachedResult) {
|
||||
return cachedResult;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return cache[key] = f.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
@ -396,7 +399,7 @@ module Utils {
|
|||
}
|
||||
}
|
||||
|
||||
module Harness.Path {
|
||||
namespace Harness.Path {
|
||||
export function getFileName(fullPath: string) {
|
||||
return fullPath.replace(/^.*[\\\/]/, "");
|
||||
}
|
||||
|
@ -409,7 +412,7 @@ module Harness.Path {
|
|||
}
|
||||
}
|
||||
|
||||
module Harness {
|
||||
namespace Harness {
|
||||
export interface IO {
|
||||
newLine(): string;
|
||||
getCurrentDirectory(): string;
|
||||
|
@ -431,11 +434,11 @@ module Harness {
|
|||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
}
|
||||
export var IO: IO;
|
||||
|
||||
|
||||
// harness always uses one kind of new line
|
||||
const harnessNewLine = "\r\n";
|
||||
|
||||
module IOImpl {
|
||||
|
||||
namespace IOImpl {
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
public moveNext(): boolean;
|
||||
|
@ -443,14 +446,15 @@ module Harness {
|
|||
constructor(o: any);
|
||||
}
|
||||
|
||||
export module CScript {
|
||||
export namespace CScript {
|
||||
let fso: any;
|
||||
if (global.ActiveXObject) {
|
||||
fso = new global.ActiveXObject("Scripting.FileSystemObject");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fso = {};
|
||||
}
|
||||
|
||||
|
||||
export const args = () => ts.sys.args;
|
||||
export const getExecutingFilePath = () => ts.sys.getExecutingFilePath();
|
||||
export const exit = (exitCode: number) => ts.sys.exit(exitCode);
|
||||
|
@ -511,16 +515,17 @@ module Harness {
|
|||
};
|
||||
}
|
||||
|
||||
export module Node {
|
||||
export namespace Node {
|
||||
declare let require: any;
|
||||
let fs: any, pathModule: any;
|
||||
if (require) {
|
||||
fs = require("fs");
|
||||
pathModule = require("path");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fs = pathModule = {};
|
||||
}
|
||||
|
||||
|
||||
export const resolvePath = (path: string) => ts.sys.resolvePath(path);
|
||||
export const getCurrentDirectory = () => ts.sys.getCurrentDirectory();
|
||||
export const newLine = () => harnessNewLine;
|
||||
|
@ -545,7 +550,8 @@ module Harness {
|
|||
export function deleteFile(path: string) {
|
||||
try {
|
||||
fs.unlinkSync(path);
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,7 +565,8 @@ module Harness {
|
|||
// Node will just continue to repeat the root path, rather than return null
|
||||
if (dirPath === path) {
|
||||
dirPath = null;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return dirPath;
|
||||
}
|
||||
}
|
||||
|
@ -596,7 +603,7 @@ module Harness {
|
|||
};
|
||||
}
|
||||
|
||||
export module Network {
|
||||
export namespace Network {
|
||||
let serverRoot = "http://localhost:8888/";
|
||||
|
||||
export const newLine = () => harnessNewLine;
|
||||
|
@ -605,10 +612,11 @@ module Harness {
|
|||
export const args = () => <string[]>[];
|
||||
export const getExecutingFilePath = () => "";
|
||||
export const exit = (exitCode: number) => {};
|
||||
|
||||
let supportsCodePage = () => false;
|
||||
|
||||
module Http {
|
||||
let supportsCodePage = () => false;
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
namespace Http {
|
||||
function waitForXHR(xhr: XMLHttpRequest) {
|
||||
while (xhr.readyState !== 4) { }
|
||||
return { status: xhr.status, responseText: xhr.responseText };
|
||||
|
@ -683,10 +691,12 @@ module Harness {
|
|||
if (dirPath.match(/localhost:\d+$/) || dirPath.match(/localhost:\d+\/$/)) {
|
||||
dirPath = null;
|
||||
// path + fileName
|
||||
} else if (dirPath.indexOf(".") === -1) {
|
||||
}
|
||||
else if (dirPath.indexOf(".") === -1) {
|
||||
dirPath = dirPath.substring(0, dirPath.lastIndexOf("/"));
|
||||
// path
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// strip any trailing slash
|
||||
if (dirPath.match(/.*\/$/)) {
|
||||
dirPath = dirPath.substring(0, dirPath.length - 2);
|
||||
|
@ -710,7 +720,8 @@ module Harness {
|
|||
let results = response.responseText.split(",");
|
||||
if (spec) {
|
||||
return results.filter(file => spec.test(file));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
@ -720,13 +731,12 @@ module Harness {
|
|||
};
|
||||
export let listFiles = Utils.memoize(_listFilesImpl);
|
||||
|
||||
export let log = (s: string) => console.log(s);
|
||||
|
||||
export function readFile(file: string) {
|
||||
let response = Http.getFileFromServerSync(serverRoot + file);
|
||||
if (response.status === 200) {
|
||||
return response.responseText;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -754,7 +764,7 @@ module Harness {
|
|||
}
|
||||
}
|
||||
|
||||
module Harness {
|
||||
namespace Harness {
|
||||
let tcServicesFileName = "typescriptServices.js";
|
||||
|
||||
export let libFolder: string;
|
||||
|
@ -785,7 +795,7 @@ module Harness {
|
|||
export let lightMode = false;
|
||||
|
||||
/** Functionality for compiling TypeScript code */
|
||||
export module Compiler {
|
||||
export namespace Compiler {
|
||||
/** Aggregate various writes into a single array of lines. Useful for passing to the
|
||||
* TypeScript compiler to fill with source code or errors.
|
||||
*/
|
||||
|
@ -864,7 +874,7 @@ module Harness {
|
|||
languageVersion: ts.ScriptTarget) {
|
||||
// We'll only assert inletiants outside of light mode.
|
||||
const shouldAssertInvariants = !Harness.lightMode;
|
||||
|
||||
|
||||
// Only set the parent nodes if we're asserting inletiants. We don't need them otherwise.
|
||||
let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants);
|
||||
|
||||
|
@ -1102,7 +1112,7 @@ module Harness {
|
|||
}
|
||||
|
||||
let useCaseSensitiveFileNames = options.useCaseSensitiveFileNames !== undefined ? options.useCaseSensitiveFileNames : Harness.IO.useCaseSensitiveFileNames();
|
||||
|
||||
|
||||
let fileOutputs: GeneratedFile[] = [];
|
||||
|
||||
let programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName);
|
||||
|
@ -1231,12 +1241,12 @@ module Harness {
|
|||
.filter(s => s.length > 0)
|
||||
.map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s);
|
||||
errLines.forEach(e => outputLines.push(e));
|
||||
|
||||
|
||||
// do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics
|
||||
// if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers)
|
||||
// then they will be added twice thus triggering 'total errors' assertion with condition
|
||||
// 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
|
||||
|
||||
|
||||
if (!error.file || !isLibraryFile(error.file.fileName)) {
|
||||
totalErrorsReportedInNonLibraryFiles++;
|
||||
}
|
||||
|
@ -1280,7 +1290,8 @@ module Harness {
|
|||
// On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly
|
||||
if (lineIndex === lines.length - 1) {
|
||||
nextLineStart = inputFile.content.length;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
nextLineStart = lineStarts[lineIndex + 1];
|
||||
}
|
||||
// Emit this line from the original file
|
||||
|
@ -1344,7 +1355,7 @@ module Harness {
|
|||
|
||||
// FileName header + content
|
||||
result += "/*====== " + outputFile.fileName + " ======*/\r\n";
|
||||
|
||||
|
||||
result += outputFile.code;
|
||||
}
|
||||
|
||||
|
@ -1444,7 +1455,7 @@ module Harness {
|
|||
}
|
||||
}
|
||||
|
||||
export module TestCaseParser {
|
||||
export namespace TestCaseParser {
|
||||
/** all the necessary information to set the right compiler settings */
|
||||
export interface CompilerSettings {
|
||||
[name: string]: string;
|
||||
|
@ -1497,7 +1508,8 @@ module Harness {
|
|||
let metaDataName = testMetaData[1].toLowerCase();
|
||||
if (metaDataName === "filename") {
|
||||
currentFileOptions[testMetaData[1]] = testMetaData[2];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1518,16 +1530,19 @@ module Harness {
|
|||
currentFileOptions = {};
|
||||
currentFileName = testMetaData[2];
|
||||
refs = [];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// First metadata marker in the file
|
||||
currentFileName = testMetaData[2];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Subfile content line
|
||||
// Append to the current subfile content, inserting a newline needed
|
||||
if (currentFileContent === null) {
|
||||
currentFileContent = "";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// End-of-line
|
||||
currentFileContent = currentFileContent + "\n";
|
||||
}
|
||||
|
@ -1553,7 +1568,7 @@ module Harness {
|
|||
}
|
||||
|
||||
/** Support class for baseline files */
|
||||
export module Baseline {
|
||||
export namespace Baseline {
|
||||
|
||||
export interface BaselineOptions {
|
||||
Subfolder?: string;
|
||||
|
@ -1581,7 +1596,8 @@ module Harness {
|
|||
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
|
||||
if (subfolder !== undefined) {
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
|
||||
}
|
||||
}
|
||||
|
@ -1673,7 +1689,8 @@ module Harness {
|
|||
actual = generateActual(actualFileName, generateContent);
|
||||
let comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
actual = generateActual(actualFileName, generateContent);
|
||||
|
||||
let comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
/// <reference path="..\server\client.ts" />
|
||||
/// <reference path="harness.ts" />
|
||||
|
||||
module Harness.LanguageService {
|
||||
namespace Harness.LanguageService {
|
||||
export class ScriptInfo {
|
||||
public version: number = 1;
|
||||
public editRanges: { length: number; textChangeRange: ts.TextChangeRange; }[] = [];
|
||||
public lineMap: number[] = null;
|
||||
public lineMap: number[] = undefined;
|
||||
|
||||
constructor(public fileName: string, public content: string) {
|
||||
this.setContent(content);
|
||||
|
@ -95,8 +95,8 @@ module Harness.LanguageService {
|
|||
let oldShim = <ScriptSnapshotProxy>oldScript;
|
||||
|
||||
let range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot);
|
||||
if (range === null) {
|
||||
return null;
|
||||
if (range === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return JSON.stringify({ span: { start: range.span.start, length: range.span.length }, newLength: range.newLength });
|
||||
|
@ -118,11 +118,11 @@ module Harness.LanguageService {
|
|||
getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo;
|
||||
}
|
||||
|
||||
export class LanguageServiceAdapterHost {
|
||||
export class LanguageServiceAdapterHost {
|
||||
protected fileNameToScript: ts.Map<ScriptInfo> = {};
|
||||
|
||||
|
||||
constructor(protected cancellationToken = DefaultHostCancellationToken.Instance,
|
||||
protected settings = ts.getDefaultCompilerOptions()) {
|
||||
protected settings = ts.getDefaultCompilerOptions()) {
|
||||
}
|
||||
|
||||
public getNewLine(): string {
|
||||
|
@ -145,7 +145,7 @@ module Harness.LanguageService {
|
|||
|
||||
public editScript(fileName: string, start: number, end: number, newText: string) {
|
||||
let script = this.getScriptInfo(fileName);
|
||||
if (script !== null) {
|
||||
if (script !== undefined) {
|
||||
script.editContent(start, end, newText);
|
||||
return;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ module Harness.LanguageService {
|
|||
}
|
||||
|
||||
/// Native adapter
|
||||
class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost {
|
||||
class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost {
|
||||
getCompilationSettings() { return this.settings; }
|
||||
getCancellationToken() { return this.cancellationToken; }
|
||||
getCurrentDirectory(): string { return ""; }
|
||||
|
@ -191,7 +191,7 @@ module Harness.LanguageService {
|
|||
|
||||
export class NativeLanugageServiceAdapter implements LanguageServiceAdapter {
|
||||
private host: NativeLanguageServiceHost;
|
||||
constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
this.host = new NativeLanguageServiceHost(cancellationToken, options);
|
||||
}
|
||||
getHost() { return this.host; }
|
||||
|
@ -204,14 +204,14 @@ module Harness.LanguageService {
|
|||
class ShimLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceShimHost, ts.CoreServicesShimHost {
|
||||
private nativeHost: NativeLanguageServiceHost;
|
||||
|
||||
public getModuleResolutionsForFile: (fileName: string)=> string;
|
||||
public getModuleResolutionsForFile: (fileName: string) => string;
|
||||
|
||||
constructor(preprocessToResolve: boolean, cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) {
|
||||
super(cancellationToken, options);
|
||||
this.nativeHost = new NativeLanguageServiceHost(cancellationToken, options);
|
||||
|
||||
if (preprocessToResolve) {
|
||||
let compilerOptions = this.nativeHost.getCompilationSettings()
|
||||
let compilerOptions = this.nativeHost.getCompilationSettings();
|
||||
let moduleResolutionHost: ts.ModuleResolutionHost = {
|
||||
fileExists: fileName => this.getScriptInfo(fileName) !== undefined,
|
||||
readFile: fileName => {
|
||||
|
@ -230,7 +230,7 @@ module Harness.LanguageService {
|
|||
}
|
||||
}
|
||||
return JSON.stringify(imports);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ module Harness.LanguageService {
|
|||
getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); }
|
||||
getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim {
|
||||
let nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
|
||||
|
@ -255,17 +255,17 @@ module Harness.LanguageService {
|
|||
readDirectory(rootDir: string, extension: string): string {
|
||||
throw new Error("NYI");
|
||||
}
|
||||
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
|
||||
readFile(fileName: string) {
|
||||
fileExists(fileName: string) { return this.getScriptInfo(fileName) !== undefined; }
|
||||
readFile(fileName: string) {
|
||||
let snapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
}
|
||||
log(s: string): void { this.nativeHost.log(s); }
|
||||
trace(s: string): void { this.nativeHost.trace(s); }
|
||||
error(s: string): void { this.nativeHost.error(s); }
|
||||
}
|
||||
|
||||
class ClassifierShimProxy implements ts.Classifier {
|
||||
class ClassifierShimProxy implements ts.Classifier {
|
||||
constructor(private shim: ts.ClassifierShim) {
|
||||
}
|
||||
getEncodedLexicalClassifications(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.Classifications {
|
||||
|
@ -302,7 +302,7 @@ module Harness.LanguageService {
|
|||
if (parsedResult.error) {
|
||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
||||
}
|
||||
else if (parsedResult.canceled) {
|
||||
else if (parsedResult.canceled) {
|
||||
throw new ts.OperationCanceledException();
|
||||
}
|
||||
return parsedResult.result;
|
||||
|
@ -369,7 +369,7 @@ module Harness.LanguageService {
|
|||
getDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] {
|
||||
return unwrapJSONCallResult(this.shim.getDefinitionAtPosition(fileName, position));
|
||||
}
|
||||
getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[]{
|
||||
getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] {
|
||||
return unwrapJSONCallResult(this.shim.getTypeDefinitionAtPosition(fileName, position));
|
||||
}
|
||||
getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
|
||||
|
@ -474,19 +474,19 @@ module Harness.LanguageService {
|
|||
}
|
||||
|
||||
// Server adapter
|
||||
class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost {
|
||||
class SessionClientHost extends NativeLanguageServiceHost implements ts.server.SessionClientHost {
|
||||
private client: ts.server.SessionClient;
|
||||
|
||||
constructor(cancellationToken: ts.HostCancellationToken, settings: ts.CompilerOptions) {
|
||||
super(cancellationToken, settings);
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
|
||||
writeMessage(message: string): void {
|
||||
|
||||
}
|
||||
|
||||
setClient(client: ts.server.SessionClient) {
|
||||
|
@ -504,7 +504,7 @@ module Harness.LanguageService {
|
|||
}
|
||||
}
|
||||
|
||||
class SessionServerHost implements ts.server.ServerHost, ts.server.Logger {
|
||||
class SessionServerHost implements ts.server.ServerHost, ts.server.Logger {
|
||||
args: string[] = [];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean = false;
|
||||
|
@ -513,23 +513,23 @@ module Harness.LanguageService {
|
|||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
}
|
||||
|
||||
writeMessage(message: string): void {
|
||||
}
|
||||
|
||||
write(message: string): void {
|
||||
write(message: string): void {
|
||||
this.writeMessage(message);
|
||||
}
|
||||
|
||||
|
||||
readFile(fileName: string): string {
|
||||
if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) {
|
||||
if (fileName.indexOf(Harness.Compiler.defaultLibFileName) >= 0) {
|
||||
fileName = Harness.Compiler.defaultLibFileName;
|
||||
}
|
||||
|
||||
|
||||
let snapshot = this.host.getScriptSnapshot(fileName);
|
||||
return snapshot && snapshot.getText(0, snapshot.getLength());
|
||||
}
|
||||
|
@ -567,8 +567,8 @@ module Harness.LanguageService {
|
|||
readDirectory(path: string, extension?: string): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
}
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
|
@ -582,7 +582,7 @@ module Harness.LanguageService {
|
|||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
|
||||
loggingEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ module Harness.LanguageService {
|
|||
startGroup(): void {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class ServerLanugageServiceAdapter implements LanguageServiceAdapter {
|
||||
private host: SessionClientHost;
|
||||
private client: ts.server.SessionClient;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/// <reference path="..\..\src\compiler\sys.ts" />
|
||||
/// <reference path="..\..\src\harness\harness.ts" />
|
||||
/// <reference path="..\..\src\harness\runnerbase.ts" />
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
interface FileInformation {
|
||||
contents: string;
|
||||
|
@ -76,7 +77,7 @@ interface PlaybackControl {
|
|||
endRecord(): void;
|
||||
}
|
||||
|
||||
module Playback {
|
||||
namespace Playback {
|
||||
let recordLog: IOLog = undefined;
|
||||
let replayLog: IOLog = undefined;
|
||||
let recordLogFileNameBase = "";
|
||||
|
@ -95,7 +96,7 @@ module Playback {
|
|||
run.reset = () => {
|
||||
lookup = null;
|
||||
};
|
||||
|
||||
|
||||
return run;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
///<reference path="harness.ts" />
|
||||
///<reference path="runnerbase.ts" />
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
// Test case is json of below type in tests/cases/project/
|
||||
interface ProjectRunnerTestCase {
|
||||
|
@ -199,7 +200,7 @@ class ProjectRunner extends RunnerBase {
|
|||
}
|
||||
}
|
||||
|
||||
function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult{
|
||||
function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult {
|
||||
let nonSubfolderDiskFiles = 0;
|
||||
|
||||
let outputFiles: BatchCompileProjectTestCaseEmittedFile[] = [];
|
||||
|
@ -300,7 +301,7 @@ class ProjectRunner extends RunnerBase {
|
|||
allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName));
|
||||
}
|
||||
else {
|
||||
let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile|| compilerOptions.out) + ".d.ts";
|
||||
let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts";
|
||||
let outputDtsFile = findOutpuDtsFile(outputDtsFileName);
|
||||
if (!ts.contains(allInputFiles, outputDtsFile)) {
|
||||
allInputFiles.unshift(outputDtsFile);
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
/// <reference path="rwcRunner.ts" />
|
||||
/// <reference path="harness.ts" />
|
||||
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
let runners: RunnerBase[] = [];
|
||||
let iterations: number = 1;
|
||||
let iterations = 1;
|
||||
|
||||
function runTests(runners: RunnerBase[]) {
|
||||
for (let i = iterations; i > 0; i--) {
|
||||
|
@ -68,10 +70,10 @@ if (testConfigFile !== "") {
|
|||
case "fourslash-shims":
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Shims));
|
||||
break;
|
||||
case 'fourslash-shims-pp':
|
||||
case "fourslash-shims-pp":
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.ShimsWithPreprocess));
|
||||
break;
|
||||
case 'fourslash-server':
|
||||
case "fourslash-server":
|
||||
runners.push(new FourSlashRunner(FourSlashTestType.Server));
|
||||
break;
|
||||
case "fourslash-generated":
|
||||
|
|
|
@ -25,12 +25,12 @@ abstract class RunnerBase {
|
|||
let fixedPath = path;
|
||||
|
||||
// full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point
|
||||
let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g;
|
||||
let fullPathList = fixedPath.match(fullPath);
|
||||
if (fullPathList) {
|
||||
fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match)));
|
||||
}
|
||||
|
||||
|
||||
// when running in the browser the 'full path' is the host name, shows up in error baselines
|
||||
let localHost = /http:\/localhost:\d+/g;
|
||||
fixedPath = fixedPath.replace(localHost, "");
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
/// <reference path="runnerbase.ts" />
|
||||
/// <reference path="loggedIO.ts" />
|
||||
/// <reference path="..\compiler\commandLineParser.ts"/>
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
module RWC {
|
||||
namespace RWC {
|
||||
function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) {
|
||||
let oldIO = Harness.IO;
|
||||
|
||||
|
@ -105,7 +106,7 @@ module RWC {
|
|||
}
|
||||
otherFiles.push(getHarnessCompilerInputUnit(fileRead.path));
|
||||
}
|
||||
else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)){
|
||||
else if (!opts.options.noLib && Harness.isLibraryFile(fileRead.path)) {
|
||||
if (!inInputList) {
|
||||
// If useCustomLibraryFile is true, we will use lib.d.ts from json object
|
||||
// otherwise use the lib.d.ts from built/local
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
|
||||
///<reference path="harness.ts"/>
|
||||
|
||||
module Harness.SourceMapRecoder {
|
||||
namespace Harness.SourceMapRecoder {
|
||||
|
||||
interface SourceMapSpanWithDecodeErrors {
|
||||
sourceMapSpan: ts.SourceMapSpan;
|
||||
decodeErrors: string[];
|
||||
}
|
||||
|
||||
module SourceMapDecoder {
|
||||
namespace SourceMapDecoder {
|
||||
let sourceMapMappings: string;
|
||||
let sourceMapNames: string[];
|
||||
let decodingIndex: number;
|
||||
|
@ -202,7 +202,7 @@ module Harness.SourceMapRecoder {
|
|||
}
|
||||
}
|
||||
|
||||
module SourceMapSpanWriter {
|
||||
namespace SourceMapSpanWriter {
|
||||
let sourceMapRecoder: Compiler.WriterAggregator;
|
||||
let sourceMapSources: string[];
|
||||
let sourceMapNames: string[];
|
||||
|
@ -442,7 +442,7 @@ module Harness.SourceMapRecoder {
|
|||
|
||||
for (let i = 0; i < sourceMapDataList.length; i++) {
|
||||
let sourceMapData = sourceMapDataList[i];
|
||||
let prevSourceFile: ts.SourceFile = null;
|
||||
let prevSourceFile: ts.SourceFile;
|
||||
|
||||
SourceMapSpanWriter.intializeSourceMapSpanWriter(sourceMapRecoder, sourceMapData, jsFiles[i]);
|
||||
for (let j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/// <reference path="harness.ts" />
|
||||
/// <reference path="runnerbase.ts" />
|
||||
/* tslint:disable:no-null */
|
||||
|
||||
class Test262BaselineRunner extends RunnerBase {
|
||||
private static basePath = "internal/cases/test262";
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"no-unreachable": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-keyword": true,
|
||||
"quotemark": [true,
|
||||
"double"
|
||||
|
|
Loading…
Reference in a new issue