Merge branch 'master' into createTypeNode

This commit is contained in:
Arthur Ozga
2017-03-23 16:29:00 -07:00
426 changed files with 4806 additions and 5334 deletions
+7 -8
View File
@@ -23,7 +23,7 @@ namespace ts.codefix {
newText: changes[0].textChanges.reduce((prev, cur) => prev + cur.newText, "")
}]
}]
}];
return consolidatedChanges;
}
@@ -108,7 +108,7 @@ namespace ts.codefix {
return signatureDeclaration;
}
let signatureDeclarations = [];
const signatureDeclarations = [];
for (let i = 0; i < signatures.length; i++) {
const signature = signatures[i];
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration);
@@ -119,7 +119,7 @@ namespace ts.codefix {
}
if (declarations.length > signatures.length) {
let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration);
const signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration);
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration);
signatureDeclaration.modifiers = modifiers;
signatureDeclaration.name = name;
@@ -141,7 +141,6 @@ namespace ts.codefix {
function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration {
Debug.assert(signatures && signatures.length > 0);
let maxArgsIndex = 0;
/** This is *a* signature with the maximal number of arguments,
* such that if there is a "maximal" signature without rest arguments,
* this is one of them.
@@ -158,7 +157,7 @@ namespace ts.codefix {
}
}
const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0);
const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName());
const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.getName());
const parameters: ParameterDeclaration[] = [];
for (let i = 0; i < maxNonRestArgs; i++) {
@@ -213,9 +212,9 @@ namespace ts.codefix {
return createBlock(
[createThrow(
createNew(
createIdentifier('Error'),
createIdentifier("Error"),
/*typeArguments*/undefined,
[createLiteral('Method not implemented.')]))],
[createLiteral("Method not implemented.")]))],
/*multiline*/true);
}
@@ -230,7 +229,7 @@ namespace ts.codefix {
}
function stripComments(node: Node): Node {
if(node === undefined) {
if (node === undefined) {
return node;
}
const strippedChildren = visitEachChild(node, stripComments, nullTransformationContext);
+1 -2
View File
@@ -301,7 +301,6 @@ namespace ts.codefix {
}
function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] {
//const newImportText = isDefault ? `default as ${name}` : name;
const importList = <NamedImports>importClause.namedBindings;
const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name));
// case 1:
@@ -556,7 +555,7 @@ namespace ts.codefix {
}
function createChangeTracker() {
return textChanges.ChangeTracker.fromCodeFixContext(context);;
return textChanges.ChangeTracker.fromCodeFixContext(context);
}
function createCodeAction(
+3 -3
View File
@@ -36,11 +36,11 @@ namespace ts.FindAllReferences {
}
else if (node.kind === SyntaxKind.ObjectLiteralExpression) {
entry.kind = ScriptElementKind.interfaceElement;
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)]
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)];
}
else if (node.kind === SyntaxKind.ClassExpression) {
entry.kind = ScriptElementKind.localClassElement;
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)]
entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)];
}
else {
entry.kind = getNodeKind(node);
@@ -335,7 +335,7 @@ namespace ts.FindAllReferences {
// if this symbol is visible from its parent container, e.g. exported, then bail out
// if symbol correspond to the union property - bail out
if (symbol.parent || (symbol.flags & SymbolFlags.Transient && (<TransientSymbol>symbol).checkFlags & CheckFlags.SyntheticProperty)) {
if (symbol.parent || (symbol.flags & SymbolFlags.Transient && (<TransientSymbol>symbol).checkFlags & CheckFlags.Synthetic)) {
return undefined;
}
+8
View File
@@ -210,6 +210,10 @@ namespace ts {
return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile);
}
public forEachChild<T>(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T {
return forEachChild(this, cbNode, cbNodeArray);
}
}
class TokenOrIdentifierObject implements Node {
@@ -283,6 +287,10 @@ namespace ts {
public getLastToken(): Node {
return undefined;
}
public forEachChild<T>(): T {
return undefined;
}
}
class SymbolObject implements Symbol {
+1 -1
View File
@@ -52,7 +52,7 @@ namespace ts.SymbolDisplay {
if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement;
if (flags & SymbolFlags.Property) {
if (flags & SymbolFlags.Transient && (<TransientSymbol>symbol).checkFlags & CheckFlags.SyntheticProperty) {
if (flags & SymbolFlags.Transient && (<TransientSymbol>symbol).checkFlags & CheckFlags.Synthetic) {
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
const unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => {
const rootSymbolFlags = rootSymbol.getFlags();
+8 -8
View File
@@ -57,7 +57,7 @@ namespace ts.textChanges {
* ^ - pos for the next variable declaration will point here
* const y; // this is y
* ^ - end for previous variable declaration
* Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding
* Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding
* variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline).
* By default when removing nodes we adjust start and end positions to respect specification of the trivia above.
* If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true
@@ -265,7 +265,7 @@ namespace ts.textChanges {
options: {},
range: { pos: after.end, end: after.end },
node: createToken(SyntaxKind.SemicolonToken)
})
});
}
}
const endPosition = getAdjustedEndPosition(sourceFile, after, options);
@@ -274,9 +274,9 @@ namespace ts.textChanges {
}
/**
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
* i.e. arguments in arguments lists, parameters in parameter lists etc.
* Separators are treated as part of the node for statements and class elements.
* Note that separators are art of the node in statements and class elements.
*/
public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) {
const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile);
@@ -307,8 +307,8 @@ namespace ts.textChanges {
// c,
// result - '*' denotes leading trivia that will be inserted after new text (displayed as '#')
// a,*
//***insertedtext<separator>#
//###b,
// ***insertedtext<separator>#
// ###b,
// c,
// find line and character of the next element
const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart()));
@@ -317,7 +317,7 @@ namespace ts.textChanges {
let prefix: string;
let startPos: number;
if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) {
// next element is located on the same line with separator:
// next element is located on the same line with separator:
// a,$$$$b
// ^ ^
// | |-next element
@@ -393,7 +393,7 @@ namespace ts.textChanges {
// insert element before the line break on the line that contains 'after' element
let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false);
if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) {
insertPos--
insertPos--;
}
this.changes.push({
sourceFile,
+2
View File
@@ -18,6 +18,8 @@ namespace ts {
getText(sourceFile?: SourceFile): string;
getFirstToken(sourceFile?: SourceFile): Node;
getLastToken(sourceFile?: SourceFile): Node;
// See ts.forEachChild for documentation.
forEachChild<T>(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T;
}
export interface Symbol {
+1 -1
View File
@@ -1384,7 +1384,7 @@ namespace ts {
// First token is the open curly, this is where we want to put the 'super' call.
return constructor.body.getFirstToken(sourceFile);
}
export function getOpenBraceOfClassLike(declaration: ClassLikeDeclaration, sourceFile: SourceFile) {
return getTokenAtPosition(sourceFile, declaration.members.pos - 1);
}