Adding a few comments per CR feedback

This commit is contained in:
Anders Hejlsberg 2015-06-08 12:56:33 -07:00
parent 7c2a3c256d
commit c96eee00ef

View file

@ -386,10 +386,10 @@ module ts {
function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol {
switch (container.kind) { switch (container.kind) {
// Modules, source files, and classes need specialized handling for how their // Modules, source files, and classes need specialized handling for how their
// members are declared (for example, a member of a class will go into a specific // members are declared (for example, a member of a class will go into a specific
// symbol table depending on if it is static or not). As such, we defer to // symbol table depending on if it is static or not). We defer to specialized
// specialized handlers to take care of declaring these child members. // handlers to take care of declaring these child members.
case SyntaxKind.ModuleDeclaration: case SyntaxKind.ModuleDeclaration:
return declareModuleMember(node, symbolFlags, symbolExcludes); return declareModuleMember(node, symbolFlags, symbolExcludes);
@ -407,9 +407,10 @@ module ts {
case SyntaxKind.ObjectLiteralExpression: case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.InterfaceDeclaration: case SyntaxKind.InterfaceDeclaration:
// Interface/Object-types always have their children added to the 'members' of // Interface/Object-types always have their children added to the 'members' of
// their container. They are only accessible through an instance of their // their container. They are only accessible through an instance of their
// container, and are never in scope otherwise (even inside the body of the // container, and are never in scope otherwise (even inside the body of the
// object / type / interface declaring them). // object / type / interface declaring them). An exception is type parameters,
// which are in scope without qualification (similar to 'locals').
return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
case SyntaxKind.FunctionType: case SyntaxKind.FunctionType:
@ -427,10 +428,10 @@ module ts {
case SyntaxKind.ArrowFunction: case SyntaxKind.ArrowFunction:
case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.TypeAliasDeclaration:
// All the children of these container types are never visible through another // All the children of these container types are never visible through another
// symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // symbol (i.e. through another symbol's 'exports' or 'members'). Instead,
// they're only accessed 'lexically' (i.e. from code that exists underneath // they're only accessed 'lexically' (i.e. from code that exists underneath
// their container in the tree. To accomplish this, we simply add their declared // their container in the tree. To accomplish this, we simply add their declared
// symbol to the 'locals' of the container. These symbols can then be found as // symbol to the 'locals' of the container. These symbols can then be found as
// the type checker walks up the containers, checking them for matching names. // the type checker walks up the containers, checking them for matching names.
return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
} }