Merge branch 'master' into react-factory-option
This commit is contained in:
commit
9d11f2b3ce
18 changed files with 47 additions and 356 deletions
|
@ -840,15 +840,6 @@ namespace ts {
|
||||||
return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier);
|
return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMemberOfModuleVariable(moduleSymbol: Symbol, name: string): Symbol {
|
|
||||||
if (moduleSymbol.flags & SymbolFlags.Variable) {
|
|
||||||
const typeAnnotation = (<VariableDeclaration>moduleSymbol.valueDeclaration).type;
|
|
||||||
if (typeAnnotation) {
|
|
||||||
return getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function creates a synthetic symbol that combines the value side of one symbol with the
|
// This function creates a synthetic symbol that combines the value side of one symbol with the
|
||||||
// type/namespace side of another symbol. Consider this example:
|
// type/namespace side of another symbol. Consider this example:
|
||||||
//
|
//
|
||||||
|
@ -1084,7 +1075,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
const moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
|
const moduleReferenceLiteral = <LiteralExpression>moduleReferenceExpression;
|
||||||
const searchPath = getDirectoryPath(getSourceFile(location).fileName);
|
|
||||||
|
|
||||||
// Module names are escaped in our symbol table. However, string literal values aren't.
|
// Module names are escaped in our symbol table. However, string literal values aren't.
|
||||||
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
|
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
|
||||||
|
@ -2204,65 +2194,15 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDeclarationVisible(node: Declaration): boolean {
|
function isDeclarationVisible(node: Declaration): boolean {
|
||||||
function getContainingExternalModule(node: Node) {
|
if (node) {
|
||||||
for (; node; node = node.parent) {
|
const links = getNodeLinks(node);
|
||||||
if (node.kind === SyntaxKind.ModuleDeclaration) {
|
if (links.isVisible === undefined) {
|
||||||
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
|
links.isVisible = !!determineIfDeclarationIsVisible();
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (node.kind === SyntaxKind.SourceFile) {
|
|
||||||
return isExternalOrCommonJsModule(<SourceFile>node) ? node : undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Debug.fail("getContainingModule cant reach here");
|
return links.isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUsedInExportAssignment(node: Node) {
|
return false;
|
||||||
// Get source File and see if it is external module and has export assigned symbol
|
|
||||||
const externalModule = getContainingExternalModule(node);
|
|
||||||
let exportAssignmentSymbol: Symbol;
|
|
||||||
let resolvedExportSymbol: Symbol;
|
|
||||||
if (externalModule) {
|
|
||||||
// This is export assigned symbol node
|
|
||||||
const externalModuleSymbol = getSymbolOfNode(externalModule);
|
|
||||||
exportAssignmentSymbol = getExportAssignmentSymbol(externalModuleSymbol);
|
|
||||||
const symbolOfNode = getSymbolOfNode(node);
|
|
||||||
if (isSymbolUsedInExportAssignment(symbolOfNode)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if symbolOfNode is alias declaration, resolve the symbol declaration and check
|
|
||||||
if (symbolOfNode.flags & SymbolFlags.Alias) {
|
|
||||||
return isSymbolUsedInExportAssignment(resolveAlias(symbolOfNode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the symbol is used in export assignment
|
|
||||||
function isSymbolUsedInExportAssignment(symbol: Symbol) {
|
|
||||||
if (exportAssignmentSymbol === symbol) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & SymbolFlags.Alias)) {
|
|
||||||
// if export assigned symbol is alias declaration, resolve the alias
|
|
||||||
resolvedExportSymbol = resolvedExportSymbol || resolveAlias(exportAssignmentSymbol);
|
|
||||||
if (resolvedExportSymbol === symbol) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Container of resolvedExportSymbol is visible
|
|
||||||
return forEach(resolvedExportSymbol.declarations, (current: Node) => {
|
|
||||||
while (current) {
|
|
||||||
if (current === node) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
current = current.parent;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function determineIfDeclarationIsVisible() {
|
function determineIfDeclarationIsVisible() {
|
||||||
switch (node.kind) {
|
switch (node.kind) {
|
||||||
|
@ -2341,14 +2281,6 @@ namespace ts {
|
||||||
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
|
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node) {
|
|
||||||
const links = getNodeLinks(node);
|
|
||||||
if (links.isVisible === undefined) {
|
|
||||||
links.isVisible = !!determineIfDeclarationIsVisible();
|
|
||||||
}
|
|
||||||
return links.isVisible;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectLinkedAliases(node: Identifier): Node[] {
|
function collectLinkedAliases(node: Identifier): Node[] {
|
||||||
|
@ -3394,14 +3326,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addInheritedSignatures(signatures: Signature[], baseSignatures: Signature[]) {
|
|
||||||
if (baseSignatures) {
|
|
||||||
for (const signature of baseSignatures) {
|
|
||||||
signatures.push(signature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers {
|
function resolveDeclaredMembers(type: InterfaceType): InterfaceTypeWithDeclaredMembers {
|
||||||
if (!(<InterfaceTypeWithDeclaredMembers>type).declaredProperties) {
|
if (!(<InterfaceTypeWithDeclaredMembers>type).declaredProperties) {
|
||||||
const symbol = type.symbol;
|
const symbol = type.symbol;
|
||||||
|
@ -3890,25 +3814,6 @@ namespace ts {
|
||||||
function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] {
|
function getSignaturesOfType(type: Type, kind: SignatureKind): Signature[] {
|
||||||
return getSignaturesOfStructuredType(getApparentType(type), kind);
|
return getSignaturesOfStructuredType(getApparentType(type), kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
function typeHasConstructSignatures(type: Type): boolean {
|
|
||||||
const apparentType = getApparentType(type);
|
|
||||||
if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) {
|
|
||||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
|
||||||
return resolved.constructSignatures.length > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function typeHasCallOrConstructSignatures(type: Type): boolean {
|
|
||||||
const apparentType = getApparentType(type);
|
|
||||||
if (apparentType.flags & TypeFlags.StructuredType) {
|
|
||||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
|
||||||
return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type {
|
function getIndexTypeOfStructuredType(type: Type, kind: IndexKind): Type {
|
||||||
if (type.flags & TypeFlags.StructuredType) {
|
if (type.flags & TypeFlags.StructuredType) {
|
||||||
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
const resolved = resolveStructuredTypeMembers(<ObjectType>type);
|
||||||
|
@ -4410,10 +4315,6 @@ namespace ts {
|
||||||
return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity);
|
return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryGetGlobalType(name: string, arity = 0): ObjectType {
|
|
||||||
return getTypeOfGlobalSymbol(getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined), arity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a type that is inside a namespace at the global scope, e.g.
|
* Returns a type that is inside a namespace at the global scope, e.g.
|
||||||
* getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type
|
* getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type
|
||||||
|
@ -6299,12 +6200,8 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
|
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
|
||||||
const inferences: TypeInferences[] = [];
|
const inferences = map(typeParameters, createTypeInferencesObject);
|
||||||
for (const unused of typeParameters) {
|
|
||||||
inferences.push({
|
|
||||||
primary: undefined, secondary: undefined, isFixed: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
typeParameters,
|
typeParameters,
|
||||||
inferUnionTypes,
|
inferUnionTypes,
|
||||||
|
@ -6313,6 +6210,14 @@ namespace ts {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createTypeInferencesObject(): TypeInferences {
|
||||||
|
return {
|
||||||
|
primary: undefined,
|
||||||
|
secondary: undefined,
|
||||||
|
isFixed: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function inferTypes(context: InferenceContext, source: Type, target: Type) {
|
function inferTypes(context: InferenceContext, source: Type, target: Type) {
|
||||||
let sourceStack: Type[];
|
let sourceStack: Type[];
|
||||||
let targetStack: Type[];
|
let targetStack: Type[];
|
||||||
|
@ -6583,10 +6488,6 @@ namespace ts {
|
||||||
return context.inferredTypes;
|
return context.inferredTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasAncestor(node: Node, kind: SyntaxKind): boolean {
|
|
||||||
return getAncestor(node, kind) !== undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// EXPRESSION TYPE CHECKING
|
// EXPRESSION TYPE CHECKING
|
||||||
|
|
||||||
function getResolvedSymbol(node: Identifier): Symbol {
|
function getResolvedSymbol(node: Identifier): Symbol {
|
||||||
|
@ -8206,7 +8107,6 @@ namespace ts {
|
||||||
/// type or factory function.
|
/// type or factory function.
|
||||||
/// Otherwise, returns unknownSymbol.
|
/// Otherwise, returns unknownSymbol.
|
||||||
function getJsxElementTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
|
function getJsxElementTagSymbol(node: JsxOpeningLikeElement | JsxClosingElement): Symbol {
|
||||||
const flags: JsxFlags = JsxFlags.UnknownElement;
|
|
||||||
const links = getNodeLinks(node);
|
const links = getNodeLinks(node);
|
||||||
if (!links.resolvedSymbol) {
|
if (!links.resolvedSymbol) {
|
||||||
if (isJsxIntrinsicIdentifier(node.tagName)) {
|
if (isJsxIntrinsicIdentifier(node.tagName)) {
|
||||||
|
@ -14480,16 +14380,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getModuleStatements(node: Declaration): Statement[] {
|
|
||||||
if (node.kind === SyntaxKind.SourceFile) {
|
|
||||||
return (<SourceFile>node).statements;
|
|
||||||
}
|
|
||||||
if (node.kind === SyntaxKind.ModuleDeclaration && (<ModuleDeclaration>node).body.kind === SyntaxKind.ModuleBlock) {
|
|
||||||
return (<ModuleBlock>(<ModuleDeclaration>node).body).statements;
|
|
||||||
}
|
|
||||||
return emptyArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasExportedMembers(moduleSymbol: Symbol) {
|
function hasExportedMembers(moduleSymbol: Symbol) {
|
||||||
for (var id in moduleSymbol.exports) {
|
for (var id in moduleSymbol.exports) {
|
||||||
if (id !== "export=") {
|
if (id !== "export=") {
|
||||||
|
@ -15568,20 +15458,6 @@ namespace ts {
|
||||||
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
|
return symbol && getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
|
|
||||||
if (functionType === unknownType) {
|
|
||||||
return unknownType;
|
|
||||||
}
|
|
||||||
|
|
||||||
const signature = getSingleCallSignature(functionType);
|
|
||||||
if (!signature) {
|
|
||||||
return unknownType;
|
|
||||||
}
|
|
||||||
|
|
||||||
const instantiatedSignature = getSignatureInstantiation(signature, typeArguments);
|
|
||||||
return getOrCreateTypeFromSignature(instantiatedSignature);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createResolver(): EmitResolver {
|
function createResolver(): EmitResolver {
|
||||||
return {
|
return {
|
||||||
getReferencedExportContainer,
|
getReferencedExportContainer,
|
||||||
|
@ -16630,25 +16506,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isIntegerLiteral(expression: Expression): boolean {
|
|
||||||
if (expression.kind === SyntaxKind.PrefixUnaryExpression) {
|
|
||||||
const unaryExpression = <PrefixUnaryExpression>expression;
|
|
||||||
if (unaryExpression.operator === SyntaxKind.PlusToken || unaryExpression.operator === SyntaxKind.MinusToken) {
|
|
||||||
expression = unaryExpression.operand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (expression.kind === SyntaxKind.NumericLiteral) {
|
|
||||||
// Allows for scientific notation since literalExpression.text was formed by
|
|
||||||
// coercing a number to a string. Sometimes this coercion can yield a string
|
|
||||||
// in scientific notation.
|
|
||||||
// We also don't need special logic for hex because a hex integer is converted
|
|
||||||
// to decimal when it is coerced.
|
|
||||||
return /^[0-9]+([eE]\+?[0-9]+)?$/.test((<LiteralExpression>expression).text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
|
function hasParseDiagnostics(sourceFile: SourceFile): boolean {
|
||||||
return sourceFile.parseDiagnostics.length > 0;
|
return sourceFile.parseDiagnostics.length > 0;
|
||||||
}
|
}
|
||||||
|
@ -16677,11 +16534,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEvalOrArgumentsIdentifier(node: Node): boolean {
|
|
||||||
return node.kind === SyntaxKind.Identifier &&
|
|
||||||
((<Identifier>node).text === "eval" || (<Identifier>node).text === "arguments");
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
|
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
|
||||||
if (node.typeParameters) {
|
if (node.typeParameters) {
|
||||||
return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
|
return grammarErrorAtPos(getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
|
||||||
|
|
|
@ -794,23 +794,6 @@ namespace ts {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const backslashOrDoubleQuote = /[\"\\]/g;
|
|
||||||
const escapedCharsRegExp = /[\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
|
||||||
const escapedCharsMap: Map<string> = {
|
|
||||||
"\0": "\\0",
|
|
||||||
"\t": "\\t",
|
|
||||||
"\v": "\\v",
|
|
||||||
"\f": "\\f",
|
|
||||||
"\b": "\\b",
|
|
||||||
"\r": "\\r",
|
|
||||||
"\n": "\\n",
|
|
||||||
"\\": "\\\\",
|
|
||||||
"\"": "\\\"",
|
|
||||||
"\u2028": "\\u2028", // lineSeparator
|
|
||||||
"\u2029": "\\u2029", // paragraphSeparator
|
|
||||||
"\u0085": "\\u0085" // nextLine
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface ObjectAllocator {
|
export interface ObjectAllocator {
|
||||||
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node;
|
||||||
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
|
getSourceFileConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => SourceFile;
|
||||||
|
|
|
@ -1534,14 +1534,6 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitBindingElement(bindingElement: BindingElement) {
|
function emitBindingElement(bindingElement: BindingElement) {
|
||||||
function getBindingElementTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
|
|
||||||
const diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
|
||||||
return diagnosticMessage !== undefined ? {
|
|
||||||
diagnosticMessage,
|
|
||||||
errorNode: bindingElement,
|
|
||||||
typeName: bindingElement.name
|
|
||||||
} : undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
|
if (bindingElement.kind === SyntaxKind.OmittedExpression) {
|
||||||
// If bindingElement is an omittedExpression (i.e. containing elision),
|
// If bindingElement is an omittedExpression (i.e. containing elision),
|
||||||
|
|
|
@ -779,12 +779,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitTrailingCommaIfPresent(nodeList: NodeArray<Node>): void {
|
|
||||||
if (nodeList.hasTrailingComma) {
|
|
||||||
write(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function emitLinePreservingList(parent: Node, nodes: NodeArray<Node>, allowTrailingComma: boolean, spacesBetweenBraces: boolean) {
|
function emitLinePreservingList(parent: Node, nodes: NodeArray<Node>, allowTrailingComma: boolean, spacesBetweenBraces: boolean) {
|
||||||
Debug.assert(nodes.length > 0);
|
Debug.assert(nodes.length > 0);
|
||||||
|
|
||||||
|
@ -3248,10 +3242,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitDownLevelForOfStatement(node: ForOfStatement) {
|
|
||||||
emitLoop(node, emitDownLevelForOfStatementWorker);
|
|
||||||
}
|
|
||||||
|
|
||||||
function emitDownLevelForOfStatementWorker(node: ForOfStatement, loop: ConvertedLoop) {
|
function emitDownLevelForOfStatementWorker(node: ForOfStatement, loop: ConvertedLoop) {
|
||||||
// The following ES6 code:
|
// The following ES6 code:
|
||||||
//
|
//
|
||||||
|
|
|
@ -771,10 +771,6 @@ namespace ts {
|
||||||
return doInsideOfContext(ParserContextFlags.Yield, func);
|
return doInsideOfContext(ParserContextFlags.Yield, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
function doOutsideOfYieldContext<T>(func: () => T): T {
|
|
||||||
return doOutsideOfContext(ParserContextFlags.Yield, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
function doInDecoratorContext<T>(func: () => T): T {
|
function doInDecoratorContext<T>(func: () => T): T {
|
||||||
return doInsideOfContext(ParserContextFlags.Decorator, func);
|
return doInsideOfContext(ParserContextFlags.Decorator, func);
|
||||||
}
|
}
|
||||||
|
@ -791,10 +787,6 @@ namespace ts {
|
||||||
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
return doInsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
function doOutsideOfYieldAndAwaitContext<T>(func: () => T): T {
|
|
||||||
return doOutsideOfContext(ParserContextFlags.Yield | ParserContextFlags.Await, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
function inContext(flags: ParserContextFlags) {
|
function inContext(flags: ParserContextFlags) {
|
||||||
return (contextFlags & flags) !== 0;
|
return (contextFlags & flags) !== 0;
|
||||||
}
|
}
|
||||||
|
@ -851,10 +843,6 @@ namespace ts {
|
||||||
return token = scanner.scan();
|
return token = scanner.scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTokenPos(pos: number): number {
|
|
||||||
return skipTrivia(sourceText, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reScanGreaterToken(): SyntaxKind {
|
function reScanGreaterToken(): SyntaxKind {
|
||||||
return token = scanner.reScanGreaterToken();
|
return token = scanner.reScanGreaterToken();
|
||||||
}
|
}
|
||||||
|
@ -2644,10 +2632,6 @@ namespace ts {
|
||||||
isStartOfExpression();
|
isStartOfExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
function allowInAndParseExpression(): Expression {
|
|
||||||
return allowInAnd(parseExpression);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseExpression(): Expression {
|
function parseExpression(): Expression {
|
||||||
// Expression[in]:
|
// Expression[in]:
|
||||||
// AssignmentExpression[in]
|
// AssignmentExpression[in]
|
||||||
|
@ -3962,7 +3946,6 @@ namespace ts {
|
||||||
|
|
||||||
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
const asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
|
||||||
const tokenIsIdentifier = isIdentifier();
|
const tokenIsIdentifier = isIdentifier();
|
||||||
const nameToken = token;
|
|
||||||
const propertyName = parsePropertyName();
|
const propertyName = parsePropertyName();
|
||||||
|
|
||||||
// Disallowing of optional property assignments happens in the grammar checker.
|
// Disallowing of optional property assignments happens in the grammar checker.
|
||||||
|
@ -5104,10 +5087,6 @@ namespace ts {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseHeritageClausesWorker() {
|
|
||||||
return parseList(ParsingContext.HeritageClauses, parseHeritageClause);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseHeritageClause() {
|
function parseHeritageClause() {
|
||||||
if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) {
|
if (token === SyntaxKind.ExtendsKeyword || token === SyntaxKind.ImplementsKeyword) {
|
||||||
const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
|
const node = <HeritageClause>createNode(SyntaxKind.HeritageClause);
|
||||||
|
@ -5253,12 +5232,6 @@ namespace ts {
|
||||||
return nextToken() === SyntaxKind.SlashToken;
|
return nextToken() === SyntaxKind.SlashToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextTokenIsCommaOrFromKeyword() {
|
|
||||||
nextToken();
|
|
||||||
return token === SyntaxKind.CommaToken ||
|
|
||||||
token === SyntaxKind.FromKeyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
|
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
|
||||||
parseExpected(SyntaxKind.ImportKeyword);
|
parseExpected(SyntaxKind.ImportKeyword);
|
||||||
const afterImportPos = scanner.getStartPos();
|
const afterImportPos = scanner.getStartPos();
|
||||||
|
@ -5751,13 +5724,6 @@ namespace ts {
|
||||||
return finishNode(parameter);
|
return finishNode(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseJSDocOptionalType(type: JSDocType): JSDocOptionalType {
|
|
||||||
const result = <JSDocOptionalType>createNode(SyntaxKind.JSDocOptionalType, type.pos);
|
|
||||||
nextToken();
|
|
||||||
result.type = type;
|
|
||||||
return finishNode(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseJSDocTypeReference(): JSDocTypeReference {
|
function parseJSDocTypeReference(): JSDocTypeReference {
|
||||||
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
|
const result = <JSDocTypeReference>createNode(SyntaxKind.JSDocTypeReference);
|
||||||
result.name = parseSimplePropertyName();
|
result.name = parseSimplePropertyName();
|
||||||
|
|
|
@ -14,7 +14,6 @@ namespace ts {
|
||||||
reset(): void;
|
reset(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nop = <(...args: any[]) => any>Function.prototype;
|
|
||||||
let nullSourceMapWriter: SourceMapWriter;
|
let nullSourceMapWriter: SourceMapWriter;
|
||||||
|
|
||||||
export function getNullSourceMapWriter(): SourceMapWriter {
|
export function getNullSourceMapWriter(): SourceMapWriter {
|
||||||
|
|
|
@ -218,7 +218,6 @@ namespace ts {
|
||||||
const _fs = require("fs");
|
const _fs = require("fs");
|
||||||
const _path = require("path");
|
const _path = require("path");
|
||||||
const _os = require("os");
|
const _os = require("os");
|
||||||
const _tty = require("tty");
|
|
||||||
|
|
||||||
// average async stat takes about 30 microseconds
|
// average async stat takes about 30 microseconds
|
||||||
// set chunk size to do 30 files in < 1 millisecond
|
// set chunk size to do 30 files in < 1 millisecond
|
||||||
|
@ -313,10 +312,6 @@ namespace ts {
|
||||||
// time dynamically to match the large reference set?
|
// time dynamically to match the large reference set?
|
||||||
const watchedFileSet = createWatchedFileSet();
|
const watchedFileSet = createWatchedFileSet();
|
||||||
|
|
||||||
function isNode4OrLater(): Boolean {
|
|
||||||
return parseInt(process.version.charAt(1)) >= 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
const platform: string = _os.platform();
|
const platform: string = _os.platform();
|
||||||
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
// win32\win64 are case insensitive platforms, MacOS (darwin) by default is also case insensitive
|
||||||
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
const useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin";
|
||||||
|
|
|
@ -251,7 +251,6 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||||
const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName));
|
||||||
|
|
||||||
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true);
|
const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true);
|
||||||
const pullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ false);
|
|
||||||
|
|
||||||
const fullResults: ts.Map<TypeWriterResult[]> = {};
|
const fullResults: ts.Map<TypeWriterResult[]> = {};
|
||||||
const pullResults: ts.Map<TypeWriterResult[]> = {};
|
const pullResults: ts.Map<TypeWriterResult[]> = {};
|
||||||
|
|
|
@ -321,11 +321,6 @@ namespace FourSlash {
|
||||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.testData.files.forEach(file => {
|
|
||||||
const fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), "").substr(1);
|
|
||||||
const fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf("."));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Open the first file by default
|
// Open the first file by default
|
||||||
this.openFile(0);
|
this.openFile(0);
|
||||||
}
|
}
|
||||||
|
@ -762,10 +757,6 @@ namespace FourSlash {
|
||||||
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private assertionMessage(name: string, actualValue: any, expectedValue: any) {
|
|
||||||
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getSyntacticDiagnostics(expected: string) {
|
public getSyntacticDiagnostics(expected: string) {
|
||||||
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
|
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
|
||||||
this.testDiagnostics(expected, diagnostics);
|
this.testDiagnostics(expected, diagnostics);
|
||||||
|
@ -910,7 +901,6 @@ namespace FourSlash {
|
||||||
}
|
}
|
||||||
|
|
||||||
public verifyCurrentParameterSpanIs(parameter: string) {
|
public verifyCurrentParameterSpanIs(parameter: string) {
|
||||||
const activeSignature = this.getActiveSignatureHelpItem();
|
|
||||||
const activeParameter = this.getActiveParameter();
|
const activeParameter = this.getActiveParameter();
|
||||||
assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter);
|
assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter);
|
||||||
}
|
}
|
||||||
|
@ -2189,9 +2179,6 @@ namespace FourSlash {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TOOD: should these just use the Harness's stdout/stderr?
|
|
||||||
const fsOutput = new Harness.Compiler.WriterAggregator();
|
|
||||||
const fsErrors = new Harness.Compiler.WriterAggregator();
|
|
||||||
export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) {
|
export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) {
|
||||||
const content = Harness.IO.readFile(fileName);
|
const content = Harness.IO.readFile(fileName);
|
||||||
runFourSlashTestContent(basePath, testType, content, fileName);
|
runFourSlashTestContent(basePath, testType, content, fileName);
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
// this will work in the browser via browserify
|
// this will work in the browser via browserify
|
||||||
var _chai: typeof chai = require("chai");
|
var _chai: typeof chai = require("chai");
|
||||||
var assert: typeof _chai.assert = _chai.assert;
|
var assert: typeof _chai.assert = _chai.assert;
|
||||||
var expect: typeof _chai.expect = _chai.expect;
|
|
||||||
declare var __dirname: string; // Node-specific
|
declare var __dirname: string; // Node-specific
|
||||||
var global = <any>Function("return this").call(null);
|
var global = <any>Function("return this").call(null);
|
||||||
/* tslint:enable:no-var-keyword */
|
/* tslint:enable:no-var-keyword */
|
||||||
|
@ -513,7 +512,6 @@ namespace Harness {
|
||||||
}
|
}
|
||||||
|
|
||||||
const folder: any = fso.GetFolder(path);
|
const folder: any = fso.GetFolder(path);
|
||||||
const paths: string[] = [];
|
|
||||||
|
|
||||||
return filesInFolder(folder, path);
|
return filesInFolder(folder, path);
|
||||||
};
|
};
|
||||||
|
@ -617,7 +615,6 @@ namespace Harness {
|
||||||
export const getExecutingFilePath = () => "";
|
export const getExecutingFilePath = () => "";
|
||||||
export const exit = (exitCode: number) => {};
|
export const exit = (exitCode: number) => {};
|
||||||
|
|
||||||
const supportsCodePage = () => false;
|
|
||||||
export let log = (s: string) => console.log(s);
|
export let log = (s: string) => console.log(s);
|
||||||
|
|
||||||
namespace Http {
|
namespace Http {
|
||||||
|
@ -627,18 +624,6 @@ namespace Harness {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ask the server to use node's path.resolve to resolve the given path
|
/// Ask the server to use node's path.resolve to resolve the given path
|
||||||
function getResolvedPathFromServer(path: string) {
|
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
try {
|
|
||||||
xhr.open("GET", path + "?resolve", /*async*/ false);
|
|
||||||
xhr.send();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return { status: 404, responseText: null };
|
|
||||||
}
|
|
||||||
|
|
||||||
return waitForXHR(xhr);
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface XHRResponse {
|
export interface XHRResponse {
|
||||||
status: number;
|
status: number;
|
||||||
|
|
|
@ -315,13 +315,6 @@ namespace Harness.LanguageService {
|
||||||
class LanguageServiceShimProxy implements ts.LanguageService {
|
class LanguageServiceShimProxy implements ts.LanguageService {
|
||||||
constructor(private shim: ts.LanguageServiceShim) {
|
constructor(private shim: ts.LanguageServiceShim) {
|
||||||
}
|
}
|
||||||
private unwrappJSONCallResult(result: string): any {
|
|
||||||
const parsedResult = JSON.parse(result);
|
|
||||||
if (parsedResult.error) {
|
|
||||||
throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error));
|
|
||||||
}
|
|
||||||
return parsedResult.result;
|
|
||||||
}
|
|
||||||
cleanupSemanticCache(): void {
|
cleanupSemanticCache(): void {
|
||||||
this.shim.cleanupSemanticCache();
|
this.shim.cleanupSemanticCache();
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,25 +305,6 @@ namespace Playback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathEquivCache: any = {};
|
|
||||||
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
|
|
||||||
const key = left + "-~~-" + right;
|
|
||||||
function areSame(a: string, b: string) {
|
|
||||||
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
|
|
||||||
}
|
|
||||||
function check() {
|
|
||||||
if (Harness.Path.getFileName(left).toLowerCase() === Harness.Path.getFileName(right).toLowerCase()) {
|
|
||||||
return areSame(left, right) || areSame(wrapper.resolvePath(left), right) || areSame(left, wrapper.resolvePath(right)) || areSame(wrapper.resolvePath(left), wrapper.resolvePath(right));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pathEquivCache.hasOwnProperty(key)) {
|
|
||||||
return pathEquivCache[key];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return pathEquivCache[key] = check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function noOpReplay(name: string) {
|
function noOpReplay(name: string) {
|
||||||
// console.log("Swallowed write operation during replay: " + name);
|
// console.log("Swallowed write operation during replay: " + name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -263,13 +263,11 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvePath(path: string): string {
|
resolvePath(path: string): string {
|
||||||
const start = new Date().getTime();
|
|
||||||
const result = this.host.resolvePath(path);
|
const result = this.host.resolvePath(path);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileExists(path: string): boolean {
|
fileExists(path: string): boolean {
|
||||||
const start = new Date().getTime();
|
|
||||||
const result = this.host.fileExists(path);
|
const result = this.host.fileExists(path);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -325,32 +323,6 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// assumes normalized paths
|
|
||||||
function getAbsolutePath(filename: string, directory: string) {
|
|
||||||
const rootLength = ts.getRootLength(filename);
|
|
||||||
if (rootLength > 0) {
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const splitFilename = filename.split("/");
|
|
||||||
const splitDir = directory.split("/");
|
|
||||||
let i = 0;
|
|
||||||
let dirTail = 0;
|
|
||||||
const sflen = splitFilename.length;
|
|
||||||
while ((i < sflen) && (splitFilename[i].charAt(0) == ".")) {
|
|
||||||
const dots = splitFilename[i];
|
|
||||||
if (dots == "..") {
|
|
||||||
dirTail++;
|
|
||||||
}
|
|
||||||
else if (dots != ".") {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join("/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ProjectOptions {
|
export interface ProjectOptions {
|
||||||
// these fields can be present in the project file
|
// these fields can be present in the project file
|
||||||
files?: string[];
|
files?: string[];
|
||||||
|
@ -583,7 +555,9 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleProjectFilelistChanges(project: Project) {
|
handleProjectFilelistChanges(project: Project) {
|
||||||
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
|
// TODO: Ignoring potentially returned 'error' and 'succeeded' condition
|
||||||
|
const { projectOptions } = this.configFileToProjectOptions(project.projectFilename);
|
||||||
|
|
||||||
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
|
const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f)));
|
||||||
const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
|
const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f)));
|
||||||
|
|
||||||
|
@ -611,7 +585,9 @@ namespace ts.server {
|
||||||
|
|
||||||
this.log("Detected newly added tsconfig file: " + fileName);
|
this.log("Detected newly added tsconfig file: " + fileName);
|
||||||
|
|
||||||
const { succeeded, projectOptions, error } = this.configFileToProjectOptions(fileName);
|
// TODO: Ignoring potentially returned 'error' and 'succeeded' condition
|
||||||
|
const { projectOptions } = this.configFileToProjectOptions(fileName);
|
||||||
|
|
||||||
const rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
|
const rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
|
||||||
const openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
|
const openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
/* tslint:disable:no-null */
|
/* tslint:disable:no-null */
|
||||||
|
|
||||||
namespace ts.server {
|
namespace ts.server {
|
||||||
const nodeproto: typeof NodeJS._debugger = require("_debugger");
|
|
||||||
const readline: NodeJS.ReadLine = require("readline");
|
const readline: NodeJS.ReadLine = require("readline");
|
||||||
const path: NodeJS.Path = require("path");
|
|
||||||
const fs: typeof NodeJS.fs = require("fs");
|
const fs: typeof NodeJS.fs = require("fs");
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
|
|
|
@ -129,9 +129,6 @@ namespace ts.server {
|
||||||
|
|
||||||
export class Session {
|
export class Session {
|
||||||
protected projectService: ProjectService;
|
protected projectService: ProjectService;
|
||||||
private pendingOperation = false;
|
|
||||||
private fileHash: ts.Map<number> = {};
|
|
||||||
private nextFileId = 1;
|
|
||||||
private errorTimer: any; /*NodeJS.Timer | number*/
|
private errorTimer: any; /*NodeJS.Timer | number*/
|
||||||
private immediateId: any;
|
private immediateId: any;
|
||||||
private changeSeq = 0;
|
private changeSeq = 0;
|
||||||
|
@ -239,11 +236,6 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private errorCheck(file: string, project: Project) {
|
|
||||||
this.syntacticCheck(file, project);
|
|
||||||
this.semanticCheck(file, project);
|
|
||||||
}
|
|
||||||
|
|
||||||
private reloadProjects() {
|
private reloadProjects() {
|
||||||
this.projectService.reloadProjects();
|
this.projectService.reloadProjects();
|
||||||
}
|
}
|
||||||
|
@ -901,7 +893,7 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDiagnosticsForProject(delay: number, fileName: string) {
|
getDiagnosticsForProject(delay: number, fileName: string) {
|
||||||
const { configFileName, fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
|
const { fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
|
||||||
// No need to analyze lib.d.ts
|
// No need to analyze lib.d.ts
|
||||||
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);
|
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);
|
||||||
|
|
||||||
|
|
|
@ -2987,7 +2987,6 @@ namespace ts {
|
||||||
|
|
||||||
function getCompletionData(fileName: string, position: number) {
|
function getCompletionData(fileName: string, position: number) {
|
||||||
const typeChecker = program.getTypeChecker();
|
const typeChecker = program.getTypeChecker();
|
||||||
const syntacticStart = new Date().getTime();
|
|
||||||
const sourceFile = getValidSourceFile(fileName);
|
const sourceFile = getValidSourceFile(fileName);
|
||||||
const isJavaScriptFile = isSourceFileJavaScript(sourceFile);
|
const isJavaScriptFile = isSourceFileJavaScript(sourceFile);
|
||||||
|
|
||||||
|
@ -6175,10 +6174,6 @@ namespace ts {
|
||||||
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
|
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function containErrors(diagnostics: Diagnostic[]): boolean {
|
|
||||||
return forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEmitOutput(fileName: string): EmitOutput {
|
function getEmitOutput(fileName: string): EmitOutput {
|
||||||
synchronizeHostData();
|
synchronizeHostData();
|
||||||
|
|
||||||
|
@ -7054,7 +7049,6 @@ namespace ts {
|
||||||
* be performed.
|
* be performed.
|
||||||
*/
|
*/
|
||||||
function getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion {
|
function getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion {
|
||||||
const start = new Date().getTime();
|
|
||||||
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||||
|
|
||||||
// Check if in a context where we don't want to perform any insertion
|
// Check if in a context where we don't want to perform any insertion
|
||||||
|
@ -7348,11 +7342,17 @@ namespace ts {
|
||||||
if (declarations && declarations.length > 0) {
|
if (declarations && declarations.length > 0) {
|
||||||
// Disallow rename for elements that are defined in the standard TypeScript library.
|
// Disallow rename for elements that are defined in the standard TypeScript library.
|
||||||
const defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings());
|
const defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings());
|
||||||
|
const canonicalDefaultLibName = getCanonicalFileName(ts.normalizePath(defaultLibFileName));
|
||||||
if (defaultLibFileName) {
|
if (defaultLibFileName) {
|
||||||
for (const current of declarations) {
|
for (const current of declarations) {
|
||||||
const sourceFile = current.getSourceFile();
|
const sourceFile = current.getSourceFile();
|
||||||
|
// TODO (drosen): When is there no source file?
|
||||||
|
if (!sourceFile) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName));
|
const canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile.fileName));
|
||||||
if (sourceFile && getCanonicalFileName(ts.normalizePath(sourceFile.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) {
|
if (canonicalName === canonicalDefaultLibName) {
|
||||||
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library));
|
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||||
|
|
||||||
|
var expect: typeof _chai.expect = _chai.expect;
|
||||||
|
|
||||||
namespace ts.server {
|
namespace ts.server {
|
||||||
let lastWrittenToHost: string;
|
let lastWrittenToHost: string;
|
||||||
const mockHost: ServerHost = {
|
const mockHost: ServerHost = {
|
||||||
|
@ -28,7 +30,7 @@ namespace ts.server {
|
||||||
endGroup(): void {},
|
endGroup(): void {},
|
||||||
msg(s: string, type?: string): void {},
|
msg(s: string, type?: string): void {},
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("the Session class", () => {
|
describe("the Session class", () => {
|
||||||
let session: Session;
|
let session: Session;
|
||||||
let lastSent: protocol.Message;
|
let lastSent: protocol.Message;
|
||||||
|
@ -204,7 +206,7 @@ namespace ts.server {
|
||||||
.to.throw(`Protocol handler already exists for command "${command}"`);
|
.to.throw(`Protocol handler already exists for command "${command}"`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("event", () => {
|
describe("event", () => {
|
||||||
it("can format event responses and send them", () => {
|
it("can format event responses and send them", () => {
|
||||||
const evt = "notify-test";
|
const evt = "notify-test";
|
||||||
|
@ -315,7 +317,7 @@ namespace ts.server {
|
||||||
responseRequired: true
|
responseRequired: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
send(msg: protocol.Message) {
|
send(msg: protocol.Message) {
|
||||||
this.client.handle(msg);
|
this.client.handle(msg);
|
||||||
}
|
}
|
||||||
|
@ -323,7 +325,7 @@ namespace ts.server {
|
||||||
enqueue(msg: protocol.Request) {
|
enqueue(msg: protocol.Request) {
|
||||||
this.queue.unshift(msg);
|
this.queue.unshift(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRequest(msg: protocol.Request) {
|
handleRequest(msg: protocol.Request) {
|
||||||
let response: protocol.Response;
|
let response: protocol.Response;
|
||||||
try {
|
try {
|
||||||
|
@ -345,7 +347,7 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InProcClient {
|
class InProcClient {
|
||||||
private server: InProcSession;
|
private server: InProcSession;
|
||||||
private seq = 0;
|
private seq = 0;
|
||||||
|
@ -379,7 +381,7 @@ namespace ts.server {
|
||||||
connect(session: InProcSession): void {
|
connect(session: InProcSession): void {
|
||||||
this.server = session;
|
this.server = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
execute(command: string, args: any, callback: (resp: protocol.Response) => void): void {
|
execute(command: string, args: any, callback: (resp: protocol.Response) => void): void {
|
||||||
if (!this.server) {
|
if (!this.server) {
|
||||||
return;
|
return;
|
||||||
|
@ -394,7 +396,7 @@ namespace ts.server {
|
||||||
this.callbacks[this.seq] = callback;
|
this.callbacks[this.seq] = callback;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
it("can be constructed and respond to commands", (done) => {
|
it("can be constructed and respond to commands", (done) => {
|
||||||
const cli = new InProcClient();
|
const cli = new InProcClient();
|
||||||
const session = new InProcSession(cli);
|
const session = new InProcSession(cli);
|
||||||
|
@ -402,23 +404,23 @@ namespace ts.server {
|
||||||
data: true
|
data: true
|
||||||
};
|
};
|
||||||
const toEvent = {
|
const toEvent = {
|
||||||
data: false
|
data: false
|
||||||
};
|
};
|
||||||
let responses = 0;
|
let responses = 0;
|
||||||
|
|
||||||
// Connect the client
|
// Connect the client
|
||||||
cli.connect(session);
|
cli.connect(session);
|
||||||
|
|
||||||
// Add an event handler
|
// Add an event handler
|
||||||
cli.on("testevent", (eventinfo) => {
|
cli.on("testevent", (eventinfo) => {
|
||||||
expect(eventinfo).to.equal(toEvent);
|
expect(eventinfo).to.equal(toEvent);
|
||||||
responses++;
|
responses++;
|
||||||
expect(responses).to.equal(1);
|
expect(responses).to.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Trigger said event from the server
|
// Trigger said event from the server
|
||||||
session.event(toEvent, "testevent");
|
session.event(toEvent, "testevent");
|
||||||
|
|
||||||
// Queue an echo command
|
// Queue an echo command
|
||||||
cli.execute("echo", toEcho, (resp) => {
|
cli.execute("echo", toEcho, (resp) => {
|
||||||
assert(resp.success, resp.message);
|
assert(resp.success, resp.message);
|
||||||
|
@ -426,7 +428,7 @@ namespace ts.server {
|
||||||
expect(responses).to.equal(2);
|
expect(responses).to.equal(2);
|
||||||
expect(resp.body).to.deep.equal(toEcho);
|
expect(resp.body).to.deep.equal(toEcho);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Queue a configure command
|
// Queue a configure command
|
||||||
cli.execute("configure", {
|
cli.execute("configure", {
|
||||||
hostInfo: "unit test",
|
hostInfo: "unit test",
|
||||||
|
@ -436,10 +438,10 @@ namespace ts.server {
|
||||||
}, (resp) => {
|
}, (resp) => {
|
||||||
assert(resp.success, resp.message);
|
assert(resp.success, resp.message);
|
||||||
responses++;
|
responses++;
|
||||||
expect(responses).to.equal(3);
|
expect(responses).to.equal(3);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Consume the queue and trigger the callbacks
|
// Consume the queue and trigger the callbacks
|
||||||
session.consumeQueue();
|
session.consumeQueue();
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
"no-trailing-whitespace": true,
|
"no-trailing-whitespace": true,
|
||||||
"no-inferrable-types": true,
|
"no-inferrable-types": true,
|
||||||
"no-null": true,
|
"no-null": true,
|
||||||
|
"no-unused-variable": true,
|
||||||
"boolean-trivia": true,
|
"boolean-trivia": true,
|
||||||
"type-operator-spacing": true,
|
"type-operator-spacing": true,
|
||||||
"prefer-const": true,
|
"prefer-const": true,
|
||||||
|
|
Loading…
Reference in a new issue