mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Merge branch 'release-1.6'
This commit is contained in:
commit
e6d91a459e
@ -1893,7 +1893,7 @@ namespace ts {
|
||||
|
||||
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) {
|
||||
let targetSymbol = getTargetSymbol(symbol);
|
||||
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) {
|
||||
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) {
|
||||
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3589,10 +3589,11 @@ namespace ts {
|
||||
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
|
||||
isFunction(containingNodeKind) ||
|
||||
containingNodeKind === SyntaxKind.ClassDeclaration || // class A<T, |
|
||||
containingNodeKind === SyntaxKind.FunctionDeclaration || // function A<T, |
|
||||
containingNodeKind === SyntaxKind.ClassExpression || // var C = class D<T, |
|
||||
containingNodeKind === SyntaxKind.InterfaceDeclaration || // interface A<T, |
|
||||
containingNodeKind === SyntaxKind.ArrayBindingPattern; // var [x, y|
|
||||
|
||||
containingNodeKind === SyntaxKind.ArrayBindingPattern || // var [x, y|
|
||||
containingNodeKind === SyntaxKind.TypeAliasDeclaration; // type Map, K, |
|
||||
|
||||
case SyntaxKind.DotToken:
|
||||
return containingNodeKind === SyntaxKind.ArrayBindingPattern; // var [.|
|
||||
|
||||
@ -3619,8 +3620,9 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.LessThanToken:
|
||||
return containingNodeKind === SyntaxKind.ClassDeclaration || // class A< |
|
||||
containingNodeKind === SyntaxKind.FunctionDeclaration || // function A< |
|
||||
containingNodeKind === SyntaxKind.ClassExpression || // var C = class D< |
|
||||
containingNodeKind === SyntaxKind.InterfaceDeclaration || // interface A< |
|
||||
containingNodeKind === SyntaxKind.TypeAliasDeclaration || // type List< |
|
||||
isFunction(containingNodeKind);
|
||||
|
||||
case SyntaxKind.StaticKeyword:
|
||||
@ -4181,6 +4183,7 @@ namespace ts {
|
||||
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
writeTypeParametersOfSymbol(symbol, sourceFile);
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
@ -4221,16 +4224,29 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
// Method/function type parameter
|
||||
let signatureDeclaration = <SignatureDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
|
||||
let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
|
||||
if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) {
|
||||
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
|
||||
let container = getContainingFunction(location);
|
||||
if (container) {
|
||||
let signatureDeclaration = <SignatureDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
|
||||
let signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration);
|
||||
if (signatureDeclaration.kind === SyntaxKind.ConstructSignature) {
|
||||
displayParts.push(keywordPart(SyntaxKind.NewKeyword));
|
||||
displayParts.push(spacePart());
|
||||
}
|
||||
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
|
||||
addFullSymbolName(signatureDeclaration.symbol);
|
||||
}
|
||||
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
}
|
||||
else {
|
||||
// Type aliash type parameter
|
||||
// For example
|
||||
// type list<T> = T[]; // Both T will go through same code path
|
||||
let declaration = <TypeAliasDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
|
||||
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(declaration.symbol);
|
||||
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
|
||||
}
|
||||
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
|
||||
addFullSymbolName(signatureDeclaration.symbol);
|
||||
}
|
||||
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
|
||||
}
|
||||
}
|
||||
if (symbolFlags & SymbolFlags.EnumMember) {
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var C0 = class D</*0*/
|
||||
////var C1 = class D</*1*/T> {}
|
||||
////var C3 = class D<T, /*2*/
|
||||
////var C4 = class D<T, /*3*/U>{}
|
||||
////var C5 = class D<T extends /*4*/>{}
|
||||
|
||||
goTo.marker("0");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("1");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("2");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("3");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("4");
|
||||
verify.not.completionListIsEmpty();
|
||||
@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type List1</*0*/
|
||||
////type List2</*1*/T> = T[];
|
||||
////type List4<T> = /*2*/T[];
|
||||
////type List3<T1> = /*3*/;
|
||||
|
||||
goTo.marker("0");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("1");
|
||||
verify.not.completionListIsEmpty();
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("T");
|
||||
goTo.marker("3");
|
||||
verify.not.completionListIsEmpty();
|
||||
verify.not.completionListContains("T");
|
||||
verify.completionListContains("T1");
|
||||
@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type Map1<K, /*0*/
|
||||
////type Map1<K, /*1*/V> = [];
|
||||
////type Map1<K,V> = /*2*/[];
|
||||
////type Map1<K1, V1> = </*3*/
|
||||
|
||||
goTo.marker("0");
|
||||
verify.completionListIsEmpty();
|
||||
goTo.marker("1");
|
||||
verify.completionListContains("V");
|
||||
goTo.marker("2");
|
||||
verify.completionListContains("K");
|
||||
verify.completionListContains("V");
|
||||
goTo.marker("3");
|
||||
verify.not.completionListContains("K");
|
||||
verify.not.completionListContains("V");
|
||||
verify.completionListContains("K1");
|
||||
verify.completionListContains("V1");
|
||||
@ -0,0 +1,44 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////type /*0*/List</*1*/T> = /*2*/T[]
|
||||
////type /*3*/List2</*4*/T extends string> = /*5*/T[];
|
||||
|
||||
type List2<T extends string> = T[];
|
||||
|
||||
type L<T> = T[]
|
||||
let typeAliashDisplayParts = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List", kind: "aliasName" },
|
||||
{ text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: ">", kind: "punctuation" }];
|
||||
|
||||
let typeAliashDisplayParts2 = [{ text: "type", kind: "keyword" }, { text: " ", kind: "space" }, { text: "List2", kind: "aliasName" },
|
||||
{ text: "<", kind: "punctuation" }, { text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "extends", kind: "keyword" },
|
||||
{ text: " ", kind: "space" }, { text: "string", kind: "keyword" }, { text: ">", kind: "punctuation" }];
|
||||
|
||||
let typeParameterDisplayParts = [{ text: "(", kind: "punctuation" }, { text: "type parameter", kind: "text" }, { text: ")", kind: "punctuation" }, { text: " ", kind: "space" },
|
||||
{ text: "T", kind: "typeParameterName" }, { text: " ", kind: "space" }, { text: "in", kind: "keyword" }, { text: " ", kind: "space" } ]
|
||||
|
||||
|
||||
goTo.marker('0');
|
||||
verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("0").position, length: "List".length },
|
||||
typeAliashDisplayParts.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" },
|
||||
{ text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []);
|
||||
|
||||
goTo.marker('1');
|
||||
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("1").position, length: "T".length },
|
||||
typeParameterDisplayParts.concat(typeAliashDisplayParts), []);
|
||||
|
||||
goTo.marker('2');
|
||||
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("2").position, length: "T".length },
|
||||
typeParameterDisplayParts.concat(typeAliashDisplayParts), []);
|
||||
|
||||
goTo.marker('3');
|
||||
verify.verifyQuickInfoDisplayParts("type", "", { start: test.markerByName("3").position, length: "List2".length },
|
||||
typeAliashDisplayParts2.concat([{ text: " ", kind: "space" }, { text: "=", kind: "operator" }, { "text": " ", "kind": "space" }, { text: "T", kind: "typeParameterName" },
|
||||
{ text: "[", kind: "punctuation" }, { text: "]", kind: "punctuation" }]), []);
|
||||
|
||||
goTo.marker('4');
|
||||
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("4").position, length: "T".length },
|
||||
typeParameterDisplayParts.concat(typeAliashDisplayParts2), []);
|
||||
|
||||
goTo.marker('5');
|
||||
verify.verifyQuickInfoDisplayParts("type parameter", "", { start: test.markerByName("5").position, length: "T".length },
|
||||
typeParameterDisplayParts.concat(typeAliashDisplayParts2), []);
|
||||
Loading…
x
Reference in New Issue
Block a user