Skip computed properties in the nav bar

This commit is contained in:
Jason Freeman 2014-11-25 14:08:21 -08:00
parent d43ed2f10e
commit 480883b227
4 changed files with 30 additions and 18 deletions

View File

@ -1,12 +0,0 @@
Parse computed expressions and add tests
Disallow computed expressions in class instance properties
Disallow computed expressions in object literal properties, methods, or accessors
Disallow in interfaces
Emit computed properties for classes and object literals
Discuss down level support for computed properties
Tests that need to move:
tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature4.ts
tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature5.ts
tests\cases\conformance\parser\ecmascript5\IndexSignatures\parserIndexSignature11.ts

View File

@ -377,9 +377,10 @@ module ts.NavigationBar {
// Add the constructor parameters in as children of the class (for property parameters).
// Note that *all* parameters will be added to the nodes array, but parameters that
// are not properties will be filtered out later by createChildItem.
var nodes: Node[] = constructor
? node.members.concat(constructor.parameters)
: node.members;
var nodes: Node[] = removeComputedProperties(node);
if (constructor) {
nodes.push.apply(nodes, constructor.parameters);
}
var childItems = getItemsWorker(sortNodes(nodes), createChildItem);
}
@ -394,7 +395,7 @@ module ts.NavigationBar {
}
function createEnumItem(node: EnumDeclaration): ts.NavigationBarItem {
var childItems = getItemsWorker(sortNodes(node.members), createChildItem);
var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
return getNavigationBarItem(
node.name.text,
ts.ScriptElementKind.enumElement,
@ -405,7 +406,7 @@ module ts.NavigationBar {
}
function createIterfaceItem(node: InterfaceDeclaration): ts.NavigationBarItem {
var childItems = getItemsWorker(sortNodes(node.members), createChildItem);
var childItems = getItemsWorker(sortNodes(removeComputedProperties(node)), createChildItem);
return getNavigationBarItem(
node.name.text,
ts.ScriptElementKind.interfaceElement,
@ -416,6 +417,10 @@ module ts.NavigationBar {
}
}
function removeComputedProperties(node: ClassDeclaration | InterfaceDeclaration | EnumDeclaration): Declaration[] {
return filter<Declaration>(node.members, member => member.name === undefined || member.name.kind !== SyntaxKind.ComputedPropertyName);
}
function getInnermostModule(node: ModuleDeclaration): ModuleDeclaration {
while (node.body.kind === SyntaxKind.ModuleDeclaration) {
node = <ModuleDeclaration>node.body;

View File

@ -0,0 +1,20 @@
/// <reference path="fourslash.ts"/>
////{| "itemName": "C", "kind": "class", "parentName": "" |}
////class C {
//// {| "itemName": "foo", "kind": "method", "parentName": "C" |}
//// foo() { }
//// ["hi" + "bye"]() { }
//// {| "itemName": "bar", "kind": "method", "parentName": "C" |}
//// bar() { }
////}
test.markers().forEach(marker => {
verify.navigationItemsListContains(
marker.data.itemName,
marker.data.kind,
marker.data.itemName,
"exact",
marker.fileName,
marker.data.parentName);
});

View File

@ -18,7 +18,6 @@
////module Module1 {
//// export var z = 0;
////}
debugger;
goTo.marker("file1");
verify.getScriptLexicalStructureListContains("Module1", "module");
verify.getScriptLexicalStructureListContains("x", "var");