mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Merge branch 'master' into grammarChecks
Conflicts: src/compiler/diagnosticMessages.json src/compiler/parser.ts tests/baselines/reference/objectTypesWithOptionalProperties.errors.txt
This commit is contained in:
@@ -361,8 +361,8 @@ module ts.formatting {
|
||||
delta = Math.min(options.IndentSize, parentDynamicIndentation.getDelta() + delta);
|
||||
}
|
||||
return {
|
||||
indentation: indentation,
|
||||
delta: delta
|
||||
indentation,
|
||||
delta
|
||||
}
|
||||
}
|
||||
|
||||
@@ -834,7 +834,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function newTextChange(start: number, len: number, newText: string): TextChange {
|
||||
return { span: new TextSpan(start, len), newText: newText }
|
||||
return { span: new TextSpan(start, len), newText }
|
||||
}
|
||||
|
||||
function recordDelete(start: number, len: number) {
|
||||
|
||||
@@ -262,12 +262,12 @@ module ts.NavigationBar {
|
||||
}
|
||||
|
||||
return {
|
||||
text: text,
|
||||
kind: kind,
|
||||
kindModifiers: kindModifiers,
|
||||
spans: spans,
|
||||
childItems: childItems,
|
||||
indent: indent,
|
||||
text,
|
||||
kind,
|
||||
kindModifiers,
|
||||
spans,
|
||||
childItems,
|
||||
indent,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
};
|
||||
|
||||
@@ -899,7 +899,6 @@ module ts {
|
||||
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
|
||||
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
getImplementorsAtPosition(fileName: string, position: number): ReferenceEntry[];
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[];
|
||||
getNavigationBarItems(fileName: string): NavigationBarItem[];
|
||||
@@ -1376,8 +1375,8 @@ module ts {
|
||||
writeSpace: text => writeKind(text, SymbolDisplayPartKind.space),
|
||||
writeStringLiteral: text => writeKind(text, SymbolDisplayPartKind.stringLiteral),
|
||||
writeParameter: text => writeKind(text, SymbolDisplayPartKind.parameterName),
|
||||
writeSymbol: writeSymbol,
|
||||
writeLine: writeLine,
|
||||
writeSymbol,
|
||||
writeLine,
|
||||
increaseIndent: () => { indent++; },
|
||||
decreaseIndent: () => { indent--; },
|
||||
clear: resetWriter,
|
||||
@@ -1767,7 +1766,7 @@ module ts {
|
||||
sourceFiles.sort((x, y) => y.refCount - x.refCount);
|
||||
return {
|
||||
bucket: name,
|
||||
sourceFiles: sourceFiles
|
||||
sourceFiles
|
||||
};
|
||||
});
|
||||
return JSON.stringify(bucketInfoArray, null, 2);
|
||||
@@ -1833,10 +1832,10 @@ module ts {
|
||||
}
|
||||
|
||||
return {
|
||||
acquireDocument: acquireDocument,
|
||||
updateDocument: updateDocument,
|
||||
releaseDocument: releaseDocument,
|
||||
reportStats: reportStats
|
||||
acquireDocument,
|
||||
updateDocument,
|
||||
releaseDocument,
|
||||
reportStats
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1899,7 +1898,7 @@ module ts {
|
||||
processImport();
|
||||
}
|
||||
processTripleSlashDirectives();
|
||||
return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib };
|
||||
return { referencedFiles, importedFiles, isLibFile: isNoDefaultLib };
|
||||
}
|
||||
|
||||
/// Helpers
|
||||
@@ -2298,7 +2297,7 @@ module ts {
|
||||
// Get emitter-diagnostics requires calling TypeChecker.emitFiles so we have to define CompilerHost.writer which does nothing because emitFiles function has side effects defined by CompilerHost.writer
|
||||
var savedWriter = writer;
|
||||
writer = (filename: string, data: string, writeByteOrderMark: boolean) => { };
|
||||
allDiagnostics = allDiagnostics.concat(checker.emitFiles(targetSourceFile).errors);
|
||||
allDiagnostics = allDiagnostics.concat(checker.invokeEmitter(targetSourceFile).diagnostics);
|
||||
writer = savedWriter;
|
||||
}
|
||||
return allDiagnostics
|
||||
@@ -2503,7 +2502,7 @@ module ts {
|
||||
host.log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart));
|
||||
|
||||
return {
|
||||
isMemberCompletion: isMemberCompletion,
|
||||
isMemberCompletion,
|
||||
entries: activeCompletionSession.entries
|
||||
};
|
||||
|
||||
@@ -2758,7 +2757,7 @@ module ts {
|
||||
while (true) {
|
||||
node = node.parent;
|
||||
if (!node) {
|
||||
return node;
|
||||
return undefined;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.SourceFile:
|
||||
@@ -3163,7 +3162,7 @@ module ts {
|
||||
documentation = symbol.getDocumentationComment();
|
||||
}
|
||||
|
||||
return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind };
|
||||
return { displayParts, documentation, symbolKind };
|
||||
|
||||
function addNewLineIfDisplayPartsExist() {
|
||||
if (displayParts.length) {
|
||||
@@ -3264,7 +3263,7 @@ module ts {
|
||||
kind: symbolKind,
|
||||
name: symbolName,
|
||||
containerKind: undefined,
|
||||
containerName: containerName
|
||||
containerName
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3973,6 +3972,10 @@ module ts {
|
||||
for (var i = 0, n = declarations.length; i < n; i++) {
|
||||
var container = getContainerNode(declarations[i]);
|
||||
|
||||
if (!container) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (scope && scope !== container) {
|
||||
// Different declarations have different containers, bail out
|
||||
return undefined;
|
||||
@@ -4537,8 +4540,8 @@ module ts {
|
||||
fileName: filename,
|
||||
textSpan: TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()),
|
||||
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
||||
containerName: container.name ? (<Identifier>container.name).text : "",
|
||||
containerKind: container.name ? getNodeKind(container) : ""
|
||||
containerName: container && container.name ? (<Identifier>container.name).text : "",
|
||||
containerKind: container && container.name ? getNodeKind(container) : ""
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4646,7 +4649,7 @@ module ts {
|
||||
// Perform semantic and force a type check before emit to ensure that all symbols are updated
|
||||
// EmitFiles will report if there is an error from TypeChecker and Emitter
|
||||
// Depend whether we will have to emit into a single file or not either emit only selected file in the project, emit all files into a single file
|
||||
var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile);
|
||||
var emitFilesResult = getFullTypeCheckChecker().invokeEmitter(targetSourceFile);
|
||||
emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus;
|
||||
|
||||
// Reset writer back to undefined to make sure that we produce an error message if CompilerHost.writeFile method is called when we are not in getEmitOutput
|
||||
@@ -4692,10 +4695,13 @@ module ts {
|
||||
else {
|
||||
return SemanticMeaning.Namespace;
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace;
|
||||
|
||||
// An external module can be a Value
|
||||
case SyntaxKind.SourceFile:
|
||||
return SemanticMeaning.Namespace | SemanticMeaning.Value;
|
||||
}
|
||||
Debug.fail("Unknown declaration type");
|
||||
}
|
||||
@@ -5427,46 +5433,45 @@ module ts {
|
||||
return {
|
||||
canRename: true,
|
||||
localizedErrorMessage: undefined,
|
||||
displayName: displayName,
|
||||
fullDisplayName: fullDisplayName,
|
||||
kind: kind,
|
||||
kindModifiers: kindModifiers,
|
||||
triggerSpan: triggerSpan
|
||||
displayName,
|
||||
fullDisplayName,
|
||||
kind,
|
||||
kindModifiers,
|
||||
triggerSpan
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
dispose: dispose,
|
||||
cleanupSemanticCache: cleanupSemanticCache,
|
||||
getSyntacticDiagnostics: getSyntacticDiagnostics,
|
||||
getSemanticDiagnostics: getSemanticDiagnostics,
|
||||
getCompilerOptionsDiagnostics: getCompilerOptionsDiagnostics,
|
||||
getSyntacticClassifications: getSyntacticClassifications,
|
||||
getSemanticClassifications: getSemanticClassifications,
|
||||
getCompletionsAtPosition: getCompletionsAtPosition,
|
||||
getCompletionEntryDetails: getCompletionEntryDetails,
|
||||
getSignatureHelpItems: getSignatureHelpItems,
|
||||
getQuickInfoAtPosition: getQuickInfoAtPosition,
|
||||
getDefinitionAtPosition: getDefinitionAtPosition,
|
||||
getReferencesAtPosition: getReferencesAtPosition,
|
||||
getOccurrencesAtPosition: getOccurrencesAtPosition,
|
||||
getImplementorsAtPosition: (filename, position) => [],
|
||||
getNameOrDottedNameSpan: getNameOrDottedNameSpan,
|
||||
getBreakpointStatementAtPosition: getBreakpointStatementAtPosition,
|
||||
getNavigateToItems: getNavigateToItems,
|
||||
getRenameInfo: getRenameInfo,
|
||||
findRenameLocations: findRenameLocations,
|
||||
getNavigationBarItems: getNavigationBarItems,
|
||||
getOutliningSpans: getOutliningSpans,
|
||||
getTodoComments: getTodoComments,
|
||||
getBraceMatchingAtPosition: getBraceMatchingAtPosition,
|
||||
getIndentationAtPosition: getIndentationAtPosition,
|
||||
getFormattingEditsForRange: getFormattingEditsForRange,
|
||||
getFormattingEditsForDocument: getFormattingEditsForDocument,
|
||||
getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke,
|
||||
getEmitOutput: getEmitOutput,
|
||||
getSignatureAtPosition: getSignatureAtPosition,
|
||||
dispose,
|
||||
cleanupSemanticCache,
|
||||
getSyntacticDiagnostics,
|
||||
getSemanticDiagnostics,
|
||||
getCompilerOptionsDiagnostics,
|
||||
getSyntacticClassifications,
|
||||
getSemanticClassifications,
|
||||
getCompletionsAtPosition,
|
||||
getCompletionEntryDetails,
|
||||
getSignatureHelpItems,
|
||||
getQuickInfoAtPosition,
|
||||
getDefinitionAtPosition,
|
||||
getReferencesAtPosition,
|
||||
getOccurrencesAtPosition,
|
||||
getNameOrDottedNameSpan,
|
||||
getBreakpointStatementAtPosition,
|
||||
getNavigateToItems,
|
||||
getRenameInfo,
|
||||
findRenameLocations,
|
||||
getNavigationBarItems,
|
||||
getOutliningSpans,
|
||||
getTodoComments,
|
||||
getBraceMatchingAtPosition,
|
||||
getIndentationAtPosition,
|
||||
getFormattingEditsForRange,
|
||||
getFormattingEditsForDocument,
|
||||
getFormattingEditsAfterKeystroke,
|
||||
getEmitOutput,
|
||||
getSignatureAtPosition,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5764,9 +5769,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
getClassificationsForLine: getClassificationsForLine
|
||||
};
|
||||
return { getClassificationsForLine };
|
||||
}
|
||||
|
||||
function initializeServices() {
|
||||
|
||||
@@ -133,12 +133,6 @@ module ts {
|
||||
*/
|
||||
getOccurrencesAtPosition(fileName: string, position: number): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
*/
|
||||
getImplementorsAtPosition(fileName: string, position: number): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
|
||||
@@ -696,16 +690,6 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
/// GET IMPLEMENTORS
|
||||
public getImplementorsAtPosition(fileName: string, position: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getImplementorsAtPosition('" + fileName + "', " + position + ")",
|
||||
() => {
|
||||
return this.languageService.getImplementorsAtPosition(fileName, position);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// COMPLETION LISTS
|
||||
|
||||
/**
|
||||
|
||||
@@ -221,7 +221,7 @@ module ts.SignatureHelp {
|
||||
var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile);
|
||||
Debug.assert(list !== undefined);
|
||||
return {
|
||||
list: list,
|
||||
list,
|
||||
listItemIndex: 0
|
||||
};
|
||||
}
|
||||
@@ -303,40 +303,40 @@ module ts.SignatureHelp {
|
||||
var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
|
||||
var items: SignatureHelpItem[] = map(candidates, candidateSignature => {
|
||||
var signatureHelpParameters: SignatureHelpParameter[];
|
||||
var prefixParts: SymbolDisplayPart[] = [];
|
||||
var suffixParts: SymbolDisplayPart[] = [];
|
||||
var prefixDisplayParts: SymbolDisplayPart[] = [];
|
||||
var suffixDisplayParts: SymbolDisplayPart[] = [];
|
||||
|
||||
if (callTargetDisplayParts) {
|
||||
prefixParts.push.apply(prefixParts, callTargetDisplayParts);
|
||||
prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts);
|
||||
}
|
||||
|
||||
if (isTypeParameterHelp) {
|
||||
prefixParts.push(punctuationPart(SyntaxKind.LessThanToken));
|
||||
prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken));
|
||||
var typeParameters = candidateSignature.typeParameters;
|
||||
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
|
||||
suffixParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
|
||||
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
|
||||
var parameterParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, argumentListOrTypeArgumentList));
|
||||
suffixParts.push.apply(suffixParts, parameterParts);
|
||||
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
|
||||
}
|
||||
else {
|
||||
var typeParameterParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, argumentListOrTypeArgumentList));
|
||||
prefixParts.push.apply(prefixParts, typeParameterParts);
|
||||
prefixParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
|
||||
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
var parameters = candidateSignature.parameters;
|
||||
signatureHelpParameters = parameters.length > 0 ? map(parameters, createSignatureHelpParameterForParameter) : emptyArray;
|
||||
suffixParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
suffixDisplayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
}
|
||||
|
||||
var returnTypeParts = mapToDisplayParts(writer =>
|
||||
typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, argumentListOrTypeArgumentList));
|
||||
suffixParts.push.apply(suffixParts, returnTypeParts);
|
||||
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
|
||||
|
||||
return {
|
||||
isVariadic: candidateSignature.hasRestParameter,
|
||||
prefixDisplayParts: prefixParts,
|
||||
suffixDisplayParts: suffixParts,
|
||||
prefixDisplayParts,
|
||||
suffixDisplayParts,
|
||||
separatorDisplayParts: [punctuationPart(SyntaxKind.CommaToken), spacePart()],
|
||||
parameters: signatureHelpParameters,
|
||||
documentation: candidateSignature.getDocumentationComment()
|
||||
@@ -378,11 +378,11 @@ module ts.SignatureHelp {
|
||||
}
|
||||
|
||||
return {
|
||||
items: items,
|
||||
applicableSpan: applicableSpan,
|
||||
selectedItemIndex: selectedItemIndex,
|
||||
argumentIndex: argumentIndex,
|
||||
argumentCount: argumentCount
|
||||
items,
|
||||
applicableSpan,
|
||||
selectedItemIndex,
|
||||
argumentIndex,
|
||||
argumentCount
|
||||
};
|
||||
|
||||
function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter {
|
||||
@@ -394,8 +394,8 @@ module ts.SignatureHelp {
|
||||
return {
|
||||
name: parameter.name,
|
||||
documentation: parameter.getDocumentationComment(),
|
||||
displayParts: displayParts,
|
||||
isOptional: isOptional
|
||||
displayParts,
|
||||
isOptional
|
||||
};
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ module ts.SignatureHelp {
|
||||
return {
|
||||
name: typeParameter.symbol.name,
|
||||
documentation: emptyArray,
|
||||
displayParts: displayParts,
|
||||
displayParts,
|
||||
isOptional: false
|
||||
};
|
||||
}
|
||||
|
||||
@@ -222,7 +222,8 @@ module ts.formatting {
|
||||
if (node.parent) {
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.TypeReference:
|
||||
if ((<TypeReferenceNode>node.parent).typeArguments) {
|
||||
if ((<TypeReferenceNode>node.parent).typeArguments &&
|
||||
rangeContainsStartEnd((<TypeReferenceNode>node.parent).typeArguments, node.getStart(sourceFile), node.getEnd())) {
|
||||
return (<TypeReferenceNode>node.parent).typeArguments;
|
||||
}
|
||||
break;
|
||||
@@ -236,21 +237,28 @@ module ts.formatting {
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
if ((<SignatureDeclaration>node.parent).typeParameters && node.end < (<SignatureDeclaration>node.parent).typeParameters.end) {
|
||||
var start = node.getStart(sourceFile);
|
||||
if ((<SignatureDeclaration>node.parent).typeParameters &&
|
||||
rangeContainsStartEnd((<SignatureDeclaration>node.parent).typeParameters, start, node.getEnd())) {
|
||||
return (<SignatureDeclaration>node.parent).typeParameters;
|
||||
}
|
||||
|
||||
return (<SignatureDeclaration>node.parent).parameters;
|
||||
if (rangeContainsStartEnd((<SignatureDeclaration>node.parent).parameters, start, node.getEnd())) {
|
||||
return (<SignatureDeclaration>node.parent).parameters;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.CallExpression:
|
||||
if ((<CallExpression>node.parent).typeArguments && node.end < (<CallExpression>node.parent).typeArguments.end) {
|
||||
var start = node.getStart(sourceFile);
|
||||
if ((<CallExpression>node.parent).typeArguments &&
|
||||
rangeContainsStartEnd((<CallExpression>node.parent).typeArguments, start, node.getEnd())) {
|
||||
return (<CallExpression>node.parent).typeArguments;
|
||||
}
|
||||
|
||||
return (<CallExpression>node.parent).arguments;
|
||||
if (rangeContainsStartEnd((<CallExpression>node.parent).arguments, start, node.getEnd())) {
|
||||
return (<CallExpression>node.parent).arguments;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,22 +66,22 @@ module ts {
|
||||
}
|
||||
|
||||
export function findListItemInfo(node: Node): ListItemInfo {
|
||||
var syntaxList = findContainingList(node);
|
||||
var list = findContainingList(node);
|
||||
|
||||
// It is possible at this point for syntaxList to be undefined, either if
|
||||
// node.parent had no list child, or if none of its list children contained
|
||||
// the span of node. If this happens, return undefined. The caller should
|
||||
// handle this case.
|
||||
if (!syntaxList) {
|
||||
if (!list) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var children = syntaxList.getChildren();
|
||||
var index = indexOf(children, node);
|
||||
var children = list.getChildren();
|
||||
var listItemIndex = indexOf(children, node);
|
||||
|
||||
return {
|
||||
listItemIndex: index,
|
||||
list: syntaxList
|
||||
listItemIndex,
|
||||
list
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user