Skip to content

Commit

Permalink
Address code review, handle type parameter in completion list inside …
Browse files Browse the repository at this point in the history
…class expression
  • Loading branch information
Yui T committed Jul 7, 2015
1 parent b01e4d8 commit f4cd1ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13371,17 +13371,27 @@ namespace ts {
case SyntaxKind.EnumDeclaration:
copySymbols(getSymbolOfNode(location).exports, meaning & SymbolFlags.EnumMember);
break;
case SyntaxKind.ClassExpression:
let className = (<ClassExpression>location).name;
if (className) {
copySymbol(className.text, location.symbol, meaning);
}
// fall through; this fall-through is necessary because we would like to handle
// type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Jul 7, 2015

Contributor

Wrap comment

case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
// If we didn't come from static member of class or interface, add the type parameters into the symbol table
// (type parameters of classDeclaration/classExpression and interface are in member property of the symbol.

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Jul 7, 2015

Contributor

Wrap comments

// jNote: that the memberFlags come from previous iteration.

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Jul 7, 2015

Contributor

Note

if (!(memberFlags & NodeFlags.Static)) {
copySymbols(getSymbolOfNode(location).members, meaning & SymbolFlags.Type);
}
break;
case SyntaxKind.FunctionExpression:
case SyntaxKind.ClassExpression:
let name = (<FunctionExpression|ClassExpression>location).name;
if (name) {
copySymbol(name.text, location.symbol, meaning);
let funcName = (<FunctionExpression>location).name;
if (funcName) {
copySymbol(funcName.text, location.symbol, meaning);
}
break;
}
Expand All @@ -13396,7 +13406,7 @@ namespace ts {
/**
* Copy the given symbol into symbol tables if the symbol has the given meaning
* and it doesn't already existed in the symbol table
* @param key a key for storing in symbol table; if null, use symbol.name
* @param key a key for storing in symbol table; if undefined, use symbol.name
* @param symbol the symbol to be added into symbol table
* @param meaning meaning of symbol to filter by before adding to symbol table
*/
Expand Down
2 changes: 1 addition & 1 deletion src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ module FourSlash {

var itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n");

this.raiseError('Expected "' + JSON.stringify({ name: name, text: text, documentation: documentation, kind: kind }) + '" to be in list [' + itemsString + ']');
this.raiseError('Expected "' + JSON.stringify({ name, text, documentation, kind }) + '" to be in list [' + itemsString + ']');
}

private findFile(indexOrName: any) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
///<reference path="fourslash.ts" />

//// var x = class myClass <TypeParam> {
//// getClassName (){
//// /*0*/
//// }
//// prop: Ty/*1*/
//// }

goTo.marker("0");
verify.completionListContains("TypeParam", "(type parameter) TypeParam in myClass<TypeParam>", /*documentation*/ undefined, "type parameter");

goTo.marker("1");
verify.completionListContains("TypeParam", "(type parameter) TypeParam in myClass<TypeParam>", /*documentation*/ undefined, "type parameter");

0 comments on commit f4cd1ac

Please sign in to comment.