From 8392ff49bd35d4ec2d31e167c1eeca02cf55798b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 21 Oct 2014 09:58:19 -0700 Subject: [PATCH] Update LKG --- bin/tsc.js | 2951 +++++++++++-------- bin/typescriptServices.js | 5826 +++++++++++++++++++++++-------------- 2 files changed, 5231 insertions(+), 3546 deletions(-) diff --git a/bin/tsc.js b/bin/tsc.js index 07cccb86d1b..f706bebc0ff 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -19,6 +19,7 @@ var ts; Unterminated_string_literal: { code: 1002, category: 1 /* Error */, key: "Unterminated string literal." }, Identifier_expected: { code: 1003, category: 1 /* Error */, key: "Identifier expected." }, _0_expected: { code: 1005, category: 1 /* Error */, key: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: 1 /* Error */, key: "A file cannot have a reference to itself." }, Trailing_comma_not_allowed: { code: 1009, category: 1 /* Error */, key: "Trailing comma not allowed." }, Asterisk_Slash_expected: { code: 1010, category: 1 /* Error */, key: "'*/' expected." }, Unexpected_token: { code: 1012, category: 1 /* Error */, key: "Unexpected token." }, @@ -127,6 +128,7 @@ var ts; Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: 1 /* Error */, key: "Cannot compile external modules unless the '--module' flag is provided." }, Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: 1 /* Error */, key: "Filename '{0}' differs from already included filename '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: 1 /* Error */, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + An_enum_member_cannot_have_a_numeric_name: { code: 1151, category: 1 /* Error */, key: "An enum member cannot have a numeric name." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -274,6 +276,7 @@ var ts; Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: 1 /* Error */, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: 1 /* Error */, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: 1 /* Error */, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: 1 /* Error */, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, @@ -758,14 +761,14 @@ var ts; return result; } } - function getLeadingComments(text, pos) { + function getLeadingCommentRanges(text, pos) { return getCommentRanges(text, pos, false); } - ts.getLeadingComments = getLeadingComments; - function getTrailingComments(text, pos) { + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { return getCommentRanges(text, pos, true); } - ts.getTrailingComments = getTrailingComments; + ts.getTrailingCommentRanges = getTrailingCommentRanges; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } @@ -1560,6 +1563,8 @@ var ts; SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.CaretEqualsToken] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.EndOfFileToken] = "FirstToken"; SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.StringKeyword] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = SyntaxKind.SingleLineCommentTrivia] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = SyntaxKind.WhitespaceTrivia] = "LastTriviaToken"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -1592,8 +1597,17 @@ var ts; TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType"; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 0x00000008] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0x00000010] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 0x00000020] = "WriteTypeArgumentsOfSignature"; })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0x00000000] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 0x00000001] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 0x00000002] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; (function (SymbolAccessibility) { SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; @@ -1667,6 +1681,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 0x00000010] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 0x00000020] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 0x00000040] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 0x00000080] = "EnumValuesComputed"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -1844,6 +1859,31 @@ var ts; CharacterCodes[CharacterCodes["verticalTab"] = 0x0B] = "verticalTab"; })(ts.CharacterCodes || (ts.CharacterCodes = {})); var CharacterCodes = ts.CharacterCodes; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; })(ts || (ts = {})); var ts; (function (ts) { @@ -1851,8 +1891,9 @@ var ts; var result; if (array) { for (var i = 0, len = array.length; i < len; i++) { - if (result = callback(array[i])) + if (result = callback(array[i])) { break; + } } } return result; @@ -1880,6 +1921,18 @@ var ts; return -1; } ts.indexOf = indexOf; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (predicate(array[i])) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; function filter(array, f) { if (array) { var result = []; @@ -2020,10 +2073,7 @@ var ts; } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { - if (ts.localizedDiagnosticMessages) { - message = ts.localizedDiagnosticMessages[message]; - } - return message; + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] ? ts.localizedDiagnosticMessages[message] : message; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { @@ -2244,14 +2294,14 @@ var ts; return getNormalizedPathComponents(pathOrUrl, currentDirectory); } } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, isAbsolutePathAnUrl) { + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { directoryComponents.length--; } for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== pathComponents[joinStartIndex]) { + if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } } @@ -2295,6 +2345,37 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; + var supportedExtensions = [".d.ts", ".ts", ".js"]; + function removeFileExtension(path) { + for (var i = 0; i < supportedExtensions.length; i++) { + var ext = supportedExtensions[i]; + if (fileExtensionIs(path, ext)) { + return path.substr(0, path.length - ext.length); + } + } + return path; + } + ts.removeFileExtension = removeFileExtension; + var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\0": "\\0", + "\r": "\\r", + "\n": "\\n", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }; + function escapeString(s) { + return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { + return escapedCharsMap[c] || c; + }) : s; + } + ts.escapeString = escapeString; function Symbol(flags, name) { this.flags = flags; this.name = name; @@ -2561,17 +2642,6 @@ var ts; node.flags = flags; return node; } - var moduleExtensions = [".d.ts", ".ts", ".js"]; - function getModuleNameFromFilename(filename) { - for (var i = 0; i < moduleExtensions.length; i++) { - var ext = moduleExtensions[i]; - var len = filename.length - ext.length; - if (len > 0 && filename.substr(len) === ext) - return filename.substr(0, len); - } - return filename; - } - ts.getModuleNameFromFilename = getModuleNameFromFilename; function getSourceFileOfNode(node) { while (node && node.kind !== 182 /* SourceFile */) node = node.parent; @@ -2592,15 +2662,15 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; - function getSourceTextOfNodeFromSourceText(sourceText, node) { + function getTextOfNodeFromSourceText(sourceText, node) { return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } - ts.getSourceTextOfNodeFromSourceText = getSourceTextOfNodeFromSourceText; - function getSourceTextOfNode(node) { + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node) { var text = getSourceFileOfNode(node).text; return text.substring(ts.skipTrivia(text, node.pos), node.end); } - ts.getSourceTextOfNode = getSourceTextOfNode; + ts.getTextOfNode = getTextOfNode; function escapeIdentifier(identifier) { return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; } @@ -2610,7 +2680,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function identifierToString(identifier) { - return identifier.kind === 115 /* Missing */ ? "(Missing)" : getSourceTextOfNode(identifier); + return identifier.kind === 115 /* Missing */ ? "(Missing)" : getTextOfNode(identifier); } ts.identifierToString = identifierToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { @@ -2648,6 +2718,10 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isDeclarationFile(file) { + return (file.flags & 1024 /* DeclarationFile */) !== 0; + } + ts.isDeclarationFile = isDeclarationFile; function isPrologueDirective(node) { return node.kind === 151 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; } @@ -2659,17 +2733,18 @@ var ts; ts.Debug.assert(isPrologueDirective(node)); return node.expression.text === "use strict"; } - function getLeadingCommentsOfNode(node, sourceFileOfNode) { + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); if (node.kind === 118 /* Parameter */ || node.kind === 117 /* TypeParameter */) { - return ts.concatenate(ts.getTrailingComments(sourceFileOfNode.text, node.pos), ts.getLeadingComments(sourceFileOfNode.text, node.pos)); + return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { - return ts.getLeadingComments(sourceFileOfNode.text, node.pos); + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } } - ts.getLeadingCommentsOfNode = getLeadingCommentsOfNode; + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentsOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); + return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; } @@ -3088,12 +3163,6 @@ var ts; ModifierContext[ModifierContext["ClassMembers"] = 2] = "ClassMembers"; ModifierContext[ModifierContext["Parameters"] = 3] = "Parameters"; })(ModifierContext || (ModifierContext = {})); - var TrailingCommaBehavior; - (function (TrailingCommaBehavior) { - TrailingCommaBehavior[TrailingCommaBehavior["Disallow"] = 0] = "Disallow"; - TrailingCommaBehavior[TrailingCommaBehavior["Allow"] = 1] = "Allow"; - TrailingCommaBehavior[TrailingCommaBehavior["Preserve"] = 2] = "Preserve"; - })(TrailingCommaBehavior || (TrailingCommaBehavior = {})); var ControlBlockContext; (function (ControlBlockContext) { ControlBlockContext[ControlBlockContext["NotNested"] = 0] = "NotNested"; @@ -3104,6 +3173,10 @@ var ts; return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword; } ts.isKeyword = isKeyword; + function isTrivia(token) { + return ts.SyntaxKind.FirstTriviaToken <= token && token <= ts.SyntaxKind.LastTriviaToken; + } + ts.isTrivia = isTrivia; function isModifier(token) { switch (token) { case 102 /* PublicKeyword */: @@ -3364,7 +3437,9 @@ var ts; return finishNode(node); } error(ts.Diagnostics.Identifier_expected); - return createMissingNode(); + var node = createMissingNode(); + node.text = ""; + return node; } function parseIdentifier() { return createIdentifier(isIdentifier()); @@ -3416,7 +3491,7 @@ var ts; case 14 /* TypeParameters */: return isIdentifier(); case 10 /* ArgumentExpressions */: - return isExpression(); + return token === 18 /* CommaToken */ || isExpression(); case 12 /* ArrayLiteralMembers */: return token === 18 /* CommaToken */ || isExpression(); case 13 /* Parameters */: @@ -3516,7 +3591,7 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseDelimitedList(kind, parseElement, trailingCommaBehavior) { + function parseDelimitedList(kind, parseElement, allowTrailingComma) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; @@ -3537,16 +3612,6 @@ var ts; error(ts.Diagnostics._0_expected, ","); } else if (isListTerminator(kind)) { - if (commaStart >= 0) { - if (trailingCommaBehavior === 0 /* Disallow */) { - if (file.syntacticErrors.length === errorCountBeforeParsingList) { - grammarErrorAtPos(commaStart, scanner.getStartPos() - commaStart, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - else if (trailingCommaBehavior === 2 /* Preserve */) { - result.push(createNode(147 /* OmittedExpression */)); - } - } break; } else { @@ -3557,6 +3622,14 @@ var ts; nextToken(); } } + if (commaStart >= 0) { + if (!allowTrailingComma) { + if (file.syntacticErrors.length === errorCountBeforeParsingList) { + grammarErrorAtPos(commaStart, scanner.getStartPos() - commaStart, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + result.hasTrailingComma = true; + } result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; @@ -3576,7 +3649,7 @@ var ts; } function parseBracketedList(kind, parseElement, startToken, endToken) { if (parseExpected(startToken)) { - var result = parseDelimitedList(kind, parseElement, 0 /* Disallow */); + var result = parseDelimitedList(kind, parseElement, false); parseExpected(endToken); return result; } @@ -4247,10 +4320,10 @@ var ts; nextToken(); var operand = parseUnaryExpression(); if (isInStrictMode) { - if ((token === 33 /* PlusPlusToken */ || token === 34 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { + if ((operator === 33 /* PlusPlusToken */ || operator === 34 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { reportInvalidUseInStrictMode(operand); } - else if (token === 68 /* DeleteKeyword */ && operand.kind === 59 /* Identifier */) { + else if (operator === 68 /* DeleteKeyword */ && operand.kind === 59 /* Identifier */) { grammarErrorOnNode(operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } } @@ -4335,7 +4408,7 @@ var ts; else { parseExpected(11 /* OpenParenToken */); } - callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseAssignmentExpression, 0 /* Disallow */); + callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); parseExpected(12 /* CloseParenToken */); expr = finishNode(callExpr); continue; @@ -4399,15 +4472,29 @@ var ts; parseExpected(12 /* CloseParenToken */); return finishNode(node); } + function parseAssignmentExpressionOrOmittedExpression(omittedExpressionDiagnostic) { + if (token === 18 /* CommaToken */) { + if (omittedExpressionDiagnostic) { + var errorStart = scanner.getTokenPos(); + var errorLength = scanner.getTextPos() - errorStart; + grammarErrorAtPos(errorStart, errorLength, omittedExpressionDiagnostic); + } + return createNode(147 /* OmittedExpression */); + } + return parseAssignmentExpression(); + } function parseArrayLiteralElement() { - return token === 18 /* CommaToken */ ? createNode(147 /* OmittedExpression */) : parseAssignmentExpression(); + return parseAssignmentExpressionOrOmittedExpression(undefined); + } + function parseArgumentExpression() { + return parseAssignmentExpressionOrOmittedExpression(ts.Diagnostics.Argument_expression_expected); } function parseArrayLiteral() { var node = createNode(132 /* ArrayLiteral */); parseExpected(13 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; - node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement, 2 /* Preserve */); + node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement, true); parseExpected(14 /* CloseBracketToken */); return finishNode(node); } @@ -4440,8 +4527,7 @@ var ts; if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } - var trailingCommaBehavior = languageVersion === 0 /* ES3 */ ? 1 /* Allow */ : 2 /* Preserve */; - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember, trailingCommaBehavior); + node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember, true); parseExpected(10 /* CloseBraceToken */); var seen = {}; var Property = 1; @@ -4515,7 +4601,7 @@ var ts; parseExpected(82 /* NewKeyword */); node.func = parseCallAndAccess(parsePrimaryExpression(), true); if (parseOptional(11 /* OpenParenToken */) || token === 19 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { - node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseAssignmentExpression, 0 /* Disallow */); + node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); parseExpected(12 /* CloseParenToken */); } return finishNode(node); @@ -4852,7 +4938,7 @@ var ts; node.label = parseIdentifier(); parseExpected(46 /* ColonToken */); if (labelledStatementInfo.nodeIsNestedInLabel(node.label, false, true)) { - grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getSourceTextOfNodeFromSourceText(sourceText, node.label)); + grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); } labelledStatementInfo.addLabel(node.label); node.statement = isLabel() ? parseLabelledStatement() : parseStatementWithLabelSet(); @@ -4985,7 +5071,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(flags, noIn) { - return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); }, 0 /* Disallow */); + return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); }, false); } function parseVariableStatement(pos, flags) { var node = createNode(149 /* VariableStatement */, pos); @@ -5324,7 +5410,7 @@ var ts; var implementsKeywordLength; if (parseOptional(96 /* ImplementsKeyword */)) { implementsKeywordLength = scanner.getStartPos() - implementsKeywordStart; - node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, 0 /* Disallow */); + node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } var errorCountBeforeClassBody = file.syntacticErrors.length; if (parseExpected(9 /* OpenBraceToken */)) { @@ -5350,7 +5436,7 @@ var ts; var extendsKeywordLength; if (parseOptional(73 /* ExtendsKeyword */)) { extendsKeywordLength = scanner.getStartPos() - extendsKeywordStart; - node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, 0 /* Disallow */); + node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } var errorCountBeforeInterfaceBody = file.syntacticErrors.length; node.members = parseTypeLiteral().members; @@ -5399,7 +5485,7 @@ var ts; parseExpected(71 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(9 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseAndCheckEnumMember, 1 /* Allow */); + node.members = parseDelimitedList(7 /* EnumMembers */, parseAndCheckEnumMember, true); parseExpected(10 /* CloseBraceToken */); } else { @@ -5593,15 +5679,16 @@ var ts; } else { var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var start = range.pos; + var end = range.end; + var length = end - start; if (!matchResult) { - var start = range.pos; - var length = range.end - start; errorAtPos(start, length, ts.Diagnostics.Invalid_reference_directive_syntax); } else { referencedFiles.push({ - pos: range.pos, - end: range.end, + pos: start, + end: end, filename: matchResult[3] }); } @@ -5704,6 +5791,9 @@ var ts; else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; } + else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + } } else { if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) { @@ -5754,7 +5844,8 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - processSourceFile(ts.normalizePath(ts.combinePaths(basePath, ref.filename)), false, file, ref.pos, ref.end); + var referencedFilename = ts.isRootedDiskPath(ref.filename) ? ref.filename : ts.combinePaths(basePath, ref.filename); + processSourceFile(ts.normalizePath(referencedFilename), false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { @@ -5777,7 +5868,7 @@ var ts; } } } - else if (node.kind === 177 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || file.flags & 1024 /* DeclarationFile */)) { + else if (node.kind === 177 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { forEachChild(node.body, function (node) { if (node.kind === 179 /* ImportDeclaration */ && node.externalModuleName) { var nameLiteral = node.externalModuleName; @@ -5927,7 +6018,10 @@ var ts; if (node.name) { node.name.parent = node; } - file.semanticErrors.push(ts.createDiagnosticForNode(node.name ? node.name : node, ts.Diagnostics.Duplicate_identifier_0, getDisplayName(node))); + ts.forEach(symbol.declarations, function (declaration) { + file.semanticErrors.push(ts.createDiagnosticForNode(declaration.name, ts.Diagnostics.Duplicate_identifier_0, getDisplayName(declaration))); + }); + file.semanticErrors.push(ts.createDiagnosticForNode(node.name, ts.Diagnostics.Duplicate_identifier_0, getDisplayName(node))); symbol = createSymbol(0, name); } } @@ -6145,7 +6239,7 @@ var ts; break; case 182 /* SourceFile */: if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 128 /* ValueModule */, '"' + ts.getModuleNameFromFilename(node.filename) + '"'); + bindAnonymousDeclaration(node, 128 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"'); break; } default: @@ -6167,11 +6261,12 @@ var ts; } return indentStrings[level]; } + ts.getIndentString = getIndentString; function getIndentSize() { return indentStrings[1].length; } function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!(sourceFile.flags & 1024 /* DeclarationFile */)) { + if (!ts.isDeclarationFile(sourceFile)) { if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.filename, ".js")) { return true; } @@ -6181,9 +6276,902 @@ var ts; } ts.shouldEmitToOwnFile = shouldEmitToOwnFile; function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || (sourceFile.flags & 1024 /* DeclarationFile */) !== 0; + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + function createTextWriter(newLine, trackSymbol) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.getLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeKind(text, kind) { + write(text); + } + function writeSymbol(text, symbol) { + write(text); + } + return { + write: write, + trackSymbol: trackSymbol, + writeKind: writeKind, + writeSymbol: writeSymbol, + rawWrite: rawWrite, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + clear: function () { + } + }; + } + function getSourceTextOfLocalNode(currentSourceFile, node) { + var text = currentSourceFile.text; + return text.substring(ts.skipTrivia(text, node.pos), node.end); + } + function getLineOfLocalPosition(currentSourceFile, pos) { + return currentSourceFile.getLineAndCharacterFromPosition(pos).line; + } + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { + var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos); + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 121 /* Constructor */ && member.body) { + return member; + } + }); + } + function getAllAccessorDeclarations(node, accessor) { + var firstAccessor; + var getAccessor; + var setAccessor; + ts.forEach(node.members, function (member) { + if ((member.kind === 122 /* GetAccessor */ || member.kind === 123 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if (!firstAccessor) { + firstAccessor = member; + } + if (member.kind === 122 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 123 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + }); + return { + firstAccessor: firstAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + function getSourceFilePathInNewDir(sourceFile, program, newDirPath) { + var compilerHost = program.getCompilerHost(); + var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory())); + sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + function getOwnEmitOutputFilePath(sourceFile, program, extension) { + var compilerOptions = program.getCompilerOptions(); + if (compilerOptions.outDir) { + var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, program, compilerOptions.outDir)); + } + else { + var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename); + } + return emitOutputFilePathWithoutExtension + extension; + } + function writeFile(compilerHost, diagnostics, filename, data, writeByteOrderMark) { + compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage)); + }); + } + function emitDeclarations(program, resolver, diagnostics, jsFilePath, root) { + var newLine = program.getCompilerHost().getNewLine(); + var compilerOptions = program.getCompilerOptions(); + var compilerHost = program.getCompilerHost(); + var writer = createTextWriter(newLine, trackSymbol); + var write = writer.write; + var writeLine = writer.writeLine; + var increaseIndent = writer.increaseIndent; + var decreaseIndent = writer.decreaseIndent; + var enclosingDeclaration; + var currentSourceFile; + var reportedDeclarationError = false; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { + } : writeJsDocComments; + var aliasDeclarationEmitInfo = []; + var getSymbolVisibilityDiagnosticMessage; + function writeAsychronousImportDeclarations(importDeclarations) { + var oldWriter = writer; + ts.forEach(importDeclarations, function (aliasToWrite) { + var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); + writer = createTextWriter(newLine, trackSymbol); + for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { + writer.increaseIndent(); + } + writeImportDeclaration(aliasToWrite); + aliasEmitInfo.asynchronousOutput = writer.getText(); + }); + writer = oldWriter; + } + function trackSymbol(symbol, enclosingDeclaration, meaning) { + var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning); + if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + reportedDeclarationError = true; + var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, getSourceTextOfLocalNode(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + } + } + } + function emitLines(nodes) { + for (var i = 0, n = nodes.length; i < n; i++) { + emitNode(nodes[i]); + } + } + function emitCommaList(nodes, eachNodeEmitFn) { + var currentWriterPos = writer.getTextPos(); + for (var i = 0, n = nodes.length; i < n; i++) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(nodes[i]); + } + } + function writeJsDocComments(declaration) { + if (declaration) { + var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); + } + } + function emitSourceTextOfNode(node) { + write(getSourceTextOfLocalNode(currentSourceFile, node)); + } + function emitSourceFile(node) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + function emitExportAssignment(node) { + write("export = "); + emitSourceTextOfNode(node.exportName); + write(";"); + writeLine(); + } + function emitDeclarationFlags(node) { + if (node.flags & 128 /* Static */) { + if (node.flags & 32 /* Private */) { + write("private "); + } + else if (node.flags & 64 /* Protected */) { + write("protected "); + } + write("static "); + } + else { + if (node.flags & 32 /* Private */) { + write("private "); + } + else if (node.flags & 64 /* Protected */) { + write("protected "); + } + else if (node.parent === currentSourceFile) { + if (node.flags & 1 /* Export */) { + write("export "); + } + if (node.kind !== 175 /* InterfaceDeclaration */) { + write("declare "); + } + } + } + } + function emitImportDeclaration(node) { + var nodeEmitInfo = { + declaration: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + hasWritten: resolver.isDeclarationVisible(node) + }; + aliasDeclarationEmitInfo.push(nodeEmitInfo); + if (nodeEmitInfo.hasWritten) { + writeImportDeclaration(node); + } + } + function writeImportDeclaration(node) { + emitJsDocComments(node); + if (node.flags & 1 /* Export */) { + writer.write("export "); + } + writer.write("import "); + writer.write(getSourceTextOfLocalNode(currentSourceFile, node.name)); + writer.write(" = "); + if (node.entityName) { + checkEntityNameAccessible(); + writer.write(getSourceTextOfLocalNode(currentSourceFile, node.entityName)); + writer.write(";"); + } + else { + writer.write("require("); + writer.write(getSourceTextOfLocalNode(currentSourceFile, node.externalModuleName)); + writer.write(");"); + } + writer.writeLine(); + function checkEntityNameAccessible() { + var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisible(node.entityName); + if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + reportedDeclarationError = true; + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Import_declaration_0_is_using_private_name_1, getSourceTextOfLocalNode(currentSourceFile, node.name), symbolAccesibilityResult.errorSymbolName)); + } + } + } + function emitModuleDeclaration(node) { + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("module "); + emitSourceTextOfNode(node.name); + while (node.body.kind !== 178 /* ModuleBlock */) { + node = node.body; + write("."); + emitSourceTextOfNode(node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + } + function emitEnumDeclaration(node) { + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("enum "); + emitSourceTextOfNode(node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + } + function emitEnumMemberDeclaration(node) { + emitJsDocComments(node); + emitSourceTextOfNode(node.name); + var enumMemberValue = resolver.getEnumMemberValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + function emitTypeParameters(typeParameters) { + function emitTypeParameter(node) { + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.parent.kind) { + case 174 /* ClassDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + case 175 /* InterfaceDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + case 125 /* ConstructSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 124 /* CallSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 120 /* Method */: + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 172 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for type parameter: " + ts.SyntaxKind[node.parent.kind]); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + emitSourceTextOfNode(node.name); + if (node.constraint && (node.parent.kind !== 120 /* Method */ || !(node.parent.flags & 32 /* Private */))) { + write(" extends "); + getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError; + resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + } + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + function emitHeritageClause(typeReferences, isImplementsList) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + function emitTypeOfTypeReference(node) { + getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer); + function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.parent.kind === 174 /* ClassDeclaration */) { + if (symbolAccesibilityResult.errorModuleName) { + diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; + } + else { + diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + } + else { + if (symbolAccesibilityResult.errorModuleName) { + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2; + } + else { + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.parent.name + }; + } + } + } + function emitClassDeclaration(node) { + function emitParameterProperties(constructorDeclaration) { + if (constructorDeclaration) { + ts.forEach(constructorDeclaration.parameters, function (param) { + if (param.flags & ts.NodeFlags.AccessibilityModifier) { + emitPropertyDeclaration(param); + } + }); + } + } + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("class "); + emitSourceTextOfNode(node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + if (node.baseType) { + emitHeritageClause([node.baseType], false); + } + emitHeritageClause(node.implementedTypes, true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + } + function emitInterfaceDeclaration(node) { + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("interface "); + emitSourceTextOfNode(node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(node.baseTypes, false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + } + function emitPropertyDeclaration(node) { + emitJsDocComments(node); + emitDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + function emitVariableDeclaration(node) { + if (node.kind !== 171 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + emitSourceTextOfNode(node.name); + if (node.kind === 119 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + write("?"); + } + if (!(node.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.kind === 171 /* VariableDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + else if (node.kind === 119 /* Property */) { + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + } + function emitVariableStatement(node) { + var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + if (hasDeclarationWithEmit) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("var "); + emitCommaList(node.declarations, emitVariableDeclaration); + write(";"); + writeLine(); + } + } + function emitAccessorDeclaration(node) { + var accessors = getAllAccessorDeclarations(node.parent, node); + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitDeclarationFlags(node); + emitSourceTextOfNode(node.name); + if (!(node.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + write(";"); + writeLine(); + } + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.kind === 123 /* SetAccessor */) { + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.parameters[0], + typeName: node.name + }; + } + else { + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name, + typeName: undefined + }; + } + } + } + function emitFunctionDeclaration(node) { + if ((node.kind !== 172 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + if (node.kind === 172 /* FunctionDeclaration */) { + write("function "); + emitSourceTextOfNode(node.name); + } + else if (node.kind === 121 /* Constructor */) { + write("constructor"); + } + else { + emitSourceTextOfNode(node.name); + if (node.flags & 4 /* QuestionMark */) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + function emitConstructSignatureDeclaration(node) { + emitJsDocComments(node); + write("new "); + emitSignatureDeclaration(node); + } + function emitSignatureDeclaration(node) { + if (node.kind === 124 /* CallSignature */ || node.kind === 126 /* IndexSignature */) { + emitJsDocComments(node); + } + emitTypeParameters(node.typeParameters); + if (node.kind === 126 /* IndexSignature */) { + write("["); + } + else { + write("("); + } + emitCommaList(node.parameters, emitParameterDeclaration); + if (node.kind === 126 /* IndexSignature */) { + write("]"); + } + else { + write(")"); + } + if (node.kind !== 121 /* Constructor */ && !(node.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError; + resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + write(";"); + writeLine(); + function getReturnTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.kind) { + case 125 /* ConstructSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 124 /* CallSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 126 /* IndexSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 120 /* Method */: + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; + } + else if (node.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + case 172 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + default: + ts.Debug.fail("This is unknown kind for signature: " + ts.SyntaxKind[node.kind]); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name || node + }; + } + } + function emitParameterDeclaration(node) { + increaseIndent(); + emitJsDocComments(node); + if (node.flags & 8 /* Rest */) { + write("..."); + } + emitSourceTextOfNode(node.name); + if (node.initializer || (node.flags & 4 /* QuestionMark */)) { + write("?"); + } + decreaseIndent(); + if (!(node.parent.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.parent.kind) { + case 121 /* Constructor */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + break; + case 125 /* ConstructSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 124 /* CallSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 120 /* Method */: + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 172 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + function emitNode(node) { + switch (node.kind) { + case 121 /* Constructor */: + case 172 /* FunctionDeclaration */: + case 120 /* Method */: + return emitFunctionDeclaration(node); + case 125 /* ConstructSignature */: + return emitConstructSignatureDeclaration(node); + case 124 /* CallSignature */: + case 126 /* IndexSignature */: + return emitSignatureDeclaration(node); + case 122 /* GetAccessor */: + case 123 /* SetAccessor */: + return emitAccessorDeclaration(node); + case 149 /* VariableStatement */: + return emitVariableStatement(node); + case 119 /* Property */: + return emitPropertyDeclaration(node); + case 175 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 174 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 181 /* EnumMember */: + return emitEnumMemberDeclaration(node); + case 176 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 177 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 179 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 180 /* ExportAssignment */: + return emitExportAssignment(node); + case 182 /* SourceFile */: + return emitSourceFile(node); + } + } + function tryResolveScriptReference(sourceFile, reference) { + var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename)); + return program.getSourceFile(referenceFileName); + } + var referencePathsOutput = ""; + function writeReferencePath(referencedFile) { + var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, program, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false); + referencePathsOutput += "/// " + newLine; + } + if (root) { + if (!compilerOptions.noResolve) { + var addedGlobalFileReference = false; + ts.forEach(root.referencedFiles, function (fileReference) { + var referencedFile = tryResolveScriptReference(root, fileReference); + if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { + writeReferencePath(referencedFile); + if (!isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + emitNode(root); + } + else { + var emittedReferencedFiles = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if (!compilerOptions.noResolve) { + ts.forEach(sourceFile.referencedFiles, function (fileReference) { + var referencedFile = tryResolveScriptReference(sourceFile, fileReference); + if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + emitNode(sourceFile); + } + }); + } + return { + reportedDeclarationError: reportedDeclarationError, + aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + declarationOutput: referencePathsOutput + }; + } + function writeDeclarationToFile(compilerHost, compilerOptions, diagnostics, aliasDeclarationEmitInfo, synchronousDeclarationOutput, jsFilePath, declarationOutput) { + var appliedSyncOutputPos = 0; + ts.forEach(aliasDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += aliasEmitInfo.asynchronousOutput; + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); + } + function getDeclarationDiagnostics(program, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); + emitDeclarations(program, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitFiles(resolver, targetSourceFile) { var program = resolver.getProgram(); var compilerHost = program.getCompilerHost(); @@ -6191,207 +7179,13 @@ var ts; var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; var diagnostics = []; var newLine = program.getCompilerHost().getNewLine(); - function getSourceFilePathInNewDir(newDirPath, sourceFile) { - var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory())); - sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, extension) { - if (compilerOptions.outDir) { - var emitOutputFilePathWithoutExtension = ts.getModuleNameFromFilename(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile)); - } - else { - var emitOutputFilePathWithoutExtension = ts.getModuleNameFromFilename(sourceFile.filename); - } - return emitOutputFilePathWithoutExtension + extension; - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 121 /* Constructor */ && member.body) { - return member; - } - }); - } - function getAllAccessorDeclarations(node, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - ts.forEach(node.members, function (member) { - if ((member.kind === 122 /* GetAccessor */ || member.kind === 123 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 122 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 123 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } - } - }); - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function createTextWriter(writeSymbol) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.getLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - return { - write: write, - writeSymbol: writeSymbol, - rawWrite: rawWrite, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - var currentSourceFile; - function getSourceTextOfLocalNode(node) { - var text = currentSourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); - } - function getLineOfLocalPosition(pos) { - return currentSourceFile.getLineAndCharacterFromPosition(pos).line; - } - function writeFile(filename, data, writeByteOrderMark) { - compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage)); - }); - } - function emitComments(comments, trailingSeparator, writer, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(comment, writer); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function emitNewLineBeforeLeadingComments(node, leadingComments, writer) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(node.pos) !== getLineOfLocalPosition(leadingComments[0].pos)) { - writer.writeLine(); - } - } - function writeCommentRange(comment, writer) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos); - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(writeSymbol); + var writer = createTextWriter(newLine, trackSymbol); var write = writer.write; var writeLine = writer.writeLine; var increaseIndent = writer.increaseIndent; var decreaseIndent = writer.decreaseIndent; + var currentSourceFile; var extendsEmitted = false; var writeEmittedFiles = writeJavaScriptFile; var emitLeadingComments = compilerOptions.removeComments ? function (node) { @@ -6417,7 +7211,7 @@ var ts; var scopeEmitEnd = function () { }; var sourceMapData; - function writeSymbol(symbol, enclosingDeclaration, meaning) { + function trackSymbol(symbol, enclosingDeclaration, meaning) { } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -6523,7 +7317,7 @@ var ts; } function recordNewSourceFileStart(node) { var sourcesDirectoryPath = compilerOptions.sourceRoot ? program.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.filename, compilerHost.getCurrentDirectory(), true)); + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.filename, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, true)); sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; sourceMapData.inputSourceFileNames.push(node.filename); } @@ -6564,25 +7358,11 @@ var ts; sourceMapNameIndices.pop(); } ; - function writeCommentRangeWithMap(comment, writer) { + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { recordSourceMapSpan(comment.pos); - writeCommentRange(comment, writer); + writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } - var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\0": "\\0", - "\r": "\\r", - "\n": "\\n", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { if (typeof JSON !== "undefined") { return JSON.stringify({ @@ -6594,26 +7374,21 @@ var ts; mappings: mappings }); } - return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}"; - function escapeString(s) { - return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { - return escapedCharsMap[c] || c; - }) : s; - } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; function serializeStringArray(list) { var output = ""; for (var i = 0, n = list.length; i < n; i++) { if (i) { output += ","; } - output += "\"" + escapeString(list[i]) + "\""; + output += "\"" + ts.escapeString(list[i]) + "\""; } return output; } } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + writeFile(compilerHost, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); sourceMapDataList.push(sourceMapData); writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); } @@ -6636,11 +7411,11 @@ var ts; if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(sourceMapDir, root)); + sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, program, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(program.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), compilerHost.getCurrentDirectory(), true); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, true); } else { sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); @@ -6672,7 +7447,7 @@ var ts; writeComment = writeCommentRangeWithMap; } function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(jsFilePath, emitOutput, writeByteOrderMark); + writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function emitTokenText(tokenKind, startPos, emitFn) { var tokenString = ts.tokenToString(tokenKind); @@ -6690,25 +7465,42 @@ var ts; emit(node); } } - function emitCommaList(nodes, count) { - if (!(count >= 0)) - count = nodes.length; - if (nodes) { - for (var i = 0; i < count; i++) { - if (i) - write(", "); - emit(nodes[i]); + function emitTrailingCommaIfPresent(nodeList, isMultiline) { + if (nodeList.hasTrailingComma) { + write(","); + if (isMultiline) { + writeLine(); } } } - function emitMultiLineList(nodes) { + function emitCommaList(nodes, includeTrailingComma, count) { + if (!(count >= 0)) { + count = nodes.length; + } + if (nodes) { + for (var i = 0; i < count; i++) { + if (i) { + write(", "); + } + emit(nodes[i]); + } + if (includeTrailingComma) { + emitTrailingCommaIfPresent(nodes, false); + } + } + } + function emitMultiLineList(nodes, includeTrailingComma) { if (nodes) { for (var i = 0; i < nodes.length; i++) { - if (i) + if (i) { write(","); + } writeLine(); emit(nodes[i]); } + if (includeTrailingComma) { + emitTrailingCommaIfPresent(nodes, true); + } } } function emitLines(nodes) { @@ -6721,7 +7513,7 @@ var ts; } } function emitLiteral(node) { - var text = getSourceTextOfLocalNode(node); + var text = getSourceTextOfLocalNode(currentSourceFile, node); if (node.kind === 7 /* StringLiteral */ && compilerOptions.sourceMap) { writer.writeLiteral(text); } @@ -6739,7 +7531,7 @@ var ts; write(node.text); } else { - write(getSourceTextOfLocalNode(node)); + write(getSourceTextOfLocalNode(currentSourceFile, node)); } write("\""); } @@ -6781,7 +7573,7 @@ var ts; write("."); } } - write(getSourceTextOfLocalNode(node)); + write(getSourceTextOfLocalNode(currentSourceFile, node)); } function emitThis(node) { if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { @@ -6807,14 +7599,14 @@ var ts; if (node.flags & 256 /* MultiLine */) { write("["); increaseIndent(); - emitMultiLineList(node.elements); + emitMultiLineList(node.elements, true); decreaseIndent(); writeLine(); write("]"); } else { write("["); - emitCommaList(node.elements); + emitCommaList(node.elements, true); write("]"); } } @@ -6825,14 +7617,14 @@ var ts; else if (node.flags & 256 /* MultiLine */) { write("{"); increaseIndent(); - emitMultiLineList(node.properties); + emitMultiLineList(node.properties, compilerOptions.target >= 1 /* ES5 */); decreaseIndent(); writeLine(); write("}"); } else { write("{ "); - emitCommaList(node.properties); + emitCommaList(node.properties, compilerOptions.target >= 1 /* ES5 */); write(" }"); } } @@ -6844,14 +7636,15 @@ var ts; emitTrailingComments(node); } function emitPropertyAccess(node) { - var text = resolver.getPropertyAccessSubstitution(node); - if (text) { - write(text); - return; + var constantValue = resolver.getConstantValue(node); + if (constantValue !== undefined) { + write(constantValue.toString() + " /* " + ts.identifierToString(node.right) + " */"); + } + else { + emit(node.left); + write("."); + emit(node.right); } - emit(node.left); - write("."); - emit(node.right); } function emitIndexedAccess(node) { emit(node.object); @@ -6874,13 +7667,13 @@ var ts; emitThis(node.func); if (node.arguments.length) { write(", "); - emitCommaList(node.arguments); + emitCommaList(node.arguments, false); } write(")"); } else { write("("); - emitCommaList(node.arguments); + emitCommaList(node.arguments, false); write(")"); } } @@ -6889,7 +7682,7 @@ var ts; emit(node.func); if (node.arguments) { write("("); - emitCommaList(node.arguments); + emitCommaList(node.arguments, false); write(")"); } } @@ -7028,7 +7821,7 @@ var ts; if (node.declarations) { emitToken(92 /* VarKeyword */, endPos); write(" "); - emitCommaList(node.declarations); + emitCommaList(node.declarations, false); } if (node.initializer) { emit(node.initializer); @@ -7162,7 +7955,7 @@ var ts; emitLeadingComments(node); if (!(node.flags & 1 /* Export */)) write("var "); - emitCommaList(node.declarations); + emitCommaList(node.declarations, false); write(";"); emitTrailingComments(node); } @@ -7262,7 +8055,7 @@ var ts; increaseIndent(); write("("); if (node) { - emitCommaList(node.parameters, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); + emitCommaList(node.parameters, false, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); } write(")"); decreaseIndent(); @@ -7986,7 +8779,7 @@ var ts; return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -8002,20 +8795,20 @@ var ts; leadingComments = getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingCommentsOfNode(node, currentSourceFile); + leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); } return leadingComments; } } function emitLeadingDeclarationComments(node) { var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(node, leadingComments, writer); - emitComments(leadingComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingDeclarationComments(node) { if (node.parent.kind === 182 /* SourceFile */ || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingComments(currentSourceFile.text, node.end); - emitComments(trailingComments, false, writer, writeComment); + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } } function emitLeadingCommentsOfLocalPosition(pos) { @@ -8024,20 +8817,20 @@ var ts; leadingComments = getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingComments(currentSourceFile.text, pos); + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer); - emitComments(leadingComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitDetachedCommentsAtPosition(node) { - var leadingComments = ts.getLeadingComments(currentSourceFile.text, node.pos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { var detachedComments = []; var lastComment; ts.forEach(leadingComments, function (comment) { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(lastComment.end); - var commentLine = getLineOfLocalPosition(comment.pos); + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { return detachedComments; } @@ -8046,11 +8839,11 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(detachedComments[detachedComments.length - 1].end); - var astLine = getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var astLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (astLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(node, leadingComments, writer); - emitComments(detachedComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -8072,8 +8865,8 @@ var ts; return true; } } - emitNewLineBeforeLeadingComments(node, pinnedComments, writer); - emitComments(pinnedComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); + emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); } if (compilerOptions.sourceMap) { initializeEmitterWithSourceMaps(); @@ -8091,700 +8884,35 @@ var ts; writeLine(); writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); } - function emitDeclarations(jsFilePath, root) { - var writer = createTextWriter(writeSymbol); - var write = writer.write; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; - var enclosingDeclaration; - var reportedDeclarationError = false; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { - } : writeJsDocComments; - var aliasDeclarationEmitInfo = []; - var getSymbolVisibilityDiagnosticMessage; - function writeAsychronousImportDeclarations(importDeclarations) { - var oldWriter = writer; - ts.forEach(importDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - writer = createTextWriter(writeSymbol); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - writer.increaseIndent(); - } - writeImportDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); - }); - writer = oldWriter; - } - function writeSymbol(symbol, enclosingDeclaration, meaning) { - var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning); - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - resolver.writeSymbol(symbol, enclosingDeclaration, meaning, writer); - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, getSourceTextOfLocalNode(errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function emitLines(nodes) { - for (var i = 0, n = nodes.length; i < n; i++) { - emitNode(nodes[i]); - } - } - function emitCommaList(nodes, eachNodeEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var i = 0, n = nodes.length; i < n; i++) { - if (currentWriterPos !== writer.getTextPos()) { - write(", "); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(nodes[i]); - } - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(declaration, jsDocComments, writer); - emitComments(jsDocComments, true, writer, writeCommentRange); - } - } - function emitSourceTextOfNode(node) { - write(getSourceTextOfLocalNode(node)); - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - function emitExportAssignment(node) { - write("export = "); - emitSourceTextOfNode(node.exportName); - write(";"); - writeLine(); - } - function emitDeclarationFlags(node) { - if (node.flags & 128 /* Static */) { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - write("static "); - } - else { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - else if (node.parent === currentSourceFile) { - if (node.flags & 1 /* Export */) { - write("export "); - } - if (node.kind !== 175 /* InterfaceDeclaration */) { - write("declare "); - } - } - } - } - function emitImportDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportDeclaration(node); - } - } - function writeImportDeclaration(node) { - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - writer.write("export "); - } - writer.write("import "); - writer.write(getSourceTextOfLocalNode(node.name)); - writer.write(" = "); - if (node.entityName) { - checkEntityNameAccessible(); - writer.write(getSourceTextOfLocalNode(node.entityName)); - writer.write(";"); - } - else { - writer.write("require("); - writer.write(getSourceTextOfLocalNode(node.externalModuleName)); - writer.write(");"); - } - writer.writeLine(); - function checkEntityNameAccessible() { - var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisibile(node.entityName); - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - if (symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Import_declaration_0_is_using_private_name_1, getSourceTextOfLocalNode(node.name), symbolAccesibilityResult.errorSymbolName)); - } - } - } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("module "); - emitSourceTextOfNode(node.name); - while (node.body.kind !== 178 /* ModuleBlock */) { - node = node.body; - write("."); - emitSourceTextOfNode(node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("enum "); - emitSourceTextOfNode(node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - emitSourceTextOfNode(node.name); - var enumMemberValue = resolver.getEnumMemberValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 174 /* ClassDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 175 /* InterfaceDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 125 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 124 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 120 /* Method */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 172 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + ts.SyntaxKind[node.parent.kind]); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - emitSourceTextOfNode(node.name); - if (node.constraint && (node.parent.kind !== 120 /* Method */ || !(node.parent.flags & 32 /* Private */))) { - write(" extends "); - getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError; - resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer); - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.parent.kind === 174 /* ClassDeclaration */) { - if (symbolAccesibilityResult.errorModuleName) { - diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; - } - else { - diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - } - else { - if (symbolAccesibilityResult.errorModuleName) { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2; - } - else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.name - }; - } - } - } - function emitClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & ts.NodeFlags.AccessibilityModifier) { - emitPropertyDeclaration(param); - } - }); - } - } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("class "); - emitSourceTextOfNode(node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], false); - } - emitHeritageClause(node.implementedTypes, true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("interface "); - emitSourceTextOfNode(node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitPropertyDeclaration(node) { - emitJsDocComments(node); - emitDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - function emitVariableDeclaration(node) { - if (node.kind !== 171 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { - emitSourceTextOfNode(node.name); - if (node.kind === 119 /* Property */ && (node.flags & 4 /* QuestionMark */)) { - write("?"); - } - if (!(node.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 171 /* VariableDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 119 /* Property */) { - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("var "); - emitCommaList(node.declarations, emitVariableDeclaration); - write(";"); - writeLine(); - } - } - function emitAccessorDeclaration(node) { - var accessors = getAllAccessorDeclarations(node.parent, node); - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitDeclarationFlags(node); - emitSourceTextOfNode(node.name); - if (!(node.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - write(";"); - writeLine(); - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 123 /* SetAccessor */) { - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.parameters[0], - typeName: node.name - }; - } - else { - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name, - typeName: undefined - }; - } - } - } - function emitFunctionDeclaration(node) { - if ((node.kind !== 172 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - if (node.kind === 172 /* FunctionDeclaration */) { - write("function "); - emitSourceTextOfNode(node.name); - } - else if (node.kind === 121 /* Constructor */) { - write("constructor"); - } - else { - emitSourceTextOfNode(node.name); - if (node.flags & 4 /* QuestionMark */) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitConstructSignatureDeclaration(node) { - emitJsDocComments(node); - write("new "); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - if (node.kind === 124 /* CallSignature */ || node.kind === 126 /* IndexSignature */) { - emitJsDocComments(node); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 126 /* IndexSignature */) { - write("["); - } - else { - write("("); - } - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 126 /* IndexSignature */) { - write("]"); - } - else { - write(")"); - } - if (node.kind !== 121 /* Constructor */ && !(node.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError; - resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - write(";"); - writeLine(); - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 125 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 124 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 126 /* IndexSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 120 /* Method */: - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; - } - else if (node.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 172 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + ts.SyntaxKind[node.kind]); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.flags & 8 /* Rest */) { - write("..."); - } - emitSourceTextOfNode(node.name); - if (node.initializer || (node.flags & 4 /* QuestionMark */)) { - write("?"); - } - decreaseIndent(); - if (!(node.parent.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 121 /* Constructor */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - break; - case 125 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 124 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 120 /* Method */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 172 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - function emitNode(node) { - switch (node.kind) { - case 121 /* Constructor */: - case 172 /* FunctionDeclaration */: - case 120 /* Method */: - return emitFunctionDeclaration(node); - case 125 /* ConstructSignature */: - return emitConstructSignatureDeclaration(node); - case 124 /* CallSignature */: - case 126 /* IndexSignature */: - return emitSignatureDeclaration(node); - case 122 /* GetAccessor */: - case 123 /* SetAccessor */: - return emitAccessorDeclaration(node); - case 149 /* VariableStatement */: - return emitVariableStatement(node); - case 119 /* Property */: - return emitPropertyDeclaration(node); - case 175 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 174 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 181 /* EnumMember */: - return emitEnumMemberDeclaration(node); - case 176 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 177 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 179 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 180 /* ExportAssignment */: - return emitExportAssignment(node); - case 182 /* SourceFile */: - return emitSourceFile(node); - } - } - function resolveScriptReference(sourceFile, reference) { - var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename)); - return program.getSourceFile(referenceFileName); - } - var referencePathsOutput = ""; - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.getModuleNameFromFilename(compilerOptions.out) + ".d.ts"; - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), false); - referencePathsOutput += "/// " + newLine; - } - if (root) { - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = resolveScriptReference(root, fileReference); - if ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference) { - writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitNode(root); - } - else { - var emittedReferencedFiles = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = resolveScriptReference(sourceFile, fileReference); - if (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile)) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitNode(sourceFile); - } - }); - } - if (!reportedDeclarationError) { - var declarationOutput = referencePathsOutput; - var synchronousDeclarationOutput = writer.getText(); - var appliedSyncOutputPos = 0; - ts.forEach(aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(ts.getModuleNameFromFilename(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); - } - } var hasSemanticErrors = resolver.hasSemanticErrors(); function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); if (!hasSemanticErrors && compilerOptions.declaration) { - emitDeclarations(jsFilePath, sourceFile); + var emitDeclarationResult = emitDeclarations(program, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + writeDeclarationToFile(compilerHost, compilerOptions, diagnostics, emitDeclarationResult.aliasDeclarationEmitInfo, emitDeclarationResult.synchronousDeclarationOutput, jsFilePath, emitDeclarationResult.declarationOutput); + } } } if (targetSourceFile === undefined) { ts.forEach(program.getSourceFiles(), function (sourceFile) { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js"); + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); emitFile(jsFilePath, sourceFile); } }); + if (compilerOptions.out) { + emitFile(compilerOptions.out); + } } else { - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js"); - emitFile(jsFilePath, targetSourceFile); - } - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + emitFile(compilerOptions.out); + } } diagnostics.sort(ts.compareDiagnostics); diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); @@ -8826,6 +8954,27 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length == 0) { + var str = ""; + return { + string: function () { return str; }, + writeKind: function (text) { return str += text; }, + writeSymbol: function (text) { return str += text; }, + writeLine: function () { return str += " "; }, + increaseIndent: function () { + }, + decreaseIndent: function () { + }, + clear: function () { return str = ""; }, + trackSymbol: function () { + } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; function createTypeChecker(program, fullTypeCheck) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -8837,6 +8986,7 @@ var ts; var checker = { getProgram: function () { return program; }, getDiagnostics: getDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getNodeCount: function () { return ts.sum(program.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(program.getSourceFiles(), "identifierCount"); }, @@ -8856,11 +9006,24 @@ var ts; getTypeOfNode: getTypeOfNode, getApparentType: getApparentType, typeToString: typeToString, + writeType: writeType, symbolToString: symbolToString, + writeSymbol: writeSymbol, getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType, getRootSymbol: getRootSymbol, getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName + getFullyQualifiedName: getFullyQualifiedName, + getResolvedSignature: getResolvedSignature, + getEnumMemberValue: getEnumMemberValue, + isValidPropertyAccess: isValidPropertyAccess, + getSignatureFromDeclaration: getSignatureFromDeclaration, + writeSignature: writeSignature, + writeTypeParameter: writeTypeParameter, + writeTypeParametersOfSymbol: writeTypeParametersOfSymbol, + isImplementationOfOverload: isImplementationOfOverload, + getAliasedSymbol: resolveImport, + isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, + isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; } }; var undefinedSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "undefined"); var argumentsSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "arguments"); @@ -9400,13 +9563,13 @@ var ts; function getQualifiedLeftMeaning(rightMeaning) { return rightMeaning === ts.SymbolFlags.Value ? ts.SymbolFlags.Value : ts.SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning) { + function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { function getAccessibleSymbolChainFromSymbolTable(symbols) { function canQualifySymbol(symbolFromSymbolTable, meaning) { if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { return true; } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning)); + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); return !!accessibleParent; } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { @@ -9419,13 +9582,15 @@ var ts; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 4194304 /* Import */) { - var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 179 /* ImportDeclaration */ && declaration.externalModuleName; })) { + var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } } } }); @@ -9458,7 +9623,7 @@ var ts; var initialSymbol = symbol; var meaningToLook = meaning; while (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -9526,139 +9691,157 @@ var ts; return true; } } - function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName) { + function isImportDeclarationEntityNameReferenceDeclarationVisible(entityName) { var firstIdentifier = getFirstIdentifier(entityName); var firstIdentifierName = ts.identifierToString(firstIdentifier); var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, ts.SymbolFlags.Namespace, ts.Diagnostics.Cannot_find_name_0, firstIdentifierName); var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace); return hasNamespaceDeclarationsVisibile ? { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } : { accessibility: 1 /* NotAccessible */, errorSymbolName: firstIdentifierName }; } + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + function writeKeyword(writer, kind) { + writer.writeKind(ts.tokenToString(kind), 5 /* keyword */); + } + function writePunctuation(writer, kind) { + writer.writeKind(ts.tokenToString(kind), 15 /* punctuation */); + } + function writeOperator(writer, kind) { + writer.writeKind(ts.tokenToString(kind), 12 /* operator */); + } + function writeSpace(writer) { + writer.writeKind(" ", 16 /* space */); + } function symbolToString(symbol, enclosingDeclaration, meaning) { - function getSymbolName(symbol) { + var writer = getSingleLineStringWriter(); + writeSymbol(symbol, writer, enclosingDeclaration, meaning); + var result = writer.string(); + releaseStringWriter(writer); + return result; + } + function writeSymbol(symbol, writer, enclosingDeclaration, meaning, flags) { + var parentSymbol; + function writeSymbolName(symbol) { + if (parentSymbol) { + if (flags & 1 /* WriteTypeParametersOrArguments */) { + if (symbol.flags & 8388608 /* Instantiated */) { + writeTypeArguments(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); + } + else { + writeTypeParametersOfSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, 15 /* DotToken */); + } + parentSymbol = symbol; if (symbol.declarations && symbol.declarations.length > 0) { var declaration = symbol.declarations[0]; if (declaration.name) { - return ts.identifierToString(declaration.name); + writer.writeSymbol(ts.identifierToString(declaration.name), symbol); + return; } } - return symbol.name; + writer.writeSymbol(symbol.name, symbol); } - if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { - var symbolName; - while (symbol) { - var isFirstName = !symbolName; - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning); - var currentSymbolName; + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol, meaning) { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); + if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); + } if (accessibleSymbolChain) { - currentSymbolName = ts.map(accessibleSymbolChain, function (accessibleSymbol) { return getSymbolName(accessibleSymbol); }).join("."); + for (var i = 0, n = accessibleSymbolChain.length; i < n; i++) { + writeSymbolName(accessibleSymbolChain[i]); + } } else { - if (!isFirstName && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { - break; + if (!parentSymbol && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { + return; } - currentSymbolName = getSymbolName(symbol); - } - symbolName = currentSymbolName + (isFirstName ? "" : ("." + symbolName)); - if (accessibleSymbolChain && !needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - break; - } - symbol = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - meaning = getQualifiedLeftMeaning(meaning); - } - return symbolName; - } - return getSymbolName(symbol); - } - function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) { - writer.write(symbolToString(symbol, enclosingDeclaration, meaning)); - } - function createSingleLineTextWriter(maxLength) { - var result = ""; - var overflow = false; - function write(s) { - if (!overflow) { - result += s; - if (result.length > maxLength) { - result = result.substr(0, maxLength - 3) + "..."; - overflow = true; + if (symbol.flags & 512 /* TypeLiteral */ || symbol.flags & 1024 /* ObjectLiteral */) { + return; + } + writeSymbolName(symbol); } } } - return { - write: write, - writeSymbol: function (symbol, enclosingDeclaration, meaning) { - writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this); - }, - writeLine: function () { - write(" "); - }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - getText: function () { - return result; - } - }; + if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { + walkSymbol(symbol, meaning); + return; + } + return writeSymbolName(symbol); } function typeToString(type, enclosingDeclaration, flags) { + var writer = getSingleLineStringWriter(); + writeType(type, writer, enclosingDeclaration, flags); + var result = writer.string(); + releaseStringWriter(writer); var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; - var stringWriter = createSingleLineTextWriter(maxLength); - writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter); - return stringWriter.getText(); + if (maxLength && result.length >= maxLength) { + result = result.substr(0, maxLength - "...".length) + "..."; + } + return result; } - function writeTypeToTextWriter(type, enclosingDeclaration, flags, writer) { - var typeStack; - return writeType(type, true); - function writeType(type, allowFunctionOrConstructorTypeLiteral) { + function writeType(type, writer, enclosingDeclaration, flags, typeStack) { + return writeType(type, flags | 8 /* WriteArrowStyleSignature */); + function writeType(type, flags) { if (type.flags & ts.TypeFlags.Intrinsic) { - writer.write(type.intrinsicName); + writer.writeKind(!(flags & 16 /* WriteOwnNameForAnyLike */) && (type.flags & 1 /* Any */) ? "any" : type.intrinsicName, 5 /* keyword */); } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type); } else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - writer.writeSymbol(type.symbol, enclosingDeclaration, ts.SymbolFlags.Type); + writeSymbol(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); } else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); } else if (type.flags & 16384 /* Anonymous */) { - writeAnonymousType(type, allowFunctionOrConstructorTypeLiteral); + writeAnonymousType(type, flags); } else if (type.flags & 256 /* StringLiteral */) { - writer.write(type.text); + writer.writeKind(type.text, 8 /* stringLiteral */); } else { - writer.write("{ ... }"); + writePunctuation(writer, 9 /* OpenBraceToken */); + writeSpace(writer); + writePunctuation(writer, 16 /* DotDotDotToken */); + writeSpace(writer); + writePunctuation(writer, 10 /* CloseBraceToken */); } } function writeTypeList(types) { for (var i = 0; i < types.length; i++) { if (i > 0) { - writer.write(", "); + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); } - writeType(types[i], true); + writeType(types[i], flags | 8 /* WriteArrowStyleSignature */); } } function writeTypeReference(type) { if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { - writeType(type.typeArguments[0], false); - writer.write("[]"); + writeType(type.typeArguments[0], flags & ~8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 14 /* CloseBracketToken */); } else { - writer.writeSymbol(type.target.symbol, enclosingDeclaration, ts.SymbolFlags.Type); - writer.write("<"); + writeSymbol(type.target.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); + writePunctuation(writer, 19 /* LessThanToken */); writeTypeList(type.typeArguments); - writer.write(">"); + writePunctuation(writer, 20 /* GreaterThanToken */); } } function writeTupleType(type) { - writer.write("["); + writePunctuation(writer, 13 /* OpenBracketToken */); writeTypeList(type.elementTypes); - writer.write("]"); + writePunctuation(writer, 14 /* CloseBracketToken */); } - function writeAnonymousType(type, allowFunctionOrConstructorTypeLiteral) { + function writeAnonymousType(type, flags) { if (type.symbol && type.symbol.flags & (16 /* Class */ | 64 /* Enum */ | 128 /* ValueModule */)) { writeTypeofSymbol(type); } @@ -9666,14 +9849,14 @@ var ts; writeTypeofSymbol(type); } else if (typeStack && ts.contains(typeStack, type)) { - writer.write("any"); + writeKeyword(writer, 105 /* AnyKeyword */); } else { if (!typeStack) { typeStack = []; } typeStack.push(type); - writeLiteralType(type, allowFunctionOrConstructorTypeLiteral); + writeLiteralType(type, flags); typeStack.pop(); } function shouldWriteTypeOfFunctionSymbol() { @@ -9687,52 +9870,70 @@ var ts; } } function writeTypeofSymbol(type) { - writer.write("typeof "); - writer.writeSymbol(type.symbol, enclosingDeclaration, ts.SymbolFlags.Value); + writeKeyword(writer, 91 /* TypeOfKeyword */); + writeSpace(writer); + writeSymbol(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Value); } - function writeLiteralType(type, allowFunctionOrConstructorTypeLiteral) { + function writeLiteralType(type, flags) { var resolved = resolveObjectTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writer.write("{}"); + writePunctuation(writer, 9 /* OpenBraceToken */); + writePunctuation(writer, 10 /* CloseBraceToken */); return; } - if (allowFunctionOrConstructorTypeLiteral) { + if (flags & 8 /* WriteArrowStyleSignature */) { if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - writeSignature(resolved.callSignatures[0], true); + writeSignature(resolved.callSignatures[0], writer, enclosingDeclaration, flags, typeStack); return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - writer.write("new "); - writeSignature(resolved.constructSignatures[0], true); + writeKeyword(writer, 82 /* NewKeyword */); + writeSpace(writer); + writeSignature(resolved.constructSignatures[0], writer, enclosingDeclaration, flags, typeStack); return; } } } - writer.write("{"); + writePunctuation(writer, 9 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var i = 0; i < resolved.callSignatures.length; i++) { - writeSignature(resolved.callSignatures[i]); - writer.write(";"); + writeSignature(resolved.callSignatures[i], writer, enclosingDeclaration, flags & ~8 /* WriteArrowStyleSignature */, typeStack); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.constructSignatures.length; i++) { - writer.write("new "); - writeSignature(resolved.constructSignatures[i]); - writer.write(";"); + writeKeyword(writer, 82 /* NewKeyword */); + writeSpace(writer); + writeSignature(resolved.constructSignatures[i], writer, enclosingDeclaration, flags & ~8 /* WriteArrowStyleSignature */, typeStack); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { - writer.write("[x: string]: "); - writeType(resolved.stringIndexType, true); - writer.write(";"); + writePunctuation(writer, 13 /* OpenBracketToken */); + writer.writeKind("x", 13 /* parameterName */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 114 /* StringKeyword */); + writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(resolved.stringIndexType, flags | 8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { - writer.write("[x: number]: "); - writeType(resolved.numberIndexType, true); - writer.write(";"); + writePunctuation(writer, 13 /* OpenBracketToken */); + writer.writeKind("x", 13 /* parameterName */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 112 /* NumberKeyword */); + writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(resolved.numberIndexType, flags | 8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.properties.length; i++) { @@ -9741,66 +9942,109 @@ var ts; if (p.flags & (8 /* Function */ | 2048 /* Method */) && !getPropertiesOfType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); for (var j = 0; j < signatures.length; j++) { - writer.writeSymbol(p); + writeSymbol(p, writer); if (isOptionalProperty(p)) { - writer.write("?"); + writePunctuation(writer, 45 /* QuestionToken */); } - writeSignature(signatures[j]); - writer.write(";"); + writeSignature(signatures[j], writer, enclosingDeclaration, flags & ~8 /* WriteArrowStyleSignature */, typeStack); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } } else { - writer.writeSymbol(p); + writeSymbol(p, writer); if (isOptionalProperty(p)) { - writer.write("?"); + writePunctuation(writer, 45 /* QuestionToken */); } - writer.write(": "); - writeType(t, true); - writer.write(";"); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(t, flags | 8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writer.write("}"); + writePunctuation(writer, 10 /* CloseBraceToken */); } - function writeSignature(signature, arrowStyle) { - if (signature.typeParameters) { - writer.write("<"); - for (var i = 0; i < signature.typeParameters.length; i++) { - if (i > 0) { - writer.write(", "); - } - var tp = signature.typeParameters[i]; - writer.writeSymbol(tp.symbol); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writer.write(" extends "); - writeType(constraint, true); - } - } - writer.write(">"); - } - writer.write("("); - for (var i = 0; i < signature.parameters.length; i++) { + } + function writeTypeParameter(tp, writer, enclosingDeclaration, flags, typeStack) { + writeSymbol(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { + writeSpace(writer); + writeKeyword(writer, 73 /* ExtendsKeyword */); + writeSpace(writer); + writeType(constraint, writer, enclosingDeclaration, flags, typeStack); + } + } + function writeTypeParameters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 19 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writer.write(", "); + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); } - var p = signature.parameters[i]; - if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { - writer.write("..."); - } - writer.writeSymbol(p); - if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { - writer.write("?"); - } - writer.write(": "); - writeType(getTypeOfSymbol(p), true); + writeTypeParameter(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); } - writer.write(arrowStyle ? ") => " : "): "); - writeType(getReturnTypeOfSignature(signature), true); + writePunctuation(writer, 20 /* GreaterThanToken */); } } + function writeTypeArguments(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 19 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); + } + writeType(mapper(typeParameters[i]), writer, enclosingDeclaration, 8 /* WriteArrowStyleSignature */); + } + writePunctuation(writer, 20 /* GreaterThanToken */); + } + } + function writeTypeParametersOfSymbol(symbol, writer, enclosingDeclaraiton, flags) { + var rootSymbol = getRootSymbol(symbol); + if (rootSymbol.flags & 16 /* Class */ || rootSymbol.flags & 32 /* Interface */) { + writeTypeParameters(getTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + } + } + function writeSignature(signature, writer, enclosingDeclaration, flags, typeStack) { + if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { + writeTypeArguments(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + writeTypeParameters(signature.typeParameters, writer, enclosingDeclaration, flags, typeStack); + } + writePunctuation(writer, 11 /* OpenParenToken */); + for (var i = 0; i < signature.parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); + } + var p = signature.parameters[i]; + if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { + writePunctuation(writer, 16 /* DotDotDotToken */); + } + writeSymbol(p, writer); + if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { + writePunctuation(writer, 45 /* QuestionToken */); + } + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); + } + writePunctuation(writer, 12 /* CloseParenToken */); + if (flags & 8 /* WriteArrowStyleSignature */) { + writeSpace(writer); + writePunctuation(writer, 27 /* EqualsGreaterThanToken */); + } + else { + writePunctuation(writer, 46 /* ColonToken */); + } + writeSpace(writer); + writeType(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); + } function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { @@ -10821,7 +11065,7 @@ var ts; if (ts.hasProperty(stringLiteralTypes, node.text)) return stringLiteralTypes[node.text]; var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); - type.text = ts.getSourceTextOfNode(node); + type.text = ts.getTextOfNode(node); return type; } function getTypeFromStringLiteral(node) { @@ -11949,9 +12193,17 @@ var ts; var func = parameter.parent; if (func.kind === 141 /* FunctionExpression */ || func.kind === 142 /* ArrowFunction */) { if (isContextSensitiveExpression(func)) { - var signature = getContextualSignature(func); - if (signature) { - return getTypeAtPosition(signature, ts.indexOf(func.parameters, parameter)); + var contextualSignature = getContextualSignature(func); + if (contextualSignature) { + var funcHasRestParameters = ts.hasRestParameters(func); + var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var indexOfParameter = ts.indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } + if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { + return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + } } } } @@ -12111,7 +12363,7 @@ var ts; return createArrayType(elementType); } function isNumericName(name) { - return !isNaN(name); + return (name !== "") && !isNaN(name); } function checkObjectLiteral(node, contextualMapper) { var members = node.symbol.members; @@ -12229,6 +12481,24 @@ var ts; } return anyType; } + function isValidPropertyAccess(node, propertyName) { + var type = checkExpression(node.left); + if (type !== unknownType && type !== anyType) { + var apparentType = getApparentType(getWidenedType(type)); + var prop = getPropertyOfApparentType(apparentType, propertyName); + if (prop && prop.parent && prop.parent.flags & 16 /* Class */) { + if (node.left.kind === 85 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 120 /* Method */) { + return false; + } + else { + var diagnosticsCount = diagnostics.length; + checkClassPropertyAccess(node, type, prop); + return diagnostics.length === diagnosticsCount; + } + } + } + return true; + } function checkIndexedAccess(node) { var objectType = checkExpression(node.object); var indexType = checkExpression(node.index); @@ -12274,42 +12544,20 @@ var ts; resolveUntypedCall(node); return unknownSignature; } - function isCandidateSignature(node, signature) { - var args = node.arguments || emptyArray; - return args.length >= signature.minArgumentCount && (signature.hasRestParameter || args.length <= signature.parameters.length) && (!node.typeArguments || signature.typeParameters && node.typeArguments.length === signature.typeParameters.length); - } - function collectCandidates(node, signatures) { - var result = []; - var lastParent; - var lastSymbol; - var cutoffPos = 0; - var pos; - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (isCandidateSignature(node, signature)) { - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent === lastParent) { - pos++; - } - else { - lastParent = parent; - pos = cutoffPos; - } - } - else { - pos = cutoffPos = result.length; - lastParent = parent; - } - lastSymbol = symbol; - for (var j = result.length; j > pos; j--) { - result[j] = result[j - 1]; - } - result[pos] = signature; - } + function signatureHasCorrectArity(node, signature) { + if (!node.arguments) { + return signature.minArgumentCount === 0; } - return result; + var args = node.arguments; + var numberOfArgs = args.hasTrailingComma ? args.length + 1 : args.length; + var hasTooManyArguments = !signature.hasRestParameter && numberOfArgs > signature.parameters.length; + var hasRightNumberOfTypeArguments = !node.typeArguments || (signature.typeParameters && node.typeArguments.length === signature.typeParameters.length); + if (hasTooManyArguments || !hasRightNumberOfTypeArguments) { + return false; + } + var callIsIncomplete = args.end === node.end; + var hasEnoughArguments = numberOfArgs >= signature.minArgumentCount; + return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { if (type.flags & ts.TypeFlags.ObjectType) { @@ -12332,6 +12580,9 @@ var ts; var context = createInferenceContext(typeParameters); var mapper = createInferenceMapper(context); for (var i = 0; i < args.length; i++) { + if (args[i].kind === 147 /* OmittedExpression */) { + continue; + } if (!excludeArgument || excludeArgument[i] === undefined) { var parameterType = getTypeAtPosition(signature, i); inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType); @@ -12339,6 +12590,9 @@ var ts; } if (excludeArgument) { for (var i = 0; i < args.length; i++) { + if (args[i].kind === 147 /* OmittedExpression */) { + continue; + } if (excludeArgument[i] === false) { var parameterType = getTypeAtPosition(signature, i); inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType); @@ -12365,6 +12619,9 @@ var ts; if (node.arguments) { for (var i = 0; i < node.arguments.length; i++) { var arg = node.arguments[i]; + if (arg.kind === 147 /* OmittedExpression */) { + continue; + } var paramType = getTypeAtPosition(signature, i); var argType = arg.kind === 7 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1); @@ -12375,9 +12632,10 @@ var ts; } return true; } - function resolveCall(node, signatures) { + function resolveCall(node, signatures, candidatesOutArray) { ts.forEach(node.typeArguments, checkSourceElement); - var candidates = collectCandidates(node, signatures); + var candidates = candidatesOutArray || []; + collectCandidates(); if (!candidates.length) { error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); @@ -12394,18 +12652,21 @@ var ts; var relation = candidates.length === 1 ? assignableRelation : subtypeRelation; while (true) { for (var i = 0; i < candidates.length; i++) { + if (!signatureHasCorrectArity(node, candidates[i])) { + continue; + } while (true) { - var candidate = candidates[i]; - if (candidate.typeParameters) { - var typeArguments = node.typeArguments ? checkTypeArguments(candidate, node.typeArguments) : inferTypeArguments(candidate, args, excludeArgument); - candidate = getSignatureInstantiation(candidate, typeArguments); + var candidateWithCorrectArity = candidates[i]; + if (candidateWithCorrectArity.typeParameters) { + var typeArguments = node.typeArguments ? checkTypeArguments(candidateWithCorrectArity, node.typeArguments) : inferTypeArguments(candidateWithCorrectArity, args, excludeArgument); + candidateWithCorrectArity = getSignatureInstantiation(candidateWithCorrectArity, typeArguments); } - if (!checkApplicableSignature(node, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, candidateWithCorrectArity, relation, excludeArgument, false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; if (index < 0) { - return candidate; + return candidateWithCorrectArity; } excludeArgument[index] = false; } @@ -12415,14 +12676,59 @@ var ts; } relation = assignableRelation; } - checkApplicableSignature(node, candidate, relation, undefined, true); + if (candidateWithCorrectArity) { + checkApplicableSignature(node, candidateWithCorrectArity, relation, undefined, true); + } + else { + error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + } + if (!fullTypeCheck) { + for (var i = 0, n = candidates.length; i < n; i++) { + if (signatureHasCorrectArity(node, candidates[i])) { + return candidates[i]; + } + } + } return resolveErrorCall(node); + function collectCandidates() { + var result = candidates; + var lastParent; + var lastSymbol; + var cutoffPos = 0; + var pos; + ts.Debug.assert(!result.length); + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (true) { + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent === lastParent) { + pos++; + } + else { + lastParent = parent; + pos = cutoffPos; + } + } + else { + pos = cutoffPos = result.length; + lastParent = parent; + } + lastSymbol = symbol; + for (var j = result.length; j > pos; j--) { + result[j] = result[j - 1]; + } + result[pos] = signature; + } + } + } } - function resolveCallExpression(node) { + function resolveCallExpression(node, candidatesOutArray) { if (node.func.kind === 85 /* SuperKeyword */) { var superType = checkSuperExpression(node.func); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */)); + return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); } return resolveUntypedCall(node); } @@ -12451,9 +12757,9 @@ var ts; } return resolveErrorCall(node); } - return resolveCall(node, callSignatures); + return resolveCall(node, callSignatures, candidatesOutArray); } - function resolveNewExpression(node) { + function resolveNewExpression(node, candidatesOutArray) { var expressionType = checkExpression(node.func); if (expressionType === unknownType) { return resolveErrorCall(node); @@ -12470,11 +12776,11 @@ var ts; } var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); if (constructSignatures.length) { - return resolveCall(node, constructSignatures); + return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures); + var signature = resolveCall(node, callSignatures, candidatesOutArray); if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } @@ -12483,11 +12789,11 @@ var ts; error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); return resolveErrorCall(node); } - function getResolvedSignature(node) { + function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); - if (!links.resolvedSignature) { + if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - links.resolvedSignature = node.kind === 137 /* CallExpression */ ? resolveCallExpression(node) : resolveNewExpression(node); + links.resolvedSignature = node.kind === 137 /* CallExpression */ ? resolveCallExpression(node, candidatesOutArray) : resolveNewExpression(node, candidatesOutArray); } return links.resolvedSignature; } @@ -12717,10 +13023,10 @@ var ts; return type === anyType || ((type.flags & (ts.TypeFlags.ObjectType | 512 /* TypeParameter */)) !== 0); } function checkInstanceOfExpression(node, leftType, rightType) { - if (!isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) { + if (leftType !== unknownType && !isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { + if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -12763,10 +13069,16 @@ var ts; leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var suggestedOperator; + if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && (suggestedOperator = getSuggestedBooleanOperator(node.operator)) !== undefined) { + error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operator), ts.tokenToString(suggestedOperator)); + } + else { + var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + if (leftOk && rightOk) { + checkAssignmentOperator(numberType); + } } return numberType; case 28 /* PlusToken */: @@ -12819,6 +13131,21 @@ var ts; case 18 /* CommaToken */: return rightType; } + function getSuggestedBooleanOperator(operator) { + switch (operator) { + case 39 /* BarToken */: + case 57 /* BarEqualsToken */: + return 44 /* BarBarToken */; + case 40 /* CaretToken */: + case 58 /* CaretEqualsToken */: + return 26 /* ExclamationEqualsEqualsToken */; + case 38 /* AmpersandToken */: + case 56 /* AmpersandEqualsToken */: + return 43 /* AmpersandAmpersandToken */; + default: + return undefined; + } + } function checkAssignmentOperator(valueType) { if (fullTypeCheck && operator >= ts.SyntaxKind.FirstAssignment && operator <= ts.SyntaxKind.LastAssignment) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression); @@ -12985,7 +13312,7 @@ var ts; if (fullTypeCheck) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -13239,6 +13566,9 @@ var ts; var declarations = symbol.declarations; var isConstructor = (symbol.flags & 4096 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { + if (node.name && node.name.kind === 115 /* Missing */) { + return; + } var seen = false; var subsequentNode = ts.forEachChild(node.parent, function (c) { if (seen) { @@ -13273,6 +13603,8 @@ var ts; } } var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & ts.SymbolFlags.Module; + var duplicateFunctionDeclaration = false; + var multipleConstructorImplementation = false; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); @@ -13286,10 +13618,10 @@ var ts; allNodeFlags &= currentNodeFlags; if (node.body && bodyDeclaration) { if (isConstructor) { - error(node, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + multipleConstructorImplementation = true; } else { - error(node, ts.Diagnostics.Duplicate_function_implementation); + duplicateFunctionDeclaration = true; } } else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { @@ -13309,6 +13641,16 @@ var ts; } } } + if (multipleConstructorImplementation) { + ts.forEach(declarations, function (declaration) { + error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + }); + } + if (duplicateFunctionDeclaration) { + ts.forEach(declarations, function (declaration) { + error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); + }); + } if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -13515,7 +13857,7 @@ var ts; } } } - function checkCollistionWithRequireExportsInGeneratedCode(node, name) { + function checkCollisionWithRequireExportsInGeneratedCode(node, name) { if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -13548,7 +13890,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); if (!useTypeFromValueDeclaration) { if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); @@ -13739,7 +14081,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkTypeParameters(node.typeParameters); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -13886,7 +14228,7 @@ var ts; checkTypeForDuplicateIndexSignatures(node); } } - function getConstantValue(node) { + function getConstantValueForExpression(node) { var isNegative = false; if (node.kind === 143 /* PrefixOperator */) { var unaryExpression = node; @@ -13901,33 +14243,44 @@ var ts; } return undefined; } + function computeEnumMemberValues(node) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { + var enumSymbol = getSymbolOfNode(node); + var enumType = getDeclaredTypeOfSymbol(enumSymbol); + var autoValue = 0; + var ambient = ts.isInAmbientContext(node); + ts.forEach(node.members, function (member) { + if (isNumericName(member.name.text)) { + error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); + } + var initializer = member.initializer; + if (initializer) { + autoValue = getConstantValueForExpression(initializer); + if (autoValue === undefined && !ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined, undefined); + } + } + else if (ambient) { + autoValue = undefined; + } + if (autoValue !== undefined) { + getNodeLinks(member).enumMemberValue = autoValue++; + } + }); + nodeLinks.flags |= 128 /* EnumValuesComputed */; + } + } function checkEnumDeclaration(node) { if (!fullTypeCheck) { return; } checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); + computeEnumMemberValues(node); var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; - var ambient = ts.isInAmbientContext(node); - ts.forEach(node.members, function (member) { - var initializer = member.initializer; - if (initializer) { - autoValue = getConstantValue(initializer); - if (autoValue === undefined && !ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined, undefined); - } - } - else if (ambient) { - autoValue = undefined; - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - }); var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { var seenEnumMissingInitialInitializer = false; @@ -13964,7 +14317,7 @@ var ts; function checkModuleDeclaration(node) { if (fullTypeCheck) { checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 128 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { @@ -13997,7 +14350,7 @@ var ts; } function checkImportDeclaration(node) { checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); var target; if (node.entityName) { @@ -14239,6 +14592,11 @@ var ts; checkProgram(); return getSortedDiagnostics(); } + function getDeclarationDiagnostics(targetSourceFile) { + var resolver = createResolver(); + checkSourceFile(targetSourceFile); + return ts.getDeclarationDiagnostics(program, resolver, targetSourceFile); + } function getGlobalDiagnostics() { return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); } @@ -14414,7 +14772,7 @@ var ts; return false; } function isTypeNode(node) { - if (node.kind >= ts.SyntaxKind.FirstTypeNode && node.kind <= ts.SyntaxKind.LastTypeNode) { + if (ts.SyntaxKind.FirstTypeNode <= node.kind && node.kind <= ts.SyntaxKind.LastTypeNode) { return true; } switch (node.kind) { @@ -14432,11 +14790,12 @@ var ts; node = node.parent; } case 116 /* QualifiedName */: + ts.Debug.assert(node.kind === 59 /* Identifier */ || node.kind === 116 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; if (parent.kind === 128 /* TypeQuery */) { return false; } - if (parent.kind >= ts.SyntaxKind.FirstTypeNode && parent.kind <= ts.SyntaxKind.LastTypeNode) { + if (ts.SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= ts.SyntaxKind.LastTypeNode) { return true; } switch (parent.kind) { @@ -14462,7 +14821,7 @@ var ts; return node === parent.type; case 137 /* CallExpression */: case 138 /* NewExpression */: - return parent.typeArguments.indexOf(node) >= 0; + return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; } } return false; @@ -14662,7 +15021,7 @@ var ts; while (!isUniqueLocalName(ts.escapeIdentifier(prefix + name), container)) { prefix += "_"; } - links.localModuleName = prefix + ts.getSourceTextOfNode(container.name); + links.localModuleName = prefix + ts.getTextOfNode(container.name); } return links.localModuleName; } @@ -14688,16 +15047,6 @@ var ts; } } } - function getPropertyAccessSubstitution(node) { - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 4 /* EnumMember */)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 181 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { - return constantValue.toString() + " /* " + ts.identifierToString(declaration.name) + " */"; - } - } - } function getExportAssignmentName(node) { var symbol = getExportAssignmentSymbol(getSymbolOfNode(node)); return symbol && symbolIsValue(symbol) ? symbolToString(symbol) : undefined; @@ -14738,23 +15087,34 @@ var ts; return getNodeLinks(node).flags; } function getEnumMemberValue(node) { + computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function getConstantValue(node) { + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol && (symbol.flags & 4 /* EnumMember */)) { + var declaration = symbol.valueDeclaration; + var constantValue; + if (declaration.kind === 181 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + return constantValue; + } + } + return undefined; + } function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { var symbol = getSymbolOfNode(location); var type = symbol && !(symbol.flags & 512 /* TypeLiteral */) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); - writeTypeToTextWriter(type, enclosingDeclaration, flags, writer); + writeType(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { var signature = getSignatureFromDeclaration(signatureDeclaration); - writeTypeToTextWriter(getReturnTypeOfSignature(signature), enclosingDeclaration, flags, writer); + writeType(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } - function invokeEmitter(targetSourceFile) { - var resolver = { + function createResolver() { + return { getProgram: function () { return program; }, getLocalNameOfContainer: getLocalNameOfContainer, getExpressionNamePrefix: getExpressionNamePrefix, - getPropertyAccessSubstitution: getPropertyAccessSubstitution, getExportAssignmentName: getExportAssignmentName, isReferencedImportDeclaration: isReferencedImportDeclaration, getNodeCheckFlags: getNodeCheckFlags, @@ -14765,10 +15125,13 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, writeTypeAtLocation: writeTypeAtLocation, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - writeSymbol: writeSymbolToTextWriter, isSymbolAccessible: isSymbolAccessible, - isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile + isImportDeclarationEntityNameReferenceDeclarationVisible: isImportDeclarationEntityNameReferenceDeclarationVisible, + getConstantValue: getConstantValue }; + } + function invokeEmitter(targetSourceFile) { + var resolver = createResolver(); checkProgram(); return ts.emitFiles(resolver, targetSourceFile); } @@ -15024,7 +15387,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var version = "1.1.0.0"; + var version = "1.3.0.0"; function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -15326,7 +15689,7 @@ var ts; output += sys.newLine + sys.newLine; var padding = makePadding(marginLength); output += getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine; - output += padding + "tsc --out foo.js foo.ts" + sys.newLine; + output += padding + "tsc --out file.js file.ts" + sys.newLine; output += padding + "tsc @args.txt" + sys.newLine; output += sys.newLine; output += getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 38f2d4e1ecf..5c3e31f30e1 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -19,6 +19,7 @@ var ts; Unterminated_string_literal: { code: 1002, category: 1 /* Error */, key: "Unterminated string literal." }, Identifier_expected: { code: 1003, category: 1 /* Error */, key: "Identifier expected." }, _0_expected: { code: 1005, category: 1 /* Error */, key: "'{0}' expected." }, + A_file_cannot_have_a_reference_to_itself: { code: 1006, category: 1 /* Error */, key: "A file cannot have a reference to itself." }, Trailing_comma_not_allowed: { code: 1009, category: 1 /* Error */, key: "Trailing comma not allowed." }, Asterisk_Slash_expected: { code: 1010, category: 1 /* Error */, key: "'*/' expected." }, Unexpected_token: { code: 1012, category: 1 /* Error */, key: "Unexpected token." }, @@ -127,6 +128,7 @@ var ts; Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: 1 /* Error */, key: "Cannot compile external modules unless the '--module' flag is provided." }, Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: 1 /* Error */, key: "Filename '{0}' differs from already included filename '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: 1 /* Error */, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, + An_enum_member_cannot_have_a_numeric_name: { code: 1151, category: 1 /* Error */, key: "An enum member cannot have a numeric name." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -274,6 +276,7 @@ var ts; Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: 1 /* Error */, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: 1 /* Error */, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: 1 /* Error */, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, + The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: { code: 2447, category: 1 /* Error */, key: "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, @@ -526,10 +529,10 @@ var ts; "|=": 57 /* BarEqualsToken */, "^=": 58 /* CaretEqualsToken */ }; - var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; + var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + var unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; function lookupInUnicodeMap(code, map) { if (code < map[0]) { return false; @@ -758,14 +761,14 @@ var ts; return result; } } - function getLeadingComments(text, pos) { + function getLeadingCommentRanges(text, pos) { return getCommentRanges(text, pos, false); } - ts.getLeadingComments = getLeadingComments; - function getTrailingComments(text, pos) { + ts.getLeadingCommentRanges = getLeadingCommentRanges; + function getTrailingCommentRanges(text, pos) { return getCommentRanges(text, pos, true); } - ts.getTrailingComments = getTrailingComments; + ts.getTrailingCommentRanges = getTrailingCommentRanges; function isIdentifierStart(ch, languageVersion) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } @@ -1560,6 +1563,8 @@ var ts; SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.CaretEqualsToken] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.EndOfFileToken] = "FirstToken"; SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.StringKeyword] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = SyntaxKind.SingleLineCommentTrivia] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = SyntaxKind.WhitespaceTrivia] = "LastTriviaToken"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -1592,8 +1597,17 @@ var ts; TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType"; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 0x00000008] = "WriteArrowStyleSignature"; + TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0x00000010] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 0x00000020] = "WriteTypeArgumentsOfSignature"; })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var TypeFormatFlags = ts.TypeFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0x00000000] = "None"; + SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 0x00000001] = "WriteTypeParametersOrArguments"; + SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 0x00000002] = "UseOnlyExternalAliasing"; + })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); + var SymbolFormatFlags = ts.SymbolFormatFlags; (function (SymbolAccessibility) { SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; @@ -1667,6 +1681,7 @@ var ts; NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 0x00000010] = "SuperInstance"; NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 0x00000020] = "SuperStatic"; NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 0x00000040] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 0x00000080] = "EnumValuesComputed"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -1844,6 +1859,31 @@ var ts; CharacterCodes[CharacterCodes["verticalTab"] = 0x0B] = "verticalTab"; })(ts.CharacterCodes || (ts.CharacterCodes = {})); var CharacterCodes = ts.CharacterCodes; + (function (SymbolDisplayPartKind) { + SymbolDisplayPartKind[SymbolDisplayPartKind["aliasName"] = 0] = "aliasName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["className"] = 1] = "className"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumName"] = 2] = "enumName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["fieldName"] = 3] = "fieldName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["interfaceName"] = 4] = "interfaceName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["keyword"] = 5] = "keyword"; + SymbolDisplayPartKind[SymbolDisplayPartKind["lineBreak"] = 6] = "lineBreak"; + SymbolDisplayPartKind[SymbolDisplayPartKind["numericLiteral"] = 7] = "numericLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["stringLiteral"] = 8] = "stringLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["localName"] = 9] = "localName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["methodName"] = 10] = "methodName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["moduleName"] = 11] = "moduleName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["operator"] = 12] = "operator"; + SymbolDisplayPartKind[SymbolDisplayPartKind["parameterName"] = 13] = "parameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["propertyName"] = 14] = "propertyName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["punctuation"] = 15] = "punctuation"; + SymbolDisplayPartKind[SymbolDisplayPartKind["space"] = 16] = "space"; + SymbolDisplayPartKind[SymbolDisplayPartKind["text"] = 17] = "text"; + SymbolDisplayPartKind[SymbolDisplayPartKind["typeParameterName"] = 18] = "typeParameterName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); + var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; })(ts || (ts = {})); var ts; (function (ts) { @@ -1851,8 +1891,9 @@ var ts; var result; if (array) { for (var i = 0, len = array.length; i < len; i++) { - if (result = callback(array[i])) + if (result = callback(array[i])) { break; + } } } return result; @@ -1880,6 +1921,18 @@ var ts; return -1; } ts.indexOf = indexOf; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var i = 0, len = array.length; i < len; i++) { + if (predicate(array[i])) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; function filter(array, f) { if (array) { var result = []; @@ -2020,10 +2073,7 @@ var ts; } ts.localizedDiagnosticMessages = undefined; function getLocaleSpecificMessage(message) { - if (ts.localizedDiagnosticMessages) { - message = ts.localizedDiagnosticMessages[message]; - } - return message; + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message] ? ts.localizedDiagnosticMessages[message] : message; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { @@ -2244,14 +2294,14 @@ var ts; return getNormalizedPathComponents(pathOrUrl, currentDirectory); } } - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, isAbsolutePathAnUrl) { + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") { directoryComponents.length--; } for (var joinStartIndex = 0; joinStartIndex < pathComponents.length && joinStartIndex < directoryComponents.length; joinStartIndex++) { - if (directoryComponents[joinStartIndex] !== pathComponents[joinStartIndex]) { + if (getCanonicalFileName(directoryComponents[joinStartIndex]) !== getCanonicalFileName(pathComponents[joinStartIndex])) { break; } } @@ -2295,6 +2345,37 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; + var supportedExtensions = [".d.ts", ".ts", ".js"]; + function removeFileExtension(path) { + for (var i = 0; i < supportedExtensions.length; i++) { + var ext = supportedExtensions[i]; + if (fileExtensionIs(path, ext)) { + return path.substr(0, path.length - ext.length); + } + } + return path; + } + ts.removeFileExtension = removeFileExtension; + var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\\\u2028\u2029\u0085]/g; + var escapedCharsMap = { + "\t": "\\t", + "\v": "\\v", + "\f": "\\f", + "\b": "\\b", + "\0": "\\0", + "\r": "\\r", + "\n": "\\n", + "\"": "\\\"", + "\u2028": "\\u2028", + "\u2029": "\\u2029", + "\u0085": "\\u0085" + }; + function escapeString(s) { + return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { + return escapedCharsMap[c] || c; + }) : s; + } + ts.escapeString = escapeString; function Symbol(flags, name) { this.flags = flags; this.name = name; @@ -2366,17 +2447,6 @@ var ts; node.flags = flags; return node; } - var moduleExtensions = [".d.ts", ".ts", ".js"]; - function getModuleNameFromFilename(filename) { - for (var i = 0; i < moduleExtensions.length; i++) { - var ext = moduleExtensions[i]; - var len = filename.length - ext.length; - if (len > 0 && filename.substr(len) === ext) - return filename.substr(0, len); - } - return filename; - } - ts.getModuleNameFromFilename = getModuleNameFromFilename; function getSourceFileOfNode(node) { while (node && node.kind !== 182 /* SourceFile */) node = node.parent; @@ -2397,15 +2467,15 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; - function getSourceTextOfNodeFromSourceText(sourceText, node) { + function getTextOfNodeFromSourceText(sourceText, node) { return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } - ts.getSourceTextOfNodeFromSourceText = getSourceTextOfNodeFromSourceText; - function getSourceTextOfNode(node) { + ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; + function getTextOfNode(node) { var text = getSourceFileOfNode(node).text; return text.substring(ts.skipTrivia(text, node.pos), node.end); } - ts.getSourceTextOfNode = getSourceTextOfNode; + ts.getTextOfNode = getTextOfNode; function escapeIdentifier(identifier) { return identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier; } @@ -2415,7 +2485,7 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function identifierToString(identifier) { - return identifier.kind === 115 /* Missing */ ? "(Missing)" : getSourceTextOfNode(identifier); + return identifier.kind === 115 /* Missing */ ? "(Missing)" : getTextOfNode(identifier); } ts.identifierToString = identifierToString; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { @@ -2453,6 +2523,10 @@ var ts; return file.externalModuleIndicator !== undefined; } ts.isExternalModule = isExternalModule; + function isDeclarationFile(file) { + return (file.flags & 1024 /* DeclarationFile */) !== 0; + } + ts.isDeclarationFile = isDeclarationFile; function isPrologueDirective(node) { return node.kind === 151 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; } @@ -2464,17 +2538,18 @@ var ts; ts.Debug.assert(isPrologueDirective(node)); return node.expression.text === "use strict"; } - function getLeadingCommentsOfNode(node, sourceFileOfNode) { + function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { + sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); if (node.kind === 118 /* Parameter */ || node.kind === 117 /* TypeParameter */) { - return ts.concatenate(ts.getTrailingComments(sourceFileOfNode.text, node.pos), ts.getLeadingComments(sourceFileOfNode.text, node.pos)); + return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { - return ts.getLeadingComments(sourceFileOfNode.text, node.pos); + return ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos); } } - ts.getLeadingCommentsOfNode = getLeadingCommentsOfNode; + ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJsDocComments(node, sourceFileOfNode) { - return ts.filter(getLeadingCommentsOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); + return ts.filter(getLeadingCommentRangesOfNode(node, sourceFileOfNode), function (comment) { return isJsDocComment(comment); }); function isJsDocComment(comment) { return sourceFileOfNode.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && sourceFileOfNode.text.charCodeAt(comment.pos + 3) !== 47 /* slash */; } @@ -2893,12 +2968,6 @@ var ts; ModifierContext[ModifierContext["ClassMembers"] = 2] = "ClassMembers"; ModifierContext[ModifierContext["Parameters"] = 3] = "Parameters"; })(ModifierContext || (ModifierContext = {})); - var TrailingCommaBehavior; - (function (TrailingCommaBehavior) { - TrailingCommaBehavior[TrailingCommaBehavior["Disallow"] = 0] = "Disallow"; - TrailingCommaBehavior[TrailingCommaBehavior["Allow"] = 1] = "Allow"; - TrailingCommaBehavior[TrailingCommaBehavior["Preserve"] = 2] = "Preserve"; - })(TrailingCommaBehavior || (TrailingCommaBehavior = {})); var ControlBlockContext; (function (ControlBlockContext) { ControlBlockContext[ControlBlockContext["NotNested"] = 0] = "NotNested"; @@ -2909,6 +2978,10 @@ var ts; return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword; } ts.isKeyword = isKeyword; + function isTrivia(token) { + return ts.SyntaxKind.FirstTriviaToken <= token && token <= ts.SyntaxKind.LastTriviaToken; + } + ts.isTrivia = isTrivia; function isModifier(token) { switch (token) { case 102 /* PublicKeyword */: @@ -3169,7 +3242,9 @@ var ts; return finishNode(node); } error(ts.Diagnostics.Identifier_expected); - return createMissingNode(); + var node = createMissingNode(); + node.text = ""; + return node; } function parseIdentifier() { return createIdentifier(isIdentifier()); @@ -3221,7 +3296,7 @@ var ts; case 14 /* TypeParameters */: return isIdentifier(); case 10 /* ArgumentExpressions */: - return isExpression(); + return token === 18 /* CommaToken */ || isExpression(); case 12 /* ArrayLiteralMembers */: return token === 18 /* CommaToken */ || isExpression(); case 13 /* Parameters */: @@ -3321,7 +3396,7 @@ var ts; parsingContext = saveParsingContext; return result; } - function parseDelimitedList(kind, parseElement, trailingCommaBehavior) { + function parseDelimitedList(kind, parseElement, allowTrailingComma) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; var result = []; @@ -3342,16 +3417,6 @@ var ts; error(ts.Diagnostics._0_expected, ","); } else if (isListTerminator(kind)) { - if (commaStart >= 0) { - if (trailingCommaBehavior === 0 /* Disallow */) { - if (file.syntacticErrors.length === errorCountBeforeParsingList) { - grammarErrorAtPos(commaStart, scanner.getStartPos() - commaStart, ts.Diagnostics.Trailing_comma_not_allowed); - } - } - else if (trailingCommaBehavior === 2 /* Preserve */) { - result.push(createNode(147 /* OmittedExpression */)); - } - } break; } else { @@ -3362,6 +3427,14 @@ var ts; nextToken(); } } + if (commaStart >= 0) { + if (!allowTrailingComma) { + if (file.syntacticErrors.length === errorCountBeforeParsingList) { + grammarErrorAtPos(commaStart, scanner.getStartPos() - commaStart, ts.Diagnostics.Trailing_comma_not_allowed); + } + } + result.hasTrailingComma = true; + } result.end = getNodeEnd(); parsingContext = saveParsingContext; return result; @@ -3381,7 +3454,7 @@ var ts; } function parseBracketedList(kind, parseElement, startToken, endToken) { if (parseExpected(startToken)) { - var result = parseDelimitedList(kind, parseElement, 0 /* Disallow */); + var result = parseDelimitedList(kind, parseElement, false); parseExpected(endToken); return result; } @@ -4052,10 +4125,10 @@ var ts; nextToken(); var operand = parseUnaryExpression(); if (isInStrictMode) { - if ((token === 33 /* PlusPlusToken */ || token === 34 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { + if ((operator === 33 /* PlusPlusToken */ || operator === 34 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { reportInvalidUseInStrictMode(operand); } - else if (token === 68 /* DeleteKeyword */ && operand.kind === 59 /* Identifier */) { + else if (operator === 68 /* DeleteKeyword */ && operand.kind === 59 /* Identifier */) { grammarErrorOnNode(operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } } @@ -4140,7 +4213,7 @@ var ts; else { parseExpected(11 /* OpenParenToken */); } - callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseAssignmentExpression, 0 /* Disallow */); + callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); parseExpected(12 /* CloseParenToken */); expr = finishNode(callExpr); continue; @@ -4204,15 +4277,29 @@ var ts; parseExpected(12 /* CloseParenToken */); return finishNode(node); } + function parseAssignmentExpressionOrOmittedExpression(omittedExpressionDiagnostic) { + if (token === 18 /* CommaToken */) { + if (omittedExpressionDiagnostic) { + var errorStart = scanner.getTokenPos(); + var errorLength = scanner.getTextPos() - errorStart; + grammarErrorAtPos(errorStart, errorLength, omittedExpressionDiagnostic); + } + return createNode(147 /* OmittedExpression */); + } + return parseAssignmentExpression(); + } function parseArrayLiteralElement() { - return token === 18 /* CommaToken */ ? createNode(147 /* OmittedExpression */) : parseAssignmentExpression(); + return parseAssignmentExpressionOrOmittedExpression(undefined); + } + function parseArgumentExpression() { + return parseAssignmentExpressionOrOmittedExpression(ts.Diagnostics.Argument_expression_expected); } function parseArrayLiteral() { var node = createNode(132 /* ArrayLiteral */); parseExpected(13 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; - node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement, 2 /* Preserve */); + node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement, true); parseExpected(14 /* CloseBracketToken */); return finishNode(node); } @@ -4245,8 +4332,7 @@ var ts; if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } - var trailingCommaBehavior = languageVersion === 0 /* ES3 */ ? 1 /* Allow */ : 2 /* Preserve */; - node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember, trailingCommaBehavior); + node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember, true); parseExpected(10 /* CloseBraceToken */); var seen = {}; var Property = 1; @@ -4320,7 +4406,7 @@ var ts; parseExpected(82 /* NewKeyword */); node.func = parseCallAndAccess(parsePrimaryExpression(), true); if (parseOptional(11 /* OpenParenToken */) || token === 19 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { - node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseAssignmentExpression, 0 /* Disallow */); + node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); parseExpected(12 /* CloseParenToken */); } return finishNode(node); @@ -4657,7 +4743,7 @@ var ts; node.label = parseIdentifier(); parseExpected(46 /* ColonToken */); if (labelledStatementInfo.nodeIsNestedInLabel(node.label, false, true)) { - grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getSourceTextOfNodeFromSourceText(sourceText, node.label)); + grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); } labelledStatementInfo.addLabel(node.label); node.statement = isLabel() ? parseLabelledStatement() : parseStatementWithLabelSet(); @@ -4790,7 +4876,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(flags, noIn) { - return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); }, 0 /* Disallow */); + return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); }, false); } function parseVariableStatement(pos, flags) { var node = createNode(149 /* VariableStatement */, pos); @@ -5129,7 +5215,7 @@ var ts; var implementsKeywordLength; if (parseOptional(96 /* ImplementsKeyword */)) { implementsKeywordLength = scanner.getStartPos() - implementsKeywordStart; - node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, 0 /* Disallow */); + node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } var errorCountBeforeClassBody = file.syntacticErrors.length; if (parseExpected(9 /* OpenBraceToken */)) { @@ -5155,7 +5241,7 @@ var ts; var extendsKeywordLength; if (parseOptional(73 /* ExtendsKeyword */)) { extendsKeywordLength = scanner.getStartPos() - extendsKeywordStart; - node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, 0 /* Disallow */); + node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } var errorCountBeforeInterfaceBody = file.syntacticErrors.length; node.members = parseTypeLiteral().members; @@ -5204,7 +5290,7 @@ var ts; parseExpected(71 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(9 /* OpenBraceToken */)) { - node.members = parseDelimitedList(7 /* EnumMembers */, parseAndCheckEnumMember, 1 /* Allow */); + node.members = parseDelimitedList(7 /* EnumMembers */, parseAndCheckEnumMember, true); parseExpected(10 /* CloseBraceToken */); } else { @@ -5398,15 +5484,16 @@ var ts; } else { var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment); + var start = range.pos; + var end = range.end; + var length = end - start; if (!matchResult) { - var start = range.pos; - var length = range.end - start; errorAtPos(start, length, ts.Diagnostics.Invalid_reference_directive_syntax); } else { referencedFiles.push({ - pos: range.pos, - end: range.end, + pos: start, + end: end, filename: matchResult[3] }); } @@ -5509,6 +5596,9 @@ var ts; else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; } + else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) { + diagnostic = ts.Diagnostics.A_file_cannot_have_a_reference_to_itself; + } } else { if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) { @@ -5559,7 +5649,8 @@ var ts; } function processReferencedFiles(file, basePath) { ts.forEach(file.referencedFiles, function (ref) { - processSourceFile(ts.normalizePath(ts.combinePaths(basePath, ref.filename)), false, file, ref.pos, ref.end); + var referencedFilename = ts.isRootedDiskPath(ref.filename) ? ref.filename : ts.combinePaths(basePath, ref.filename); + processSourceFile(ts.normalizePath(referencedFilename), false, file, ref.pos, ref.end); }); } function processImportedModules(file, basePath) { @@ -5582,7 +5673,7 @@ var ts; } } } - else if (node.kind === 177 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || file.flags & 1024 /* DeclarationFile */)) { + else if (node.kind === 177 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { forEachChild(node.body, function (node) { if (node.kind === 179 /* ImportDeclaration */ && node.externalModuleName) { var nameLiteral = node.externalModuleName; @@ -5732,7 +5823,10 @@ var ts; if (node.name) { node.name.parent = node; } - file.semanticErrors.push(ts.createDiagnosticForNode(node.name ? node.name : node, ts.Diagnostics.Duplicate_identifier_0, getDisplayName(node))); + ts.forEach(symbol.declarations, function (declaration) { + file.semanticErrors.push(ts.createDiagnosticForNode(declaration.name, ts.Diagnostics.Duplicate_identifier_0, getDisplayName(declaration))); + }); + file.semanticErrors.push(ts.createDiagnosticForNode(node.name, ts.Diagnostics.Duplicate_identifier_0, getDisplayName(node))); symbol = createSymbol(0, name); } } @@ -5950,7 +6044,7 @@ var ts; break; case 182 /* SourceFile */: if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 128 /* ValueModule */, '"' + ts.getModuleNameFromFilename(node.filename) + '"'); + bindAnonymousDeclaration(node, 128 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"'); break; } default: @@ -5972,11 +6066,12 @@ var ts; } return indentStrings[level]; } + ts.getIndentString = getIndentString; function getIndentSize() { return indentStrings[1].length; } function shouldEmitToOwnFile(sourceFile, compilerOptions) { - if (!(sourceFile.flags & 1024 /* DeclarationFile */)) { + if (!ts.isDeclarationFile(sourceFile)) { if ((ts.isExternalModule(sourceFile) || !compilerOptions.out) && !ts.fileExtensionIs(sourceFile.filename, ".js")) { return true; } @@ -5986,9 +6081,902 @@ var ts; } ts.shouldEmitToOwnFile = shouldEmitToOwnFile; function isExternalModuleOrDeclarationFile(sourceFile) { - return ts.isExternalModule(sourceFile) || (sourceFile.flags & 1024 /* DeclarationFile */) !== 0; + return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + function createTextWriter(newLine, trackSymbol) { + var output = ""; + var indent = 0; + var lineStart = true; + var lineCount = 0; + var linePos = 0; + function write(s) { + if (s && s.length) { + if (lineStart) { + output += getIndentString(indent); + lineStart = false; + } + output += s; + } + } + function rawWrite(s) { + if (s !== undefined) { + if (lineStart) { + lineStart = false; + } + output += s; + } + } + function writeLiteral(s) { + if (s && s.length) { + write(s); + var lineStartsOfS = ts.getLineStarts(s); + if (lineStartsOfS.length > 1) { + lineCount = lineCount + lineStartsOfS.length - 1; + linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; + } + } + } + function writeLine() { + if (!lineStart) { + output += newLine; + lineCount++; + linePos = output.length; + lineStart = true; + } + } + function writeKind(text, kind) { + write(text); + } + function writeSymbol(text, symbol) { + write(text); + } + return { + write: write, + trackSymbol: trackSymbol, + writeKind: writeKind, + writeSymbol: writeSymbol, + rawWrite: rawWrite, + writeLiteral: writeLiteral, + writeLine: writeLine, + increaseIndent: function () { return indent++; }, + decreaseIndent: function () { return indent--; }, + getIndent: function () { return indent; }, + getTextPos: function () { return output.length; }, + getLine: function () { return lineCount + 1; }, + getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, + getText: function () { return output; }, + clear: function () { + } + }; + } + function getSourceTextOfLocalNode(currentSourceFile, node) { + var text = currentSourceFile.text; + return text.substring(ts.skipTrivia(text, node.pos), node.end); + } + function getLineOfLocalPosition(currentSourceFile, pos) { + return currentSourceFile.getLineAndCharacterFromPosition(pos).line; + } + function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) { + if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) { + writer.writeLine(); + } + } + function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) { + var emitLeadingSpace = !trailingSeparator; + ts.forEach(comments, function (comment) { + if (emitLeadingSpace) { + writer.write(" "); + emitLeadingSpace = false; + } + writeComment(currentSourceFile, writer, comment, newLine); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + else if (trailingSeparator) { + writer.write(" "); + } + else { + emitLeadingSpace = true; + } + }); + } + function writeCommentRange(currentSourceFile, writer, comment, newLine) { + if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { + var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos); + var firstCommentLineIndent; + for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { + var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1); + if (pos !== comment.pos) { + if (firstCommentLineIndent === undefined) { + firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos); + } + var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); + var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); + if (spacesToEmit > 0) { + var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); + var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); + writer.rawWrite(indentSizeSpaceString); + while (numberOfSingleSpacesToEmit) { + writer.rawWrite(" "); + numberOfSingleSpacesToEmit--; + } + } + else { + writer.rawWrite(""); + } + } + writeTrimmedCurrentLine(pos, nextLineStart); + pos = nextLineStart; + } + } + else { + writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); + } + function writeTrimmedCurrentLine(pos, nextLineStart) { + var end = Math.min(comment.end, nextLineStart - 1); + var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); + if (currentLineText) { + writer.write(currentLineText); + if (end !== comment.end) { + writer.writeLine(); + } + } + else { + writer.writeLiteral(newLine); + } + } + function calculateIndent(pos, end) { + var currentLineIndent = 0; + for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { + if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { + currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); + } + else { + currentLineIndent++; + } + } + return currentLineIndent; + } + } + function getFirstConstructorWithBody(node) { + return ts.forEach(node.members, function (member) { + if (member.kind === 121 /* Constructor */ && member.body) { + return member; + } + }); + } + function getAllAccessorDeclarations(node, accessor) { + var firstAccessor; + var getAccessor; + var setAccessor; + ts.forEach(node.members, function (member) { + if ((member.kind === 122 /* GetAccessor */ || member.kind === 123 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if (!firstAccessor) { + firstAccessor = member; + } + if (member.kind === 122 /* GetAccessor */ && !getAccessor) { + getAccessor = member; + } + if (member.kind === 123 /* SetAccessor */ && !setAccessor) { + setAccessor = member; + } + } + }); + return { + firstAccessor: firstAccessor, + getAccessor: getAccessor, + setAccessor: setAccessor + }; + } + function getSourceFilePathInNewDir(sourceFile, program, newDirPath) { + var compilerHost = program.getCompilerHost(); + var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory())); + sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), ""); + return ts.combinePaths(newDirPath, sourceFilePath); + } + function getOwnEmitOutputFilePath(sourceFile, program, extension) { + var compilerOptions = program.getCompilerOptions(); + if (compilerOptions.outDir) { + var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, program, compilerOptions.outDir)); + } + else { + var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename); + } + return emitOutputFilePathWithoutExtension + extension; + } + function writeFile(compilerHost, diagnostics, filename, data, writeByteOrderMark) { + compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) { + diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage)); + }); + } + function emitDeclarations(program, resolver, diagnostics, jsFilePath, root) { + var newLine = program.getCompilerHost().getNewLine(); + var compilerOptions = program.getCompilerOptions(); + var compilerHost = program.getCompilerHost(); + var writer = createTextWriter(newLine, trackSymbol); + var write = writer.write; + var writeLine = writer.writeLine; + var increaseIndent = writer.increaseIndent; + var decreaseIndent = writer.decreaseIndent; + var enclosingDeclaration; + var currentSourceFile; + var reportedDeclarationError = false; + var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { + } : writeJsDocComments; + var aliasDeclarationEmitInfo = []; + var getSymbolVisibilityDiagnosticMessage; + function writeAsychronousImportDeclarations(importDeclarations) { + var oldWriter = writer; + ts.forEach(importDeclarations, function (aliasToWrite) { + var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); + writer = createTextWriter(newLine, trackSymbol); + for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { + writer.increaseIndent(); + } + writeImportDeclaration(aliasToWrite); + aliasEmitInfo.asynchronousOutput = writer.getText(); + }); + writer = oldWriter; + } + function trackSymbol(symbol, enclosingDeclaration, meaning) { + var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning); + if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + reportedDeclarationError = true; + var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult); + if (errorInfo) { + if (errorInfo.typeName) { + diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, getSourceTextOfLocalNode(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + else { + diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); + } + } + } + } + function emitLines(nodes) { + for (var i = 0, n = nodes.length; i < n; i++) { + emitNode(nodes[i]); + } + } + function emitCommaList(nodes, eachNodeEmitFn) { + var currentWriterPos = writer.getTextPos(); + for (var i = 0, n = nodes.length; i < n; i++) { + if (currentWriterPos !== writer.getTextPos()) { + write(", "); + } + currentWriterPos = writer.getTextPos(); + eachNodeEmitFn(nodes[i]); + } + } + function writeJsDocComments(declaration) { + if (declaration) { + var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments); + emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange); + } + } + function emitSourceTextOfNode(node) { + write(getSourceTextOfLocalNode(currentSourceFile, node)); + } + function emitSourceFile(node) { + currentSourceFile = node; + enclosingDeclaration = node; + emitLines(node.statements); + } + function emitExportAssignment(node) { + write("export = "); + emitSourceTextOfNode(node.exportName); + write(";"); + writeLine(); + } + function emitDeclarationFlags(node) { + if (node.flags & 128 /* Static */) { + if (node.flags & 32 /* Private */) { + write("private "); + } + else if (node.flags & 64 /* Protected */) { + write("protected "); + } + write("static "); + } + else { + if (node.flags & 32 /* Private */) { + write("private "); + } + else if (node.flags & 64 /* Protected */) { + write("protected "); + } + else if (node.parent === currentSourceFile) { + if (node.flags & 1 /* Export */) { + write("export "); + } + if (node.kind !== 175 /* InterfaceDeclaration */) { + write("declare "); + } + } + } + } + function emitImportDeclaration(node) { + var nodeEmitInfo = { + declaration: node, + outputPos: writer.getTextPos(), + indent: writer.getIndent(), + hasWritten: resolver.isDeclarationVisible(node) + }; + aliasDeclarationEmitInfo.push(nodeEmitInfo); + if (nodeEmitInfo.hasWritten) { + writeImportDeclaration(node); + } + } + function writeImportDeclaration(node) { + emitJsDocComments(node); + if (node.flags & 1 /* Export */) { + writer.write("export "); + } + writer.write("import "); + writer.write(getSourceTextOfLocalNode(currentSourceFile, node.name)); + writer.write(" = "); + if (node.entityName) { + checkEntityNameAccessible(); + writer.write(getSourceTextOfLocalNode(currentSourceFile, node.entityName)); + writer.write(";"); + } + else { + writer.write("require("); + writer.write(getSourceTextOfLocalNode(currentSourceFile, node.externalModuleName)); + writer.write(");"); + } + writer.writeLine(); + function checkEntityNameAccessible() { + var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisible(node.entityName); + if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccesibilityResult.aliasesToMakeVisible) { + writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); + } + } + else { + reportedDeclarationError = true; + diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Import_declaration_0_is_using_private_name_1, getSourceTextOfLocalNode(currentSourceFile, node.name), symbolAccesibilityResult.errorSymbolName)); + } + } + } + function emitModuleDeclaration(node) { + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("module "); + emitSourceTextOfNode(node.name); + while (node.body.kind !== 178 /* ModuleBlock */) { + node = node.body; + write("."); + emitSourceTextOfNode(node.name); + } + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.body.statements); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + } + function emitEnumDeclaration(node) { + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("enum "); + emitSourceTextOfNode(node.name); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + } + } + function emitEnumMemberDeclaration(node) { + emitJsDocComments(node); + emitSourceTextOfNode(node.name); + var enumMemberValue = resolver.getEnumMemberValue(node); + if (enumMemberValue !== undefined) { + write(" = "); + write(enumMemberValue.toString()); + } + write(","); + writeLine(); + } + function emitTypeParameters(typeParameters) { + function emitTypeParameter(node) { + function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.parent.kind) { + case 174 /* ClassDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; + break; + case 175 /* InterfaceDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; + break; + case 125 /* ConstructSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 124 /* CallSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 120 /* Method */: + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 172 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for type parameter: " + ts.SyntaxKind[node.parent.kind]); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + increaseIndent(); + emitJsDocComments(node); + decreaseIndent(); + emitSourceTextOfNode(node.name); + if (node.constraint && (node.parent.kind !== 120 /* Method */ || !(node.parent.flags & 32 /* Private */))) { + write(" extends "); + getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError; + resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + } + if (typeParameters) { + write("<"); + emitCommaList(typeParameters, emitTypeParameter); + write(">"); + } + } + function emitHeritageClause(typeReferences, isImplementsList) { + if (typeReferences) { + write(isImplementsList ? " implements " : " extends "); + emitCommaList(typeReferences, emitTypeOfTypeReference); + } + function emitTypeOfTypeReference(node) { + getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer); + function getHeritageClauseVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.parent.kind === 174 /* ClassDeclaration */) { + if (symbolAccesibilityResult.errorModuleName) { + diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; + } + else { + diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; + } + } + else { + if (symbolAccesibilityResult.errorModuleName) { + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2; + } + else { + diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; + } + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.parent.name + }; + } + } + } + function emitClassDeclaration(node) { + function emitParameterProperties(constructorDeclaration) { + if (constructorDeclaration) { + ts.forEach(constructorDeclaration.parameters, function (param) { + if (param.flags & ts.NodeFlags.AccessibilityModifier) { + emitPropertyDeclaration(param); + } + }); + } + } + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("class "); + emitSourceTextOfNode(node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + if (node.baseType) { + emitHeritageClause([node.baseType], false); + } + emitHeritageClause(node.implementedTypes, true); + write(" {"); + writeLine(); + increaseIndent(); + emitParameterProperties(getFirstConstructorWithBody(node)); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + } + function emitInterfaceDeclaration(node) { + if (resolver.isDeclarationVisible(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("interface "); + emitSourceTextOfNode(node.name); + var prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + emitTypeParameters(node.typeParameters); + emitHeritageClause(node.baseTypes, false); + write(" {"); + writeLine(); + increaseIndent(); + emitLines(node.members); + decreaseIndent(); + write("}"); + writeLine(); + enclosingDeclaration = prevEnclosingDeclaration; + } + } + function emitPropertyDeclaration(node) { + emitJsDocComments(node); + emitDeclarationFlags(node); + emitVariableDeclaration(node); + write(";"); + writeLine(); + } + function emitVariableDeclaration(node) { + if (node.kind !== 171 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + emitSourceTextOfNode(node.name); + if (node.kind === 119 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + write("?"); + } + if (!(node.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + } + function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.kind === 171 /* VariableDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; + } + else if (node.kind === 119 /* Property */) { + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; + } + } + return diagnosticMessage !== undefined ? { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + } : undefined; + } + } + function emitVariableStatement(node) { + var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); + if (hasDeclarationWithEmit) { + emitJsDocComments(node); + emitDeclarationFlags(node); + write("var "); + emitCommaList(node.declarations, emitVariableDeclaration); + write(";"); + writeLine(); + } + } + function emitAccessorDeclaration(node) { + var accessors = getAllAccessorDeclarations(node.parent, node); + if (node === accessors.firstAccessor) { + emitJsDocComments(accessors.getAccessor); + emitJsDocComments(accessors.setAccessor); + emitDeclarationFlags(node); + emitSourceTextOfNode(node.name); + if (!(node.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + write(";"); + writeLine(); + } + function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + if (node.kind === 123 /* SetAccessor */) { + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.parameters[0], + typeName: node.name + }; + } + else { + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name, + typeName: undefined + }; + } + } + } + function emitFunctionDeclaration(node) { + if ((node.kind !== 172 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + emitJsDocComments(node); + emitDeclarationFlags(node); + if (node.kind === 172 /* FunctionDeclaration */) { + write("function "); + emitSourceTextOfNode(node.name); + } + else if (node.kind === 121 /* Constructor */) { + write("constructor"); + } + else { + emitSourceTextOfNode(node.name); + if (node.flags & 4 /* QuestionMark */) { + write("?"); + } + } + emitSignatureDeclaration(node); + } + } + function emitConstructSignatureDeclaration(node) { + emitJsDocComments(node); + write("new "); + emitSignatureDeclaration(node); + } + function emitSignatureDeclaration(node) { + if (node.kind === 124 /* CallSignature */ || node.kind === 126 /* IndexSignature */) { + emitJsDocComments(node); + } + emitTypeParameters(node.typeParameters); + if (node.kind === 126 /* IndexSignature */) { + write("["); + } + else { + write("("); + } + emitCommaList(node.parameters, emitParameterDeclaration); + if (node.kind === 126 /* IndexSignature */) { + write("]"); + } + else { + write(")"); + } + if (node.kind !== 121 /* Constructor */ && !(node.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError; + resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + write(";"); + writeLine(); + function getReturnTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.kind) { + case 125 /* ConstructSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 124 /* CallSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 126 /* IndexSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; + break; + case 120 /* Method */: + if (node.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; + } + else if (node.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; + } + break; + case 172 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; + break; + default: + ts.Debug.fail("This is unknown kind for signature: " + ts.SyntaxKind[node.kind]); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node.name || node + }; + } + } + function emitParameterDeclaration(node) { + increaseIndent(); + emitJsDocComments(node); + if (node.flags & 8 /* Rest */) { + write("..."); + } + emitSourceTextOfNode(node.name); + if (node.initializer || (node.flags & 4 /* QuestionMark */)) { + write("?"); + } + decreaseIndent(); + if (!(node.parent.flags & 32 /* Private */)) { + write(": "); + getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError; + resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); + } + function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { + var diagnosticMessage; + switch (node.parent.kind) { + case 121 /* Constructor */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; + break; + case 125 /* ConstructSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 124 /* CallSignature */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + break; + case 120 /* Method */: + if (node.parent.flags & 128 /* Static */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; + } + else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; + } + else { + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; + } + break; + case 172 /* FunctionDeclaration */: + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + break; + default: + ts.Debug.fail("This is unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + } + return { + diagnosticMessage: diagnosticMessage, + errorNode: node, + typeName: node.name + }; + } + } + function emitNode(node) { + switch (node.kind) { + case 121 /* Constructor */: + case 172 /* FunctionDeclaration */: + case 120 /* Method */: + return emitFunctionDeclaration(node); + case 125 /* ConstructSignature */: + return emitConstructSignatureDeclaration(node); + case 124 /* CallSignature */: + case 126 /* IndexSignature */: + return emitSignatureDeclaration(node); + case 122 /* GetAccessor */: + case 123 /* SetAccessor */: + return emitAccessorDeclaration(node); + case 149 /* VariableStatement */: + return emitVariableStatement(node); + case 119 /* Property */: + return emitPropertyDeclaration(node); + case 175 /* InterfaceDeclaration */: + return emitInterfaceDeclaration(node); + case 174 /* ClassDeclaration */: + return emitClassDeclaration(node); + case 181 /* EnumMember */: + return emitEnumMemberDeclaration(node); + case 176 /* EnumDeclaration */: + return emitEnumDeclaration(node); + case 177 /* ModuleDeclaration */: + return emitModuleDeclaration(node); + case 179 /* ImportDeclaration */: + return emitImportDeclaration(node); + case 180 /* ExportAssignment */: + return emitExportAssignment(node); + case 182 /* SourceFile */: + return emitSourceFile(node); + } + } + function tryResolveScriptReference(sourceFile, reference) { + var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename)); + return program.getSourceFile(referenceFileName); + } + var referencePathsOutput = ""; + function writeReferencePath(referencedFile) { + var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, program, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false); + referencePathsOutput += "/// " + newLine; + } + if (root) { + if (!compilerOptions.noResolve) { + var addedGlobalFileReference = false; + ts.forEach(root.referencedFiles, function (fileReference) { + var referencedFile = tryResolveScriptReference(root, fileReference); + if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { + writeReferencePath(referencedFile); + if (!isExternalModuleOrDeclarationFile(referencedFile)) { + addedGlobalFileReference = true; + } + } + }); + } + emitNode(root); + } + else { + var emittedReferencedFiles = []; + ts.forEach(program.getSourceFiles(), function (sourceFile) { + if (!isExternalModuleOrDeclarationFile(sourceFile)) { + if (!compilerOptions.noResolve) { + ts.forEach(sourceFile.referencedFiles, function (fileReference) { + var referencedFile = tryResolveScriptReference(sourceFile, fileReference); + if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) { + writeReferencePath(referencedFile); + emittedReferencedFiles.push(referencedFile); + } + }); + } + emitNode(sourceFile); + } + }); + } + return { + reportedDeclarationError: reportedDeclarationError, + aliasDeclarationEmitInfo: aliasDeclarationEmitInfo, + synchronousDeclarationOutput: writer.getText(), + declarationOutput: referencePathsOutput + }; + } + function writeDeclarationToFile(compilerHost, compilerOptions, diagnostics, aliasDeclarationEmitInfo, synchronousDeclarationOutput, jsFilePath, declarationOutput) { + var appliedSyncOutputPos = 0; + ts.forEach(aliasDeclarationEmitInfo, function (aliasEmitInfo) { + if (aliasEmitInfo.asynchronousOutput) { + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); + declarationOutput += aliasEmitInfo.asynchronousOutput; + appliedSyncOutputPos = aliasEmitInfo.outputPos; + } + }); + declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); + writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); + } + function getDeclarationDiagnostics(program, resolver, targetSourceFile) { + var diagnostics = []; + var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); + emitDeclarations(program, resolver, diagnostics, jsFilePath, targetSourceFile); + return diagnostics; + } + ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitFiles(resolver, targetSourceFile) { var program = resolver.getProgram(); var compilerHost = program.getCompilerHost(); @@ -5996,207 +6984,13 @@ var ts; var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined; var diagnostics = []; var newLine = program.getCompilerHost().getNewLine(); - function getSourceFilePathInNewDir(newDirPath, sourceFile) { - var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory())); - sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), ""); - return ts.combinePaths(newDirPath, sourceFilePath); - } - function getOwnEmitOutputFilePath(sourceFile, extension) { - if (compilerOptions.outDir) { - var emitOutputFilePathWithoutExtension = ts.getModuleNameFromFilename(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile)); - } - else { - var emitOutputFilePathWithoutExtension = ts.getModuleNameFromFilename(sourceFile.filename); - } - return emitOutputFilePathWithoutExtension + extension; - } - function getFirstConstructorWithBody(node) { - return ts.forEach(node.members, function (member) { - if (member.kind === 121 /* Constructor */ && member.body) { - return member; - } - }); - } - function getAllAccessorDeclarations(node, accessor) { - var firstAccessor; - var getAccessor; - var setAccessor; - ts.forEach(node.members, function (member) { - if ((member.kind === 122 /* GetAccessor */ || member.kind === 123 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { - if (!firstAccessor) { - firstAccessor = member; - } - if (member.kind === 122 /* GetAccessor */ && !getAccessor) { - getAccessor = member; - } - if (member.kind === 123 /* SetAccessor */ && !setAccessor) { - setAccessor = member; - } - } - }); - return { - firstAccessor: firstAccessor, - getAccessor: getAccessor, - setAccessor: setAccessor - }; - } - function createTextWriter(writeSymbol) { - var output = ""; - var indent = 0; - var lineStart = true; - var lineCount = 0; - var linePos = 0; - function write(s) { - if (s && s.length) { - if (lineStart) { - output += getIndentString(indent); - lineStart = false; - } - output += s; - } - } - function rawWrite(s) { - if (s !== undefined) { - if (lineStart) { - lineStart = false; - } - output += s; - } - } - function writeLiteral(s) { - if (s && s.length) { - write(s); - var lineStartsOfS = ts.getLineStarts(s); - if (lineStartsOfS.length > 1) { - lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1]; - } - } - } - function writeLine() { - if (!lineStart) { - output += newLine; - lineCount++; - linePos = output.length; - lineStart = true; - } - } - return { - write: write, - writeSymbol: writeSymbol, - rawWrite: rawWrite, - writeLiteral: writeLiteral, - writeLine: writeLine, - increaseIndent: function () { return indent++; }, - decreaseIndent: function () { return indent--; }, - getIndent: function () { return indent; }, - getTextPos: function () { return output.length; }, - getLine: function () { return lineCount + 1; }, - getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; }, - getText: function () { return output; } - }; - } - var currentSourceFile; - function getSourceTextOfLocalNode(node) { - var text = currentSourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); - } - function getLineOfLocalPosition(pos) { - return currentSourceFile.getLineAndCharacterFromPosition(pos).line; - } - function writeFile(filename, data, writeByteOrderMark) { - compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) { - diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage)); - }); - } - function emitComments(comments, trailingSeparator, writer, writeComment) { - var emitLeadingSpace = !trailingSeparator; - ts.forEach(comments, function (comment) { - if (emitLeadingSpace) { - writer.write(" "); - emitLeadingSpace = false; - } - writeComment(comment, writer); - if (comment.hasTrailingNewLine) { - writer.writeLine(); - } - else if (trailingSeparator) { - writer.write(" "); - } - else { - emitLeadingSpace = true; - } - }); - } - function emitNewLineBeforeLeadingComments(node, leadingComments, writer) { - if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(node.pos) !== getLineOfLocalPosition(leadingComments[0].pos)) { - writer.writeLine(); - } - } - function writeCommentRange(comment, writer) { - if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { - var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos); - var firstCommentLineIndent; - for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) { - var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1); - if (pos !== comment.pos) { - if (firstCommentLineIndent === undefined) { - firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos); - } - var currentWriterIndentSpacing = writer.getIndent() * getIndentSize(); - var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart); - if (spacesToEmit > 0) { - var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize(); - var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize()); - writer.rawWrite(indentSizeSpaceString); - while (numberOfSingleSpacesToEmit) { - writer.rawWrite(" "); - numberOfSingleSpacesToEmit--; - } - } - else { - writer.rawWrite(""); - } - } - writeTrimmedCurrentLine(pos, nextLineStart); - pos = nextLineStart; - } - } - else { - writer.write(currentSourceFile.text.substring(comment.pos, comment.end)); - } - function writeTrimmedCurrentLine(pos, nextLineStart) { - var end = Math.min(comment.end, nextLineStart - 1); - var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, ''); - if (currentLineText) { - writer.write(currentLineText); - if (end !== comment.end) { - writer.writeLine(); - } - } - else { - writer.writeLiteral(newLine); - } - } - function calculateIndent(pos, end) { - var currentLineIndent = 0; - for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) { - if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) { - currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); - } - else { - currentLineIndent++; - } - } - return currentLineIndent; - } - } function emitJavaScript(jsFilePath, root) { - var writer = createTextWriter(writeSymbol); + var writer = createTextWriter(newLine, trackSymbol); var write = writer.write; var writeLine = writer.writeLine; var increaseIndent = writer.increaseIndent; var decreaseIndent = writer.decreaseIndent; + var currentSourceFile; var extendsEmitted = false; var writeEmittedFiles = writeJavaScriptFile; var emitLeadingComments = compilerOptions.removeComments ? function (node) { @@ -6222,7 +7016,7 @@ var ts; var scopeEmitEnd = function () { }; var sourceMapData; - function writeSymbol(symbol, enclosingDeclaration, meaning) { + function trackSymbol(symbol, enclosingDeclaration, meaning) { } function initializeEmitterWithSourceMaps() { var sourceMapDir; @@ -6328,7 +7122,7 @@ var ts; } function recordNewSourceFileStart(node) { var sourcesDirectoryPath = compilerOptions.sourceRoot ? program.getCommonSourceDirectory() : sourceMapDir; - sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.filename, compilerHost.getCurrentDirectory(), true)); + sourceMapData.sourceMapSources.push(ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, node.filename, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, true)); sourceMapSourceIndex = sourceMapData.sourceMapSources.length - 1; sourceMapData.inputSourceFileNames.push(node.filename); } @@ -6369,25 +7163,11 @@ var ts; sourceMapNameIndices.pop(); } ; - function writeCommentRangeWithMap(comment, writer) { + function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) { recordSourceMapSpan(comment.pos); - writeCommentRange(comment, writer); + writeCommentRange(currentSourceFile, writer, comment, newLine); recordSourceMapSpan(comment.end); } - var escapedCharsRegExp = /[\t\v\f\b\0\r\n\"\u2028\u2029\u0085]/g; - var escapedCharsMap = { - "\t": "\\t", - "\v": "\\v", - "\f": "\\f", - "\b": "\\b", - "\0": "\\0", - "\r": "\\r", - "\n": "\\n", - "\"": "\\\"", - "\u2028": "\\u2028", - "\u2029": "\\u2029", - "\u0085": "\\u0085" - }; function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) { if (typeof JSON !== "undefined") { return JSON.stringify({ @@ -6399,26 +7179,21 @@ var ts; mappings: mappings }); } - return "{\"version\":" + version + ",\"file\":\"" + escapeString(file) + "\",\"sourceRoot\":\"" + escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + escapeString(mappings) + "\"}"; - function escapeString(s) { - return escapedCharsRegExp.test(s) ? s.replace(escapedCharsRegExp, function (c) { - return escapedCharsMap[c] || c; - }) : s; - } + return "{\"version\":" + version + ",\"file\":\"" + ts.escapeString(file) + "\",\"sourceRoot\":\"" + ts.escapeString(sourceRoot) + "\",\"sources\":[" + serializeStringArray(sources) + "],\"names\":[" + serializeStringArray(names) + "],\"mappings\":\"" + ts.escapeString(mappings) + "\"}"; function serializeStringArray(list) { var output = ""; for (var i = 0, n = list.length; i < n; i++) { if (i) { output += ","; } - output += "\"" + escapeString(list[i]) + "\""; + output += "\"" + ts.escapeString(list[i]) + "\""; } return output; } } function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) { encodeLastRecordedSourceMapSpan(); - writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); + writeFile(compilerHost, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false); sourceMapDataList.push(sourceMapData); writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark); } @@ -6441,11 +7216,11 @@ var ts; if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); if (root) { - sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(sourceMapDir, root)); + sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, program, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { sourceMapDir = ts.combinePaths(program.getCommonSourceDirectory(), sourceMapDir); - sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), compilerHost.getCurrentDirectory(), true); + sourceMapData.jsSourceMappingURL = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(jsFilePath)), ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL), compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, true); } else { sourceMapData.jsSourceMappingURL = ts.combinePaths(sourceMapDir, sourceMapData.jsSourceMappingURL); @@ -6477,7 +7252,7 @@ var ts; writeComment = writeCommentRangeWithMap; } function writeJavaScriptFile(emitOutput, writeByteOrderMark) { - writeFile(jsFilePath, emitOutput, writeByteOrderMark); + writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function emitTokenText(tokenKind, startPos, emitFn) { var tokenString = ts.tokenToString(tokenKind); @@ -6495,25 +7270,42 @@ var ts; emit(node); } } - function emitCommaList(nodes, count) { - if (!(count >= 0)) - count = nodes.length; - if (nodes) { - for (var i = 0; i < count; i++) { - if (i) - write(", "); - emit(nodes[i]); + function emitTrailingCommaIfPresent(nodeList, isMultiline) { + if (nodeList.hasTrailingComma) { + write(","); + if (isMultiline) { + writeLine(); } } } - function emitMultiLineList(nodes) { + function emitCommaList(nodes, includeTrailingComma, count) { + if (!(count >= 0)) { + count = nodes.length; + } + if (nodes) { + for (var i = 0; i < count; i++) { + if (i) { + write(", "); + } + emit(nodes[i]); + } + if (includeTrailingComma) { + emitTrailingCommaIfPresent(nodes, false); + } + } + } + function emitMultiLineList(nodes, includeTrailingComma) { if (nodes) { for (var i = 0; i < nodes.length; i++) { - if (i) + if (i) { write(","); + } writeLine(); emit(nodes[i]); } + if (includeTrailingComma) { + emitTrailingCommaIfPresent(nodes, true); + } } } function emitLines(nodes) { @@ -6526,7 +7318,7 @@ var ts; } } function emitLiteral(node) { - var text = getSourceTextOfLocalNode(node); + var text = getSourceTextOfLocalNode(currentSourceFile, node); if (node.kind === 7 /* StringLiteral */ && compilerOptions.sourceMap) { writer.writeLiteral(text); } @@ -6544,7 +7336,7 @@ var ts; write(node.text); } else { - write(getSourceTextOfLocalNode(node)); + write(getSourceTextOfLocalNode(currentSourceFile, node)); } write("\""); } @@ -6586,7 +7378,7 @@ var ts; write("."); } } - write(getSourceTextOfLocalNode(node)); + write(getSourceTextOfLocalNode(currentSourceFile, node)); } function emitThis(node) { if (resolver.getNodeCheckFlags(node) & 2 /* LexicalThis */) { @@ -6612,14 +7404,14 @@ var ts; if (node.flags & 256 /* MultiLine */) { write("["); increaseIndent(); - emitMultiLineList(node.elements); + emitMultiLineList(node.elements, true); decreaseIndent(); writeLine(); write("]"); } else { write("["); - emitCommaList(node.elements); + emitCommaList(node.elements, true); write("]"); } } @@ -6630,14 +7422,14 @@ var ts; else if (node.flags & 256 /* MultiLine */) { write("{"); increaseIndent(); - emitMultiLineList(node.properties); + emitMultiLineList(node.properties, compilerOptions.target >= 1 /* ES5 */); decreaseIndent(); writeLine(); write("}"); } else { write("{ "); - emitCommaList(node.properties); + emitCommaList(node.properties, compilerOptions.target >= 1 /* ES5 */); write(" }"); } } @@ -6649,14 +7441,15 @@ var ts; emitTrailingComments(node); } function emitPropertyAccess(node) { - var text = resolver.getPropertyAccessSubstitution(node); - if (text) { - write(text); - return; + var constantValue = resolver.getConstantValue(node); + if (constantValue !== undefined) { + write(constantValue.toString() + " /* " + ts.identifierToString(node.right) + " */"); + } + else { + emit(node.left); + write("."); + emit(node.right); } - emit(node.left); - write("."); - emit(node.right); } function emitIndexedAccess(node) { emit(node.object); @@ -6679,13 +7472,13 @@ var ts; emitThis(node.func); if (node.arguments.length) { write(", "); - emitCommaList(node.arguments); + emitCommaList(node.arguments, false); } write(")"); } else { write("("); - emitCommaList(node.arguments); + emitCommaList(node.arguments, false); write(")"); } } @@ -6694,7 +7487,7 @@ var ts; emit(node.func); if (node.arguments) { write("("); - emitCommaList(node.arguments); + emitCommaList(node.arguments, false); write(")"); } } @@ -6833,7 +7626,7 @@ var ts; if (node.declarations) { emitToken(92 /* VarKeyword */, endPos); write(" "); - emitCommaList(node.declarations); + emitCommaList(node.declarations, false); } if (node.initializer) { emit(node.initializer); @@ -6967,7 +7760,7 @@ var ts; emitLeadingComments(node); if (!(node.flags & 1 /* Export */)) write("var "); - emitCommaList(node.declarations); + emitCommaList(node.declarations, false); write(";"); emitTrailingComments(node); } @@ -7067,7 +7860,7 @@ var ts; increaseIndent(); write("("); if (node) { - emitCommaList(node.parameters, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); + emitCommaList(node.parameters, false, node.parameters.length - (ts.hasRestParameters(node) ? 1 : 0)); } write(")"); decreaseIndent(); @@ -7791,7 +8584,7 @@ var ts; return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos; } function getLeadingCommentsWithoutDetachedComments() { - var leadingComments = ts.getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos); if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -7807,20 +8600,20 @@ var ts; leadingComments = getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingCommentsOfNode(node, currentSourceFile); + leadingComments = ts.getLeadingCommentRangesOfNode(node, currentSourceFile); } return leadingComments; } } function emitLeadingDeclarationComments(node) { var leadingComments = getLeadingCommentsToEmit(node); - emitNewLineBeforeLeadingComments(node, leadingComments, writer); - emitComments(leadingComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitTrailingDeclarationComments(node) { if (node.parent.kind === 182 /* SourceFile */ || node.end !== node.parent.end) { - var trailingComments = ts.getTrailingComments(currentSourceFile.text, node.end); - emitComments(trailingComments, false, writer, writeComment); + var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); + emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment); } } function emitLeadingCommentsOfLocalPosition(pos) { @@ -7829,20 +8622,20 @@ var ts; leadingComments = getLeadingCommentsWithoutDetachedComments(); } else { - leadingComments = ts.getLeadingComments(currentSourceFile.text, pos); + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos); } - emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer); - emitComments(leadingComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); + emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } function emitDetachedCommentsAtPosition(node) { - var leadingComments = ts.getLeadingComments(currentSourceFile.text, node.pos); + var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); if (leadingComments) { var detachedComments = []; var lastComment; ts.forEach(leadingComments, function (comment) { if (lastComment) { - var lastCommentLine = getLineOfLocalPosition(lastComment.end); - var commentLine = getLineOfLocalPosition(comment.pos); + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); if (commentLine >= lastCommentLine + 2) { return detachedComments; } @@ -7851,11 +8644,11 @@ var ts; lastComment = comment; }); if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPosition(detachedComments[detachedComments.length - 1].end); - var astLine = getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node.pos)); + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end); + var astLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); if (astLine >= lastCommentLine + 2) { - emitNewLineBeforeLeadingComments(node, leadingComments, writer); - emitComments(detachedComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end }; if (detachedCommentsInfo) { detachedCommentsInfo.push(currentDetachedCommentInfo); @@ -7877,8 +8670,8 @@ var ts; return true; } } - emitNewLineBeforeLeadingComments(node, pinnedComments, writer); - emitComments(pinnedComments, true, writer, writeComment); + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments); + emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment); } if (compilerOptions.sourceMap) { initializeEmitterWithSourceMaps(); @@ -7896,700 +8689,35 @@ var ts; writeLine(); writeEmittedFiles(writer.getText(), compilerOptions.emitBOM); } - function emitDeclarations(jsFilePath, root) { - var writer = createTextWriter(writeSymbol); - var write = writer.write; - var writeLine = writer.writeLine; - var increaseIndent = writer.increaseIndent; - var decreaseIndent = writer.decreaseIndent; - var enclosingDeclaration; - var reportedDeclarationError = false; - var emitJsDocComments = compilerOptions.removeComments ? function (declaration) { - } : writeJsDocComments; - var aliasDeclarationEmitInfo = []; - var getSymbolVisibilityDiagnosticMessage; - function writeAsychronousImportDeclarations(importDeclarations) { - var oldWriter = writer; - ts.forEach(importDeclarations, function (aliasToWrite) { - var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; }); - writer = createTextWriter(writeSymbol); - for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) { - writer.increaseIndent(); - } - writeImportDeclaration(aliasToWrite); - aliasEmitInfo.asynchronousOutput = writer.getText(); - }); - writer = oldWriter; - } - function writeSymbol(symbol, enclosingDeclaration, meaning) { - var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning); - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - resolver.writeSymbol(symbol, enclosingDeclaration, meaning, writer); - if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult); - if (errorInfo) { - if (errorInfo.typeName) { - diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, getSourceTextOfLocalNode(errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - else { - diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName)); - } - } - } - } - function emitLines(nodes) { - for (var i = 0, n = nodes.length; i < n; i++) { - emitNode(nodes[i]); - } - } - function emitCommaList(nodes, eachNodeEmitFn) { - var currentWriterPos = writer.getTextPos(); - for (var i = 0, n = nodes.length; i < n; i++) { - if (currentWriterPos !== writer.getTextPos()) { - write(", "); - } - currentWriterPos = writer.getTextPos(); - eachNodeEmitFn(nodes[i]); - } - } - function writeJsDocComments(declaration) { - if (declaration) { - var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile); - emitNewLineBeforeLeadingComments(declaration, jsDocComments, writer); - emitComments(jsDocComments, true, writer, writeCommentRange); - } - } - function emitSourceTextOfNode(node) { - write(getSourceTextOfLocalNode(node)); - } - function emitSourceFile(node) { - currentSourceFile = node; - enclosingDeclaration = node; - emitLines(node.statements); - } - function emitExportAssignment(node) { - write("export = "); - emitSourceTextOfNode(node.exportName); - write(";"); - writeLine(); - } - function emitDeclarationFlags(node) { - if (node.flags & 128 /* Static */) { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - write("static "); - } - else { - if (node.flags & 32 /* Private */) { - write("private "); - } - else if (node.flags & 64 /* Protected */) { - write("protected "); - } - else if (node.parent === currentSourceFile) { - if (node.flags & 1 /* Export */) { - write("export "); - } - if (node.kind !== 175 /* InterfaceDeclaration */) { - write("declare "); - } - } - } - } - function emitImportDeclaration(node) { - var nodeEmitInfo = { - declaration: node, - outputPos: writer.getTextPos(), - indent: writer.getIndent(), - hasWritten: resolver.isDeclarationVisible(node) - }; - aliasDeclarationEmitInfo.push(nodeEmitInfo); - if (nodeEmitInfo.hasWritten) { - writeImportDeclaration(node); - } - } - function writeImportDeclaration(node) { - emitJsDocComments(node); - if (node.flags & 1 /* Export */) { - writer.write("export "); - } - writer.write("import "); - writer.write(getSourceTextOfLocalNode(node.name)); - writer.write(" = "); - if (node.entityName) { - checkEntityNameAccessible(); - writer.write(getSourceTextOfLocalNode(node.entityName)); - writer.write(";"); - } - else { - writer.write("require("); - writer.write(getSourceTextOfLocalNode(node.externalModuleName)); - writer.write(");"); - } - writer.writeLine(); - function checkEntityNameAccessible() { - var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisibile(node.entityName); - if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) { - if (symbolAccesibilityResult.aliasesToMakeVisible) { - writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible); - } - } - else { - reportedDeclarationError = true; - diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Import_declaration_0_is_using_private_name_1, getSourceTextOfLocalNode(node.name), symbolAccesibilityResult.errorSymbolName)); - } - } - } - function emitModuleDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("module "); - emitSourceTextOfNode(node.name); - while (node.body.kind !== 178 /* ModuleBlock */) { - node = node.body; - write("."); - emitSourceTextOfNode(node.name); - } - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.body.statements); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitEnumDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("enum "); - emitSourceTextOfNode(node.name); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - } - } - function emitEnumMemberDeclaration(node) { - emitJsDocComments(node); - emitSourceTextOfNode(node.name); - var enumMemberValue = resolver.getEnumMemberValue(node); - if (enumMemberValue !== undefined) { - write(" = "); - write(enumMemberValue.toString()); - } - write(","); - writeLine(); - } - function emitTypeParameters(typeParameters) { - function emitTypeParameter(node) { - function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 174 /* ClassDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; - break; - case 175 /* InterfaceDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; - break; - case 125 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 124 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 120 /* Method */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 172 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for type parameter: " + ts.SyntaxKind[node.parent.kind]); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - increaseIndent(); - emitJsDocComments(node); - decreaseIndent(); - emitSourceTextOfNode(node.name); - if (node.constraint && (node.parent.kind !== 120 /* Method */ || !(node.parent.flags & 32 /* Private */))) { - write(" extends "); - getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError; - resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - } - if (typeParameters) { - write("<"); - emitCommaList(typeParameters, emitTypeParameter); - write(">"); - } - } - function emitHeritageClause(typeReferences, isImplementsList) { - if (typeReferences) { - write(isImplementsList ? " implements " : " extends "); - emitCommaList(typeReferences, emitTypeOfTypeReference); - } - function emitTypeOfTypeReference(node) { - getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer); - function getHeritageClauseVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.parent.kind === 174 /* ClassDeclaration */) { - if (symbolAccesibilityResult.errorModuleName) { - diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; - } - else { - diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } - } - else { - if (symbolAccesibilityResult.errorModuleName) { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2; - } - else { - diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.parent.name - }; - } - } - } - function emitClassDeclaration(node) { - function emitParameterProperties(constructorDeclaration) { - if (constructorDeclaration) { - ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & ts.NodeFlags.AccessibilityModifier) { - emitPropertyDeclaration(param); - } - }); - } - } - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("class "); - emitSourceTextOfNode(node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - if (node.baseType) { - emitHeritageClause([node.baseType], false); - } - emitHeritageClause(node.implementedTypes, true); - write(" {"); - writeLine(); - increaseIndent(); - emitParameterProperties(getFirstConstructorWithBody(node)); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitInterfaceDeclaration(node) { - if (resolver.isDeclarationVisible(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("interface "); - emitSourceTextOfNode(node.name); - var prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; - emitTypeParameters(node.typeParameters); - emitHeritageClause(node.baseTypes, false); - write(" {"); - writeLine(); - increaseIndent(); - emitLines(node.members); - decreaseIndent(); - write("}"); - writeLine(); - enclosingDeclaration = prevEnclosingDeclaration; - } - } - function emitPropertyDeclaration(node) { - emitJsDocComments(node); - emitDeclarationFlags(node); - emitVariableDeclaration(node); - write(";"); - writeLine(); - } - function emitVariableDeclaration(node) { - if (node.kind !== 171 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { - emitSourceTextOfNode(node.name); - if (node.kind === 119 /* Property */ && (node.flags & 4 /* QuestionMark */)) { - write("?"); - } - if (!(node.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - } - function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 171 /* VariableDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; - } - else if (node.kind === 119 /* Property */) { - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; - } - } - return diagnosticMessage !== undefined ? { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - } : undefined; - } - } - function emitVariableStatement(node) { - var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); }); - if (hasDeclarationWithEmit) { - emitJsDocComments(node); - emitDeclarationFlags(node); - write("var "); - emitCommaList(node.declarations, emitVariableDeclaration); - write(";"); - writeLine(); - } - } - function emitAccessorDeclaration(node) { - var accessors = getAllAccessorDeclarations(node.parent, node); - if (node === accessors.firstAccessor) { - emitJsDocComments(accessors.getAccessor); - emitJsDocComments(accessors.setAccessor); - emitDeclarationFlags(node); - emitSourceTextOfNode(node.name); - if (!(node.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - write(";"); - writeLine(); - } - function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - if (node.kind === 123 /* SetAccessor */) { - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.parameters[0], - typeName: node.name - }; - } - else { - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name, - typeName: undefined - }; - } - } - } - function emitFunctionDeclaration(node) { - if ((node.kind !== 172 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { - emitJsDocComments(node); - emitDeclarationFlags(node); - if (node.kind === 172 /* FunctionDeclaration */) { - write("function "); - emitSourceTextOfNode(node.name); - } - else if (node.kind === 121 /* Constructor */) { - write("constructor"); - } - else { - emitSourceTextOfNode(node.name); - if (node.flags & 4 /* QuestionMark */) { - write("?"); - } - } - emitSignatureDeclaration(node); - } - } - function emitConstructSignatureDeclaration(node) { - emitJsDocComments(node); - write("new "); - emitSignatureDeclaration(node); - } - function emitSignatureDeclaration(node) { - if (node.kind === 124 /* CallSignature */ || node.kind === 126 /* IndexSignature */) { - emitJsDocComments(node); - } - emitTypeParameters(node.typeParameters); - if (node.kind === 126 /* IndexSignature */) { - write("["); - } - else { - write("("); - } - emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 126 /* IndexSignature */) { - write("]"); - } - else { - write(")"); - } - if (node.kind !== 121 /* Constructor */ && !(node.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError; - resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - write(";"); - writeLine(); - function getReturnTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.kind) { - case 125 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 124 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 126 /* IndexSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; - break; - case 120 /* Method */: - if (node.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; - } - else if (node.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; - } - break; - case 172 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; - break; - default: - ts.Debug.fail("This is unknown kind for signature: " + ts.SyntaxKind[node.kind]); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node.name || node - }; - } - } - function emitParameterDeclaration(node) { - increaseIndent(); - emitJsDocComments(node); - if (node.flags & 8 /* Rest */) { - write("..."); - } - emitSourceTextOfNode(node.name); - if (node.initializer || (node.flags & 4 /* QuestionMark */)) { - write("?"); - } - decreaseIndent(); - if (!(node.parent.flags & 32 /* Private */)) { - write(": "); - getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError; - resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); - } - function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { - var diagnosticMessage; - switch (node.parent.kind) { - case 121 /* Constructor */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - break; - case 125 /* ConstructSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 124 /* CallSignature */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - break; - case 120 /* Method */: - if (node.parent.flags & 128 /* Static */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; - } - else if (node.parent.parent.kind === 174 /* ClassDeclaration */) { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; - } - else { - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; - } - break; - case 172 /* FunctionDeclaration */: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - break; - default: - ts.Debug.fail("This is unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); - } - return { - diagnosticMessage: diagnosticMessage, - errorNode: node, - typeName: node.name - }; - } - } - function emitNode(node) { - switch (node.kind) { - case 121 /* Constructor */: - case 172 /* FunctionDeclaration */: - case 120 /* Method */: - return emitFunctionDeclaration(node); - case 125 /* ConstructSignature */: - return emitConstructSignatureDeclaration(node); - case 124 /* CallSignature */: - case 126 /* IndexSignature */: - return emitSignatureDeclaration(node); - case 122 /* GetAccessor */: - case 123 /* SetAccessor */: - return emitAccessorDeclaration(node); - case 149 /* VariableStatement */: - return emitVariableStatement(node); - case 119 /* Property */: - return emitPropertyDeclaration(node); - case 175 /* InterfaceDeclaration */: - return emitInterfaceDeclaration(node); - case 174 /* ClassDeclaration */: - return emitClassDeclaration(node); - case 181 /* EnumMember */: - return emitEnumMemberDeclaration(node); - case 176 /* EnumDeclaration */: - return emitEnumDeclaration(node); - case 177 /* ModuleDeclaration */: - return emitModuleDeclaration(node); - case 179 /* ImportDeclaration */: - return emitImportDeclaration(node); - case 180 /* ExportAssignment */: - return emitExportAssignment(node); - case 182 /* SourceFile */: - return emitSourceFile(node); - } - } - function resolveScriptReference(sourceFile, reference) { - var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename)); - return program.getSourceFile(referenceFileName); - } - var referencePathsOutput = ""; - function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.getModuleNameFromFilename(compilerOptions.out) + ".d.ts"; - declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), false); - referencePathsOutput += "/// " + newLine; - } - if (root) { - if (!compilerOptions.noResolve) { - var addedGlobalFileReference = false; - ts.forEach(root.referencedFiles, function (fileReference) { - var referencedFile = resolveScriptReference(root, fileReference); - if ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference) { - writeReferencePath(referencedFile); - if (!isExternalModuleOrDeclarationFile(referencedFile)) { - addedGlobalFileReference = true; - } - } - }); - } - emitNode(root); - } - else { - var emittedReferencedFiles = []; - ts.forEach(program.getSourceFiles(), function (sourceFile) { - if (!isExternalModuleOrDeclarationFile(sourceFile)) { - if (!compilerOptions.noResolve) { - ts.forEach(sourceFile.referencedFiles, function (fileReference) { - var referencedFile = resolveScriptReference(sourceFile, fileReference); - if (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile)) { - writeReferencePath(referencedFile); - emittedReferencedFiles.push(referencedFile); - } - }); - } - emitNode(sourceFile); - } - }); - } - if (!reportedDeclarationError) { - var declarationOutput = referencePathsOutput; - var synchronousDeclarationOutput = writer.getText(); - var appliedSyncOutputPos = 0; - ts.forEach(aliasDeclarationEmitInfo, function (aliasEmitInfo) { - if (aliasEmitInfo.asynchronousOutput) { - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos); - declarationOutput += aliasEmitInfo.asynchronousOutput; - appliedSyncOutputPos = aliasEmitInfo.outputPos; - } - }); - declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos); - writeFile(ts.getModuleNameFromFilename(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM); - } - } var hasSemanticErrors = resolver.hasSemanticErrors(); function emitFile(jsFilePath, sourceFile) { emitJavaScript(jsFilePath, sourceFile); if (!hasSemanticErrors && compilerOptions.declaration) { - emitDeclarations(jsFilePath, sourceFile); + var emitDeclarationResult = emitDeclarations(program, resolver, diagnostics, jsFilePath, sourceFile); + if (!emitDeclarationResult.reportedDeclarationError) { + writeDeclarationToFile(compilerHost, compilerOptions, diagnostics, emitDeclarationResult.aliasDeclarationEmitInfo, emitDeclarationResult.synchronousDeclarationOutput, jsFilePath, emitDeclarationResult.declarationOutput); + } } } if (targetSourceFile === undefined) { ts.forEach(program.getSourceFiles(), function (sourceFile) { if (shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js"); + var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js"); emitFile(jsFilePath, sourceFile); } }); + if (compilerOptions.out) { + emitFile(compilerOptions.out); + } } else { - var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js"); - emitFile(jsFilePath, targetSourceFile); - } - if (compilerOptions.out) { - emitFile(compilerOptions.out); + if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { + var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js"); + emitFile(jsFilePath, targetSourceFile); + } + else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { + emitFile(compilerOptions.out); + } } diagnostics.sort(ts.compareDiagnostics); diagnostics = ts.deduplicateSortedDiagnostics(diagnostics); @@ -8631,6 +8759,27 @@ var ts; return undefined; } ts.getDeclarationOfKind = getDeclarationOfKind; + var stringWriters = []; + function getSingleLineStringWriter() { + if (stringWriters.length == 0) { + var str = ""; + return { + string: function () { return str; }, + writeKind: function (text) { return str += text; }, + writeSymbol: function (text) { return str += text; }, + writeLine: function () { return str += " "; }, + increaseIndent: function () { + }, + decreaseIndent: function () { + }, + clear: function () { return str = ""; }, + trackSymbol: function () { + } + }; + } + return stringWriters.pop(); + } + ts.getSingleLineStringWriter = getSingleLineStringWriter; function createTypeChecker(program, fullTypeCheck) { var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); @@ -8642,6 +8791,7 @@ var ts; var checker = { getProgram: function () { return program; }, getDiagnostics: getDiagnostics, + getDeclarationDiagnostics: getDeclarationDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getNodeCount: function () { return ts.sum(program.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(program.getSourceFiles(), "identifierCount"); }, @@ -8661,11 +8811,24 @@ var ts; getTypeOfNode: getTypeOfNode, getApparentType: getApparentType, typeToString: typeToString, + writeType: writeType, symbolToString: symbolToString, + writeSymbol: writeSymbol, getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType, getRootSymbol: getRootSymbol, getContextualType: getContextualType, - getFullyQualifiedName: getFullyQualifiedName + getFullyQualifiedName: getFullyQualifiedName, + getResolvedSignature: getResolvedSignature, + getEnumMemberValue: getEnumMemberValue, + isValidPropertyAccess: isValidPropertyAccess, + getSignatureFromDeclaration: getSignatureFromDeclaration, + writeSignature: writeSignature, + writeTypeParameter: writeTypeParameter, + writeTypeParametersOfSymbol: writeTypeParametersOfSymbol, + isImplementationOfOverload: isImplementationOfOverload, + getAliasedSymbol: resolveImport, + isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, + isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; } }; var undefinedSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "undefined"); var argumentsSymbol = createSymbol(2 /* Property */ | 33554432 /* Transient */, "arguments"); @@ -9205,13 +9368,13 @@ var ts; function getQualifiedLeftMeaning(rightMeaning) { return rightMeaning === ts.SymbolFlags.Value ? ts.SymbolFlags.Value : ts.SymbolFlags.Namespace; } - function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning) { + function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { function getAccessibleSymbolChainFromSymbolTable(symbols) { function canQualifySymbol(symbolFromSymbolTable, meaning) { if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { return true; } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning)); + var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); return !!accessibleParent; } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { @@ -9224,13 +9387,15 @@ var ts; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 4194304 /* Import */) { - var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 179 /* ImportDeclaration */ && declaration.externalModuleName; })) { + var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } } } }); @@ -9263,7 +9428,7 @@ var ts; var initialSymbol = symbol; var meaningToLook = meaning; while (symbol) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaningToLook, false); if (accessibleSymbolChain) { var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0]); if (!hasAccessibleDeclarations) { @@ -9331,139 +9496,157 @@ var ts; return true; } } - function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName) { + function isImportDeclarationEntityNameReferenceDeclarationVisible(entityName) { var firstIdentifier = getFirstIdentifier(entityName); var firstIdentifierName = ts.identifierToString(firstIdentifier); var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, ts.SymbolFlags.Namespace, ts.Diagnostics.Cannot_find_name_0, firstIdentifierName); var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace); return hasNamespaceDeclarationsVisibile ? { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } : { accessibility: 1 /* NotAccessible */, errorSymbolName: firstIdentifierName }; } + function releaseStringWriter(writer) { + writer.clear(); + stringWriters.push(writer); + } + function writeKeyword(writer, kind) { + writer.writeKind(ts.tokenToString(kind), 5 /* keyword */); + } + function writePunctuation(writer, kind) { + writer.writeKind(ts.tokenToString(kind), 15 /* punctuation */); + } + function writeOperator(writer, kind) { + writer.writeKind(ts.tokenToString(kind), 12 /* operator */); + } + function writeSpace(writer) { + writer.writeKind(" ", 16 /* space */); + } function symbolToString(symbol, enclosingDeclaration, meaning) { - function getSymbolName(symbol) { + var writer = getSingleLineStringWriter(); + writeSymbol(symbol, writer, enclosingDeclaration, meaning); + var result = writer.string(); + releaseStringWriter(writer); + return result; + } + function writeSymbol(symbol, writer, enclosingDeclaration, meaning, flags) { + var parentSymbol; + function writeSymbolName(symbol) { + if (parentSymbol) { + if (flags & 1 /* WriteTypeParametersOrArguments */) { + if (symbol.flags & 8388608 /* Instantiated */) { + writeTypeArguments(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); + } + else { + writeTypeParametersOfSymbol(parentSymbol, writer, enclosingDeclaration); + } + } + writePunctuation(writer, 15 /* DotToken */); + } + parentSymbol = symbol; if (symbol.declarations && symbol.declarations.length > 0) { var declaration = symbol.declarations[0]; if (declaration.name) { - return ts.identifierToString(declaration.name); + writer.writeSymbol(ts.identifierToString(declaration.name), symbol); + return; } } - return symbol.name; + writer.writeSymbol(symbol.name, symbol); } - if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { - var symbolName; - while (symbol) { - var isFirstName = !symbolName; - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning); - var currentSymbolName; + writer.trackSymbol(symbol, enclosingDeclaration, meaning); + function walkSymbol(symbol, meaning) { + if (symbol) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2 /* UseOnlyExternalAliasing */)); + if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); + } if (accessibleSymbolChain) { - currentSymbolName = ts.map(accessibleSymbolChain, function (accessibleSymbol) { return getSymbolName(accessibleSymbol); }).join("."); + for (var i = 0, n = accessibleSymbolChain.length; i < n; i++) { + writeSymbolName(accessibleSymbolChain[i]); + } } else { - if (!isFirstName && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { - break; + if (!parentSymbol && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { + return; } - currentSymbolName = getSymbolName(symbol); - } - symbolName = currentSymbolName + (isFirstName ? "" : ("." + symbolName)); - if (accessibleSymbolChain && !needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - break; - } - symbol = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - meaning = getQualifiedLeftMeaning(meaning); - } - return symbolName; - } - return getSymbolName(symbol); - } - function writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, writer) { - writer.write(symbolToString(symbol, enclosingDeclaration, meaning)); - } - function createSingleLineTextWriter(maxLength) { - var result = ""; - var overflow = false; - function write(s) { - if (!overflow) { - result += s; - if (result.length > maxLength) { - result = result.substr(0, maxLength - 3) + "..."; - overflow = true; + if (symbol.flags & 512 /* TypeLiteral */ || symbol.flags & 1024 /* ObjectLiteral */) { + return; + } + writeSymbolName(symbol); } } } - return { - write: write, - writeSymbol: function (symbol, enclosingDeclaration, meaning) { - writeSymbolToTextWriter(symbol, enclosingDeclaration, meaning, this); - }, - writeLine: function () { - write(" "); - }, - increaseIndent: function () { - }, - decreaseIndent: function () { - }, - getText: function () { - return result; - } - }; + if (enclosingDeclaration && !(symbol.flags & 262144 /* TypeParameter */)) { + walkSymbol(symbol, meaning); + return; + } + return writeSymbolName(symbol); } function typeToString(type, enclosingDeclaration, flags) { + var writer = getSingleLineStringWriter(); + writeType(type, writer, enclosingDeclaration, flags); + var result = writer.string(); + releaseStringWriter(writer); var maxLength = compilerOptions.noErrorTruncation || flags & 4 /* NoTruncation */ ? undefined : 100; - var stringWriter = createSingleLineTextWriter(maxLength); - writeTypeToTextWriter(type, enclosingDeclaration, flags, stringWriter); - return stringWriter.getText(); + if (maxLength && result.length >= maxLength) { + result = result.substr(0, maxLength - "...".length) + "..."; + } + return result; } - function writeTypeToTextWriter(type, enclosingDeclaration, flags, writer) { - var typeStack; - return writeType(type, true); - function writeType(type, allowFunctionOrConstructorTypeLiteral) { + function writeType(type, writer, enclosingDeclaration, flags, typeStack) { + return writeType(type, flags | 8 /* WriteArrowStyleSignature */); + function writeType(type, flags) { if (type.flags & ts.TypeFlags.Intrinsic) { - writer.write(type.intrinsicName); + writer.writeKind(!(flags & 16 /* WriteOwnNameForAnyLike */) && (type.flags & 1 /* Any */) ? "any" : type.intrinsicName, 5 /* keyword */); } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type); } else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - writer.writeSymbol(type.symbol, enclosingDeclaration, ts.SymbolFlags.Type); + writeSymbol(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); } else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); } else if (type.flags & 16384 /* Anonymous */) { - writeAnonymousType(type, allowFunctionOrConstructorTypeLiteral); + writeAnonymousType(type, flags); } else if (type.flags & 256 /* StringLiteral */) { - writer.write(type.text); + writer.writeKind(type.text, 8 /* stringLiteral */); } else { - writer.write("{ ... }"); + writePunctuation(writer, 9 /* OpenBraceToken */); + writeSpace(writer); + writePunctuation(writer, 16 /* DotDotDotToken */); + writeSpace(writer); + writePunctuation(writer, 10 /* CloseBraceToken */); } } function writeTypeList(types) { for (var i = 0; i < types.length; i++) { if (i > 0) { - writer.write(", "); + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); } - writeType(types[i], true); + writeType(types[i], flags | 8 /* WriteArrowStyleSignature */); } } function writeTypeReference(type) { if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { - writeType(type.typeArguments[0], false); - writer.write("[]"); + writeType(type.typeArguments[0], flags & ~8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 14 /* CloseBracketToken */); } else { - writer.writeSymbol(type.target.symbol, enclosingDeclaration, ts.SymbolFlags.Type); - writer.write("<"); + writeSymbol(type.target.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); + writePunctuation(writer, 19 /* LessThanToken */); writeTypeList(type.typeArguments); - writer.write(">"); + writePunctuation(writer, 20 /* GreaterThanToken */); } } function writeTupleType(type) { - writer.write("["); + writePunctuation(writer, 13 /* OpenBracketToken */); writeTypeList(type.elementTypes); - writer.write("]"); + writePunctuation(writer, 14 /* CloseBracketToken */); } - function writeAnonymousType(type, allowFunctionOrConstructorTypeLiteral) { + function writeAnonymousType(type, flags) { if (type.symbol && type.symbol.flags & (16 /* Class */ | 64 /* Enum */ | 128 /* ValueModule */)) { writeTypeofSymbol(type); } @@ -9471,14 +9654,14 @@ var ts; writeTypeofSymbol(type); } else if (typeStack && ts.contains(typeStack, type)) { - writer.write("any"); + writeKeyword(writer, 105 /* AnyKeyword */); } else { if (!typeStack) { typeStack = []; } typeStack.push(type); - writeLiteralType(type, allowFunctionOrConstructorTypeLiteral); + writeLiteralType(type, flags); typeStack.pop(); } function shouldWriteTypeOfFunctionSymbol() { @@ -9492,52 +9675,70 @@ var ts; } } function writeTypeofSymbol(type) { - writer.write("typeof "); - writer.writeSymbol(type.symbol, enclosingDeclaration, ts.SymbolFlags.Value); + writeKeyword(writer, 91 /* TypeOfKeyword */); + writeSpace(writer); + writeSymbol(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Value); } - function writeLiteralType(type, allowFunctionOrConstructorTypeLiteral) { + function writeLiteralType(type, flags) { var resolved = resolveObjectTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writer.write("{}"); + writePunctuation(writer, 9 /* OpenBraceToken */); + writePunctuation(writer, 10 /* CloseBraceToken */); return; } - if (allowFunctionOrConstructorTypeLiteral) { + if (flags & 8 /* WriteArrowStyleSignature */) { if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - writeSignature(resolved.callSignatures[0], true); + writeSignature(resolved.callSignatures[0], writer, enclosingDeclaration, flags, typeStack); return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - writer.write("new "); - writeSignature(resolved.constructSignatures[0], true); + writeKeyword(writer, 82 /* NewKeyword */); + writeSpace(writer); + writeSignature(resolved.constructSignatures[0], writer, enclosingDeclaration, flags, typeStack); return; } } } - writer.write("{"); + writePunctuation(writer, 9 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var i = 0; i < resolved.callSignatures.length; i++) { - writeSignature(resolved.callSignatures[i]); - writer.write(";"); + writeSignature(resolved.callSignatures[i], writer, enclosingDeclaration, flags & ~8 /* WriteArrowStyleSignature */, typeStack); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.constructSignatures.length; i++) { - writer.write("new "); - writeSignature(resolved.constructSignatures[i]); - writer.write(";"); + writeKeyword(writer, 82 /* NewKeyword */); + writeSpace(writer); + writeSignature(resolved.constructSignatures[i], writer, enclosingDeclaration, flags & ~8 /* WriteArrowStyleSignature */, typeStack); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { - writer.write("[x: string]: "); - writeType(resolved.stringIndexType, true); - writer.write(";"); + writePunctuation(writer, 13 /* OpenBracketToken */); + writer.writeKind("x", 13 /* parameterName */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 114 /* StringKeyword */); + writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(resolved.stringIndexType, flags | 8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { - writer.write("[x: number]: "); - writeType(resolved.numberIndexType, true); - writer.write(";"); + writePunctuation(writer, 13 /* OpenBracketToken */); + writer.writeKind("x", 13 /* parameterName */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeKeyword(writer, 112 /* NumberKeyword */); + writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(resolved.numberIndexType, flags | 8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.properties.length; i++) { @@ -9546,66 +9747,109 @@ var ts; if (p.flags & (8 /* Function */ | 2048 /* Method */) && !getPropertiesOfType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); for (var j = 0; j < signatures.length; j++) { - writer.writeSymbol(p); + writeSymbol(p, writer); if (isOptionalProperty(p)) { - writer.write("?"); + writePunctuation(writer, 45 /* QuestionToken */); } - writeSignature(signatures[j]); - writer.write(";"); + writeSignature(signatures[j], writer, enclosingDeclaration, flags & ~8 /* WriteArrowStyleSignature */, typeStack); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } } else { - writer.writeSymbol(p); + writeSymbol(p, writer); if (isOptionalProperty(p)) { - writer.write("?"); + writePunctuation(writer, 45 /* QuestionToken */); } - writer.write(": "); - writeType(t, true); - writer.write(";"); + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(t, flags | 8 /* WriteArrowStyleSignature */); + writePunctuation(writer, 17 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writer.write("}"); + writePunctuation(writer, 10 /* CloseBraceToken */); } - function writeSignature(signature, arrowStyle) { - if (signature.typeParameters) { - writer.write("<"); - for (var i = 0; i < signature.typeParameters.length; i++) { - if (i > 0) { - writer.write(", "); - } - var tp = signature.typeParameters[i]; - writer.writeSymbol(tp.symbol); - var constraint = getConstraintOfTypeParameter(tp); - if (constraint) { - writer.write(" extends "); - writeType(constraint, true); - } - } - writer.write(">"); - } - writer.write("("); - for (var i = 0; i < signature.parameters.length; i++) { + } + function writeTypeParameter(tp, writer, enclosingDeclaration, flags, typeStack) { + writeSymbol(tp.symbol, writer); + var constraint = getConstraintOfTypeParameter(tp); + if (constraint) { + writeSpace(writer); + writeKeyword(writer, 73 /* ExtendsKeyword */); + writeSpace(writer); + writeType(constraint, writer, enclosingDeclaration, flags, typeStack); + } + } + function writeTypeParameters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 19 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writer.write(", "); + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); } - var p = signature.parameters[i]; - if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { - writer.write("..."); - } - writer.writeSymbol(p); - if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { - writer.write("?"); - } - writer.write(": "); - writeType(getTypeOfSymbol(p), true); + writeTypeParameter(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); } - writer.write(arrowStyle ? ") => " : "): "); - writeType(getReturnTypeOfSignature(signature), true); + writePunctuation(writer, 20 /* GreaterThanToken */); } } + function writeTypeArguments(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { + if (typeParameters && typeParameters.length) { + writePunctuation(writer, 19 /* LessThanToken */); + for (var i = 0; i < typeParameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); + } + writeType(mapper(typeParameters[i]), writer, enclosingDeclaration, 8 /* WriteArrowStyleSignature */); + } + writePunctuation(writer, 20 /* GreaterThanToken */); + } + } + function writeTypeParametersOfSymbol(symbol, writer, enclosingDeclaraiton, flags) { + var rootSymbol = getRootSymbol(symbol); + if (rootSymbol.flags & 16 /* Class */ || rootSymbol.flags & 32 /* Interface */) { + writeTypeParameters(getTypeParametersOfClassOrInterface(symbol), writer, enclosingDeclaraiton, flags); + } + } + function writeSignature(signature, writer, enclosingDeclaration, flags, typeStack) { + if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { + writeTypeArguments(signature.target.typeParameters, signature.mapper, writer, enclosingDeclaration); + } + else { + writeTypeParameters(signature.typeParameters, writer, enclosingDeclaration, flags, typeStack); + } + writePunctuation(writer, 11 /* OpenParenToken */); + for (var i = 0; i < signature.parameters.length; i++) { + if (i > 0) { + writePunctuation(writer, 18 /* CommaToken */); + writeSpace(writer); + } + var p = signature.parameters[i]; + if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { + writePunctuation(writer, 16 /* DotDotDotToken */); + } + writeSymbol(p, writer); + if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { + writePunctuation(writer, 45 /* QuestionToken */); + } + writePunctuation(writer, 46 /* ColonToken */); + writeSpace(writer); + writeType(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); + } + writePunctuation(writer, 12 /* CloseParenToken */); + if (flags & 8 /* WriteArrowStyleSignature */) { + writeSpace(writer); + writePunctuation(writer, 27 /* EqualsGreaterThanToken */); + } + else { + writePunctuation(writer, 46 /* ColonToken */); + } + writeSpace(writer); + writeType(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); + } function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { @@ -10626,7 +10870,7 @@ var ts; if (ts.hasProperty(stringLiteralTypes, node.text)) return stringLiteralTypes[node.text]; var type = stringLiteralTypes[node.text] = createType(256 /* StringLiteral */); - type.text = ts.getSourceTextOfNode(node); + type.text = ts.getTextOfNode(node); return type; } function getTypeFromStringLiteral(node) { @@ -11754,9 +11998,17 @@ var ts; var func = parameter.parent; if (func.kind === 141 /* FunctionExpression */ || func.kind === 142 /* ArrowFunction */) { if (isContextSensitiveExpression(func)) { - var signature = getContextualSignature(func); - if (signature) { - return getTypeAtPosition(signature, ts.indexOf(func.parameters, parameter)); + var contextualSignature = getContextualSignature(func); + if (contextualSignature) { + var funcHasRestParameters = ts.hasRestParameters(func); + var len = func.parameters.length - (funcHasRestParameters ? 1 : 0); + var indexOfParameter = ts.indexOf(func.parameters, parameter); + if (indexOfParameter < len) { + return getTypeAtPosition(contextualSignature, indexOfParameter); + } + if (indexOfParameter === (func.parameters.length - 1) && funcHasRestParameters && contextualSignature.hasRestParameter && func.parameters.length >= contextualSignature.parameters.length) { + return getTypeOfSymbol(contextualSignature.parameters[contextualSignature.parameters.length - 1]); + } } } } @@ -11916,7 +12168,7 @@ var ts; return createArrayType(elementType); } function isNumericName(name) { - return !isNaN(name); + return (name !== "") && !isNaN(name); } function checkObjectLiteral(node, contextualMapper) { var members = node.symbol.members; @@ -12034,6 +12286,24 @@ var ts; } return anyType; } + function isValidPropertyAccess(node, propertyName) { + var type = checkExpression(node.left); + if (type !== unknownType && type !== anyType) { + var apparentType = getApparentType(getWidenedType(type)); + var prop = getPropertyOfApparentType(apparentType, propertyName); + if (prop && prop.parent && prop.parent.flags & 16 /* Class */) { + if (node.left.kind === 85 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 120 /* Method */) { + return false; + } + else { + var diagnosticsCount = diagnostics.length; + checkClassPropertyAccess(node, type, prop); + return diagnostics.length === diagnosticsCount; + } + } + } + return true; + } function checkIndexedAccess(node) { var objectType = checkExpression(node.object); var indexType = checkExpression(node.index); @@ -12079,42 +12349,20 @@ var ts; resolveUntypedCall(node); return unknownSignature; } - function isCandidateSignature(node, signature) { - var args = node.arguments || emptyArray; - return args.length >= signature.minArgumentCount && (signature.hasRestParameter || args.length <= signature.parameters.length) && (!node.typeArguments || signature.typeParameters && node.typeArguments.length === signature.typeParameters.length); - } - function collectCandidates(node, signatures) { - var result = []; - var lastParent; - var lastSymbol; - var cutoffPos = 0; - var pos; - for (var i = 0; i < signatures.length; i++) { - var signature = signatures[i]; - if (isCandidateSignature(node, signature)) { - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent === lastParent) { - pos++; - } - else { - lastParent = parent; - pos = cutoffPos; - } - } - else { - pos = cutoffPos = result.length; - lastParent = parent; - } - lastSymbol = symbol; - for (var j = result.length; j > pos; j--) { - result[j] = result[j - 1]; - } - result[pos] = signature; - } + function signatureHasCorrectArity(node, signature) { + if (!node.arguments) { + return signature.minArgumentCount === 0; } - return result; + var args = node.arguments; + var numberOfArgs = args.hasTrailingComma ? args.length + 1 : args.length; + var hasTooManyArguments = !signature.hasRestParameter && numberOfArgs > signature.parameters.length; + var hasRightNumberOfTypeArguments = !node.typeArguments || (signature.typeParameters && node.typeArguments.length === signature.typeParameters.length); + if (hasTooManyArguments || !hasRightNumberOfTypeArguments) { + return false; + } + var callIsIncomplete = args.end === node.end; + var hasEnoughArguments = numberOfArgs >= signature.minArgumentCount; + return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { if (type.flags & ts.TypeFlags.ObjectType) { @@ -12137,6 +12385,9 @@ var ts; var context = createInferenceContext(typeParameters); var mapper = createInferenceMapper(context); for (var i = 0; i < args.length; i++) { + if (args[i].kind === 147 /* OmittedExpression */) { + continue; + } if (!excludeArgument || excludeArgument[i] === undefined) { var parameterType = getTypeAtPosition(signature, i); inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType); @@ -12144,6 +12395,9 @@ var ts; } if (excludeArgument) { for (var i = 0; i < args.length; i++) { + if (args[i].kind === 147 /* OmittedExpression */) { + continue; + } if (excludeArgument[i] === false) { var parameterType = getTypeAtPosition(signature, i); inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType); @@ -12170,6 +12424,9 @@ var ts; if (node.arguments) { for (var i = 0; i < node.arguments.length; i++) { var arg = node.arguments[i]; + if (arg.kind === 147 /* OmittedExpression */) { + continue; + } var paramType = getTypeAtPosition(signature, i); var argType = arg.kind === 7 /* StringLiteral */ && !reportErrors ? getStringLiteralType(arg) : checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1, ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1); @@ -12180,9 +12437,10 @@ var ts; } return true; } - function resolveCall(node, signatures) { + function resolveCall(node, signatures, candidatesOutArray) { ts.forEach(node.typeArguments, checkSourceElement); - var candidates = collectCandidates(node, signatures); + var candidates = candidatesOutArray || []; + collectCandidates(); if (!candidates.length) { error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); return resolveErrorCall(node); @@ -12199,18 +12457,21 @@ var ts; var relation = candidates.length === 1 ? assignableRelation : subtypeRelation; while (true) { for (var i = 0; i < candidates.length; i++) { + if (!signatureHasCorrectArity(node, candidates[i])) { + continue; + } while (true) { - var candidate = candidates[i]; - if (candidate.typeParameters) { - var typeArguments = node.typeArguments ? checkTypeArguments(candidate, node.typeArguments) : inferTypeArguments(candidate, args, excludeArgument); - candidate = getSignatureInstantiation(candidate, typeArguments); + var candidateWithCorrectArity = candidates[i]; + if (candidateWithCorrectArity.typeParameters) { + var typeArguments = node.typeArguments ? checkTypeArguments(candidateWithCorrectArity, node.typeArguments) : inferTypeArguments(candidateWithCorrectArity, args, excludeArgument); + candidateWithCorrectArity = getSignatureInstantiation(candidateWithCorrectArity, typeArguments); } - if (!checkApplicableSignature(node, candidate, relation, excludeArgument, false)) { + if (!checkApplicableSignature(node, candidateWithCorrectArity, relation, excludeArgument, false)) { break; } var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; if (index < 0) { - return candidate; + return candidateWithCorrectArity; } excludeArgument[index] = false; } @@ -12220,14 +12481,59 @@ var ts; } relation = assignableRelation; } - checkApplicableSignature(node, candidate, relation, undefined, true); + if (candidateWithCorrectArity) { + checkApplicableSignature(node, candidateWithCorrectArity, relation, undefined, true); + } + else { + error(node, ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); + } + if (!fullTypeCheck) { + for (var i = 0, n = candidates.length; i < n; i++) { + if (signatureHasCorrectArity(node, candidates[i])) { + return candidates[i]; + } + } + } return resolveErrorCall(node); + function collectCandidates() { + var result = candidates; + var lastParent; + var lastSymbol; + var cutoffPos = 0; + var pos; + ts.Debug.assert(!result.length); + for (var i = 0; i < signatures.length; i++) { + var signature = signatures[i]; + if (true) { + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent === lastParent) { + pos++; + } + else { + lastParent = parent; + pos = cutoffPos; + } + } + else { + pos = cutoffPos = result.length; + lastParent = parent; + } + lastSymbol = symbol; + for (var j = result.length; j > pos; j--) { + result[j] = result[j - 1]; + } + result[pos] = signature; + } + } + } } - function resolveCallExpression(node) { + function resolveCallExpression(node, candidatesOutArray) { if (node.func.kind === 85 /* SuperKeyword */) { var superType = checkSuperExpression(node.func); if (superType !== unknownType) { - return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */)); + return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); } return resolveUntypedCall(node); } @@ -12256,9 +12562,9 @@ var ts; } return resolveErrorCall(node); } - return resolveCall(node, callSignatures); + return resolveCall(node, callSignatures, candidatesOutArray); } - function resolveNewExpression(node) { + function resolveNewExpression(node, candidatesOutArray) { var expressionType = checkExpression(node.func); if (expressionType === unknownType) { return resolveErrorCall(node); @@ -12275,11 +12581,11 @@ var ts; } var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); if (constructSignatures.length) { - return resolveCall(node, constructSignatures); + return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures); + var signature = resolveCall(node, callSignatures, candidatesOutArray); if (getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); } @@ -12288,11 +12594,11 @@ var ts; error(node, ts.Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); return resolveErrorCall(node); } - function getResolvedSignature(node) { + function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); - if (!links.resolvedSignature) { + if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - links.resolvedSignature = node.kind === 137 /* CallExpression */ ? resolveCallExpression(node) : resolveNewExpression(node); + links.resolvedSignature = node.kind === 137 /* CallExpression */ ? resolveCallExpression(node, candidatesOutArray) : resolveNewExpression(node, candidatesOutArray); } return links.resolvedSignature; } @@ -12522,10 +12828,10 @@ var ts; return type === anyType || ((type.flags & (ts.TypeFlags.ObjectType | 512 /* TypeParameter */)) !== 0); } function checkInstanceOfExpression(node, leftType, rightType) { - if (!isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) { + if (leftType !== unknownType && !isTypeAnyTypeObjectTypeOrTypeParameter(leftType)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } - if (rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { + if (rightType !== unknownType && rightType !== anyType && !isTypeSubtypeOf(rightType, globalFunctionType)) { error(node.right, ts.Diagnostics.The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type); } return booleanType; @@ -12568,10 +12874,16 @@ var ts; leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; - var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); - if (leftOk && rightOk) { - checkAssignmentOperator(numberType); + var suggestedOperator; + if ((leftType.flags & 8 /* Boolean */) && (rightType.flags & 8 /* Boolean */) && (suggestedOperator = getSuggestedBooleanOperator(node.operator)) !== undefined) { + error(node, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(node.operator), ts.tokenToString(suggestedOperator)); + } + else { + var leftOk = checkArithmeticOperandType(node.left, leftType, ts.Diagnostics.The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + var rightOk = checkArithmeticOperandType(node.right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type); + if (leftOk && rightOk) { + checkAssignmentOperator(numberType); + } } return numberType; case 28 /* PlusToken */: @@ -12624,6 +12936,21 @@ var ts; case 18 /* CommaToken */: return rightType; } + function getSuggestedBooleanOperator(operator) { + switch (operator) { + case 39 /* BarToken */: + case 57 /* BarEqualsToken */: + return 44 /* BarBarToken */; + case 40 /* CaretToken */: + case 58 /* CaretEqualsToken */: + return 26 /* ExclamationEqualsEqualsToken */; + case 38 /* AmpersandToken */: + case 56 /* AmpersandEqualsToken */: + return 43 /* AmpersandAmpersandToken */; + default: + return undefined; + } + } function checkAssignmentOperator(valueType) { if (fullTypeCheck && operator >= ts.SyntaxKind.FirstAssignment && operator <= ts.SyntaxKind.LastAssignment) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression); @@ -12790,7 +13117,7 @@ var ts; if (fullTypeCheck) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { @@ -13044,6 +13371,9 @@ var ts; var declarations = symbol.declarations; var isConstructor = (symbol.flags & 4096 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { + if (node.name && node.name.kind === 115 /* Missing */) { + return; + } var seen = false; var subsequentNode = ts.forEachChild(node.parent, function (c) { if (seen) { @@ -13078,6 +13408,8 @@ var ts; } } var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & ts.SymbolFlags.Module; + var duplicateFunctionDeclaration = false; + var multipleConstructorImplementation = false; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); @@ -13091,10 +13423,10 @@ var ts; allNodeFlags &= currentNodeFlags; if (node.body && bodyDeclaration) { if (isConstructor) { - error(node, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + multipleConstructorImplementation = true; } else { - error(node, ts.Diagnostics.Duplicate_function_implementation); + duplicateFunctionDeclaration = true; } } else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) { @@ -13114,6 +13446,16 @@ var ts; } } } + if (multipleConstructorImplementation) { + ts.forEach(declarations, function (declaration) { + error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed); + }); + } + if (duplicateFunctionDeclaration) { + ts.forEach(declarations, function (declaration) { + error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); + }); + } if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -13320,7 +13662,7 @@ var ts; } } } - function checkCollistionWithRequireExportsInGeneratedCode(node, name) { + function checkCollisionWithRequireExportsInGeneratedCode(node, name) { if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } @@ -13353,7 +13695,7 @@ var ts; } checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); if (!useTypeFromValueDeclaration) { if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) { error(node.name, ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, ts.identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type)); @@ -13544,7 +13886,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkTypeParameters(node.typeParameters); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -13691,7 +14033,7 @@ var ts; checkTypeForDuplicateIndexSignatures(node); } } - function getConstantValue(node) { + function getConstantValueForExpression(node) { var isNegative = false; if (node.kind === 143 /* PrefixOperator */) { var unaryExpression = node; @@ -13706,33 +14048,44 @@ var ts; } return undefined; } + function computeEnumMemberValues(node) { + var nodeLinks = getNodeLinks(node); + if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { + var enumSymbol = getSymbolOfNode(node); + var enumType = getDeclaredTypeOfSymbol(enumSymbol); + var autoValue = 0; + var ambient = ts.isInAmbientContext(node); + ts.forEach(node.members, function (member) { + if (isNumericName(member.name.text)) { + error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); + } + var initializer = member.initializer; + if (initializer) { + autoValue = getConstantValueForExpression(initializer); + if (autoValue === undefined && !ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined, undefined); + } + } + else if (ambient) { + autoValue = undefined; + } + if (autoValue !== undefined) { + getNodeLinks(member).enumMemberValue = autoValue++; + } + }); + nodeLinks.flags |= 128 /* EnumValuesComputed */; + } + } function checkEnumDeclaration(node) { if (!fullTypeCheck) { return; } checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0); checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); + computeEnumMemberValues(node); var enumSymbol = getSymbolOfNode(node); - var enumType = getDeclaredTypeOfSymbol(enumSymbol); - var autoValue = 0; - var ambient = ts.isInAmbientContext(node); - ts.forEach(node.members, function (member) { - var initializer = member.initializer; - if (initializer) { - autoValue = getConstantValue(initializer); - if (autoValue === undefined && !ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined, undefined); - } - } - else if (ambient) { - autoValue = undefined; - } - if (autoValue !== undefined) { - getNodeLinks(member).enumMemberValue = autoValue++; - } - }); var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { var seenEnumMissingInitialInitializer = false; @@ -13769,7 +14122,7 @@ var ts; function checkModuleDeclaration(node) { if (fullTypeCheck) { checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); if (symbol.flags & 128 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { @@ -13802,7 +14155,7 @@ var ts; } function checkImportDeclaration(node) { checkCollisionWithCapturedThisVariable(node, node.name); - checkCollistionWithRequireExportsInGeneratedCode(node, node.name); + checkCollisionWithRequireExportsInGeneratedCode(node, node.name); var symbol = getSymbolOfNode(node); var target; if (node.entityName) { @@ -14044,6 +14397,11 @@ var ts; checkProgram(); return getSortedDiagnostics(); } + function getDeclarationDiagnostics(targetSourceFile) { + var resolver = createResolver(); + checkSourceFile(targetSourceFile); + return ts.getDeclarationDiagnostics(program, resolver, targetSourceFile); + } function getGlobalDiagnostics() { return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; }); } @@ -14219,7 +14577,7 @@ var ts; return false; } function isTypeNode(node) { - if (node.kind >= ts.SyntaxKind.FirstTypeNode && node.kind <= ts.SyntaxKind.LastTypeNode) { + if (ts.SyntaxKind.FirstTypeNode <= node.kind && node.kind <= ts.SyntaxKind.LastTypeNode) { return true; } switch (node.kind) { @@ -14237,11 +14595,12 @@ var ts; node = node.parent; } case 116 /* QualifiedName */: + ts.Debug.assert(node.kind === 59 /* Identifier */ || node.kind === 116 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; if (parent.kind === 128 /* TypeQuery */) { return false; } - if (parent.kind >= ts.SyntaxKind.FirstTypeNode && parent.kind <= ts.SyntaxKind.LastTypeNode) { + if (ts.SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= ts.SyntaxKind.LastTypeNode) { return true; } switch (parent.kind) { @@ -14267,7 +14626,7 @@ var ts; return node === parent.type; case 137 /* CallExpression */: case 138 /* NewExpression */: - return parent.typeArguments.indexOf(node) >= 0; + return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; } } return false; @@ -14467,7 +14826,7 @@ var ts; while (!isUniqueLocalName(ts.escapeIdentifier(prefix + name), container)) { prefix += "_"; } - links.localModuleName = prefix + ts.getSourceTextOfNode(container.name); + links.localModuleName = prefix + ts.getTextOfNode(container.name); } return links.localModuleName; } @@ -14493,16 +14852,6 @@ var ts; } } } - function getPropertyAccessSubstitution(node) { - var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 4 /* EnumMember */)) { - var declaration = symbol.valueDeclaration; - var constantValue; - if (declaration.kind === 181 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { - return constantValue.toString() + " /* " + ts.identifierToString(declaration.name) + " */"; - } - } - } function getExportAssignmentName(node) { var symbol = getExportAssignmentSymbol(getSymbolOfNode(node)); return symbol && symbolIsValue(symbol) ? symbolToString(symbol) : undefined; @@ -14543,23 +14892,34 @@ var ts; return getNodeLinks(node).flags; } function getEnumMemberValue(node) { + computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function getConstantValue(node) { + var symbol = getNodeLinks(node).resolvedSymbol; + if (symbol && (symbol.flags & 4 /* EnumMember */)) { + var declaration = symbol.valueDeclaration; + var constantValue; + if (declaration.kind === 181 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + return constantValue; + } + } + return undefined; + } function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { var symbol = getSymbolOfNode(location); var type = symbol && !(symbol.flags & 512 /* TypeLiteral */) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); - writeTypeToTextWriter(type, enclosingDeclaration, flags, writer); + writeType(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { var signature = getSignatureFromDeclaration(signatureDeclaration); - writeTypeToTextWriter(getReturnTypeOfSignature(signature), enclosingDeclaration, flags, writer); + writeType(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } - function invokeEmitter(targetSourceFile) { - var resolver = { + function createResolver() { + return { getProgram: function () { return program; }, getLocalNameOfContainer: getLocalNameOfContainer, getExpressionNamePrefix: getExpressionNamePrefix, - getPropertyAccessSubstitution: getPropertyAccessSubstitution, getExportAssignmentName: getExportAssignmentName, isReferencedImportDeclaration: isReferencedImportDeclaration, getNodeCheckFlags: getNodeCheckFlags, @@ -14570,10 +14930,13 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, writeTypeAtLocation: writeTypeAtLocation, writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration, - writeSymbol: writeSymbolToTextWriter, isSymbolAccessible: isSymbolAccessible, - isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile + isImportDeclarationEntityNameReferenceDeclarationVisible: isImportDeclarationEntityNameReferenceDeclarationVisible, + getConstantValue: getConstantValue }; + } + function invokeEmitter(targetSourceFile) { + var resolver = createResolver(); checkProgram(); return ts.emitFiles(resolver, targetSourceFile); } @@ -15712,7 +16075,6 @@ var __extends = this.__extends || function (d, b) { }; var TypeScript; (function (TypeScript) { - TypeScript.LocalizedDiagnosticMessages = null; var Location = (function () { function Location(fileName, lineMap, start, length) { this._fileName = fileName; @@ -19472,7 +19834,7 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - TypeScript.nodeMetadata = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], ["moduleElements", "endOfFileToken"], ["left", "dotToken", "right"], ["openBraceToken", "typeMembers", "closeBraceToken"], ["typeParameterList", "parameterList", "equalsGreaterThanToken", "type"], ["type", "openBracketToken", "closeBracketToken"], ["newKeyword", "typeParameterList", "parameterList", "equalsGreaterThanToken", "type"], ["name", "typeArgumentList"], ["typeOfKeyword", "name"], ["openBracketToken", "types", "closeBracketToken"], ["modifiers", "interfaceKeyword", "identifier", "typeParameterList", "heritageClauses", "body"], ["modifiers", "functionKeyword", "identifier", "callSignature", "block", "semicolonToken"], ["modifiers", "moduleKeyword", "name", "stringLiteral", "openBraceToken", "moduleElements", "closeBraceToken"], ["modifiers", "classKeyword", "identifier", "typeParameterList", "heritageClauses", "openBraceToken", "classElements", "closeBraceToken"], ["modifiers", "enumKeyword", "identifier", "openBraceToken", "enumElements", "closeBraceToken"], ["modifiers", "importKeyword", "identifier", "equalsToken", "moduleReference", "semicolonToken"], ["exportKeyword", "equalsToken", "identifier", "semicolonToken"], ["modifiers", "propertyName", "callSignature", "block", "semicolonToken"], ["modifiers", "variableDeclarator", "semicolonToken"], ["modifiers", "constructorKeyword", "callSignature", "block", "semicolonToken"], ["modifiers", "indexSignature", "semicolonToken"], ["modifiers", "getKeyword", "propertyName", "callSignature", "block"], ["modifiers", "setKeyword", "propertyName", "callSignature", "block"], ["propertyName", "questionToken", "typeAnnotation"], ["typeParameterList", "parameterList", "typeAnnotation"], ["newKeyword", "callSignature"], ["openBracketToken", "parameters", "closeBracketToken", "typeAnnotation"], ["propertyName", "questionToken", "callSignature"], ["openBraceToken", "statements", "closeBraceToken"], ["ifKeyword", "openParenToken", "condition", "closeParenToken", "statement", "elseClause"], ["modifiers", "variableDeclaration", "semicolonToken"], ["expression", "semicolonToken"], ["returnKeyword", "expression", "semicolonToken"], ["switchKeyword", "openParenToken", "expression", "closeParenToken", "openBraceToken", "switchClauses", "closeBraceToken"], ["breakKeyword", "identifier", "semicolonToken"], ["continueKeyword", "identifier", "semicolonToken"], ["forKeyword", "openParenToken", "variableDeclaration", "initializer", "firstSemicolonToken", "condition", "secondSemicolonToken", "incrementor", "closeParenToken", "statement"], ["forKeyword", "openParenToken", "variableDeclaration", "left", "inKeyword", "expression", "closeParenToken", "statement"], ["semicolonToken"], ["throwKeyword", "expression", "semicolonToken"], ["whileKeyword", "openParenToken", "condition", "closeParenToken", "statement"], ["tryKeyword", "block", "catchClause", "finallyClause"], ["identifier", "colonToken", "statement"], ["doKeyword", "statement", "whileKeyword", "openParenToken", "condition", "closeParenToken", "semicolonToken"], ["debuggerKeyword", "semicolonToken"], ["withKeyword", "openParenToken", "condition", "closeParenToken", "statement"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["deleteKeyword", "expression"], ["typeOfKeyword", "expression"], ["voidKeyword", "expression"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["condition", "questionToken", "whenTrue", "colonToken", "whenFalse"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["operand", "operatorToken"], ["operand", "operatorToken"], ["expression", "dotToken", "name"], ["expression", "argumentList"], ["openBracketToken", "expressions", "closeBracketToken"], ["openBraceToken", "propertyAssignments", "closeBraceToken"], ["newKeyword", "expression", "argumentList"], ["openParenToken", "expression", "closeParenToken"], ["callSignature", "equalsGreaterThanToken", "block", "expression"], ["parameter", "equalsGreaterThanToken", "block", "expression"], ["lessThanToken", "type", "greaterThanToken", "expression"], ["expression", "openBracketToken", "argumentExpression", "closeBracketToken"], ["functionKeyword", "identifier", "callSignature", "block"], [], ["varKeyword", "variableDeclarators"], ["propertyName", "typeAnnotation", "equalsValueClause"], ["typeArgumentList", "openParenToken", "arguments", "closeParenToken"], ["openParenToken", "parameters", "closeParenToken"], ["lessThanToken", "typeArguments", "greaterThanToken"], ["lessThanToken", "typeParameters", "greaterThanToken"], ["extendsOrImplementsKeyword", "typeNames"], ["extendsOrImplementsKeyword", "typeNames"], ["equalsToken", "value"], ["caseKeyword", "expression", "colonToken", "statements"], ["defaultKeyword", "colonToken", "statements"], ["elseKeyword", "statement"], ["catchKeyword", "openParenToken", "identifier", "typeAnnotation", "closeParenToken", "block"], ["finallyKeyword", "block"], ["identifier", "constraint"], ["extendsKeyword", "typeOrExpression"], ["propertyName", "colonToken", "expression"], ["propertyName", "callSignature", "block"], ["dotDotDotToken", "modifiers", "identifier", "questionToken", "typeAnnotation", "equalsValueClause"], ["propertyName", "equalsValueClause"], ["colonToken", "type"], ["requireKeyword", "openParenToken", "stringLiteral", "closeParenToken"], ["moduleName"], ]; + TypeScript.nodeMetadata = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], ["moduleElements", "endOfFileToken"], ["left", "dotToken", "right"], ["openBraceToken", "typeMembers", "closeBraceToken"], ["typeParameterList", "parameterList", "equalsGreaterThanToken", "type"], ["type", "openBracketToken", "closeBracketToken"], ["newKeyword", "typeParameterList", "parameterList", "equalsGreaterThanToken", "type"], ["name", "typeArgumentList"], ["typeOfKeyword", "name"], ["openBracketToken", "types", "closeBracketToken"], ["modifiers", "interfaceKeyword", "identifier", "typeParameterList", "heritageClauses", "body"], ["modifiers", "functionKeyword", "identifier", "callSignature", "block", "semicolonToken"], ["modifiers", "moduleKeyword", "name", "stringLiteral", "openBraceToken", "moduleElements", "closeBraceToken"], ["modifiers", "classKeyword", "identifier", "typeParameterList", "heritageClauses", "openBraceToken", "classElements", "closeBraceToken"], ["modifiers", "enumKeyword", "identifier", "openBraceToken", "enumElements", "closeBraceToken"], ["modifiers", "importKeyword", "identifier", "equalsToken", "moduleReference", "semicolonToken"], ["exportKeyword", "equalsToken", "identifier", "semicolonToken"], ["modifiers", "propertyName", "callSignature", "block", "semicolonToken"], ["modifiers", "variableDeclarator", "semicolonToken"], ["modifiers", "constructorKeyword", "callSignature", "block", "semicolonToken"], ["modifiers", "indexSignature", "semicolonToken"], ["modifiers", "getKeyword", "propertyName", "callSignature", "block"], ["modifiers", "setKeyword", "propertyName", "callSignature", "block"], ["propertyName", "questionToken", "typeAnnotation"], ["typeParameterList", "parameterList", "typeAnnotation"], ["newKeyword", "callSignature"], ["openBracketToken", "parameters", "closeBracketToken", "typeAnnotation"], ["propertyName", "questionToken", "callSignature"], ["openBraceToken", "statements", "closeBraceToken"], ["ifKeyword", "openParenToken", "condition", "closeParenToken", "statement", "elseClause"], ["modifiers", "variableDeclaration", "semicolonToken"], ["expression", "semicolonToken"], ["returnKeyword", "expression", "semicolonToken"], ["switchKeyword", "openParenToken", "expression", "closeParenToken", "openBraceToken", "switchClauses", "closeBraceToken"], ["breakKeyword", "identifier", "semicolonToken"], ["continueKeyword", "identifier", "semicolonToken"], ["forKeyword", "openParenToken", "variableDeclaration", "initializer", "firstSemicolonToken", "condition", "secondSemicolonToken", "incrementor", "closeParenToken", "statement"], ["forKeyword", "openParenToken", "variableDeclaration", "left", "inKeyword", "expression", "closeParenToken", "statement"], ["semicolonToken"], ["throwKeyword", "expression", "semicolonToken"], ["whileKeyword", "openParenToken", "condition", "closeParenToken", "statement"], ["tryKeyword", "block", "catchClause", "finallyClause"], ["identifier", "colonToken", "statement"], ["doKeyword", "statement", "whileKeyword", "openParenToken", "condition", "closeParenToken", "semicolonToken"], ["debuggerKeyword", "semicolonToken"], ["withKeyword", "openParenToken", "condition", "closeParenToken", "statement"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["deleteKeyword", "expression"], ["typeOfKeyword", "expression"], ["voidKeyword", "expression"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["condition", "questionToken", "whenTrue", "colonToken", "whenFalse"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["operand", "operatorToken"], ["operand", "operatorToken"], ["expression", "dotToken", "name"], ["expression", "argumentList"], ["openBracketToken", "expressions", "closeBracketToken"], ["openBraceToken", "propertyAssignments", "closeBraceToken"], ["newKeyword", "expression", "argumentList"], ["openParenToken", "expression", "closeParenToken"], ["callSignature", "equalsGreaterThanToken", "block", "expression"], ["parameter", "equalsGreaterThanToken", "block", "expression"], ["lessThanToken", "type", "greaterThanToken", "expression"], ["expression", "openBracketToken", "argumentExpression", "closeBracketToken"], ["functionKeyword", "identifier", "callSignature", "block"], [], ["varKeyword", "variableDeclarators"], ["propertyName", "typeAnnotation", "equalsValueClause"], ["typeArgumentList", "openParenToken", "arguments", "closeParenToken"], ["openParenToken", "parameters", "closeParenToken"], ["lessThanToken", "typeArguments", "greaterThanToken"], ["lessThanToken", "typeParameters", "greaterThanToken"], ["extendsOrImplementsKeyword", "typeNames"], ["extendsOrImplementsKeyword", "typeNames"], ["equalsToken", "value"], ["caseKeyword", "expression", "colonToken", "statements"], ["defaultKeyword", "colonToken", "statements"], ["elseKeyword", "statement"], ["catchKeyword", "openParenToken", "identifier", "typeAnnotation", "closeParenToken", "block"], ["finallyKeyword", "block"], ["identifier", "constraint"], ["extendsKeyword", "typeOrExpression"], ["propertyName", "colonToken", "expression"], ["propertyName", "callSignature", "block"], ["dotDotDotToken", "modifiers", "identifier", "questionToken", "typeAnnotation", "equalsValueClause"], ["propertyName", "equalsValueClause"], ["colonToken", "type"], ["requireKeyword", "openParenToken", "stringLiteral", "closeParenToken"], ["moduleName"],]; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -25976,10 +26338,10 @@ var TypeScript; throw TypeScript.Errors.argumentOutOfRange("languageVersion"); } }; - Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; - Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, ]; + Unicode.unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + Unicode.unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + Unicode.unicodeES5IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2208, 2208, 2210, 2220, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2423, 2425, 2431, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3133, 3160, 3161, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6263, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6428, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7401, 7404, 7406, 7409, 7413, 7414, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11823, 11823, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42647, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43648, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; + Unicode.unicodeES5IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1319, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1520, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2048, 2093, 2112, 2139, 2208, 2208, 2210, 2220, 2276, 2302, 2304, 2403, 2406, 2415, 2417, 2423, 2425, 2431, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3161, 3168, 3171, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3396, 3398, 3400, 3402, 3406, 3415, 3415, 3424, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5872, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6263, 6272, 6314, 6320, 6389, 6400, 6428, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6617, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7376, 7378, 7380, 7414, 7424, 7654, 7676, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8204, 8205, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 11823, 11823, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12442, 12445, 12447, 12449, 12538, 12540, 12543, 12549, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42647, 42655, 42737, 42775, 42783, 42786, 42888, 42891, 42894, 42896, 42899, 42912, 42922, 43000, 43047, 43072, 43123, 43136, 43204, 43216, 43225, 43232, 43255, 43259, 43259, 43264, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43643, 43648, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65062, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; return Unicode; })(); TypeScript.Unicode = Unicode; @@ -26394,17 +26756,28 @@ var ts; (function (OutliningElementsCollector) { function collectElements(sourceFile) { var elements = []; - function addOutlineRange(hintSpanNode, startElement, endElement) { + var collapseText = "..."; + function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { if (hintSpanNode && startElement && endElement) { var span = { textSpan: TypeScript.TextSpan.fromBounds(startElement.pos, endElement.end), hintSpan: TypeScript.TextSpan.fromBounds(hintSpanNode.getStart(), hintSpanNode.end), - bannerText: "...", - autoCollapse: false + bannerText: collapseText, + autoCollapse: autoCollapse }; elements.push(span); } } + function autoCollapse(node) { + switch (node.kind) { + case 178 /* ModuleBlock */: + case 174 /* ClassDeclaration */: + case 175 /* InterfaceDeclaration */: + case 176 /* EnumDeclaration */: + return false; + } + return true; + } var depth = 0; var maxDepth = 20; function walk(n) { @@ -26413,23 +26786,44 @@ var ts; } switch (n.kind) { case 148 /* Block */: + var parent = n.parent; + var openBrace = ts.findChildOfKind(n, 9 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 10 /* CloseBraceToken */, sourceFile); + if (parent.kind === 153 /* DoStatement */ || parent.kind === 156 /* ForInStatement */ || parent.kind === 155 /* ForStatement */ || parent.kind === 152 /* IfStatement */ || parent.kind === 154 /* WhileStatement */ || parent.kind === 160 /* WithStatement */) { + addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); + } + else { + var span = TypeScript.TextSpan.fromBounds(n.getStart(), n.end); + elements.push({ + textSpan: span, + hintSpan: span, + bannerText: collapseText, + autoCollapse: autoCollapse(n) + }); + } + break; case 173 /* FunctionBlock */: case 178 /* ModuleBlock */: case 167 /* TryBlock */: - case 167 /* TryBlock */: case 168 /* CatchBlock */: case 169 /* FinallyBlock */: - var openBrace = ts.forEach(n.getChildren(), function (c) { return c.kind === 9 /* OpenBraceToken */ && c; }); - var closeBrace = ts.forEach(n.getChildren(), function (c) { return c.kind === 10 /* CloseBraceToken */ && c; }); - addOutlineRange(n.parent, openBrace, closeBrace); + var openBrace = ts.findChildOfKind(n, 9 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 10 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; case 174 /* ClassDeclaration */: case 175 /* InterfaceDeclaration */: case 176 /* EnumDeclaration */: case 133 /* ObjectLiteral */: - var openBrace = ts.forEach(n.getChildren(), function (c) { return c.kind === 9 /* OpenBraceToken */ && c; }); - var closeBrace = ts.forEach(n.getChildren(), function (c) { return c.kind === 10 /* CloseBraceToken */ && c; }); - addOutlineRange(n, openBrace, closeBrace); + case 161 /* SwitchStatement */: + var openBrace = ts.findChildOfKind(n, 9 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 10 /* CloseBraceToken */, sourceFile); + addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); + break; + case 132 /* ArrayLiteral */: + var openBracket = ts.findChildOfKind(n, 13 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 14 /* CloseBracketToken */, sourceFile); + addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } depth++; @@ -26442,96 +26836,117 @@ var ts; OutliningElementsCollector.collectElements = collectElements; })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - var NavigationBarItemGetter = (function () { - function NavigationBarItemGetter() { - this.hasGlobalNode = false; - } - NavigationBarItemGetter.prototype.getIndent = function (node) { - var indent = this.hasGlobalNode ? 1 : 0; +var ts; +(function (ts) { + var NavigationBar; + (function (NavigationBar) { + function getNavigationBarItems(sourceFile) { + var hasGlobalNode = false; + return getItemsWorker(getTopLevelNodes(sourceFile), createTopLevelItem); + function getIndent(node) { + var indent = hasGlobalNode ? 1 : 0; var current = node.parent; - while (current != null) { - if (current.kind() == 131 /* ModuleDeclaration */ || current.kind() === 130 /* FunctionDeclaration */) { - indent++; + while (current) { + switch (current.kind) { + case 177 /* ModuleDeclaration */: + do { + current = current.parent; + } while (current.kind === 177 /* ModuleDeclaration */); + case 174 /* ClassDeclaration */: + case 176 /* EnumDeclaration */: + case 175 /* InterfaceDeclaration */: + case 172 /* FunctionDeclaration */: + indent++; } current = current.parent; } return indent; - }; - NavigationBarItemGetter.prototype.getKindModifiers = function (modifiers) { - var result = []; - for (var i = 0, n = modifiers.length; i < n; i++) { - result.push(modifiers[i].text()); - } - return result.length > 0 ? result.join(',') : ts.ScriptElementKindModifier.none; - }; - NavigationBarItemGetter.prototype.getItems = function (node) { - var _this = this; - return this.getItemsWorker(function () { return _this.getTopLevelNodes(node); }, function (n) { return _this.createTopLevelItem(n); }); - }; - NavigationBarItemGetter.prototype.getChildNodes = function (nodes) { + } + function getChildNodes(nodes) { var childNodes = []; for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; - if (node.kind() === 130 /* FunctionDeclaration */) { + if (node.kind === 174 /* ClassDeclaration */ || node.kind === 176 /* EnumDeclaration */ || node.kind === 175 /* InterfaceDeclaration */ || node.kind === 177 /* ModuleDeclaration */ || node.kind === 172 /* FunctionDeclaration */) { childNodes.push(node); } - else if (node.kind() === 149 /* VariableStatement */) { - var variableDeclaration = node.variableDeclaration; - childNodes.push.apply(childNodes, variableDeclaration.variableDeclarators); + else if (node.kind === 149 /* VariableStatement */) { + childNodes.push.apply(childNodes, node.declarations); } } - return childNodes; - }; - NavigationBarItemGetter.prototype.getTopLevelNodes = function (node) { + return sortNodes(childNodes); + } + function getTopLevelNodes(node) { var topLevelNodes = []; topLevelNodes.push(node); - this.addTopLevelNodes(node.moduleElements, topLevelNodes); + addTopLevelNodes(node.statements, topLevelNodes); return topLevelNodes; - }; - NavigationBarItemGetter.prototype.addTopLevelNodes = function (nodes, topLevelNodes) { + } + function sortNodes(nodes) { + return nodes.slice(0).sort(function (n1, n2) { + if (n1.name && n2.name) { + return n1.name.text.localeCompare(n2.name.text); + } + else if (n1.name) { + return 1; + } + else if (n2.name) { + -1; + } + else { + return n1.kind - n2.kind; + } + }); + } + function addTopLevelNodes(nodes, topLevelNodes) { + nodes = sortNodes(nodes); for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; - switch (node.kind()) { - case 132 /* ClassDeclaration */: - case 133 /* EnumDeclaration */: - case 129 /* InterfaceDeclaration */: + switch (node.kind) { + case 174 /* ClassDeclaration */: + case 176 /* EnumDeclaration */: + case 175 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 131 /* ModuleDeclaration */: + case 177 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); - this.addTopLevelNodes(moduleDeclaration.moduleElements, topLevelNodes); + addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 130 /* FunctionDeclaration */: + case 172 /* FunctionDeclaration */: var functionDeclaration = node; - if (this.isTopLevelFunctionDeclaration(functionDeclaration)) { + if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); - this.addTopLevelNodes(functionDeclaration.block.statements, topLevelNodes); + addTopLevelNodes(functionDeclaration.body.statements, topLevelNodes); } break; } } - }; - NavigationBarItemGetter.prototype.isTopLevelFunctionDeclaration = function (functionDeclaration) { - return functionDeclaration.block && TypeScript.ArrayUtilities.any(functionDeclaration.block.statements, function (s) { return s.kind() === 130 /* FunctionDeclaration */; }); - }; - NavigationBarItemGetter.prototype.getItemsWorker = function (getNodes, createItem) { + } + function isTopLevelFunctionDeclaration(functionDeclaration) { + if (functionDeclaration.kind === 172 /* FunctionDeclaration */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 173 /* FunctionBlock */) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 172 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + return true; + } + if (functionDeclaration.parent.kind !== 173 /* FunctionBlock */) { + return true; + } + } + } + return false; + } + function getItemsWorker(nodes, createItem) { var items = []; - var keyToItem = TypeScript.createIntrinsicsObject(); - var nodes = getNodes(); + var keyToItem = {}; for (var i = 0, n = nodes.length; i < n; i++) { var child = nodes[i]; var item = createItem(child); - if (item != null) { + if (item !== undefined) { if (item.text.length > 0) { - var key = item.text + "-" + item.kind; + var key = item.text + "-" + item.kind + "-" + item.indent; var itemWithSameName = keyToItem[key]; if (itemWithSameName) { - this.merge(itemWithSameName, item); + merge(itemWithSameName, item); } else { keyToItem[key] = item; @@ -26541,8 +26956,8 @@ var TypeScript; } } return items; - }; - NavigationBarItemGetter.prototype.merge = function (target, source) { + } + function merge(target, source) { target.spans.push.apply(target.spans, source.spans); if (source.childItems) { if (!target.childItems) { @@ -26553,206 +26968,154 @@ var TypeScript; for (var j = 0, m = target.childItems.length; j < m; j++) { var targetChild = target.childItems[j]; if (targetChild.text === sourceChild.text && targetChild.kind === sourceChild.kind) { - this.merge(targetChild, sourceChild); + merge(targetChild, sourceChild); continue outer; } } target.childItems.push(sourceChild); } } - }; - NavigationBarItemGetter.prototype.createChildItem = function (node) { - switch (node.kind()) { - case 243 /* Parameter */: - var parameter = node; - if (parameter.modifiers.length === 0) { - return null; - } - return new ts.NavigationBarItem(parameter.identifier.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(parameter.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 136 /* MemberFunctionDeclaration */: - var memberFunction = node; - return new ts.NavigationBarItem(memberFunction.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, this.getKindModifiers(memberFunction.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 140 /* GetAccessor */: - var getAccessor = node; - return new ts.NavigationBarItem(getAccessor.propertyName.text(), ts.ScriptElementKind.memberGetAccessorElement, this.getKindModifiers(getAccessor.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 141 /* SetAccessor */: - var setAccessor = node; - return new ts.NavigationBarItem(setAccessor.propertyName.text(), ts.ScriptElementKind.memberSetAccessorElement, this.getKindModifiers(setAccessor.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 145 /* IndexSignature */: - var indexSignature = node; - return new ts.NavigationBarItem("[]", ts.ScriptElementKind.indexSignatureElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 244 /* EnumElement */: - var enumElement = node; - return new ts.NavigationBarItem(enumElement.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 143 /* CallSignature */: - var callSignature = node; - return new ts.NavigationBarItem("()", ts.ScriptElementKind.callSignatureElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 144 /* ConstructSignature */: - var constructSignature = node; - return new ts.NavigationBarItem("new()", ts.ScriptElementKind.constructSignatureElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 146 /* MethodSignature */: - var methodSignature = node; - return new ts.NavigationBarItem(methodSignature.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 142 /* PropertySignature */: - var propertySignature = node; - return new ts.NavigationBarItem(propertySignature.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - case 130 /* FunctionDeclaration */: - var functionDeclaration = node; - if (!this.isTopLevelFunctionDeclaration(functionDeclaration)) { - return new ts.NavigationBarItem(functionDeclaration.identifier.text(), ts.ScriptElementKind.functionElement, this.getKindModifiers(functionDeclaration.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - } - break; - case 137 /* MemberVariableDeclaration */: - var memberVariableDeclaration = node; - return new ts.NavigationBarItem(memberVariableDeclaration.variableDeclarator.propertyName.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(memberVariableDeclaration.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(memberVariableDeclaration.variableDeclarator), TypeScript.end(memberVariableDeclaration.variableDeclarator))]); - case 226 /* VariableDeclarator */: - var variableDeclarator = node; - return new ts.NavigationBarItem(variableDeclarator.propertyName.text(), ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(variableDeclarator), TypeScript.end(variableDeclarator))]); - case 138 /* ConstructorDeclaration */: - var constructorDeclaration = node; - return new ts.NavigationBarItem("constructor", ts.ScriptElementKind.constructorImplementationElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))]); - } - return null; - }; - NavigationBarItemGetter.prototype.createTopLevelItem = function (node) { - switch (node.kind()) { - case 120 /* SourceUnit */: - return this.createSourceUnitItem(node); - case 132 /* ClassDeclaration */: - return this.createClassItem(node); - case 133 /* EnumDeclaration */: - return this.createEnumItem(node); - case 129 /* InterfaceDeclaration */: - return this.createIterfaceItem(node); - case 131 /* ModuleDeclaration */: - return this.createModuleItem(node); - case 130 /* FunctionDeclaration */: - return this.createFunctionItem(node); - } - return null; - }; - NavigationBarItemGetter.prototype.getModuleNames = function (node) { - var result = []; - if (node.stringLiteral) { - result.push(node.stringLiteral.text()); - } - else { - this.getModuleNamesHelper(node.name, result); - } - return result; - }; - NavigationBarItemGetter.prototype.getModuleNamesHelper = function (name, result) { - if (name.kind() === 121 /* QualifiedName */) { - var qualifiedName = name; - this.getModuleNamesHelper(qualifiedName.left, result); - result.push(qualifiedName.right.text()); - } - else { - result.push(name.text()); - } - }; - NavigationBarItemGetter.prototype.createModuleItem = function (node) { - var _this = this; - var moduleNames = this.getModuleNames(node); - var childItems = this.getItemsWorker(function () { return _this.getChildNodes(node.moduleElements); }, function (n) { return _this.createChildItem(n); }); - return new ts.NavigationBarItem(moduleNames.join("."), ts.ScriptElementKind.moduleElement, this.getKindModifiers(node.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))], childItems, this.getIndent(node)); - }; - NavigationBarItemGetter.prototype.createFunctionItem = function (node) { - var _this = this; - var childItems = this.getItemsWorker(function () { return node.block.statements; }, function (n) { return _this.createChildItem(n); }); - return new ts.NavigationBarItem(node.identifier.text(), ts.ScriptElementKind.functionElement, this.getKindModifiers(node.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))], childItems, this.getIndent(node)); - }; - NavigationBarItemGetter.prototype.createSourceUnitItem = function (node) { - var _this = this; - var childItems = this.getItemsWorker(function () { return _this.getChildNodes(node.moduleElements); }, function (n) { return _this.createChildItem(n); }); - if (childItems === null || childItems.length === 0) { - return null; - } - this.hasGlobalNode = true; - return new ts.NavigationBarItem("", ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))], childItems); - }; - NavigationBarItemGetter.prototype.createClassItem = function (node) { - var _this = this; - var constructor = TypeScript.ArrayUtilities.firstOrDefault(node.classElements, function (n) { return n.kind() === 138 /* ConstructorDeclaration */; }); - var nodes = constructor ? constructor.callSignature.parameterList.parameters.concat(node.classElements) : node.classElements; - var childItems = this.getItemsWorker(function () { return nodes; }, function (n) { return _this.createChildItem(n); }); - return new ts.NavigationBarItem(node.identifier.text(), ts.ScriptElementKind.classElement, this.getKindModifiers(node.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))], childItems, this.getIndent(node)); - }; - NavigationBarItemGetter.prototype.createEnumItem = function (node) { - var _this = this; - var childItems = this.getItemsWorker(function () { return node.enumElements; }, function (n) { return _this.createChildItem(n); }); - return new ts.NavigationBarItem(node.identifier.text(), ts.ScriptElementKind.enumElement, this.getKindModifiers(node.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))], childItems, this.getIndent(node)); - }; - NavigationBarItemGetter.prototype.createIterfaceItem = function (node) { - var _this = this; - var childItems = this.getItemsWorker(function () { return node.body.typeMembers; }, function (n) { return _this.createChildItem(n); }); - return new ts.NavigationBarItem(node.identifier.text(), ts.ScriptElementKind.interfaceElement, this.getKindModifiers(node.modifiers), [TypeScript.TextSpan.fromBounds(TypeScript.start(node), TypeScript.end(node))], childItems, this.getIndent(node)); - }; - return NavigationBarItemGetter; - })(); - Services.NavigationBarItemGetter = NavigationBarItemGetter; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var Services; - (function (Services) { - var BraceMatcher = (function () { - function BraceMatcher() { } - BraceMatcher.getMatchSpans = function (syntaxTree, position) { - var result = []; - var token = TypeScript.findToken(syntaxTree.sourceUnit(), position); - if (TypeScript.start(token) === position) { - var matchKind = BraceMatcher.getMatchingTokenKind(token); - if (matchKind !== null) { - var parentElement = token.parent; - for (var i = 0, n = TypeScript.childCount(parentElement); i < n; i++) { - var current = TypeScript.childAt(parentElement, i); - if (current !== null && TypeScript.fullWidth(current) > 0) { - if (current.kind() === matchKind) { - var range1 = new TypeScript.TextSpan(TypeScript.start(token), TypeScript.width(token)); - var range2 = new TypeScript.TextSpan(TypeScript.start(current), TypeScript.width(current)); - if (range1.start() < range2.start()) { - result.push(range1, range2); - } - else { - result.push(range2, range1); - } - break; - } - } + function createChildItem(node) { + switch (node.kind) { + case 118 /* Parameter */: + if ((node.flags & ts.NodeFlags.Modifier) === 0) { + return undefined; } + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 120 /* Method */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 122 /* GetAccessor */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 123 /* SetAccessor */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 126 /* IndexSignature */: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 181 /* EnumMember */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 124 /* CallSignature */: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 125 /* ConstructSignature */: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 119 /* Property */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 172 /* FunctionDeclaration */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); + case 171 /* VariableDeclaration */: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.variableElement); + case 121 /* Constructor */: + return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); + } + return undefined; + function createItem(node, name, scriptElementKind) { + return getNavigationBarItem(name, scriptElementKind, ts.getNodeModifiers(node), [getNodeSpan(node)]); + } + } + function isEmpty(text) { + return !text || text.trim() === ""; + } + function getNavigationBarItem(text, kind, kindModifiers, spans, childItems, indent) { + if (childItems === void 0) { childItems = []; } + if (indent === void 0) { indent = 0; } + if (isEmpty(text)) { + return undefined; + } + return { + text: text, + kind: kind, + kindModifiers: kindModifiers, + spans: spans, + childItems: childItems, + indent: indent, + bolded: false, + grayed: false + }; + } + function createTopLevelItem(node) { + switch (node.kind) { + case 182 /* SourceFile */: + return createSourceFileItem(node); + case 174 /* ClassDeclaration */: + return createClassItem(node); + case 176 /* EnumDeclaration */: + return createEnumItem(node); + case 175 /* InterfaceDeclaration */: + return createIterfaceItem(node); + case 177 /* ModuleDeclaration */: + return createModuleItem(node); + case 172 /* FunctionDeclaration */: + return createFunctionItem(node); + } + return undefined; + function getModuleName(moduleDeclaration) { + if (moduleDeclaration.name.kind === 7 /* StringLiteral */) { + return getTextOfNode(moduleDeclaration.name); } + var result = []; + result.push(moduleDeclaration.name.text); + while (moduleDeclaration.body && moduleDeclaration.body.kind === 177 /* ModuleDeclaration */) { + moduleDeclaration = moduleDeclaration.body; + result.push(moduleDeclaration.name.text); + } + return result.join("."); } - return result; - }; - BraceMatcher.getMatchingTokenKind = function (token) { - switch (token.kind()) { - case 70 /* OpenBraceToken */: - return 71 /* CloseBraceToken */; - case 72 /* OpenParenToken */: - return 73 /* CloseParenToken */; - case 74 /* OpenBracketToken */: - return 75 /* CloseBracketToken */; - case 80 /* LessThanToken */: - return 81 /* GreaterThanToken */; - case 71 /* CloseBraceToken */: - return 70 /* OpenBraceToken */; - case 73 /* CloseParenToken */: - return 72 /* OpenParenToken */; - case 75 /* CloseBracketToken */: - return 74 /* OpenBracketToken */; - case 81 /* GreaterThanToken */: - return 80 /* LessThanToken */; + function createModuleItem(node) { + var moduleName = getModuleName(node); + var childItems = getItemsWorker(getChildNodes(getInnermostModule(node).body.statements), createChildItem); + return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } - return null; - }; - return BraceMatcher; - })(); - Services.BraceMatcher = BraceMatcher; - })(Services = TypeScript.Services || (TypeScript.Services = {})); -})(TypeScript || (TypeScript = {})); + function createFunctionItem(node) { + if (node.name && node.body && node.body.kind === 173 /* FunctionBlock */) { + var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + return undefined; + } + function createSourceFileItem(node) { + var childItems = getItemsWorker(getChildNodes(node.statements), createChildItem); + if (childItems === undefined || childItems.length === 0) { + return undefined; + } + hasGlobalNode = true; + var rootName = ts.isExternalModule(node) ? "\"" + ts.escapeString(ts.getBaseFilename(ts.removeFileExtension(ts.normalizePath(node.filename)))) + "\"" : ""; + return getNavigationBarItem(rootName, ts.ScriptElementKind.moduleElement, ts.ScriptElementKindModifier.none, [getNodeSpan(node)], childItems); + } + function createClassItem(node) { + var childItems; + if (node.members) { + var constructor = ts.forEach(node.members, function (member) { + return member.kind === 121 /* Constructor */ && member; + }); + var nodes = constructor ? constructor.parameters.concat(node.members) : node.members; + var childItems = getItemsWorker(sortNodes(nodes), createChildItem); + } + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.classElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createEnumItem(node) { + var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.enumElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + function createIterfaceItem(node) { + var childItems = getItemsWorker(sortNodes(node.members), createChildItem); + return getNavigationBarItem(node.name.text, ts.ScriptElementKind.interfaceElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); + } + } + function getInnermostModule(node) { + while (node.body.kind === 177 /* ModuleDeclaration */) { + node = node.body; + } + return node; + } + function getNodeSpan(node) { + return node.kind === 182 /* SourceFile */ ? TypeScript.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()); + } + function getTextOfNode(node) { + return ts.getTextOfNodeFromSourceText(sourceFile.text, node); + } + } + NavigationBar.getNavigationBarItems = getNavigationBarItems; + })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); +})(ts || (ts = {})); var TypeScript; (function (TypeScript) { var Services; @@ -27741,6 +28104,328 @@ var TypeScript; Indentation.firstNonWhitespacePosition = firstNonWhitespacePosition; })(Indentation = TypeScript.Indentation || (TypeScript.Indentation = {})); })(TypeScript || (TypeScript = {})); +var ts; +(function (ts) { + var SignatureHelp; + (function (SignatureHelp) { + var emptyArray = []; + function getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken) { + var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); + if (!startingToken) { + return undefined; + } + var argumentInfo = getContainingArgumentInfo(startingToken); + cancellationToken.throwIfCancellationRequested(); + if (!argumentInfo) { + return undefined; + } + var call = argumentInfo.list.parent; + var candidates = []; + var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates); + cancellationToken.throwIfCancellationRequested(); + if (!candidates.length) { + return undefined; + } + return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); + function getImmediatelyContainingArgumentInfo(node) { + if (node.parent.kind !== 137 /* CallExpression */ && node.parent.kind !== 138 /* NewExpression */) { + return undefined; + } + var parent = node.parent; + if (node.kind === 19 /* LessThanToken */ || node.kind === 11 /* OpenParenToken */) { + var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); + ts.Debug.assert(list); + return { + list: list, + listItemIndex: 0 + }; + } + return ts.findListItemInfo(node); + } + function getContainingArgumentInfo(node) { + for (var n = node; n.kind !== 182 /* SourceFile */; n = n.parent) { + if (n.kind === 173 /* FunctionBlock */) { + return undefined; + } + if (n.pos < n.parent.pos || n.end > n.parent.end) { + ts.Debug.fail("Node of kind " + ts.SyntaxKind[n.kind] + " is not a subspan of its parent of kind " + ts.SyntaxKind[n.parent.kind]); + } + var argumentInfo = getImmediatelyContainingArgumentInfo(n); + if (argumentInfo) { + return argumentInfo; + } + } + return undefined; + } + function selectBestInvalidOverloadIndex(candidates, argumentCount) { + var maxParamsSignatureIndex = -1; + var maxParams = -1; + for (var i = 0; i < candidates.length; i++) { + var candidate = candidates[i]; + if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) { + return i; + } + if (candidate.parameters.length > maxParams) { + maxParams = candidate.parameters.length; + maxParamsSignatureIndex = i; + } + } + return maxParamsSignatureIndex; + } + function createSignatureHelpItems(candidates, bestSignature, argumentInfoOrTypeArgumentInfo) { + var argumentListOrTypeArgumentList = argumentInfoOrTypeArgumentInfo.list; + var items = ts.map(candidates, function (candidateSignature) { + var parameters = candidateSignature.parameters; + var parameterHelpItems = parameters.length === 0 ? emptyArray : ts.map(parameters, function (p) { + var displayParts = []; + if (candidateSignature.hasRestParameter && parameters[parameters.length - 1] === p) { + displayParts.push(ts.punctuationPart(16 /* DotDotDotToken */)); + } + displayParts.push(ts.symbolPart(p.name, p)); + var isOptional = !!(p.valueDeclaration.flags & 4 /* QuestionMark */); + if (isOptional) { + displayParts.push(ts.punctuationPart(45 /* QuestionToken */)); + } + displayParts.push(ts.punctuationPart(46 /* ColonToken */)); + displayParts.push(ts.spacePart()); + var typeParts = ts.typeToDisplayParts(typeInfoResolver, typeInfoResolver.getTypeOfSymbol(p), argumentListOrTypeArgumentList); + displayParts.push.apply(displayParts, typeParts); + return { + name: p.name, + documentation: p.getDocumentationComment(), + displayParts: displayParts, + isOptional: isOptional + }; + }); + var callTargetNode = argumentListOrTypeArgumentList.parent.func; + var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTargetNode); + var prefixParts = callTargetSymbol ? ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined) : []; + var separatorParts = [ts.punctuationPart(18 /* CommaToken */), ts.spacePart()]; + if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { + prefixParts.push(ts.punctuationPart(19 /* LessThanToken */)); + for (var i = 0, n = candidateSignature.typeParameters.length; i < n; i++) { + if (i) { + prefixParts.push.apply(prefixParts, separatorParts); + } + var tp = candidateSignature.typeParameters[i].symbol; + prefixParts.push(ts.symbolPart(tp.name, tp)); + } + prefixParts.push(ts.punctuationPart(20 /* GreaterThanToken */)); + } + prefixParts.push(ts.punctuationPart(11 /* OpenParenToken */)); + var suffixParts = [ts.punctuationPart(12 /* CloseParenToken */)]; + suffixParts.push(ts.punctuationPart(46 /* ColonToken */)); + suffixParts.push(ts.spacePart()); + var typeParts = ts.typeToDisplayParts(typeInfoResolver, candidateSignature.getReturnType(), argumentListOrTypeArgumentList); + suffixParts.push.apply(suffixParts, typeParts); + return { + isVariadic: candidateSignature.hasRestParameter, + prefixDisplayParts: prefixParts, + suffixDisplayParts: suffixParts, + separatorDisplayParts: separatorParts, + parameters: parameterHelpItems, + documentation: candidateSignature.getDocumentationComment() + }; + }); + var applicableSpanStart = argumentListOrTypeArgumentList.getFullStart(); + var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, false); + var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + var argumentIndex = (argumentInfoOrTypeArgumentInfo.listItemIndex + 1) >> 1; + var argumentCount = argumentListOrTypeArgumentList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentListOrTypeArgumentList.getChildren(), function (arg) { return arg.kind === 18 /* CommaToken */; }); + var selectedItemIndex = candidates.indexOf(bestSignature); + if (selectedItemIndex < 0) { + selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); + } + return { + items: items, + applicableSpan: applicableSpan, + selectedItemIndex: selectedItemIndex, + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + } + SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; + function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { + var children = parent.getChildren(sourceFile); + var indexOfOpenerToken = children.indexOf(openerToken); + return children[indexOfOpenerToken + 1]; + } + })(SignatureHelp = ts.SignatureHelp || (ts.SignatureHelp = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + function findListItemInfo(node) { + var syntaxList = findContainingList(node); + if (!syntaxList) { + return undefined; + } + var children = syntaxList.getChildren(); + var index = ts.indexOf(children, node); + return { + listItemIndex: index, + list: syntaxList + }; + } + ts.findListItemInfo = findListItemInfo; + function findChildOfKind(n, kind, sourceFile) { + return ts.forEach(n.getChildren(sourceFile), function (c) { return c.kind === kind && c; }); + } + ts.findChildOfKind = findChildOfKind; + function findContainingList(node) { + var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { + if (c.kind === 184 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + return c; + } + }); + return syntaxList; + } + ts.findContainingList = findContainingList; + function findListItemIndexContainingPosition(list, position) { + ts.Debug.assert(list.kind === 184 /* SyntaxList */); + var children = list.getChildren(); + for (var i = 0; i < children.length; i++) { + if (children[i].pos <= position && children[i].end > position) { + return i; + } + } + return -1; + } + ts.findListItemIndexContainingPosition = findListItemIndexContainingPosition; + function getTouchingWord(sourceFile, position) { + return getTouchingToken(sourceFile, position, isWord); + } + ts.getTouchingWord = getTouchingWord; + function getTouchingPropertyName(sourceFile, position) { + return getTouchingToken(sourceFile, position, isPropertyName); + } + ts.getTouchingPropertyName = getTouchingPropertyName; + function getTouchingToken(sourceFile, position, includeItemAtEndPosition) { + return getTokenAtPositionWorker(sourceFile, position, false, includeItemAtEndPosition); + } + ts.getTouchingToken = getTouchingToken; + function getTokenAtPosition(sourceFile, position) { + return getTokenAtPositionWorker(sourceFile, position, true, undefined); + } + ts.getTokenAtPosition = getTokenAtPosition; + function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includeItemAtEndPosition) { + var current = sourceFile; + outer: while (true) { + if (isToken(current)) { + return current; + } + for (var i = 0, n = current.getChildCount(sourceFile); i < n; i++) { + var child = current.getChildAt(i); + var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile); + if (start <= position) { + if (position < child.getEnd()) { + current = child; + continue outer; + } + else if (includeItemAtEndPosition && child.getEnd() === position) { + var previousToken = findPrecedingToken(position, sourceFile, child); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; + } + } + } + } + return current; + } + } + function findTokenOnLeftOfPosition(file, position) { + var tokenAtPosition = getTokenAtPosition(file, position); + if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + return tokenAtPosition; + } + return findPrecedingToken(position, file); + } + ts.findTokenOnLeftOfPosition = findTokenOnLeftOfPosition; + function findNextToken(previousToken, parent) { + return find(parent); + function find(n) { + if (isToken(n) && n.pos === previousToken.end) { + return n; + } + var children = n.getChildren(); + for (var i = 0, len = children.length; i < len; ++i) { + var child = children[i]; + var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || (child.pos === previousToken.end); + if (shouldDiveInChildNode && nodeHasTokens(child)) { + return find(child); + } + } + return undefined; + } + } + ts.findNextToken = findNextToken; + function findPrecedingToken(position, sourceFile, startNode) { + return find(startNode || sourceFile); + function findRightmostToken(n) { + if (isToken(n)) { + return n; + } + var children = n.getChildren(); + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); + } + function find(n) { + if (isToken(n)) { + return n; + } + var children = n.getChildren(); + for (var i = 0, len = children.length; i < len; ++i) { + var child = children[i]; + if (nodeHasTokens(child)) { + if (position < child.end) { + if (child.getStart(sourceFile) >= position) { + var candidate = findRightmostChildNodeWithTokens(children, i); + return candidate && findRightmostToken(candidate); + } + else { + return find(child); + } + } + } + } + ts.Debug.assert(startNode || n.kind === 182 /* SourceFile */); + if (children.length) { + var candidate = findRightmostChildNodeWithTokens(children, children.length); + return candidate && findRightmostToken(candidate); + } + } + function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { + for (var i = exclusiveStartPosition - 1; i >= 0; --i) { + if (nodeHasTokens(children[i])) { + return children[i]; + } + } + } + } + ts.findPrecedingToken = findPrecedingToken; + function nodeHasTokens(n) { + if (n.kind === 151 /* ExpressionStatement */) { + return nodeHasTokens(n.expression); + } + if (n.kind === 1 /* EndOfFileToken */ || n.kind === 147 /* OmittedExpression */ || n.kind === 115 /* Missing */) { + return false; + } + return n.kind !== 184 /* SyntaxList */ || n.getChildCount() !== 0; + } + function isToken(n) { + return n.kind >= ts.SyntaxKind.FirstToken && n.kind <= ts.SyntaxKind.LastToken; + } + ts.isToken = isToken; + function isKeyword(n) { + return n.kind >= ts.SyntaxKind.FirstKeyword && n.kind <= ts.SyntaxKind.LastKeyword; + } + function isWord(n) { + return n.kind === 59 /* Identifier */ || isKeyword(n); + } + function isPropertyName(n) { + return n.kind === 7 /* StringLiteral */ || n.kind === 6 /* NumericLiteral */ || isWord(n); + } +})(ts || (ts = {})); var TypeScript; (function (TypeScript) { var Services; @@ -28027,8 +28712,10 @@ var TypeScript; var result = []; var formattingEdits = Formatting.Formatter.getEdits(span, this.syntaxTree.sourceUnit(), this.options, true, this.snapshot, this.rulesProvider, formattingRequestKind); formattingEdits.forEach(function (item) { - var edit = new ts.TextChange(new TypeScript.TextSpan(item.position, item.length), item.replaceWith); - result.push(edit); + result.push({ + span: new TypeScript.TextSpan(item.position, item.length), + newText: item.replaceWith + }); }); return result; }; @@ -29632,7 +30319,7 @@ var ts; if (position > sourceFile.text.length) { return 0; } - var precedingToken = findPrecedingToken(position, sourceFile); + var precedingToken = ts.findPrecedingToken(position, sourceFile); if (!precedingToken) { return 0; } @@ -29695,8 +30382,9 @@ var ts; } SmartIndenter.getIndentation = getIndentation; function getActualIndentationForListItemBeforeComma(commaToken, sourceFile, options) { - var itemInfo = findPrecedingListItem(commaToken); - return deriveActualIndentationFromList(itemInfo.list.getChildren(), itemInfo.listItemIndex, sourceFile, options); + var commaItemInfo = ts.findListItemInfo(commaToken); + ts.Debug.assert(commaItemInfo && commaItemInfo.listItemIndex > 0); + return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 182 /* SourceFile */ || !parentAndChildShareLine); @@ -29706,7 +30394,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { - var nextToken = findNextToken(precedingToken, current); + var nextToken = ts.findNextToken(precedingToken, current); if (!nextToken) { return false; } @@ -29722,27 +30410,12 @@ var ts; function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)); } - function findPrecedingListItem(commaToken) { - var syntaxList = ts.forEach(commaToken.parent.getChildren(), function (c) { - if (c.kind == 184 /* SyntaxList */ && c.pos <= commaToken.end && c.end >= commaToken.end) { - return c; - } - }); - ts.Debug.assert(syntaxList); - var children = syntaxList.getChildren(); - var commaIndex = ts.indexOf(children, commaToken); - ts.Debug.assert(commaIndex !== -1 && commaIndex !== 0); - return { - listItemIndex: commaIndex - 1, - list: syntaxList - }; - } function positionBelongsToNode(candidate, position, sourceFile) { return candidate.end > position || !isCompletedNode(candidate, sourceFile); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { if (parent.kind === 152 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.forEach(parent.getChildren(), function (c) { return c.kind === 70 /* ElseKeyword */ && c; }); + var elseKeyword = ts.findChildOfKind(parent, 70 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -29819,78 +30492,6 @@ var ts; } return column; } - function findNextToken(previousToken, parent) { - return find(parent); - function find(n) { - if (isToken(n) && n.pos === previousToken.end) { - return n; - } - var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; ++i) { - var child = children[i]; - var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || (child.pos === previousToken.end); - if (shouldDiveInChildNode && nodeHasTokens(child)) { - return find(child); - } - } - return undefined; - } - } - function findPrecedingToken(position, sourceFile) { - return find(sourceFile); - function findRightmostToken(n) { - if (isToken(n)) { - return n; - } - var children = n.getChildren(); - var candidate = findRightmostChildNodeWithTokens(children, children.length); - return candidate && findRightmostToken(candidate); - } - function find(n) { - if (isToken(n)) { - return n; - } - var children = n.getChildren(); - for (var i = 0, len = children.length; i < len; ++i) { - var child = children[i]; - if (nodeHasTokens(child)) { - if (position < child.end) { - if (child.getStart(sourceFile) >= position) { - var candidate = findRightmostChildNodeWithTokens(children, i); - return candidate && findRightmostToken(candidate); - } - else { - return find(child); - } - } - } - } - ts.Debug.assert(n.kind === 182 /* SourceFile */); - if (children.length) { - var candidate = findRightmostChildNodeWithTokens(children, children.length); - return candidate && findRightmostToken(candidate); - } - } - function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) { - for (var i = exclusiveStartPosition - 1; i >= 0; --i) { - if (nodeHasTokens(children[i])) { - return children[i]; - } - } - } - } - function nodeHasTokens(n) { - if (n.kind === 151 /* ExpressionStatement */) { - return nodeHasTokens(n.expression); - } - if (n.kind === 1 /* EndOfFileToken */ || n.kind === 147 /* OmittedExpression */ || n.kind === 115 /* Missing */) { - return false; - } - return n.kind !== 184 /* SyntaxList */ || n.getChildCount() !== 0; - } - function isToken(n) { - return n.kind >= ts.SyntaxKind.FirstToken && n.kind <= ts.SyntaxKind.LastToken; - } function nodeContentIsIndented(parent, child) { switch (parent.kind) { case 174 /* ClassDeclaration */: @@ -29992,7 +30593,7 @@ var ts; case 154 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); case 153 /* DoStatement */: - var hasWhileKeyword = ts.forEach(n.getChildren(), function (c) { return c.kind === 94 /* WhileKeyword */ && c; }); + var hasWhileKeyword = ts.findChildOfKind(n, 94 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 12 /* CloseParenToken */, sourceFile); } @@ -31236,98 +31837,6 @@ var TypeScript; })(ASTHelpers = TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); })(TypeScript || (TypeScript = {})); var TypeScript; -(function (TypeScript) { - var MemberName = (function () { - function MemberName() { - this.prefix = ""; - this.suffix = ""; - } - MemberName.prototype.isString = function () { - return false; - }; - MemberName.prototype.isArray = function () { - return false; - }; - MemberName.prototype.isMarker = function () { - return !this.isString() && !this.isArray(); - }; - MemberName.prototype.toString = function () { - return MemberName.memberNameToString(this); - }; - MemberName.memberNameToString = function (memberName, markerInfo, markerBaseLength) { - if (markerBaseLength === void 0) { markerBaseLength = 0; } - var result = memberName.prefix; - if (memberName.isString()) { - result += memberName.text; - } - else if (memberName.isArray()) { - var ar = memberName; - for (var index = 0; index < ar.entries.length; index++) { - if (ar.entries[index].isMarker()) { - if (markerInfo) { - markerInfo.push(markerBaseLength + result.length); - } - continue; - } - result += MemberName.memberNameToString(ar.entries[index], markerInfo, markerBaseLength + result.length); - result += ar.delim; - } - } - result += memberName.suffix; - return result; - }; - MemberName.create = function (arg1, arg2, arg3) { - if (typeof arg1 === "string") { - return new MemberNameString(arg1); - } - else { - var result = new MemberNameArray(); - if (arg2) - result.prefix = arg2; - if (arg3) - result.suffix = arg3; - result.entries.push(arg1); - return result; - } - }; - return MemberName; - })(); - TypeScript.MemberName = MemberName; - var MemberNameString = (function (_super) { - __extends(MemberNameString, _super); - function MemberNameString(text) { - _super.call(this); - this.text = text; - } - MemberNameString.prototype.isString = function () { - return true; - }; - return MemberNameString; - })(MemberName); - TypeScript.MemberNameString = MemberNameString; - var MemberNameArray = (function (_super) { - __extends(MemberNameArray, _super); - function MemberNameArray() { - _super.call(this); - this.delim = ""; - this.entries = []; - } - MemberNameArray.prototype.isArray = function () { - return true; - }; - MemberNameArray.prototype.add = function (entry) { - this.entries.push(entry); - }; - MemberNameArray.prototype.addAll = function (entries) { - for (var i = 0; i < entries.length; i++) { - this.entries.push(entries[i]); - } - }; - return MemberNameArray; - })(MemberName); - TypeScript.MemberNameArray = MemberNameArray; -})(TypeScript || (TypeScript = {})); -var TypeScript; (function (TypeScript) { function stripStartAndEndQuotes(str) { var firstCharCode = str && str.charCodeAt(0); @@ -31506,10 +32015,7 @@ var ts; function NodeObject() { } NodeObject.prototype.getSourceFile = function () { - var node = this; - while (node.kind !== 182 /* SourceFile */) - node = node.parent; - return node; + return ts.getSourceFileOfNode(this); }; NodeObject.prototype.getStart = function (sourceFile) { return ts.getTokenPosOfNode(this, sourceFile); @@ -31603,7 +32109,7 @@ var ts; return this._children; }; NodeObject.prototype.getFirstToken = function (sourceFile) { - var children = this.getChildren(sourceFile); + var children = this.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; if (child.kind < 115 /* Missing */) @@ -31638,8 +32144,225 @@ var ts; SymbolObject.prototype.getDeclarations = function () { return this.declarations; }; + SymbolObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = getJsDocCommentsFromDeclarations(this.declarations, this.name, !(this.flags & 2 /* Property */)); + } + return this.documentationComment; + }; return SymbolObject; })(); + function getJsDocCommentsFromDeclarations(declarations, name, canUseParsedParamTagComments) { + var documentationComment = []; + var docComments = getJsDocCommentsSeparatedByNewLines(); + ts.forEach(docComments, function (docComment) { + if (documentationComment.length) { + documentationComment.push(lineBreakPart()); + } + documentationComment.push(docComment); + }); + return documentationComment; + function getJsDocCommentsSeparatedByNewLines() { + var paramTag = "@param"; + var jsDocCommentParts = []; + ts.forEach(declarations, function (declaration) { + var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); + if (canUseParsedParamTagComments && declaration.kind === 118 /* Parameter */) { + ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedParamJsDocComment) { + jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment); + } + }); + } + if (declaration.kind === 177 /* ModuleDeclaration */ && declaration.body.kind === 177 /* ModuleDeclaration */) { + return; + } + while (declaration.kind === 177 /* ModuleDeclaration */ && declaration.parent.kind === 177 /* ModuleDeclaration */) { + declaration = declaration.parent; + } + ts.forEach(getJsDocCommentTextRange(declaration.kind === 171 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); + if (cleanedJsDocComment) { + jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); + } + }); + }); + return jsDocCommentParts; + function getJsDocCommentTextRange(node, sourceFile) { + return ts.map(ts.getJsDocComments(node, sourceFile), function (jsDocComment) { + return { + pos: jsDocComment.pos + "/*".length, + end: jsDocComment.end - "*/".length + }; + }); + } + function consumeWhiteSpacesOnTheLine(pos, end, sourceFile, maxSpacesToRemove) { + if (maxSpacesToRemove !== undefined) { + end = Math.min(end, pos + maxSpacesToRemove); + } + for (; pos < end; pos++) { + var ch = sourceFile.text.charCodeAt(pos); + if (!ts.isWhiteSpace(ch) || ts.isLineBreak(ch)) { + return pos; + } + } + return end; + } + function consumeLineBreaks(pos, end, sourceFile) { + while (pos < end && ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function isName(pos, end, sourceFile, name) { + return pos + name.length < end && sourceFile.text.substr(pos, name.length) === name && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)); + } + function isParamTag(pos, end, sourceFile) { + return isName(pos, end, sourceFile, paramTag); + } + function getCleanedJsDocComment(pos, end, sourceFile) { + var spacesToRemoveAfterAsterisk; + var docComments = []; + var isInParamTag = false; + while (pos < end) { + var docCommentTextOfLine = ""; + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); + if (pos < end && sourceFile.text.charCodeAt(pos) === 42 /* asterisk */) { + var lineStartPos = pos + 1; + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); + if (spacesToRemoveAfterAsterisk === undefined && pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + spacesToRemoveAfterAsterisk = pos - lineStartPos; + } + } + else if (spacesToRemoveAfterAsterisk === undefined) { + spacesToRemoveAfterAsterisk = 0; + } + while (pos < end && !ts.isLineBreak(sourceFile.text.charCodeAt(pos))) { + var ch = sourceFile.text.charAt(pos); + if (ch === "@") { + if (isParamTag(pos, end, sourceFile)) { + isInParamTag = true; + pos += paramTag.length; + continue; + } + else { + isInParamTag = false; + } + } + if (!isInParamTag) { + docCommentTextOfLine += ch; + } + pos++; + } + pos = consumeLineBreaks(pos, end, sourceFile); + if (docCommentTextOfLine) { + docComments.push(textPart(docCommentTextOfLine)); + } + } + return docComments; + } + function getCleanedParamJsDocComment(pos, end, sourceFile) { + var paramHelpStringMargin; + var paramDocComments = []; + while (pos < end) { + if (isParamTag(pos, end, sourceFile)) { + pos = consumeWhiteSpaces(pos + paramTag.length); + if (pos >= end) { + break; + } + if (sourceFile.text.charCodeAt(pos) === 123 /* openBrace */) { + pos++; + for (var curlies = 1; pos < end; pos++) { + var charCode = sourceFile.text.charCodeAt(pos); + if (charCode === 123 /* openBrace */) { + curlies++; + continue; + } + if (charCode === 125 /* closeBrace */) { + curlies--; + if (curlies === 0) { + pos++; + break; + } + else { + continue; + } + } + if (charCode === 64 /* at */) { + break; + } + } + pos = consumeWhiteSpaces(pos); + if (pos >= end) { + break; + } + } + if (isName(pos, end, sourceFile, name)) { + pos = consumeWhiteSpaces(pos + name.length); + if (pos >= end) { + break; + } + var paramHelpString = ""; + var firstLineParamHelpStringPos = pos; + while (pos < end) { + var ch = sourceFile.text.charCodeAt(pos); + if (ts.isLineBreak(ch)) { + if (paramHelpString) { + paramDocComments.push(textPart(paramHelpString)); + paramHelpString = ""; + } + setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); + continue; + } + if (ch === 64 /* at */) { + break; + } + paramHelpString += sourceFile.text.charAt(pos); + pos++; + } + if (paramHelpString) { + paramDocComments.push(textPart(paramHelpString)); + } + paramHelpStringMargin = undefined; + } + if (sourceFile.text.charCodeAt(pos) === 64 /* at */) { + continue; + } + } + pos++; + } + return paramDocComments; + function consumeWhiteSpaces(pos) { + while (pos < end && ts.isWhiteSpace(sourceFile.text.charCodeAt(pos))) { + pos++; + } + return pos; + } + function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos) { + pos = consumeLineBreaks(pos, end, sourceFile); + if (pos >= end) { + return; + } + if (paramHelpStringMargin === undefined) { + paramHelpStringMargin = sourceFile.getLineAndCharacterFromPosition(firstLineParamHelpStringPos).character - 1; + } + var startOfLinePos = pos; + pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); + if (pos >= end) { + return; + } + var consumedSpaces = pos - startOfLinePos; + if (consumedSpaces < paramHelpStringMargin) { + var ch = sourceFile.text.charCodeAt(pos); + if (ch === 42 /* asterisk */) { + pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); + } + } + } + } + } + } var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -31690,6 +32413,12 @@ var ts; SignatureObject.prototype.getReturnType = function () { return this.checker.getReturnTypeOfSignature(this); }; + SignatureObject.prototype.getDocumentationComment = function () { + if (this.documentationComment === undefined) { + this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations([this.declaration], this.declaration.name ? this.declaration.name.text : "", false) : []; + } + return this.documentationComment; + }; return SignatureObject; })(); var incrementalParse = TypeScript.IncrementalParser.parse; @@ -31717,25 +32446,36 @@ var ts; if (!this.namedDeclarations) { var sourceFile = this; var namedDeclarations = []; - var isExternalModule = ts.isExternalModule(sourceFile); ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { + case 172 /* FunctionDeclaration */: + case 120 /* Method */: + var functionDeclaration = node; + if (functionDeclaration.name && functionDeclaration.name.kind !== 115 /* Missing */) { + var lastDeclaration = namedDeclarations.length > 0 ? namedDeclarations[namedDeclarations.length - 1] : undefined; + if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) { + if (functionDeclaration.body && !lastDeclaration.body) { + namedDeclarations[namedDeclarations.length - 1] = functionDeclaration; + } + } + else { + namedDeclarations.push(node); + } + ts.forEachChild(node, visit); + } + break; case 174 /* ClassDeclaration */: case 175 /* InterfaceDeclaration */: case 176 /* EnumDeclaration */: case 177 /* ModuleDeclaration */: case 179 /* ImportDeclaration */: - case 120 /* Method */: - case 172 /* FunctionDeclaration */: - case 121 /* Constructor */: case 122 /* GetAccessor */: case 123 /* SetAccessor */: case 129 /* TypeLiteral */: if (node.name) { namedDeclarations.push(node); } - ts.forEachChild(node, visit); - break; + case 121 /* Constructor */: case 149 /* VariableStatement */: case 178 /* ModuleBlock */: case 173 /* FunctionBlock */: @@ -31751,7 +32491,6 @@ var ts; namedDeclarations.push(node); break; } - return undefined; }); this.namedDeclarations = namedDeclarations; } @@ -31795,192 +32534,12 @@ var ts; }; return SourceFileObject; })(NodeObject); - var ClassificationTypeNames = (function () { - function ClassificationTypeNames() { - } - ClassificationTypeNames.comment = "comment"; - ClassificationTypeNames.identifier = "identifier"; - ClassificationTypeNames.keyword = "keyword"; - ClassificationTypeNames.numericLiteral = "number"; - ClassificationTypeNames.operator = "operator"; - ClassificationTypeNames.stringLiteral = "string"; - ClassificationTypeNames.whiteSpace = "whitespace"; - ClassificationTypeNames.text = "text"; - ClassificationTypeNames.punctuation = "punctuation"; - ClassificationTypeNames.className = "class name"; - ClassificationTypeNames.enumName = "enum name"; - ClassificationTypeNames.interfaceName = "interface name"; - ClassificationTypeNames.moduleName = "module name"; - ClassificationTypeNames.typeParameterName = "type parameter name"; - return ClassificationTypeNames; - })(); - ts.ClassificationTypeNames = ClassificationTypeNames; - var ClassifiedSpan = (function () { - function ClassifiedSpan(textSpan, classificationType) { - this.textSpan = textSpan; - this.classificationType = classificationType; - } - return ClassifiedSpan; - })(); - ts.ClassifiedSpan = ClassifiedSpan; - var NavigationBarItem = (function () { - function NavigationBarItem(text, kind, kindModifiers, spans, childItems, indent, bolded, grayed) { - if (childItems === void 0) { childItems = null; } - if (indent === void 0) { indent = 0; } - if (bolded === void 0) { bolded = false; } - if (grayed === void 0) { grayed = false; } - this.text = text; - this.kind = kind; - this.kindModifiers = kindModifiers; - this.spans = spans; - this.childItems = childItems; - this.indent = indent; - this.bolded = bolded; - this.grayed = grayed; - } - return NavigationBarItem; - })(); - ts.NavigationBarItem = NavigationBarItem; - var TodoCommentDescriptor = (function () { - function TodoCommentDescriptor(text, priority) { - this.text = text; - this.priority = priority; - } - return TodoCommentDescriptor; - })(); - ts.TodoCommentDescriptor = TodoCommentDescriptor; - var TodoComment = (function () { - function TodoComment(descriptor, message, position) { - this.descriptor = descriptor; - this.message = message; - this.position = position; - } - return TodoComment; - })(); - ts.TodoComment = TodoComment; var TextChange = (function () { - function TextChange(span, newText) { - this.span = span; - this.newText = newText; + function TextChange() { } - TextChange.createInsert = function (pos, newText) { - return new TextChange(new TypeScript.TextSpan(pos, 0), newText); - }; - TextChange.createDelete = function (start, end) { - return new TextChange(TypeScript.TextSpan.fromBounds(start, end), ""); - }; - TextChange.createReplace = function (start, end, newText) { - return new TextChange(TypeScript.TextSpan.fromBounds(start, end), newText); - }; return TextChange; })(); ts.TextChange = TextChange; - var ReferenceEntry = (function () { - function ReferenceEntry(fileName, textSpan, isWriteAccess) { - this.fileName = ""; - this.isWriteAccess = false; - this.fileName = fileName; - this.textSpan = textSpan; - this.isWriteAccess = isWriteAccess; - } - return ReferenceEntry; - })(); - ts.ReferenceEntry = ReferenceEntry; - var NavigateToItem = (function () { - function NavigateToItem(name, kind, kindModifiers, matchKind, fileName, textSpan, containerName, containerKind) { - this.name = name; - this.kind = kind; - this.kindModifiers = kindModifiers; - this.matchKind = matchKind; - this.fileName = fileName; - this.textSpan = textSpan; - this.containerName = containerName; - this.containerKind = containerKind; - } - return NavigateToItem; - })(); - ts.NavigateToItem = NavigateToItem; - var DefinitionInfo = (function () { - function DefinitionInfo(fileName, textSpan, kind, name, containerKind, containerName) { - this.fileName = fileName; - this.textSpan = textSpan; - this.kind = kind; - this.name = name; - this.containerKind = containerKind; - this.containerName = containerName; - } - return DefinitionInfo; - })(); - ts.DefinitionInfo = DefinitionInfo; - var TypeInfo = (function () { - function TypeInfo(memberName, docComment, fullSymbolName, kind, textSpan) { - this.memberName = memberName; - this.docComment = docComment; - this.fullSymbolName = fullSymbolName; - this.kind = kind; - this.textSpan = textSpan; - } - return TypeInfo; - })(); - ts.TypeInfo = TypeInfo; - var RenameInfo = (function () { - function RenameInfo(canRename, localizedErrorMessage, displayName, fullDisplayName, kind, kindModifiers, triggerSpan) { - this.canRename = canRename; - this.localizedErrorMessage = localizedErrorMessage; - this.displayName = displayName; - this.fullDisplayName = fullDisplayName; - this.kind = kind; - this.kindModifiers = kindModifiers; - this.triggerSpan = triggerSpan; - } - RenameInfo.CreateError = function (localizedErrorMessage) { - return new RenameInfo(false, localizedErrorMessage, null, null, null, null, null); - }; - RenameInfo.Create = function (displayName, fullDisplayName, kind, kindModifiers, triggerSpan) { - return new RenameInfo(true, null, displayName, fullDisplayName, kind, kindModifiers, triggerSpan); - }; - return RenameInfo; - })(); - ts.RenameInfo = RenameInfo; - var SignatureHelpParameter = (function () { - function SignatureHelpParameter(name, documentation, display, isOptional) { - this.name = name; - this.documentation = documentation; - this.display = display; - this.isOptional = isOptional; - } - return SignatureHelpParameter; - })(); - ts.SignatureHelpParameter = SignatureHelpParameter; - var SignatureHelpItem = (function () { - function SignatureHelpItem(isVariadic, prefix, suffix, separator, parameters, documentation) { - this.isVariadic = isVariadic; - this.prefix = prefix; - this.suffix = suffix; - this.separator = separator; - this.parameters = parameters; - this.documentation = documentation; - } - return SignatureHelpItem; - })(); - ts.SignatureHelpItem = SignatureHelpItem; - var SignatureHelpItems = (function () { - function SignatureHelpItems(items, applicableSpan, selectedItemIndex) { - this.items = items; - this.applicableSpan = applicableSpan; - this.selectedItemIndex = selectedItemIndex; - } - return SignatureHelpItems; - })(); - ts.SignatureHelpItems = SignatureHelpItems; - var SignatureHelpState = (function () { - function SignatureHelpState(argumentIndex, argumentCount) { - this.argumentIndex = argumentIndex; - this.argumentCount = argumentCount; - } - return SignatureHelpState; - })(); - ts.SignatureHelpState = SignatureHelpState; (function (OutputFileType) { OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; @@ -32032,6 +32591,7 @@ var ts; ScriptElementKind.typeParameterElement = "type parameter"; ScriptElementKind.primitiveType = "primitive type"; ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; return ScriptElementKind; })(); ts.ScriptElementKind = ScriptElementKind; @@ -32041,12 +32601,33 @@ var ts; ScriptElementKindModifier.none = ""; ScriptElementKindModifier.publicMemberModifier = "public"; ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; ScriptElementKindModifier.exportedModifier = "export"; ScriptElementKindModifier.ambientModifier = "declare"; ScriptElementKindModifier.staticModifier = "static"; return ScriptElementKindModifier; })(); ts.ScriptElementKindModifier = ScriptElementKindModifier; + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + return ClassificationTypeNames; + })(); + ts.ClassificationTypeNames = ClassificationTypeNames; var MatchKind; (function (MatchKind) { MatchKind[MatchKind["none"] = 0] = "none"; @@ -32054,6 +32635,171 @@ var ts; MatchKind[MatchKind["substring"] = 2] = "substring"; MatchKind[MatchKind["prefix"] = 3] = "prefix"; })(MatchKind || (MatchKind = {})); + function displayPartsToString(displayParts) { + if (displayParts) { + return ts.map(displayParts, function (displayPart) { return displayPart.text; }).join(""); + } + return ""; + } + ts.displayPartsToString = displayPartsToString; + var displayPartWriter = getDisplayPartWriter(); + function getDisplayPartWriter() { + var displayParts; + var lineStart; + var indent; + resetWriter(); + return { + displayParts: function () { return displayParts; }, + writeKind: writeKind, + writeSymbol: writeSymbol, + writeLine: writeLine, + increaseIndent: function () { + indent++; + }, + decreaseIndent: function () { + indent--; + }, + clear: resetWriter, + trackSymbol: function () { + } + }; + function writeIndent() { + if (lineStart) { + displayParts.push(displayPart(ts.getIndentString(indent), 16 /* space */)); + lineStart = false; + } + } + function writeKind(text, kind) { + writeIndent(); + displayParts.push(displayPart(text, kind)); + } + function writeSymbol(text, symbol) { + writeIndent(); + displayParts.push(symbolPart(text, symbol)); + } + function writeLine() { + displayParts.push(lineBreakPart()); + lineStart = true; + } + function resetWriter() { + displayParts = []; + lineStart = true; + indent = 0; + } + } + function displayPart(text, kind, symbol) { + return { + text: text, + kind: ts.SymbolDisplayPartKind[kind] + }; + } + function spacePart() { + return displayPart(" ", 16 /* space */); + } + ts.spacePart = spacePart; + function keywordPart(kind) { + return displayPart(ts.tokenToString(kind), 5 /* keyword */); + } + ts.keywordPart = keywordPart; + function punctuationPart(kind) { + return displayPart(ts.tokenToString(kind), 15 /* punctuation */); + } + ts.punctuationPart = punctuationPart; + function operatorPart(kind) { + return displayPart(ts.tokenToString(kind), 12 /* operator */); + } + ts.operatorPart = operatorPart; + function textPart(text) { + return displayPart(text, 17 /* text */); + } + ts.textPart = textPart; + function lineBreakPart() { + return displayPart("\n", 6 /* lineBreak */); + } + ts.lineBreakPart = lineBreakPart; + function isFirstDeclarationOfSymbolParameter(symbol) { + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 118 /* Parameter */; + } + function isLocalVariableOrFunction(symbol) { + if (symbol.parent) { + return false; + } + return ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 141 /* FunctionExpression */) { + return true; + } + if (declaration.kind !== 171 /* VariableDeclaration */ && declaration.kind !== 172 /* FunctionDeclaration */) { + return false; + } + for (var parent = declaration.parent; parent.kind !== 173 /* FunctionBlock */; parent = parent.parent) { + if (parent.kind === 182 /* SourceFile */ || parent.kind === 178 /* ModuleBlock */) { + return false; + } + } + return true; + }); + } + function symbolPart(text, symbol) { + return displayPart(text, displayPartKind(symbol), symbol); + function displayPartKind(symbol) { + var flags = symbol.flags; + if (flags & 1 /* Variable */) { + return isFirstDeclarationOfSymbolParameter(symbol) ? 13 /* parameterName */ : 9 /* localName */; + } + else if (flags & 2 /* Property */) { + return 14 /* propertyName */; + } + else if (flags & 4 /* EnumMember */) { + return 19 /* enumMemberName */; + } + else if (flags & 8 /* Function */) { + return 20 /* functionName */; + } + else if (flags & 16 /* Class */) { + return 1 /* className */; + } + else if (flags & 32 /* Interface */) { + return 4 /* interfaceName */; + } + else if (flags & 64 /* Enum */) { + return 2 /* enumName */; + } + else if (flags & ts.SymbolFlags.Module) { + return 11 /* moduleName */; + } + else if (flags & 2048 /* Method */) { + return 10 /* methodName */; + } + else if (flags & 262144 /* TypeParameter */) { + return 18 /* typeParameterName */; + } + return 17 /* text */; + } + } + ts.symbolPart = symbolPart; + function mapToDisplayParts(writeDisplayParts) { + writeDisplayParts(displayPartWriter); + var result = displayPartWriter.displayParts(); + displayPartWriter.clear(); + return result; + } + function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.writeType(type, writer, enclosingDeclaration, flags); + }); + } + ts.typeToDisplayParts = typeToDisplayParts; + function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + return mapToDisplayParts(function (writer) { + typeChecker.writeSymbol(symbol, writer, enclosingDeclaration, meaning, flags); + }); + } + ts.symbolToDisplayParts = symbolToDisplayParts; + function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + return mapToDisplayParts(function (writer) { + typechecker.writeSignature(signature, writer, enclosingDeclaration, flags); + }); + } function getDefaultCompilerOptions() { return { target: 1 /* ES5 */, @@ -32096,6 +32842,7 @@ var ts; CancellationTokenObject.None = new CancellationTokenObject(null); return CancellationTokenObject; })(); + ts.CancellationTokenObject = CancellationTokenObject; var HostCache = (function () { function HostCache(host) { this.host = host; @@ -32343,6 +33090,24 @@ var ts; }; } ts.createDocumentRegistry = createDocumentRegistry; + function getNodeModifiers(node) { + var flags = node.flags; + var result = []; + if (flags & 32 /* Private */) + result.push(ScriptElementKindModifier.privateMemberModifier); + if (flags & 64 /* Protected */) + result.push(ScriptElementKindModifier.protectedMemberModifier); + if (flags & 16 /* Public */) + result.push(ScriptElementKindModifier.publicMemberModifier); + if (flags & 128 /* Static */) + result.push(ScriptElementKindModifier.staticModifier); + if (flags & 1 /* Export */) + result.push(ScriptElementKindModifier.exportedModifier); + if (ts.isInAmbientContext(node)) + result.push(ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none; + } + ts.getNodeModifiers = getNodeModifiers; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { if (referenceNode.kind === 164 /* LabeledStatement */ && referenceNode.label.text === labelName) { @@ -32405,13 +33170,14 @@ var ts; function isNameOfExternalModuleImportOrDeclaration(node) { return node.kind === 7 /* StringLiteral */ && ((node.parent.kind === 177 /* ModuleDeclaration */ && node.parent.name === node) || (node.parent.kind === 179 /* ImportDeclaration */ && node.parent.externalModuleName === node)); } - var SearchMeaning; - (function (SearchMeaning) { - SearchMeaning[SearchMeaning["None"] = 0x0] = "None"; - SearchMeaning[SearchMeaning["Value"] = 0x1] = "Value"; - SearchMeaning[SearchMeaning["Type"] = 0x2] = "Type"; - SearchMeaning[SearchMeaning["Namespace"] = 0x4] = "Namespace"; - })(SearchMeaning || (SearchMeaning = {})); + var SemanticMeaning; + (function (SemanticMeaning) { + SemanticMeaning[SemanticMeaning["None"] = 0x0] = "None"; + SemanticMeaning[SemanticMeaning["Value"] = 0x1] = "Value"; + SemanticMeaning[SemanticMeaning["Type"] = 0x2] = "Type"; + SemanticMeaning[SemanticMeaning["Namespace"] = 0x4] = "Namespace"; + SemanticMeaning[SemanticMeaning["All"] = SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace] = "All"; + })(SemanticMeaning || (SemanticMeaning = {})); var BreakContinueSearchType; (function (BreakContinueSearchType) { BreakContinueSearchType[BreakContinueSearchType["None"] = 0x0] = "None"; @@ -32440,11 +33206,14 @@ var ts; var cancellationToken = new CancellationTokenObject(host.getCancellationToken()); var activeCompletionSession; var writer = undefined; - if (!TypeScript.LocalizedDiagnosticMessages) { - TypeScript.LocalizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); + if (!ts.localizedDiagnosticMessages) { + ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); + } + function getCanonicalFileName(filename) { + return useCaseSensitivefilenames ? filename : filename.toLowerCase(); } function getSourceFile(filename) { - return ts.lookUp(sourceFilesByName, filename); + return ts.lookUp(sourceFilesByName, getCanonicalFileName(filename)); } function getFullTypeCheckChecker() { return fullTypeCheckChecker_doNotAccessDirectly || (fullTypeCheckChecker_doNotAccessDirectly = program.getTypeChecker(true)); @@ -32505,7 +33274,7 @@ var ts; var filename = oldSourceFiles[i].filename; if (!hostCache.contains(filename) || changesInCompilationSettingsAffectSyntax) { documentRegistry.releaseDocument(filename, oldSettings); - delete sourceFilesByName[filename]; + delete sourceFilesByName[getCanonicalFileName(filename)]; } } } @@ -32529,7 +33298,7 @@ var ts; else { sourceFile = documentRegistry.acquireDocument(filename, compilationSettings, scriptSnapshot, version, isOpen); } - sourceFilesByName[filename] = sourceFile; + sourceFilesByName[getCanonicalFileName(filename)] = sourceFile; } program = ts.createProgram(hostfilenames, compilationSettings, createCompilerHost()); typeInfoResolver = program.getTypeChecker(false); @@ -32561,11 +33330,7 @@ var ts; var targetSourceFile = getSourceFile(filename); var allDiagnostics = checker.getDiagnostics(targetSourceFile); if (compilerOptions.declaration) { - var savedWriter = writer; - writer = function (filename, data, writeByteOrderMark) { - }; - allDiagnostics = allDiagnostics.concat(checker.emitFiles(targetSourceFile).errors); - writer = savedWriter; + allDiagnostics = allDiagnostics.concat(checker.getDeclarationDiagnostics(targetSourceFile)); } return allDiagnostics; } @@ -32573,9 +33338,13 @@ var ts; synchronizeHostData(); return program.getGlobalDiagnostics(); } - function getValidCompletionEntryDisplayName(displayName, target) { + function getValidCompletionEntryDisplayName(symbol, target) { + var displayName = symbol.getName(); if (displayName && displayName.length > 0) { var firstCharCode = displayName.charCodeAt(0); + if ((symbol.flags & ts.SymbolFlags.Namespace) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + return undefined; + } if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { displayName = displayName.substring(1, displayName.length - 1); } @@ -32589,22 +33358,21 @@ var ts; } return undefined; } - function createCompletionEntry(symbol) { - var displayName = getValidCompletionEntryDisplayName(symbol.getName(), program.getCompilerOptions().target); + function createCompletionEntry(symbol, typeChecker) { + var displayName = getValidCompletionEntryDisplayName(symbol, program.getCompilerOptions().target); if (!displayName) { return undefined; } - var declarations = symbol.getDeclarations(); return { name: displayName, - kind: getSymbolKind(symbol), - kindModifiers: declarations ? getNodeModifiers(declarations[0]) : ScriptElementKindModifier.none + kind: getSymbolKind(symbol, typeChecker), + kindModifiers: getSymbolModifiers(symbol) }; } function getCompletionsAtPosition(filename, position, isMemberCompletion) { function getCompletionEntriesFromSymbols(symbols, session) { ts.forEach(symbols, function (symbol) { - var entry = createCompletionEntry(symbol); + var entry = createCompletionEntry(symbol, session.typeChecker); if (entry && !ts.lookUp(session.symbols, entry.name)) { session.entries.push(entry); session.symbols[entry.name] = symbol; @@ -32698,14 +33466,6 @@ var ts; function isPunctuation(kind) { return (ts.SyntaxKind.FirstPunctuation <= kind && kind <= ts.SyntaxKind.LastPunctuation); } - function isVisibleWithinClassDeclaration(symbol, containingClass) { - var declaration = symbol.declarations && symbol.declarations[0]; - if (declaration && (declaration.flags & 32 /* Private */)) { - var declarationClass = ts.getAncestor(declaration, 174 /* ClassDeclaration */); - return containingClass === declarationClass; - } - return true; - } function filterContextualMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; @@ -32757,9 +33517,16 @@ var ts; isRightOfDot = true; node = node.parent.left; } - var mappedNode = getNodeAtPosition(sourceFile, TypeScript.end(node) - 1); - if (isPunctuation(mappedNode.kind)) { - mappedNode = mappedNode.parent; + var precedingToken = ts.findTokenOnLeftOfPosition(sourceFile, TypeScript.end(node)); + var mappedNode; + if (!precedingToken) { + mappedNode = sourceFile; + } + else if (isPunctuation(precedingToken.kind)) { + mappedNode = precedingToken.parent; + } + else { + mappedNode = precedingToken; } ts.Debug.assert(mappedNode, "Could not map a Fidelity node to an AST node"); activeCompletionSession = { @@ -32772,13 +33539,15 @@ var ts; }; if (isRightOfDot) { var symbols = []; - var containingClass = ts.getAncestor(mappedNode, 174 /* ClassDeclaration */); isMemberCompletion = true; if (mappedNode.kind === 59 /* Identifier */ || mappedNode.kind === 116 /* QualifiedName */ || mappedNode.kind === 135 /* PropertyAccess */) { var symbol = typeInfoResolver.getSymbolInfo(mappedNode); + if (symbol && symbol.flags & 4194304 /* Import */) { + symbol = typeInfoResolver.getAliasedSymbol(symbol); + } if (symbol && symbol.flags & ts.SymbolFlags.HasExports) { ts.forEachValue(symbol.exports, function (symbol) { - if (isVisibleWithinClassDeclaration(symbol, containingClass)) { + if (typeInfoResolver.isValidPropertyAccess((mappedNode.parent), symbol.name)) { symbols.push(symbol); } }); @@ -32788,7 +33557,7 @@ var ts; var apparentType = type && typeInfoResolver.getApparentType(type); if (apparentType) { ts.forEach(apparentType.getApparentProperties(), function (symbol) { - if (isVisibleWithinClassDeclaration(symbol, containingClass)) { + if (typeInfoResolver.isValidPropertyAccess((mappedNode.parent), symbol.name)) { symbols.push(symbol); } }); @@ -32813,7 +33582,7 @@ var ts; } else { isMemberCompletion = false; - var symbolMeanings = ts.SymbolFlags.Type | ts.SymbolFlags.Value | ts.SymbolFlags.Namespace; + var symbolMeanings = ts.SymbolFlags.Type | ts.SymbolFlags.Value | ts.SymbolFlags.Namespace | 4194304 /* Import */; var symbols = typeInfoResolver.getSymbolsInScope(mappedNode, symbolMeanings); getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } @@ -32836,14 +33605,14 @@ var ts; if (symbol) { var type = session.typeChecker.getTypeOfSymbol(symbol); ts.Debug.assert(type, "Could not find type for symbol"); - var completionEntry = createCompletionEntry(symbol); + var completionEntry = createCompletionEntry(symbol, session.typeChecker); + var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), session.location, session.typeChecker, session.location); return { name: entryName, - kind: completionEntry.kind, + kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: completionEntry.kindModifiers, - type: session.typeChecker.typeToString(type, session.location), - fullSymbolName: typeInfoResolver.symbolToString(symbol, session.location), - docComment: "" + displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, + documentation: displayPartsDocumentationsAndSymbolKind.documentation }; } else { @@ -32851,38 +33620,11 @@ var ts; name: entryName, kind: ScriptElementKind.keyword, kindModifiers: ScriptElementKindModifier.none, - type: undefined, - fullSymbolName: entryName, - docComment: undefined + displayParts: [displayPart(entryName, 5 /* keyword */)], + documentation: undefined }; } } - function getNodeAtPosition(sourceFile, position) { - var current = sourceFile; - outer: while (true) { - for (var i = 0, n = current.getChildCount(); i < n; i++) { - var child = current.getChildAt(i); - if (child.getStart() <= position && position < child.getEnd()) { - current = child; - continue outer; - } - } - return current; - } - } - function getTokenAtPosition(sourceFile, position) { - var current = sourceFile; - outer: while (true) { - for (var i = 0, n = current.getChildCount(); i < n; i++) { - var child = current.getChildAt(i); - if (child.getFullStart() <= position && position < child.getEnd()) { - current = child; - continue outer; - } - } - return current; - } - } function getContainerNode(node) { while (true) { node = node.parent; @@ -32904,20 +33646,42 @@ var ts; } } } - function getSymbolKind(symbol) { + function getSymbolKind(symbol, typeResolver) { var flags = typeInfoResolver.getRootSymbol(symbol).getFlags(); - if (flags & ts.SymbolFlags.Module) - return ScriptElementKind.moduleElement; if (flags & 16 /* Class */) return ScriptElementKind.classElement; - if (flags & 32 /* Interface */) - return ScriptElementKind.interfaceElement; if (flags & 64 /* Enum */) return ScriptElementKind.enumElement; - if (flags & 1 /* Variable */) + if (flags & 32 /* Interface */) + return ScriptElementKind.interfaceElement; + if (flags & 262144 /* TypeParameter */) + return ScriptElementKind.typeParameterElement; + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver); + if (result === ScriptElementKind.unknown) { + if (flags & 262144 /* TypeParameter */) + return ScriptElementKind.typeParameterElement; + if (flags & 4 /* EnumMember */) + return ScriptElementKind.variableElement; + if (flags & 4194304 /* Import */) + return ScriptElementKind.alias; + } + return result; + } + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver) { + if (typeResolver.isUndefinedSymbol(symbol)) { return ScriptElementKind.variableElement; + } + if (typeResolver.isArgumentsSymbol(symbol)) { + return ScriptElementKind.localVariableElement; + } + if (flags & 1 /* Variable */) { + if (isFirstDeclarationOfSymbolParameter(symbol)) { + return ScriptElementKind.parameterElement; + } + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement; + } if (flags & 8 /* Function */) - return ScriptElementKind.functionElement; + return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; if (flags & 8192 /* GetAccessor */) return ScriptElementKind.memberGetAccessorElement; if (flags & 16384 /* SetAccessor */) @@ -32926,18 +33690,8 @@ var ts; return ScriptElementKind.memberFunctionElement; if (flags & 2 /* Property */) return ScriptElementKind.memberVariableElement; - if (flags & 131072 /* IndexSignature */) - return ScriptElementKind.indexSignatureElement; - if (flags & 65536 /* ConstructSignature */) - return ScriptElementKind.constructSignatureElement; - if (flags & 32768 /* CallSignature */) - return ScriptElementKind.callSignatureElement; if (flags & 4096 /* Constructor */) return ScriptElementKind.constructorImplementationElement; - if (flags & 262144 /* TypeParameter */) - return ScriptElementKind.typeParameterElement; - if (flags & 4 /* EnumMember */) - return ScriptElementKind.variableElement; return ScriptElementKind.unknown; } function getTypeKind(type) { @@ -32995,39 +33749,308 @@ var ts; return ScriptElementKind.unknown; } } - function getNodeModifiers(node) { - var flags = node.flags; - var result = []; - if (flags & 32 /* Private */) - result.push(ScriptElementKindModifier.privateMemberModifier); - if (flags & 16 /* Public */) - result.push(ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) - result.push(ScriptElementKindModifier.staticModifier); - if (flags & 1 /* Export */) - result.push(ScriptElementKindModifier.exportedModifier); - if (ts.isInAmbientContext(node)) - result.push(ScriptElementKindModifier.ambientModifier); - return result.length > 0 ? result.join(',') : ScriptElementKindModifier.none; + function getSymbolModifiers(symbol) { + return symbol && symbol.declarations && symbol.declarations.length > 0 ? getNodeModifiers(symbol.declarations[0]) : ScriptElementKindModifier.none; } - function getTypeAtPosition(fileName, position) { + function getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, enclosingDeclaration, typeResolver, location) { + var displayParts = []; + var documentation; + var symbolFlags = typeResolver.getRootSymbol(symbol).flags; + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver); + var hasAddedSymbolInfo; + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 16 /* Class */ || symbolFlags & 4194304 /* Import */) { + if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { + symbolKind = ScriptElementKind.memberVariableElement; + } + var type = typeResolver.getTypeOfSymbol(symbol); + if (type) { + if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { + var callExpression; + if (location.parent.kind === 135 /* PropertyAccess */ && location.parent.right === location) { + location = location.parent; + } + callExpression = location.parent; + var candidateSignatures = []; + signature = typeResolver.getResolvedSignature(callExpression, candidateSignatures); + if (!signature && candidateSignatures.length) { + signature = candidateSignatures[0]; + } + var useConstructSignatures = callExpression.kind === 138 /* NewExpression */ || callExpression.func.kind === 85 /* SuperKeyword */; + var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); + if (!ts.contains(allSignatures, signature.target || signature)) { + signature = allSignatures.length ? allSignatures[0] : undefined; + } + if (signature) { + if (useConstructSignatures && (symbolFlags & 16 /* Class */)) { + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else if (symbolFlags & 4194304 /* Import */) { + symbolKind = ScriptElementKind.alias; + displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(textPart(symbolKind)); + displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(spacePart()); + if (useConstructSignatures) { + displayParts.push(keywordPart(82 /* NewKeyword */)); + displayParts.push(spacePart()); + } + addFullSymbolName(symbol); + } + else { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + } + switch (symbolKind) { + case ScriptElementKind.memberVariableElement: + case ScriptElementKind.variableElement: + case ScriptElementKind.parameterElement: + case ScriptElementKind.localVariableElement: + displayParts.push(punctuationPart(46 /* ColonToken */)); + displayParts.push(spacePart()); + if (useConstructSignatures) { + displayParts.push(keywordPart(82 /* NewKeyword */)); + displayParts.push(spacePart()); + } + if (!(type.flags & 16384 /* Anonymous */)) { + displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + } + addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); + break; + default: + addSignatureDisplayParts(signature, allSignatures); + } + hasAddedSymbolInfo = true; + } + } + else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & ts.SymbolFlags.Accessor)) || (location.kind === 107 /* ConstructorKeyword */ && location.parent.kind === 121 /* Constructor */)) { + var signature; + var functionDeclaration = location.parent; + var allSignatures = functionDeclaration.kind === 121 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + if (!typeResolver.isImplementationOfOverload(functionDeclaration)) { + signature = typeResolver.getSignatureFromDeclaration(functionDeclaration); + } + else { + signature = allSignatures[0]; + } + if (functionDeclaration.kind === 121 /* Constructor */) { + addPrefixForAnyFunctionOrVar(type.symbol, ScriptElementKind.constructorImplementationElement); + } + else { + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 124 /* CallSignature */ && !(type.symbol.flags & 512 /* TypeLiteral */ || type.symbol.flags & 1024 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + } + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; + } + } + } + if (symbolFlags & 16 /* Class */ && !hasAddedSymbolInfo) { + displayParts.push(keywordPart(63 /* ClassKeyword */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if (symbolFlags & 32 /* Interface */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(keywordPart(97 /* InterfaceKeyword */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + writeTypeParametersOfSymbol(symbol, sourceFile); + } + if (symbolFlags & 64 /* Enum */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(keywordPart(71 /* EnumKeyword */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + } + if (symbolFlags & ts.SymbolFlags.Module) { + addNewLineIfDisplayPartsExist(); + displayParts.push(keywordPart(110 /* ModuleKeyword */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + } + if (symbolFlags & 262144 /* TypeParameter */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(textPart("type parameter")); + displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + displayParts.push(spacePart()); + displayParts.push(keywordPart(80 /* InKeyword */)); + displayParts.push(spacePart()); + if (symbol.parent) { + addFullSymbolName(symbol.parent, enclosingDeclaration); + writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); + } + else { + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 117 /* TypeParameter */).parent; + var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); + if (signatureDeclaration.kind === 125 /* ConstructSignature */) { + displayParts.push(keywordPart(82 /* NewKeyword */)); + displayParts.push(spacePart()); + } + else if (signatureDeclaration.kind !== 124 /* CallSignature */ && signatureDeclaration.name) { + addFullSymbolName(signatureDeclaration.symbol); + } + displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + } + } + if (symbolFlags & 4 /* EnumMember */) { + addPrefixForAnyFunctionOrVar(symbol, "enum member"); + var declaration = symbol.declarations[0]; + if (declaration.kind === 181 /* EnumMember */) { + var constantValue = typeResolver.getEnumMemberValue(declaration); + if (constantValue !== undefined) { + displayParts.push(spacePart()); + displayParts.push(operatorPart(47 /* EqualsToken */)); + displayParts.push(spacePart()); + displayParts.push(displayPart(constantValue.toString(), 7 /* numericLiteral */)); + } + } + } + if (symbolFlags & 4194304 /* Import */) { + addNewLineIfDisplayPartsExist(); + displayParts.push(keywordPart(79 /* ImportKeyword */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + displayParts.push(spacePart()); + displayParts.push(punctuationPart(47 /* EqualsToken */)); + displayParts.push(spacePart()); + ts.forEach(symbol.declarations, function (declaration) { + if (declaration.kind === 179 /* ImportDeclaration */) { + var importDeclaration = declaration; + if (importDeclaration.externalModuleName) { + displayParts.push(keywordPart(111 /* RequireKeyword */)); + displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(displayPart(ts.getTextOfNode(importDeclaration.externalModuleName), 8 /* stringLiteral */)); + displayParts.push(punctuationPart(12 /* CloseParenToken */)); + } + else { + var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } + return true; + } + }); + } + if (!hasAddedSymbolInfo) { + if (symbolKind !== ScriptElementKind.unknown) { + if (type) { + addPrefixForAnyFunctionOrVar(symbol, symbolKind); + if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 1 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { + displayParts.push(punctuationPart(46 /* ColonToken */)); + displayParts.push(spacePart()); + if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + var typeParameterParts = mapToDisplayParts(function (writer) { + typeResolver.writeTypeParameter(type, writer, enclosingDeclaration); + }); + displayParts.push.apply(displayParts, typeParameterParts); + } + else { + displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration)); + } + } + else if (symbolFlags & 8 /* Function */ || symbolFlags & 2048 /* Method */ || symbolFlags & 4096 /* Constructor */ || symbolFlags & ts.SymbolFlags.Signature || symbolFlags & ts.SymbolFlags.Accessor) { + var allSignatures = type.getCallSignatures(); + addSignatureDisplayParts(allSignatures[0], allSignatures); + } + } + } + else { + symbolKind = getSymbolKind(symbol, typeResolver); + } + } + if (!documentation) { + documentation = symbol.getDocumentationComment(); + } + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + function addNewLineIfDisplayPartsExist() { + if (displayParts.length) { + displayParts.push(lineBreakPart()); + } + } + function addFullSymbolName(symbol, enclosingDeclaration) { + var fullSymbolDisplayParts = symbolToDisplayParts(typeResolver, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); + displayParts.push.apply(displayParts, fullSymbolDisplayParts); + } + function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { + addNewLineIfDisplayPartsExist(); + if (symbolKind) { + displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(textPart(symbolKind)); + displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(spacePart()); + addFullSymbolName(symbol); + } + } + function addSignatureDisplayParts(signature, allSignatures, flags) { + displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (allSignatures.length > 1) { + displayParts.push(spacePart()); + displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(operatorPart(28 /* PlusToken */)); + displayParts.push(displayPart((allSignatures.length - 1).toString(), 7 /* numericLiteral */)); + displayParts.push(spacePart()); + displayParts.push(textPart(allSignatures.length === 2 ? "overload" : "overloads")); + displayParts.push(punctuationPart(12 /* CloseParenToken */)); + } + documentation = signature.getDocumentationComment(); + } + function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { + var typeParameterParts = mapToDisplayParts(function (writer) { + typeResolver.writeTypeParametersOfSymbol(symbol, writer, enclosingDeclaration); + }); + displayParts.push.apply(displayParts, typeParameterParts); + } + } + function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); fileName = TypeScript.switchToForwardSlashes(fileName); var sourceFile = getSourceFile(fileName); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingPropertyName(sourceFile, position); if (!node) { return undefined; } var symbol = typeInfoResolver.getSymbolInfo(node); - var type = symbol && typeInfoResolver.getTypeOfSymbol(symbol); - if (type) { - return new TypeInfo(new TypeScript.MemberNameString(typeInfoResolver.typeToString(type)), "", typeInfoResolver.symbolToString(symbol, getContainerNode(node)), getSymbolKind(symbol), TypeScript.TextSpan.fromBounds(node.pos, node.end)); + if (!symbol) { + switch (node.kind) { + case 59 /* Identifier */: + case 135 /* PropertyAccess */: + case 116 /* QualifiedName */: + case 87 /* ThisKeyword */: + case 85 /* SuperKeyword */: + var type = typeInfoResolver.getTypeOfNode(node); + if (type) { + return { + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()), + displayParts: typeToDisplayParts(typeInfoResolver, type, getContainerNode(node)), + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + }; + } + } + return undefined; } - return undefined; + var displayPartsDocumentationsAndKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, sourceFile, getContainerNode(node), typeInfoResolver, node); + return { + kind: displayPartsDocumentationsAndKind.symbolKind, + kindModifiers: getSymbolModifiers(symbol), + textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()), + displayParts: displayPartsDocumentationsAndKind.displayParts, + documentation: displayPartsDocumentationsAndKind.documentation + }; } function getDefinitionAtPosition(filename, position) { function getDefinitionInfo(node, symbolKind, symbolName, containerName) { - return new DefinitionInfo(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()), symbolKind, symbolName, undefined, containerName); + return { + fileName: node.getSourceFile().filename, + textSpan: TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()), + kind: symbolKind, + name: symbolName, + containerKind: undefined, + containerName: containerName + }; } function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { var declarations = []; @@ -33068,7 +34091,7 @@ var ts; synchronizeHostData(); filename = TypeScript.switchToForwardSlashes(filename); var sourceFile = getSourceFile(filename); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingPropertyName(sourceFile, position); if (!node) { return undefined; } @@ -33079,9 +34102,17 @@ var ts; } var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; }); if (comment) { - var targetFilename = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(filename), comment.filename)); + var targetFilename = ts.isRootedDiskPath(comment.filename) ? comment.filename : ts.combinePaths(ts.getDirectoryPath(filename), comment.filename); + targetFilename = ts.normalizePath(targetFilename); if (program.getSourceFile(targetFilename)) { - return [new DefinitionInfo(targetFilename, TypeScript.TextSpan.fromBounds(0, 0), ScriptElementKind.scriptElement, comment.filename, undefined, undefined)]; + return [{ + fileName: targetFilename, + textSpan: TypeScript.TextSpan.fromBounds(0, 0), + kind: ScriptElementKind.scriptElement, + name: comment.filename, + containerName: undefined, + containerKind: undefined + }]; } return undefined; } @@ -33091,11 +34122,10 @@ var ts; } var result = []; var declarations = symbol.getDeclarations(); - var symbolName = typeInfoResolver.symbolToString(symbol, node); - var symbolKind = getSymbolKind(symbol); + var symbolName = typeInfoResolver.symbolToString(symbol); + var symbolKind = getSymbolKind(symbol, typeInfoResolver); var containerSymbol = symbol.parent; var containerName = containerSymbol ? typeInfoResolver.symbolToString(containerSymbol, node) : ""; - var containerKind = containerSymbol ? getSymbolKind(symbol) : ""; if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { ts.forEach(declarations, function (declaration) { result.push(getDefinitionInfo(declaration, symbolKind, symbolName, containerName)); @@ -33107,12 +34137,12 @@ var ts; synchronizeHostData(); filename = TypeScript.switchToForwardSlashes(filename); var sourceFile = getSourceFile(filename); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingWord(sourceFile, position); if (!node) { return undefined; } if (node.kind === 59 /* Identifier */ || node.kind === 87 /* ThisKeyword */ || node.kind === 85 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - return getReferencesForNode(node, [sourceFile]); + return getReferencesForNode(node, [sourceFile], false, false); } switch (node.kind) { case 78 /* IfKeyword */: @@ -33126,6 +34156,11 @@ var ts; return getReturnOccurrences(node.parent); } break; + case 88 /* ThrowKeyword */: + if (hasKind(node.parent, 165 /* ThrowStatement */)) { + return getThrowOccurrences(node.parent); + } + break; case 90 /* TryKeyword */: case 62 /* CatchKeyword */: case 75 /* FinallyKeyword */: @@ -33166,6 +34201,11 @@ var ts; return getConstructorOccurrences(node.parent); } break; + case 109 /* GetKeyword */: + case 113 /* SetKeyword */: + if (hasKind(node.parent, 122 /* GetAccessor */) || hasKind(node.parent, 123 /* SetAccessor */)) { + return getGetAndSetOccurrences(node.parent); + } } return undefined; function getIfElseOccurrences(ifStatement) { @@ -33199,7 +34239,11 @@ var ts; } } if (shouldHighlightNextKeyword) { - result.push(new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), false)); + result.push({ + fileName: filename, + textSpan: TypeScript.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), + isWriteAccess: false + }); i++; continue; } @@ -33217,8 +34261,70 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { pushKeywordIf(keywords, returnStatement.getFirstToken(), 84 /* ReturnKeyword */); }); + ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 88 /* ThrowKeyword */); + }); return ts.map(keywords, getReferenceEntryFromNode); } + function getThrowOccurrences(throwStatement) { + var owner = getThrowStatementOwner(throwStatement); + if (!owner) { + return undefined; + } + var keywords = []; + ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { + pushKeywordIf(keywords, throwStatement.getFirstToken(), 88 /* ThrowKeyword */); + }); + if (owner.kind === 173 /* FunctionBlock */) { + ts.forEachReturnStatement(owner, function (returnStatement) { + pushKeywordIf(keywords, returnStatement.getFirstToken(), 84 /* ReturnKeyword */); + }); + } + return ts.map(keywords, getReferenceEntryFromNode); + } + function aggregateOwnedThrowStatements(node) { + var statementAccumulator = []; + aggregate(node); + return statementAccumulator; + function aggregate(node) { + if (node.kind === 165 /* ThrowStatement */) { + statementAccumulator.push(node); + } + else if (node.kind === 166 /* TryStatement */) { + var tryStatement = node; + if (tryStatement.catchBlock) { + aggregate(tryStatement.catchBlock); + } + else { + aggregate(tryStatement.tryBlock); + } + if (tryStatement.finallyBlock) { + aggregate(tryStatement.finallyBlock); + } + } + else if (!ts.isAnyFunction(node)) { + ts.forEachChild(node, aggregate); + } + } + ; + } + function getThrowStatementOwner(throwStatement) { + var child = throwStatement; + while (child.parent) { + var parent = child.parent; + if (parent.kind === 173 /* FunctionBlock */ || parent.kind === 182 /* SourceFile */) { + return parent; + } + if (parent.kind === 166 /* TryStatement */) { + var tryStatement = parent; + if (tryStatement.tryBlock === child && tryStatement.catchBlock) { + return child; + } + } + child = parent; + } + return undefined; + } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; pushKeywordIf(keywords, tryStatement.getFirstToken(), 90 /* TryKeyword */); @@ -33332,6 +34438,18 @@ var ts; }); return ts.map(keywords, getReferenceEntryFromNode); } + function getGetAndSetOccurrences(accessorDeclaration) { + var keywords = []; + tryPushAccessorKeyword(accessorDeclaration.symbol, 122 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 123 /* SetAccessor */); + return ts.map(keywords, getReferenceEntryFromNode); + function tryPushAccessorKeyword(accessorSymbol, accessorKind) { + var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); + if (accessor) { + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 109 /* GetKeyword */, 113 /* SetKeyword */); }); + } + } + } function hasKind(node, kind) { return node !== undefined && node.kind === kind; } @@ -33350,20 +34468,27 @@ var ts; return false; } } - function getReferencesAtPosition(filename, position) { + function findRenameLocations(fileName, position, findInStrings, findInComments) { + return findReferences(fileName, position, findInStrings, findInComments); + } + function getReferencesAtPosition(fileName, position) { + return findReferences(fileName, position, false, false); + } + function findReferences(fileName, position, findInStrings, findInComments) { synchronizeHostData(); - filename = TypeScript.switchToForwardSlashes(filename); - var sourceFile = getSourceFile(filename); - var node = getNodeAtPosition(sourceFile, position); + fileName = TypeScript.switchToForwardSlashes(fileName); + var sourceFile = getSourceFile(fileName); + var node = ts.getTouchingPropertyName(sourceFile, position); if (!node) { return undefined; } if (node.kind !== 59 /* Identifier */ && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - return getReferencesForNode(node, program.getSourceFiles()); + ts.Debug.assert(node.kind === 59 /* Identifier */ || node.kind === 6 /* NumericLiteral */ || node.kind === 7 /* StringLiteral */); + return getReferencesForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencesForNode(node, sourceFiles) { + function getReferencesForNode(node, sourceFiles, findInStrings, findInComments) { if (isLabelName(node)) { if (isJumpStatementTarget(node)) { var labelDefinition = getTargetLabel(node.parent, node.text); @@ -33392,14 +34517,14 @@ var ts; var scope = getSymbolScope(symbol); if (scope) { result = []; - getReferencesInNode(scope, symbol, symbolName, node, searchMeaning, result); + getReferencesInNode(scope, symbol, symbolName, node, searchMeaning, findInStrings, findInComments, result); } else { ts.forEach(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (ts.lookUp(sourceFile.identifiers, symbolName)) { result = result || []; - getReferencesInNode(sourceFile, symbol, symbolName, node, searchMeaning, result); + getReferencesInNode(sourceFile, symbol, symbolName, node, searchMeaning, findInStrings, findInComments, result); } }); } @@ -33471,7 +34596,7 @@ var ts; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingWord(sourceFile, position); if (!node || node.getWidth() !== labelName.length) { return; } @@ -33500,15 +34625,23 @@ var ts; } return false; } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, result) { + function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result) { var sourceFile = container.getSourceFile(); + var tripleSlashDirectivePrefixRegex = /^\/\/\/\s* token.getStart(); + } + function isInComment(position) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (token && position < token.getStart()) { + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + return ts.forEach(commentRanges, function (c) { + if (c.pos < position && position < c.end) { + var commentText = sourceFile.text.substring(c.pos, c.end); + if (!tripleSlashDirectivePrefixRegex.test(commentText)) { + return true; + } + } + }); + } + return false; + } } function getReferencesForSuperKeyword(superKeyword) { var searchSpaceNode = ts.getSuperContainer(superKeyword); @@ -33547,7 +34699,7 @@ var ts; var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingWord(sourceFile, position); if (!node || node.kind !== 85 /* SuperKeyword */) { return; } @@ -33596,7 +34748,7 @@ var ts; function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingWord(sourceFile, position); if (!node || node.kind !== 87 /* ThisKeyword */) { return; } @@ -33639,7 +34791,7 @@ var ts; return result; } function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { - if (symbol.flags & (16 /* Class */ | 32 /* Interface */)) { + if (symbol && symbol.flags & (16 /* Class */ | 32 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { if (declaration.kind === 174 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(declaration.baseType); @@ -33653,12 +34805,13 @@ var ts; return; function getPropertySymbolFromTypeReference(typeReference) { if (typeReference) { - var typeReferenceSymbol = typeInfoResolver.getSymbolInfo(typeReference.typeName); - if (typeReferenceSymbol) { - var propertySymbol = typeReferenceSymbol.members[propertyName]; - if (propertySymbol) - result.push(typeReferenceSymbol.members[propertyName]); - getPropertySymbolsFromBaseTypes(typeReferenceSymbol, propertyName, result); + var type = typeInfoResolver.getTypeOfNode(typeReference); + if (type) { + var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push(propertySymbol); + } + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result); } } } @@ -33691,93 +34844,6 @@ var ts; } return undefined; } - function getMeaningFromDeclaration(node) { - switch (node.kind) { - case 118 /* Parameter */: - case 171 /* VariableDeclaration */: - case 119 /* Property */: - case 134 /* PropertyAssignment */: - case 181 /* EnumMember */: - case 120 /* Method */: - case 121 /* Constructor */: - case 122 /* GetAccessor */: - case 123 /* SetAccessor */: - case 172 /* FunctionDeclaration */: - case 141 /* FunctionExpression */: - case 142 /* ArrowFunction */: - case 168 /* CatchBlock */: - return 1 /* Value */; - case 117 /* TypeParameter */: - case 175 /* InterfaceDeclaration */: - case 129 /* TypeLiteral */: - return 2 /* Type */; - case 174 /* ClassDeclaration */: - case 176 /* EnumDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 177 /* ModuleDeclaration */: - if (node.name.kind === 7 /* StringLiteral */) { - return 4 /* Namespace */ | 1 /* Value */; - } - else if (ts.isInstantiated(node)) { - return 4 /* Namespace */ | 1 /* Value */; - } - else { - return 4 /* Namespace */; - } - break; - case 179 /* ImportDeclaration */: - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - ts.Debug.fail("Unknown declaration type"); - } - function isTypeReference(node) { - if (node.parent.kind === 116 /* QualifiedName */ && node.parent.right === node) - node = node.parent; - return node.parent.kind === 127 /* TypeReference */; - } - function isNamespaceReference(node) { - var root = node; - var isLastClause = true; - if (root.parent.kind === 116 /* QualifiedName */) { - while (root.parent && root.parent.kind === 116 /* QualifiedName */) - root = root.parent; - isLastClause = root.right === node; - } - return root.parent.kind === 127 /* TypeReference */ && !isLastClause; - } - function isInRightSideOfImport(node) { - while (node.parent.kind === 116 /* QualifiedName */) { - node = node.parent; - } - return node.parent.kind === 179 /* ImportDeclaration */ && node.parent.entityName === node; - } - function getMeaningFromRightHandSideOfImport(node) { - ts.Debug.assert(node.kind === 59 /* Identifier */); - if (node.parent.kind === 116 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 179 /* ImportDeclaration */) { - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - return 4 /* Namespace */; - } - function getMeaningFromLocation(node) { - if (node.parent.kind === 180 /* ExportAssignment */) { - return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - } - else if (isInRightSideOfImport(node)) { - return getMeaningFromRightHandSideOfImport(node); - } - else if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { - return getMeaningFromDeclaration(node.parent); - } - else if (isTypeReference(node)) { - return 2 /* Type */; - } - else if (isNamespaceReference(node)) { - return 4 /* Namespace */; - } - else { - return 1 /* Value */; - } - } function getIntersectingMeaningFromDeclarations(meaning, declarations) { if (declarations) { do { @@ -33800,7 +34866,11 @@ var ts; start += 1; end -= 1; } - return new ReferenceEntry(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(start, end), isWriteAccess(node)); + return { + fileName: node.getSourceFile().filename, + textSpan: TypeScript.TextSpan.fromBounds(start, end), + isWriteAccess: isWriteAccess(node) + }; } function isWriteAccess(node) { if (node.kind === 59 /* Identifier */ && ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { @@ -33886,7 +34956,7 @@ var ts; filename = TypeScript.switchToForwardSlashes(filename); var compilerOptions = program.getCompilerOptions(); var targetSourceFile = program.getSourceFile(filename); - var emitToSingleFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions); + var shouldEmitToOwnFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions); var emitDeclaration = compilerOptions.declaration; var emitOutput = { outputFiles: [], @@ -33902,7 +34972,7 @@ var ts; writer = getEmitOutputWriter; var syntacticDiagnostics = []; var containSyntacticErrors = false; - if (emitToSingleFile) { + if (shouldEmitToOwnFile) { containSyntacticErrors = containErrors(program.getDiagnostics(targetSourceFile)); } else { @@ -33918,11 +34988,152 @@ var ts; writer = undefined; return emitOutput; } - var emitFilesResult = emitToSingleFile ? getFullTypeCheckChecker().emitFiles(targetSourceFile) : getFullTypeCheckChecker().emitFiles(); + var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile); emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus; writer = undefined; return emitOutput; } + function getMeaningFromDeclaration(node) { + switch (node.kind) { + case 118 /* Parameter */: + case 171 /* VariableDeclaration */: + case 119 /* Property */: + case 134 /* PropertyAssignment */: + case 181 /* EnumMember */: + case 120 /* Method */: + case 121 /* Constructor */: + case 122 /* GetAccessor */: + case 123 /* SetAccessor */: + case 172 /* FunctionDeclaration */: + case 141 /* FunctionExpression */: + case 142 /* ArrowFunction */: + case 168 /* CatchBlock */: + return 1 /* Value */; + case 117 /* TypeParameter */: + case 175 /* InterfaceDeclaration */: + case 129 /* TypeLiteral */: + return 2 /* Type */; + case 174 /* ClassDeclaration */: + case 176 /* EnumDeclaration */: + return 1 /* Value */ | 2 /* Type */; + case 177 /* ModuleDeclaration */: + if (node.name.kind === 7 /* StringLiteral */) { + return 4 /* Namespace */ | 1 /* Value */; + } + else if (ts.isInstantiated(node)) { + return 4 /* Namespace */ | 1 /* Value */; + } + else { + return 4 /* Namespace */; + } + break; + case 179 /* ImportDeclaration */: + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + ts.Debug.fail("Unknown declaration type"); + } + function isTypeReference(node) { + if (node.parent.kind === 116 /* QualifiedName */ && node.parent.right === node) + node = node.parent; + return node.parent.kind === 127 /* TypeReference */; + } + function isNamespaceReference(node) { + var root = node; + var isLastClause = true; + if (root.parent.kind === 116 /* QualifiedName */) { + while (root.parent && root.parent.kind === 116 /* QualifiedName */) + root = root.parent; + isLastClause = root.right === node; + } + return root.parent.kind === 127 /* TypeReference */ && !isLastClause; + } + function isInRightSideOfImport(node) { + while (node.parent.kind === 116 /* QualifiedName */) { + node = node.parent; + } + return node.parent.kind === 179 /* ImportDeclaration */ && node.parent.entityName === node; + } + function getMeaningFromRightHandSideOfImport(node) { + ts.Debug.assert(node.kind === 59 /* Identifier */); + if (node.parent.kind === 116 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 179 /* ImportDeclaration */) { + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + return 4 /* Namespace */; + } + function getMeaningFromLocation(node) { + if (node.parent.kind === 180 /* ExportAssignment */) { + return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; + } + else if (isInRightSideOfImport(node)) { + return getMeaningFromRightHandSideOfImport(node); + } + else if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + return getMeaningFromDeclaration(node.parent); + } + else if (isTypeReference(node)) { + return 2 /* Type */; + } + else if (isNamespaceReference(node)) { + return 4 /* Namespace */; + } + else { + return 1 /* Value */; + } + } + function getSignatureHelpItems(fileName, position) { + synchronizeHostData(); + fileName = TypeScript.switchToForwardSlashes(fileName); + var sourceFile = getSourceFile(fileName); + return ts.SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken); + } + function getSignatureAtPosition(filename, position) { + var signatureHelpItems = getSignatureHelpItems(filename, position); + if (!signatureHelpItems) { + return undefined; + } + var currentArgumentState = { argumentIndex: signatureHelpItems.argumentIndex, argumentCount: signatureHelpItems.argumentCount }; + var formalSignatures = []; + ts.forEach(signatureHelpItems.items, function (signature) { + var signatureInfoString = displayPartsToString(signature.prefixDisplayParts); + var parameters = []; + if (signature.parameters) { + for (var i = 0, n = signature.parameters.length; i < n; i++) { + var parameter = signature.parameters[i]; + if (i) { + signatureInfoString += displayPartsToString(signature.separatorDisplayParts); + } + var start = signatureInfoString.length; + signatureInfoString += displayPartsToString(parameter.displayParts); + var end = signatureInfoString.length - 1; + parameters.push({ + name: parameter.name, + isVariable: i === n - 1 && signature.isVariadic, + docComment: displayPartsToString(parameter.documentation), + minChar: start, + limChar: end + }); + } + } + signatureInfoString += displayPartsToString(signature.suffixDisplayParts); + formalSignatures.push({ + signatureInfo: signatureInfoString, + docComment: displayPartsToString(signature.documentation), + parameters: parameters, + typeParameters: [] + }); + }); + var actualSignature = { + parameterMinChar: signatureHelpItems.applicableSpan.start(), + parameterLimChar: signatureHelpItems.applicableSpan.end(), + currentParameterIsTypeParameter: false, + currentParameter: currentArgumentState.argumentIndex + }; + return { + actual: actualSignature, + formal: formalSignatures, + activeFormal: 0 + }; + } function getSyntaxTree(filename) { filename = TypeScript.switchToForwardSlashes(filename); return syntaxTreeCache.getCurrentFileSyntaxTree(filename); @@ -33985,8 +35196,7 @@ var ts; } function getNavigationBarItems(filename) { filename = TypeScript.switchToForwardSlashes(filename); - var syntaxTree = getSyntaxTree(filename); - return new TypeScript.Services.NavigationBarItemGetter().getItems(syntaxTree.sourceUnit()); + return ts.NavigationBar.getNavigationBarItems(getCurrentSourceFile(filename)); } function getSemanticClassifications(fileName, span) { synchronizeHostData(); @@ -33995,7 +35205,7 @@ var ts; var result = []; processNode(sourceFile); return result; - function classifySymbol(symbol) { + function classifySymbol(symbol, meaningAtPosition) { var flags = symbol.getFlags(); if (flags & 16 /* Class */) { return ClassificationTypeNames.className; @@ -34003,24 +35213,30 @@ var ts; else if (flags & 64 /* Enum */) { return ClassificationTypeNames.enumName; } - else if (flags & 32 /* Interface */) { - return ClassificationTypeNames.interfaceName; + else if (meaningAtPosition & 2 /* Type */) { + if (flags & 32 /* Interface */) { + return ClassificationTypeNames.interfaceName; + } + else if (flags & 262144 /* TypeParameter */) { + return ClassificationTypeNames.typeParameterName; + } } else if (flags & ts.SymbolFlags.Module) { return ClassificationTypeNames.moduleName; } - else if (flags & 262144 /* TypeParameter */) { - return ClassificationTypeNames.typeParameterName; - } + return undefined; } function processNode(node) { if (node && span.intersectsWith(node.getStart(), node.getWidth())) { if (node.kind === 59 /* Identifier */ && node.getWidth() > 0) { var symbol = typeInfoResolver.getSymbolInfo(node); if (symbol) { - var type = classifySymbol(symbol); + var type = classifySymbol(symbol, getMeaningFromLocation(node)); if (type) { - result.push(new ClassifiedSpan(new TypeScript.TextSpan(node.getStart(), node.getWidth()), type)); + result.push({ + textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()), + classificationType: type + }); } } } @@ -34036,7 +35252,10 @@ var ts; return result; function classifyTrivia(trivia) { if (trivia.isComment() && span.intersectsWith(trivia.fullStart(), trivia.fullWidth())) { - result.push(new ClassifiedSpan(new TypeScript.TextSpan(trivia.fullStart(), trivia.fullWidth()), ClassificationTypeNames.comment)); + result.push({ + textSpan: new TypeScript.TextSpan(trivia.fullStart(), trivia.fullWidth()), + classificationType: ClassificationTypeNames.comment + }); } } function classifyTriviaList(trivia) { @@ -34051,7 +35270,10 @@ var ts; if (TypeScript.width(token) > 0) { var type = classifyTokenType(token); if (type) { - result.push(new ClassifiedSpan(new TypeScript.TextSpan(TypeScript.start(token), TypeScript.width(token)), type)); + result.push({ + textSpan: new TypeScript.TextSpan(TypeScript.start(token), TypeScript.width(token)), + classificationType: type + }); } } if (token.hasTrailingComment()) { @@ -34149,9 +35371,52 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile); } function getBraceMatchingAtPosition(filename, position) { - filename = TypeScript.switchToForwardSlashes(filename); - var syntaxTree = getSyntaxTree(filename); - return TypeScript.Services.BraceMatcher.getMatchSpans(syntaxTree, position); + var sourceFile = getCurrentSourceFile(filename); + var result = []; + var token = ts.getTouchingToken(sourceFile, position); + if (token.getStart(sourceFile) === position) { + var matchKind = getMatchingTokenKind(token); + if (matchKind) { + var parentElement = token.parent; + var childNodes = parentElement.getChildren(sourceFile); + for (var i = 0, n = childNodes.length; i < n; i++) { + var current = childNodes[i]; + if (current.kind === matchKind) { + var range1 = new TypeScript.TextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); + var range2 = new TypeScript.TextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); + if (range1.start() < range2.start()) { + result.push(range1, range2); + } + else { + result.push(range2, range1); + } + break; + } + } + } + } + return result; + function getMatchingTokenKind(token) { + switch (token.kind) { + case 9 /* OpenBraceToken */: + return 10 /* CloseBraceToken */; + case 11 /* OpenParenToken */: + return 12 /* CloseParenToken */; + case 13 /* OpenBracketToken */: + return 14 /* CloseBracketToken */; + case 19 /* LessThanToken */: + return 20 /* GreaterThanToken */; + case 10 /* CloseBraceToken */: + return 9 /* OpenBraceToken */; + case 12 /* CloseParenToken */: + return 11 /* OpenParenToken */; + case 14 /* CloseBracketToken */: + return 13 /* OpenBracketToken */; + case 20 /* GreaterThanToken */: + return 19 /* LessThanToken */; + } + return undefined; + } } function getIndentationAtPosition(filename, position, editorOptions) { filename = TypeScript.switchToForwardSlashes(filename); @@ -34211,11 +35476,11 @@ var ts; ts.Debug.assert(matchArray.length === descriptors.length + firstDescriptorCaptureIndex); var preamble = matchArray[1]; var matchPosition = matchArray.index + preamble.length; - var token = getTokenAtPosition(sourceFile, matchPosition); + var token = ts.getTokenAtPosition(sourceFile, matchPosition); if (token.getStart() <= matchPosition && matchPosition < token.getEnd()) { continue; } - if (!getContainingComment(ts.getTrailingComments(fileContents, token.getFullStart()), matchPosition) && !getContainingComment(ts.getLeadingComments(fileContents, token.getFullStart()), matchPosition)) { + if (!getContainingComment(ts.getTrailingCommentRanges(fileContents, token.getFullStart()), matchPosition) && !getContainingComment(ts.getLeadingCommentRanges(fileContents, token.getFullStart()), matchPosition)) { continue; } var descriptor = undefined; @@ -34229,7 +35494,11 @@ var ts; continue; } var message = matchArray[2]; - result.push(new TodoComment(descriptor, message, matchPosition)); + result.push({ + descriptor: descriptor, + message: message, + position: matchPosition + }); } } return result; @@ -34267,17 +35536,39 @@ var ts; synchronizeHostData(); fileName = TypeScript.switchToForwardSlashes(fileName); var sourceFile = getSourceFile(fileName); - var node = getNodeAtPosition(sourceFile, position); + var node = ts.getTouchingWord(sourceFile, position); if (node && node.kind === 59 /* Identifier */) { var symbol = typeInfoResolver.getSymbolInfo(node); if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) { - var kind = getSymbolKind(symbol); + var kind = getSymbolKind(symbol, typeInfoResolver); if (kind) { - return RenameInfo.Create(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getNodeModifiers(symbol.getDeclarations()[0]), new TypeScript.TextSpan(node.getStart(), node.getWidth())); + return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind, getSymbolModifiers(symbol), new TypeScript.TextSpan(node.getStart(), node.getWidth())); } } } - return RenameInfo.CreateError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key)); + return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key)); + function getRenameInfoError(localizedErrorMessage) { + return { + canRename: false, + localizedErrorMessage: ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_this_element.key), + displayName: undefined, + fullDisplayName: undefined, + kind: undefined, + kindModifiers: undefined, + triggerSpan: undefined + }; + } + function getRenameInfo(displayName, fullDisplayName, kind, kindModifiers, triggerSpan) { + return { + canRename: true, + localizedErrorMessage: undefined, + displayName: displayName, + fullDisplayName: fullDisplayName, + kind: kind, + kindModifiers: kindModifiers, + triggerSpan: triggerSpan + }; + } } return { dispose: dispose, @@ -34289,9 +35580,8 @@ var ts; getSemanticClassifications: getSemanticClassifications, getCompletionsAtPosition: getCompletionsAtPosition, getCompletionEntryDetails: getCompletionEntryDetails, - getTypeAtPosition: getTypeAtPosition, - getSignatureHelpItems: function (filename, position) { return null; }, - getSignatureHelpCurrentArgumentState: function (fileName, position, applicableSpanStart) { return null; }, + getSignatureHelpItems: getSignatureHelpItems, + getQuickInfoAtPosition: getQuickInfoAtPosition, getDefinitionAtPosition: getDefinitionAtPosition, getReferencesAtPosition: getReferencesAtPosition, getOccurrencesAtPosition: getOccurrencesAtPosition, @@ -34300,6 +35590,7 @@ var ts; getBreakpointStatementAtPosition: getBreakpointStatementAtPosition, getNavigateToItems: getNavigateToItems, getRenameInfo: getRenameInfo, + findRenameLocations: findRenameLocations, getNavigationBarItems: getNavigationBarItems, getOutliningSpans: getOutliningSpans, getTodoComments: getTodoComments, @@ -34308,33 +35599,49 @@ var ts; getFormattingEditsForRange: getFormattingEditsForRange, getFormattingEditsForDocument: getFormattingEditsForDocument, getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, - getEmitOutput: getEmitOutput + getEmitOutput: getEmitOutput, + getSignatureAtPosition: getSignatureAtPosition }; } ts.createLanguageService = createLanguageService; function createClassifier(host) { - var scanner; - var noRegexTable; - if (!noRegexTable) { - noRegexTable = []; - noRegexTable[59 /* Identifier */] = true; - noRegexTable[7 /* StringLiteral */] = true; - noRegexTable[6 /* NumericLiteral */] = true; - noRegexTable[8 /* RegularExpressionLiteral */] = true; - noRegexTable[87 /* ThisKeyword */] = true; - noRegexTable[33 /* PlusPlusToken */] = true; - noRegexTable[34 /* MinusMinusToken */] = true; - noRegexTable[12 /* CloseParenToken */] = true; - noRegexTable[14 /* CloseBracketToken */] = true; - noRegexTable[10 /* CloseBraceToken */] = true; - noRegexTable[89 /* TrueKeyword */] = true; - noRegexTable[74 /* FalseKeyword */] = true; + var scanner = ts.createScanner(1 /* ES5 */, false); + var noRegexTable = []; + noRegexTable[59 /* Identifier */] = true; + noRegexTable[7 /* StringLiteral */] = true; + noRegexTable[6 /* NumericLiteral */] = true; + noRegexTable[8 /* RegularExpressionLiteral */] = true; + noRegexTable[87 /* ThisKeyword */] = true; + noRegexTable[33 /* PlusPlusToken */] = true; + noRegexTable[34 /* MinusMinusToken */] = true; + noRegexTable[12 /* CloseParenToken */] = true; + noRegexTable[14 /* CloseBracketToken */] = true; + noRegexTable[10 /* CloseBraceToken */] = true; + noRegexTable[89 /* TrueKeyword */] = true; + noRegexTable[74 /* FalseKeyword */] = true; + function isAccessibilityModifier(kind) { + switch (kind) { + case 102 /* PublicKeyword */: + case 100 /* PrivateKeyword */: + case 101 /* ProtectedKeyword */: + return true; + } + return false; + } + function canFollow(keyword1, keyword2) { + if (isAccessibilityModifier(keyword1)) { + if (keyword2 === 109 /* GetKeyword */ || keyword2 === 113 /* SetKeyword */ || keyword2 === 107 /* ConstructorKeyword */ || keyword2 === 103 /* StaticKeyword */) { + return true; + } + return false; + } + return true; } function getClassificationsForLine(text, lexState) { var offset = 0; var lastTokenOrCommentEnd = 0; - var lastToken = 0 /* Unknown */; - var inUnterminatedMultiLineComment = false; + var token = 0 /* Unknown */; + var lastNonTriviaToken = 0 /* Unknown */; switch (lexState) { case 3 /* InDoubleQuoteStringLiteral */: text = '"\\\n' + text; @@ -34349,57 +35656,62 @@ var ts; offset = 3; break; } + scanner.setText(text); var result = { finalLexState: 0 /* Start */, entries: [] }; - scanner = ts.createScanner(1 /* ES5 */, true, text, onError, processComment); - var token = 0 /* Unknown */; + var angleBracketStack = 0; do { token = scanner.scan(); - if ((token === 31 /* SlashToken */ || token === 51 /* SlashEqualsToken */) && !noRegexTable[lastToken]) { - if (scanner.reScanSlashToken() === 8 /* RegularExpressionLiteral */) { - token = 8 /* RegularExpressionLiteral */; + if (!ts.isTrivia(token)) { + if ((token === 31 /* SlashToken */ || token === 51 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 8 /* RegularExpressionLiteral */) { + token = 8 /* RegularExpressionLiteral */; + } } + else if (lastNonTriviaToken === 15 /* DotToken */ && isKeyword(token)) { + token = 59 /* Identifier */; + } + else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { + token = 59 /* Identifier */; + } + else if (lastNonTriviaToken === 59 /* Identifier */ && token === 19 /* LessThanToken */) { + angleBracketStack++; + } + else if (token === 20 /* GreaterThanToken */ && angleBracketStack > 0) { + angleBracketStack--; + } + else if (token === 105 /* AnyKeyword */ || token === 114 /* StringKeyword */ || token === 112 /* NumberKeyword */ || token === 106 /* BooleanKeyword */) { + if (angleBracketStack > 0) { + token = 59 /* Identifier */; + } + } + lastNonTriviaToken = token; } - else if (lastToken === 15 /* DotToken */) { - token = 59 /* Identifier */; - } - lastToken = token; processToken(); } while (token !== 1 /* EndOfFileToken */); return result; - function onError(message) { - inUnterminatedMultiLineComment = message.key === ts.Diagnostics.Asterisk_Slash_expected.key; - } - function processComment(start, end) { - addLeadingWhiteSpace(start, end); - addResult(end - start, 3 /* Comment */); - } function processToken() { var start = scanner.getTokenPos(); var end = scanner.getTextPos(); - addLeadingWhiteSpace(start, end); addResult(end - start, classFromKind(token)); if (end >= text.length) { - if (inUnterminatedMultiLineComment) { - result.finalLexState = 1 /* InMultiLineCommentTrivia */; - } - else if (token === 7 /* StringLiteral */) { + if (token === 7 /* StringLiteral */) { var tokenText = scanner.getTokenText(); if (tokenText.length > 0 && tokenText.charCodeAt(tokenText.length - 1) === 92 /* backslash */) { var quoteChar = tokenText.charCodeAt(0); result.finalLexState = quoteChar === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; } } + else if (token === 3 /* MultiLineCommentTrivia */) { + var tokenText = scanner.getTokenText(); + if (!(tokenText.length > 3 && tokenText.charCodeAt(tokenText.length - 2) === 42 /* asterisk */ && tokenText.charCodeAt(tokenText.length - 1) === 47 /* slash */)) { + result.finalLexState = 1 /* InMultiLineCommentTrivia */; + } + } } } - function addLeadingWhiteSpace(start, end) { - if (start > lastTokenOrCommentEnd) { - addResult(start - lastTokenOrCommentEnd, 4 /* Whitespace */); - } - lastTokenOrCommentEnd = end; - } function addResult(length, classification) { if (length > 0) { if (result.entries.length === 0) { @@ -34485,6 +35797,11 @@ var ts; return 7 /* StringLiteral */; case 8 /* RegularExpressionLiteral */: return 8 /* RegExpLiteral */; + case 3 /* MultiLineCommentTrivia */: + case 2 /* SingleLineCommentTrivia */: + return 3 /* Comment */; + case 5 /* WhitespaceTrivia */: + return 4 /* Whitespace */; case 59 /* Identifier */: default: return 5 /* Identifier */; @@ -34641,11 +35958,11 @@ var TypeScript; var debugObjectHost = this; var ts; (function (ts) { - var LanguageVersion; (function (LanguageVersion) { LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - })(LanguageVersion || (LanguageVersion = {})); + })(ts.LanguageVersion || (ts.LanguageVersion = {})); + var LanguageVersion = ts.LanguageVersion; (function (ModuleGenTarget) { ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; @@ -34785,7 +36102,6 @@ var ts; return null; } var options = compilationSettingsToCompilerOptions(JSON.parse(settingsJson)); - options.noResolve = true; return options; }; LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { @@ -34904,7 +36220,8 @@ var ts; message: diagnostic.messageText, start: diagnostic.start, length: diagnostic.length, - category: ts.DiagnosticCategory[diagnostic.category].toLowerCase() + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code }; }; LanguageServiceShimObject.prototype.realizeDiagnosticWithFileName = function (diagnostic) { @@ -34951,11 +36268,11 @@ var ts; return errors.map(function (d) { return _this.realizeDiagnosticWithFileName(d); }); }); }; - LanguageServiceShimObject.prototype.getTypeAtPosition = function (fileName, position) { + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeAtPosition('" + fileName + "', " + position + ")", function () { - var typeInfo = _this.languageService.getTypeAtPosition(fileName, position); - return typeInfo; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { + var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); + return quickInfo; }); }; LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { @@ -34979,11 +36296,10 @@ var ts; return signatureInfo; }); }; - LanguageServiceShimObject.prototype.getSignatureHelpCurrentArgumentState = function (fileName, position, applicableSpanStart) { + LanguageServiceShimObject.prototype.getSignatureAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSignatureHelpCurrentArgumentState('" + fileName + "', " + position + ", " + applicableSpanStart + ")", function () { - var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); - return signatureInfo; + return this.forwardJSONCall("getSignatureAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getSignatureAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { @@ -34998,6 +36314,12 @@ var ts; return _this.languageService.getRenameInfo(fileName, position); }); }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { + return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); + }); + }; LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () {