diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 048beb21e0..c33c9107ad 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1959,70 +1959,42 @@ namespace FourSlash { } } - public verifyNavigationBarCount(expected: number) { - const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - const actual = this.getNavigationBarItemsCount(items[0]); - - if (expected !== actual) { - this.raiseError(`verifyNavigationBarCount failed - found: ${actual} navigation items, expected: ${expected}.`); + public verifyNavigationBar(json: any) { + let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + items = this.simplifyNavigationBar(items); + if (JSON.stringify(items) !== JSON.stringify(json)) { + this.raiseError(`verifyNavigationBar failed - expected: ${JSON.stringify(json, undefined, 2)}, got: ${JSON.stringify(items, undefined, 2)}`) } } - private getNavigationBarItemsCount(root: ts.NavigationBarItem) { - ts.Debug.assert(root.kind === ts.ScriptElementKind.moduleElement); - function recur(item: ts.NavigationBarItem) { - let count = 1; - for (const child of item.childItems) - count += recur(child); - return count; - } - return recur(root); - } - - public verifyNavigationBarContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number) { - fileName = fileName || this.activeFile.fileName; - const items = this.languageService.getNavigationBarItems(fileName); - - if (!items || items.length === 0) { - this.raiseError("verifyNavigationBarContains failed - found 0 navigation items, expected at least one."); - } - - if (this.navigationBarItemsContains(items, name, kind, parentName)) { - return; - } - - const missingItem = { name, kind, parentName }; - this.raiseError(`verifyNavigationBarContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`); - } - - private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string, parentName?: string) { - function recur(items: ts.NavigationBarItem[], curParentName: string) { - for (let i = 0; i < items.length; i++) { - const item = items[i]; - if (item && item.text === name && item.kind === kind && (!parentName || curParentName === parentName)) { - return true; - } - if (recur(item.childItems, item.text)) { - return true; - } - } - return false; - } - return recur(items, ""); - } - - public verifyNavigationBarChildItem(parent: string, name: string, kind: string) { - const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - - for (let i = 0; i < items.length; i++) { - const item = items[i]; - if (item.text === parent) { - if (this.navigationBarItemsContains(item.childItems, name, kind)) - return; - const missingItem = { name, kind }; - this.raiseError(`verifyNavigationBarChildItem failed - could not find the item: ${JSON.stringify(missingItem)} in the children list: (${JSON.stringify(item.childItems, undefined, 2)})`); - } - } + // Remove any properties that tend to all have the same value so that test data is easier to read. + private simplifyNavigationBar(items: ts.NavigationBarItem[]): any { + return items.map(item => { + item = ts.clone(item); + if (item.kindModifiers === "") + delete item.kindModifiers; + delete item.spans; + item.childItems = item.childItems.map(child => { + child = ts.clone(child); + ts.Debug.assert(child.childItems.length === 0); + ts.Debug.assert(child.indent === 0); + ts.Debug.assert(child.bolded === false); + ts.Debug.assert(child.grayed === false); + delete child.childItems; + delete child.indent; + delete child.bolded; + delete child.grayed; + delete child.spans; + if (child.kindModifiers === "") + delete child.kindModifiers; + return child; + }); + if (item.bolded === false) + delete item.bolded; + if (item.grayed === false) + delete item.grayed; + return item; + }) } public printNavigationItems(searchValue: string) { @@ -3041,23 +3013,8 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } - public navigationBarCount(count: number) { - this.state.verifyNavigationBarCount(count); - } - - // TODO: figure out what to do with the unused arguments. - public navigationBarContains( - name: string, - kind: string, - fileName?: string, - parentName?: string, - isAdditionalSpan?: boolean, - markerPosition?: number) { - this.state.verifyNavigationBarContains(name, kind, fileName, parentName, isAdditionalSpan, markerPosition); - } - - public navigationBarChildItem(parent: string, name: string, kind: string) { - this.state.verifyNavigationBarChildItem(parent, name, kind); + public navigationBar(json: any) { + this.state.verifyNavigationBar(json); } public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) { diff --git a/tests/cases/fourslash/deleteClassWithEnumPresent.ts b/tests/cases/fourslash/deleteClassWithEnumPresent.ts index 29f7c61e25..d8d4478afe 100644 --- a/tests/cases/fourslash/deleteClassWithEnumPresent.ts +++ b/tests/cases/fourslash/deleteClassWithEnumPresent.ts @@ -5,4 +5,35 @@ goTo.marker(); edit.deleteAtCaret('class Bar { }'.length); -verify.navigationBarContains('Foo', 'enum', 'tests/cases/fourslash/deleteClassWithEnumPresent.ts', ''); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "Foo", + "kind": "enum" + } + ], + "indent": 0 + }, + { + "text": "Foo", + "kind": "enum", + "childItems": [ + { + "text": "a", + "kind": "property" + }, + { + "text": "b", + "kind": "property" + }, + { + "text": "c", + "kind": "property" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 08883f163f..8a0d2d3636 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -175,9 +175,7 @@ declare namespace FourSlashInterface { DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - navigationBarCount(count: number): void; - navigationBarContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number): void; - navigationBarChildItem(parent: string, text: string, kind: string): void; + navigationBar(json: any): void; navigationItemsListCount(count: number, searchValue: string, matchKind?: string): void; navigationItemsListContains(name: string, kind: string, searchValue: string, matchKind: string, fileName?: string, parentName?: string): void; occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void; diff --git a/tests/cases/fourslash/getNavigationBarItems.ts b/tests/cases/fourslash/getNavigationBarItems.ts index cd09f61011..a2b0492514 100644 --- a/tests/cases/fourslash/getNavigationBarItems.ts +++ b/tests/cases/fourslash/getNavigationBarItems.ts @@ -5,7 +5,31 @@ //// ["bar"]: string; ////} -verify.navigationBarCount(5); -verify.navigationBarContains("C", "class"); -verify.navigationBarChildItem("C", "[\"bar\"]", "property"); -verify.navigationBarChildItem("C", "foo", "property"); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "C", + "kind": "class", + "childItems": [ + { + "text": "[\"bar\"]", + "kind": "property" + }, + { + "text": "foo", + "kind": "property" + } + ], + "indent": 1 + } +]) diff --git a/tests/cases/fourslash/navbar_const.ts b/tests/cases/fourslash/navbar_const.ts index 5d8b42607c..02a10f46a7 100644 --- a/tests/cases/fourslash/navbar_const.ts +++ b/tests/cases/fourslash/navbar_const.ts @@ -1,13 +1,17 @@ /// -//// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0; +//// const c = 0; -test.markers().forEach(marker => { - verify.navigationBarContains( - marker.data.itemName, - marker.data.kind, - marker.fileName, - marker.data.parentName, - marker.data.isAdditionalRange, - marker.position); -}); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "c", + "kind": "const" + } + ], + "indent": 0 + } +]); diff --git a/tests/cases/fourslash/navbar_contains-no-duplicates.ts b/tests/cases/fourslash/navbar_contains-no-duplicates.ts index 42b33a722a..333130ff79 100644 --- a/tests/cases/fourslash/navbar_contains-no-duplicates.ts +++ b/tests/cases/fourslash/navbar_contains-no-duplicates.ts @@ -1,42 +1,142 @@ /// -//// {| "itemName": "Windows", "kind": "module", "parentName": "" |}declare module Windows { -//// {| "itemName": "Foundation", "kind": "module", "parentName": "Windows" |}export module Foundation { -//// export var {| "itemName": "A", "kind": "var" |}A; -//// {| "itemName": "Test", "kind": "class", "parentName": "Foundation" |}export class Test { -//// {| "itemName": "wow", "kind": "method" |}public wow(); +//// declare module Windows { +//// export module Foundation { +//// export var A; +//// export class Test { +//// public wow(); //// } //// } //// } //// -//// {| "itemName": "Windows", "kind": "module", "parentName": "", "isAdditionalRange": true |}declare module Windows { -//// {| "itemName": "Foundation", "kind": "module", "parentName": "Windows", "isAdditionalRange": true |}export module Foundation { -//// export var {| "itemName": "B", "kind": "var" |}B; -//// {| "itemName": "Test", "kind": "module" |}export module Test { -//// {| "itemName": "Boom", "kind": "function" |}export function Boom(): number; +//// declare module Windows { +//// export module Foundation { +//// export var B; +//// export module Test { +//// export function Boom(): number; //// } //// } //// } //// -//// {| "itemName": "ABC", "kind": "class", "parentName": "" |}class ABC { -//// {| "itemName": "foo", "kind": "method" |}public foo() { +//// class ABC { +//// public foo() { //// return 3; //// } //// } //// -//// {| "itemName": "ABC", "kind": "module", "parentName": "" |}module ABC { -//// export var {| "itemName": "x", "kind": "var" |}x = 3; +//// module ABC { +//// export var x = 3; //// } -test.markers().forEach(marker => { - if (marker.data) { - verify.navigationBarContains( - marker.data.itemName, - marker.data.kind, - marker.fileName, - marker.data.parentName, - marker.data.isAdditionalRange, - marker.position); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "ABC", + "kind": "class" + }, + { + "text": "ABC", + "kind": "module" + }, + { + "text": "Windows", + "kind": "module", + "kindModifiers": "declare" + } + ], + "indent": 0 + }, + { + "text": "ABC", + "kind": "class", + "childItems": [ + { + "text": "foo", + "kind": "method", + "kindModifiers": "public" + } + ], + "indent": 1 + }, + { + "text": "ABC", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 1 + }, + { + "text": "Windows", + "kind": "module", + "kindModifiers": "declare", + "childItems": [ + { + "text": "Foundation", + "kind": "module", + "kindModifiers": "export,declare" + } + ], + "indent": 1 + }, + { + "text": "Foundation", + "kind": "module", + "kindModifiers": "export,declare", + "childItems": [ + { + "text": "A", + "kind": "var", + "kindModifiers": "export,declare" + }, + { + "text": "Test", + "kind": "class", + "kindModifiers": "export,declare" + }, + { + "text": "B", + "kind": "var", + "kindModifiers": "export,declare" + }, + { + "text": "Test", + "kind": "module", + "kindModifiers": "export,declare" + } + ], + "indent": 2 + }, + { + "text": "Test", + "kind": "class", + "kindModifiers": "export,declare", + "childItems": [ + { + "text": "wow", + "kind": "method", + "kindModifiers": "public,declare" + } + ], + "indent": 3 + }, + { + "text": "Test", + "kind": "module", + "kindModifiers": "export,declare", + "childItems": [ + { + "text": "Boom", + "kind": "function", + "kindModifiers": "export,declare" + } + ], + "indent": 3 } -}); - -verify.navigationBarCount(19); +]); diff --git a/tests/cases/fourslash/navbar_exportDefault.ts b/tests/cases/fourslash/navbar_exportDefault.ts index a56eeb8b22..7c666589f1 100644 --- a/tests/cases/fourslash/navbar_exportDefault.ts +++ b/tests/cases/fourslash/navbar_exportDefault.ts @@ -1,24 +1,93 @@ /// // @Filename: a.ts -//// {| "itemName": "default", "kind": "class", "parentName": "" |}export default class { } +////export default class { } // @Filename: b.ts -//// {| "itemName": "C", "kind": "class", "parentName": "" |}export default class C { } +////export default class C { } // @Filename: c.ts -//// {| "itemName": "default", "kind": "function", "parentName": "" |}export default function { } +////export default function { } // @Filename: d.ts -//// {| "itemName": "Func", "kind": "function", "parentName": "" |}export default function Func { } +////export default function Func { } -test.markers().forEach(marker => { - goTo.file(marker.fileName); - verify.navigationBarContains( - marker.data.itemName, - marker.data.kind, - marker.fileName, - marker.data.parentName, - marker.data.isAdditionalRange, - marker.position); -}); \ No newline at end of file +goTo.file("a.ts"); +verify.navigationBar([ + { + "text": "\"a\"", + "kind": "module", + "childItems": [], + "indent": 0 + }, + { + "text": "default", + "kind": "class", + "kindModifiers": "export", + "childItems": [], + "indent": 1 + } +]); + +goTo.file("b.ts"); +verify.navigationBar([ + { + "text": "\"b\"", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "class", + "kindModifiers": "export" + } + ], + "indent": 0 + }, + { + "text": "C", + "kind": "class", + "kindModifiers": "export", + "childItems": [], + "indent": 1 + } +]); + +goTo.file("c.ts"); +verify.navigationBar([ + { + "text": "\"c\"", + "kind": "module", + "childItems": [], + "indent": 0 + }, + { + "text": "default", + "kind": "function", + "kindModifiers": "export", + "childItems": [], + "indent": 1 + } +]); + +goTo.file("d.ts"); +verify.navigationBar([ + { + "text": "\"d\"", + "kind": "module", + "childItems": [ + { + "text": "Func", + "kind": "function", + "kindModifiers": "export" + } + ], + "indent": 0 + }, + { + "text": "Func", + "kind": "function", + "kindModifiers": "export", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navbar_let.ts b/tests/cases/fourslash/navbar_let.ts index c3b125526e..dc9d9c0785 100644 --- a/tests/cases/fourslash/navbar_let.ts +++ b/tests/cases/fourslash/navbar_let.ts @@ -1,13 +1,17 @@ /// -//// {| "itemName": "c", "kind": "let", "parentName": "" |}let c = 0; +////let c = 0; -test.markers().forEach(marker => { - verify.navigationBarContains( - marker.data.itemName, - marker.data.kind, - marker.fileName, - marker.data.parentName, - marker.data.isAdditionalRange, - marker.position); -}); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "c", + "kind": "let" + } + ], + "indent": 0 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts b/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts index afac15daac..007a9c9b80 100644 --- a/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts +++ b/tests/cases/fourslash/navigationBarItemsBindingPatterns.ts @@ -6,16 +6,56 @@ ////const bar1, [c, d] ////var {e, x: [f, g]} = {a:1, x:[]}; -verify.navigationBarCount(12); // global (1) + variable declarations (4) + binding patterns (7) -verify.navigationBarContains("foo", "var"); -verify.navigationBarContains("bar", "var"); -verify.navigationBarContains("foo1", "let") -verify.navigationBarContains("a", "let"); -verify.navigationBarContains("b", "let"); -verify.navigationBarContains("bar1", "const"); -verify.navigationBarContains("c", "const"); -verify.navigationBarContains("d", "const"); -verify.navigationBarContains("e", "var"); -verify.navigationBarContains("f", "var"); -verify.navigationBarContains("g", "var"); - +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "a", + "kind": "let" + }, + { + "text": "b", + "kind": "let" + }, + { + "text": "bar", + "kind": "var" + }, + { + "text": "bar1", + "kind": "const" + }, + { + "text": "c", + "kind": "const" + }, + { + "text": "d", + "kind": "const" + }, + { + "text": "e", + "kind": "var" + }, + { + "text": "f", + "kind": "var" + }, + { + "text": "foo", + "kind": "var" + }, + { + "text": "foo1", + "kind": "let" + }, + { + "text": "g", + "kind": "var" + } + ], + "indent": 0 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts b/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts index 24979e141e..41751f5c74 100644 --- a/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts +++ b/tests/cases/fourslash/navigationBarItemsBindingPatternsInConstructor.ts @@ -11,4 +11,50 @@ //// } ////} -verify.navigationBarCount(9); // global + 2 children + 2x(class + field + constructor) +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "A", + "kind": "class" + }, + { + "text": "B", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "A", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "x", + "kind": "property" + } + ], + "indent": 1 + }, + { + "text": "B", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "x", + "kind": "property" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts b/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts index a80f4c596d..27c33f6afb 100644 --- a/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsEmptyConstructors.ts @@ -5,8 +5,27 @@ //// } ////} -verify.navigationBarContains("Test", "class"); -verify.navigationBarContains("constructor", "constructor"); - -// no other items -verify.navigationBarCount(4); // global + 1 child, Test + 1 child \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "Test", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "Test", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsExports.ts b/tests/cases/fourslash/navigationBarItemsExports.ts index b88b60d0ef..79422f9627 100644 --- a/tests/cases/fourslash/navigationBarItemsExports.ts +++ b/tests/cases/fourslash/navigationBarItemsExports.ts @@ -1,18 +1,33 @@ /// -////export { {| "itemName": "a", "kind": "alias", "parentName": "" |}a } from "a"; +////export { a } from "a"; //// -////export { {| "itemName": "B", "kind": "alias", "parentName": "" |}b as B } from "a" +////export { b as B } from "a" //// -////{| "itemName": "e", "kind": "alias", "parentName": "" |} export import e = require("a"); +////export import e = require("a"); //// ////export * from "a"; // no bindings here -test.markers().forEach((marker) => { - if (marker.data) { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); +verify.navigationBar([ + { + "text": "\"navigationBarItemsExports\"", + "kind": "module", + "childItems": [ + { + "text": "a", + "kind": "alias" + }, + { + "text": "B", + "kind": "alias" + }, + { + "text": "e", + "kind": "alias", + "kindModifiers": "export" + } + ], + "indent": 0 } -}); - -verify.navigationBarCount(4); +]); diff --git a/tests/cases/fourslash/navigationBarItemsFunctions.ts b/tests/cases/fourslash/navigationBarItemsFunctions.ts index 0948923c04..e2260f2ff2 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctions.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctions.ts @@ -1,23 +1,61 @@ /// -////{| "itemName": "", "kind": "module" |} -//// -////{| "itemName": "foo", "kind": "function" |}function foo() { +////function foo() { //// var x = 10; -//// {| "itemName": "bar", "kind": "function", "parentName": "foo" |}function bar() { +//// function bar() { //// var y = 10; -//// {| "itemName": "biz", "kind": "function", "parentName": "bar" |}function biz() { +//// function biz() { //// var z = 10; //// } //// } ////} //// -////{| "itemName": "baz", "kind": "function", "parentName": "" |}function baz() { +////function baz() { //// var v = 10; ////} -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(8); // 4 functions + global. Note: there are 8 because of the functions show up at the top level and as child items. +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "baz", + "kind": "function" + }, + { + "text": "foo", + "kind": "function" + } + ], + "indent": 0 + }, + { + "text": "baz", + "kind": "function", + "childItems": [], + "indent": 1 + }, + { + "text": "foo", + "kind": "function", + "childItems": [ + { + "text": "bar", + "kind": "function" + } + ], + "indent": 1 + }, + { + "text": "bar", + "kind": "function", + "childItems": [ + { + "text": "biz", + "kind": "function" + } + ], + "indent": 2 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts b/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts index e8bf1d33fc..dc84b50ff3 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctionsBroken.ts @@ -1,12 +1,25 @@ /// -////{| "itemName": "f", "kind": "function" |} ////function f() { //// function; ////} -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(3); // and 'f'. \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "f", + "kind": "function" + } + ], + "indent": 0 + }, + { + "text": "f", + "kind": "function", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts b/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts index 9576d4dd78..b4612efcac 100644 --- a/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts +++ b/tests/cases/fourslash/navigationBarItemsFunctionsBroken2.ts @@ -1,13 +1,26 @@ /// ////function; -////{| "itemName": "f", "kind": "function" |} ////function f() { //// function; ////} -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(3); // and 'f' \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "f", + "kind": "function" + } + ], + "indent": 0 + }, + { + "text": "f", + "kind": "function", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsImports.ts b/tests/cases/fourslash/navigationBarItemsImports.ts index 53619da310..d6526a7a68 100644 --- a/tests/cases/fourslash/navigationBarItemsImports.ts +++ b/tests/cases/fourslash/navigationBarItemsImports.ts @@ -1,25 +1,57 @@ /// -////import {| "itemName": "d1", "kind": "alias", "parentName": "" |}d1 from "a"; +////import d1 from "a"; //// -////import { {| "itemName": "a", "kind": "alias", "parentName": "" |}a } from "a"; +////import { a } from "a"; //// -////import { {| "itemName": "B", "kind": "alias", "parentName": "" |}b as B } from "a" +////import { b as B } from "a" //// -////import {| "itemName": "d2", "kind": "alias", "parentName": "" |}d2, -//// { {| "itemName": "c", "kind": "alias", "parentName": "" |}c, -//// {| "itemName": "D", "kind": "alias", "parentName": "" |} d as D } from "a" +////import d2, { c, d as D } from "a" //// -////{| "itemName": "e", "kind": "alias", "parentName": "" |}import e = require("a"); +////import e = require("a"); //// -////import {| "itemName": "ns", "kind": "alias", "parentName": "" |}* as ns from "a"; +////import * as ns from "a"; -test.markers().forEach((marker) => { - if (marker.data) { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); +verify.navigationBar([ + { + "text": "\"navigationBarItemsImports\"", + "kind": "module", + "childItems": [ + { + "text": "a", + "kind": "alias" + }, + { + "text": "B", + "kind": "alias" + }, + { + "text": "c", + "kind": "alias" + }, + { + "text": "D", + "kind": "alias" + }, + { + "text": "d1", + "kind": "alias" + }, + { + "text": "d2", + "kind": "alias" + }, + { + "text": "e", + "kind": "alias" + }, + { + "text": "ns", + "kind": "alias" + } + ], + "indent": 0 } -}); - -verify.navigationBarCount(9); +]); diff --git a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts index 8d93d241ae..7d2fb4ed12 100644 --- a/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsInsideMethodsAndConstructors.ts @@ -2,41 +2,140 @@ ////class Class { //// constructor() { -//// {| "itemName": "LocalFunctionInConstructor", "kind": "function", "parentName": "constructor"|}function LocalFunctionInConstructor() { -//// -//// } -//// -//// {| "itemName": "LocalInterfaceInConstrcutor", "kind": "interface", "parentName": "constructor"|}interface LocalInterfaceInConstrcutor { -//// } -//// -//// {| "itemName": "LocalEnumInConstructor", "kind": "enum", "parentName": "constructor"|}enum LocalEnumInConstructor { -//// {| "itemName": "LocalEnumMemberInConstructor", "kind": "property", "parentName": "LocalEnumInConstructor"|}LocalEnumMemberInConstructor, -//// } +//// function LocalFunctionInConstructor() {} +//// interface LocalInterfaceInConstrcutor {} +//// enum LocalEnumInConstructor { LocalEnumMemberInConstructor } //// } //// //// method() { -//// {| "itemName": "LocalFunctionInMethod", "kind": "function", "parentName": "method"|}function LocalFunctionInMethod() { -//// {| "itemName": "LocalFunctionInLocalFunctionInMethod", "kind": "function", "parentName": "LocalFunctionInMethod"|}function LocalFunctionInLocalFunctionInMethod() { -//// -//// } -//// } -//// -//// {| "itemName": "LocalInterfaceInMethod", "kind": "interface", "parentName": "method"|}interface LocalInterfaceInMethod { -//// } -//// -//// {| "itemName": "LocalEnumInMethod", "kind": "enum", "parentName": "method"|}enum LocalEnumInMethod { -//// {| "itemName": "LocalEnumMemberInMethod", "kind": "property", "parentName": "LocalEnumInMethod"|}LocalEnumMemberInMethod, +//// function LocalFunctionInMethod() { +//// function LocalFunctionInLocalFunctionInMethod() {} //// } +//// interface LocalInterfaceInMethod {} +//// enum LocalEnumInMethod { LocalEnumMemberInMethod } //// } //// -//// emptyMethod() { // Non child functions method should not be duplicated -//// -//// } +//// emptyMethod() { } // Non child functions method should not be duplicated ////} -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -// no other items -verify.navigationBarCount(23); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "Class", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "Class", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "emptyMethod", + "kind": "method" + }, + { + "text": "method", + "kind": "method" + } + ], + "indent": 1 + }, + { + "text": "constructor", + "kind": "constructor", + "childItems": [ + { + "text": "LocalEnumInConstructor", + "kind": "enum" + }, + { + "text": "LocalFunctionInConstructor", + "kind": "function" + }, + { + "text": "LocalInterfaceInConstrcutor", + "kind": "interface" + } + ], + "indent": 2 + }, + { + "text": "LocalEnumInConstructor", + "kind": "enum", + "childItems": [ + { + "text": "LocalEnumMemberInConstructor", + "kind": "property" + } + ], + "indent": 2 + }, + { + "text": "LocalFunctionInConstructor", + "kind": "function", + "childItems": [], + "indent": 2 + }, + { + "text": "LocalInterfaceInConstrcutor", + "kind": "interface", + "childItems": [], + "indent": 2 + }, + { + "text": "method", + "kind": "method", + "childItems": [ + { + "text": "LocalEnumInMethod", + "kind": "enum" + }, + { + "text": "LocalFunctionInMethod", + "kind": "function" + }, + { + "text": "LocalInterfaceInMethod", + "kind": "interface" + } + ], + "indent": 2 + }, + { + "text": "LocalEnumInMethod", + "kind": "enum", + "childItems": [ + { + "text": "LocalEnumMemberInMethod", + "kind": "property" + } + ], + "indent": 2 + }, + { + "text": "LocalFunctionInMethod", + "kind": "function", + "childItems": [ + { + "text": "LocalFunctionInLocalFunctionInMethod", + "kind": "function" + } + ], + "indent": 2 + }, + { + "text": "LocalInterfaceInMethod", + "kind": "interface", + "childItems": [], + "indent": 2 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsItems.ts b/tests/cases/fourslash/navigationBarItemsItems.ts index e8e9fd4082..013d28cd40 100644 --- a/tests/cases/fourslash/navigationBarItemsItems.ts +++ b/tests/cases/fourslash/navigationBarItemsItems.ts @@ -1,52 +1,172 @@ /// ////// Interface -////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint { -//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number; -//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint; -//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any; -//// {| "itemName": "[]", "kind": "index", "parentName": "IPoint" |}[x:string]: number; -//// {| "itemName": "prop", "kind": "property", "parentName": "IPoint" |}prop: string; +////interface IPoint { +//// getDist(): number; +//// new(): IPoint; +//// (): any; +//// [x:string]: number; +//// prop: string; ////} //// /////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { +////module Shapes { //// //// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint { -//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Point" |}constructor (public x: number, public y: number) { } +//// export class Point implements IPoint { +//// constructor (public x: number, public y: number) { } //// //// // Instance member -//// {| "itemName": "getDist", "kind": "method", "parentName": "Point" |}getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } +//// getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } //// //// // Getter -//// {| "itemName": "value", "kind": "getter", "parentName": "Point" |}get value(): number { return 0; } +//// get value(): number { return 0; } //// //// // Setter -//// {| "itemName": "value", "kind": "setter", "parentName": "Point" |}set value(newValue: number) { return; } +//// set value(newValue: number) { return; } //// //// // Static member -//// {| "itemName": "origin", "kind": "property", "parentName": "Point" |}static origin = new Point(0, 0); +//// static origin = new Point(0, 0); //// //// // Static method -//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Point" |}private static getOrigin() { return Point.origin;} +//// private static getOrigin() { return Point.origin; } //// } //// -//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values { -//// value1, -//// {| "itemName": "value2", "kind": "property", "parentName": "Values" |}value2, -//// value3, -//// } +//// enum Values { value1, value2, value3 } ////} //// ////// Local variables -////{| "itemName": "p", "kind": "var", "parentName": "" |}var p: IPoint = new Shapes.Point(3, 4); -////{| "itemName": "dist", "kind": "var", "parentName": "" |}var dist = p.getDist(); +////var p: IPoint = new Shapes.Point(3, 4); +////var dist = p.getDist(); -test.markers().forEach((marker) => { - if (marker.data) { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "dist", + "kind": "var" + }, + { + "text": "IPoint", + "kind": "interface" + }, + { + "text": "p", + "kind": "var" + }, + { + "text": "Shapes", + "kind": "module" + } + ], + "indent": 0 + }, + { + "text": "IPoint", + "kind": "interface", + "childItems": [ + { + "text": "()", + "kind": "call" + }, + { + "text": "new()", + "kind": "construct" + }, + { + "text": "[]", + "kind": "index" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "prop", + "kind": "property" + } + ], + "indent": 1 + }, + { + "text": "Shapes", + "kind": "module", + "childItems": [ + { + "text": "Point", + "kind": "class", + "kindModifiers": "export" + }, + { + "text": "Values", + "kind": "enum" + } + ], + "indent": 1 + }, + { + "text": "Point", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "getOrigin", + "kind": "method", + "kindModifiers": "private,static" + }, + { + "text": "origin", + "kind": "property", + "kindModifiers": "static" + }, + { + "text": "value", + "kind": "getter" + }, + { + "text": "value", + "kind": "setter" + }, + { + "text": "x", + "kind": "property", + "kindModifiers": "public" + }, + { + "text": "y", + "kind": "property", + "kindModifiers": "public" + } + ], + "indent": 2 + }, + { + "text": "Values", + "kind": "enum", + "childItems": [ + { + "text": "value1", + "kind": "property" + }, + { + "text": "value2", + "kind": "property" + }, + { + "text": "value3", + "kind": "property" + } + ], + "indent": 2 } -}); - -verify.navigationBarCount(27); +]); diff --git a/tests/cases/fourslash/navigationBarItemsItems2.ts b/tests/cases/fourslash/navigationBarItemsItems2.ts index 013f27b4d7..27c32531d6 100644 --- a/tests/cases/fourslash/navigationBarItemsItems2.ts +++ b/tests/cases/fourslash/navigationBarItemsItems2.ts @@ -1,6 +1,5 @@ /// - /////**/ goTo.marker(); @@ -8,5 +7,29 @@ edit.insertLine("module A"); edit.insert("export class "); // should not crash -verify.navigationBarCount(4); - +verify.navigationBar([ + { + "text": "\"navigationBarItemsItems2\"", + "kind": "module", + "childItems": [ + { + "text": "A", + "kind": "module" + } + ], + "indent": 0 + }, + { + "text": "default", + "kind": "class", + "kindModifiers": "export", + "childItems": [], + "indent": 1 + }, + { + "text": "A", + "kind": "module", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsItemsContainsNoAnonymousFunctions.ts b/tests/cases/fourslash/navigationBarItemsItemsContainsNoAnonymousFunctions.ts index dac6e96ab9..34e4a1c0c8 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsContainsNoAnonymousFunctions.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsContainsNoAnonymousFunctions.ts @@ -30,15 +30,57 @@ ////} goTo.marker("file1"); -verify.navigationBarCount(0); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [], + "indent": 0 + } +]); goTo.marker("file2"); -verify.navigationBarContains("", "module"); -verify.navigationBarContains("x", "var"); -verify.navigationBarCount(2); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var" + } + ], + "indent": 0 + } +]); goTo.marker("file3"); -verify.navigationBarContains("", "module"); -verify.navigationBarContains("foo", "function"); -verify.navigationBarContains("bar", "function"); -verify.navigationBarCount(5); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "bar", + "kind": "function" + }, + { + "text": "foo", + "kind": "function" + } + ], + "indent": 0 + }, + { + "text": "bar", + "kind": "function", + "childItems": [], + "indent": 1 + }, + { + "text": "foo", + "kind": "function", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts index 7b2e0def4b..f2df772fb1 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsExternalModules.ts @@ -1,11 +1,33 @@ /// -////{| "itemName": "Bar", "kind": "class", "parentName": "\"navigationBarItemsItemsExternalModules\"" |}export class Bar { -//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string; +////export class Bar { +//// public s: string; ////} -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(4); // external module node + class + property +verify.navigationBar([ + { + "text": "\"navigationBarItemsItemsExternalModules\"", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export" + } + ], + "indent": 0 + }, + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "s", + "kind": "property", + "kindModifiers": "public" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts index 9087493b29..54d4759afe 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsExternalModules2.ts @@ -1,15 +1,40 @@ /// // @Filename: test/file.ts -////{| "itemName": "Bar", "kind": "class", "parentName": "\"file\"" |}export class Bar { -//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string; +////export class Bar { +//// public s: string; ////} -////{| "itemName": "\"file\"", "kind": "module" |} -////{| "itemName": "x", "kind": "var", "parentName": "\"file\"" |} ////export var x: number; -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(5); // external module node + variable in module + class + property +verify.navigationBar([ + { + "text": "\"file\"", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export" + }, + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 0 + }, + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "s", + "kind": "property", + "kindModifiers": "public" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts b/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts index a00b3a131d..2db04c980d 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsExternalModules3.ts @@ -1,15 +1,40 @@ /// // @Filename: test/my fil"e.ts -////{| "itemName": "Bar", "kind": "class", "parentName": "\"my fil\\\"e\"" |}export class Bar { -//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string; +////export class Bar { +//// public s: string; ////} -////{| "itemName": "\"my fil\\\"e\"", "kind": "module" |} -////{| "itemName": "x", "kind": "var", "parentName": "\"my fil\\\"e\"" |} ////export var x: number; -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(5); // external module node + 2 children + class + property +verify.navigationBar([ + { + "text": "\"my fil\\\"e\"", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export" + }, + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 0 + }, + { + "text": "Bar", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "s", + "kind": "property", + "kindModifiers": "public" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts b/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts index 5429011888..ef4022ce04 100644 --- a/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts +++ b/tests/cases/fourslash/navigationBarItemsItemsModuleVariables.ts @@ -19,12 +19,56 @@ //// export var z = 0; ////} goTo.marker("file1"); -verify.navigationBarContains("Module1", "module"); -verify.navigationBarContains("x", "var"); // nothing else should show up -verify.navigationBarCount(4); // , its child, Module1, its child +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "Module1", + "kind": "module" + } + ], + "indent": 0 + }, + { + "text": "Module1", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 1 + } +]); goTo.marker("file2"); -verify.navigationBarContains("Module1.SubModule", "module"); -verify.navigationBarContains("y", "var"); -verify.navigationBarCount(4); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "Module1.SubModule", + "kind": "module" + } + ], + "indent": 0 + }, + { + "text": "Module1.SubModule", + "kind": "module", + "childItems": [ + { + "text": "y", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsMissingName1.ts b/tests/cases/fourslash/navigationBarItemsMissingName1.ts index 59f2911f3a..4738cc4506 100644 --- a/tests/cases/fourslash/navigationBarItemsMissingName1.ts +++ b/tests/cases/fourslash/navigationBarItemsMissingName1.ts @@ -1,16 +1,29 @@ ////export function -/////** -//// * This is a class. -//// */ -////{| "itemName": "C", "kind": "class", "parentName": "\"navigationBarItemsMissingName1\"" |} class C { -//// {| "itemName": "foo", "kind": "method" |} foo() { -//// } +////class C { +//// foo() {} ////} - -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -/// Root + 1 child, class + 1 child -verify.navigationBarCount(4); +verify.navigationBar([ + { + "text": "\"navigationBarItemsMissingName1\"", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "C", + "kind": "class", + "childItems": [ + { + "text": "foo", + "kind": "method" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsMissingName2.ts b/tests/cases/fourslash/navigationBarItemsMissingName2.ts index d26aa0b553..f4a37cf115 100644 --- a/tests/cases/fourslash/navigationBarItemsMissingName2.ts +++ b/tests/cases/fourslash/navigationBarItemsMissingName2.ts @@ -2,10 +2,26 @@ //// * This is a class. //// */ ////class /* But it has no name! */ { -//// foo() { -//// } +//// foo() {} ////} - -// The class is unnamed, so its method is not included either. -verify.navigationBarCount(2); +// Anonymous classes are still included. +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [], + "indent": 0 + }, + { + "text": "default", + "kind": "class", + "childItems": [ + { + "text": "foo", + "kind": "method" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsModules.ts b/tests/cases/fourslash/navigationBarItemsModules.ts index 237ec8eb27..c3b8aef08e 100644 --- a/tests/cases/fourslash/navigationBarItemsModules.ts +++ b/tests/cases/fourslash/navigationBarItemsModules.ts @@ -1,49 +1,137 @@ /// -////{| "itemName": "\"X.Y.Z\"", "kind": "module", "parentName": "" |} -////declare module "X.Y.Z" { -////} +////declare module "X.Y.Z" {} //// -////{| "itemName": "'X2.Y2.Z2'", "kind": "module", "parentName": "" |} -////declare module 'X2.Y2.Z2' { -////} +////declare module 'X2.Y2.Z2' {} //// -////{| "itemName": "A.B.C", "kind": "module", "parentName": "" |} ////module A.B.C { -//// {| "itemName": "x", "kind": "var", "parentName": "A.B.C" |} //// export var x; ////} //// -////{| "itemName": "A.B", "kind": "module", "parentName": "" |} ////module A.B { -//// {| "itemName": "y", "kind": "var", "parentName": "A.B" |} //// export var y; ////} //// -////{| "itemName": "A", "kind": "module", "parentName": "" |} ////module A { -//// {| "itemName": "z", "kind": "var", "parentName": "A" |} //// export var z; ////} //// -////{| "itemName": "A", "kind": "module", "parentName": "" |} ////module A { -//// {| "itemName": "B", "kind": "module", "parentName": "A" |} //// module B { -//// {| "itemName": "C", "kind": "module", "parentName": "B" |} //// module C { -//// {| "itemName": "x", "kind": "var", "parentName": "C" |} //// declare var x; //// } //// } ////} - -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -/// We have 8 module keywords, and 4 var keywords. -/// The declarations of A.B.C.x do not get merged, so the 4 vars are independent. -/// The two 'A' modules, however, do get merged, so in reality we have 7 modules. -verify.navigationBarCount(19); +//We have 8 module keywords, and 4 var keywords. +//The declarations of A.B.C.x do not get merged, so the 4 vars are independent. +//The two 'A' modules, however, do get merged, so in reality we have 7 modules. +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "A.B.C", + "kind": "module" + }, + { + "text": "A.B", + "kind": "module" + }, + { + "text": "A", + "kind": "module" + }, + { + "text": "\"X.Y.Z\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "'X2.Y2.Z2'", + "kind": "module", + "kindModifiers": "declare" + } + ], + "indent": 0 + }, + { + "text": "A.B.C", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 1 + }, + { + "text": "A.B", + "kind": "module", + "childItems": [ + { + "text": "y", + "kind": "var", + "kindModifiers": "export" + } + ], + "indent": 1 + }, + { + "text": "A", + "kind": "module", + "childItems": [ + { + "text": "z", + "kind": "var", + "kindModifiers": "export" + }, + { + "text": "B", + "kind": "module" + } + ], + "indent": 1 + }, + { + "text": "B", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "module" + } + ], + "indent": 2 + }, + { + "text": "C", + "kind": "module", + "childItems": [ + { + "text": "x", + "kind": "var", + "kindModifiers": "declare" + } + ], + "indent": 3 + }, + { + "text": "\"X.Y.Z\"", + "kind": "module", + "kindModifiers": "declare", + "childItems": [], + "indent": 1 + }, + { + "text": "'X2.Y2.Z2'", + "kind": "module", + "kindModifiers": "declare", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts b/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts index 6bd3d79917..c2e43f5f7b 100644 --- a/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts +++ b/tests/cases/fourslash/navigationBarItemsMultilineStringIdentifiers.ts @@ -1,31 +1,22 @@ -////{| "itemName": "\"Multiline\\r\\nMadness\"", "kind": "module", "parentName": "" |} ////declare module "Multiline\r\nMadness" { ////} //// -////{| "itemName": "\"Multiline\\\nMadness\"", "kind": "module", "parentName": "" |} ////declare module "Multiline\ ////Madness" { ////} -////{| "itemName": "\"MultilineMadness\"", "kind": "module", "parentName": "" |} ////declare module "MultilineMadness" {} //// -////{| "itemName": "Foo", "kind": "interface", "parentName": "" |} ////interface Foo { -//// {| "itemName": "\"a1\\\\\\r\\nb\"", "kind": "property", "parentName": "Foo" |} //// "a1\\\r\nb"; -//// {| "itemName": "\"a2\\\n \\\n b\"", "kind": "method", "parentName": "Foo" |} //// "a2\ //// \ //// b"(): Foo; ////} //// -////{| "itemName": "Bar", "kind": "class", "parentName": "" |} ////class Bar implements Foo { -//// {| "itemName": "'a1\\\\\\r\\nb'", "kind": "property", "parentName": "Bar" |} //// 'a1\\\r\nb': Foo; //// -//// {| "itemName": "'a2\\\n \\\n b'", "kind": "method", "parentName": "Bar" |} //// 'a2\ //// \ //// b'(): Foo { @@ -33,9 +24,86 @@ //// } ////} - -test.markers().forEach((marker) => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(15); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "Bar", + "kind": "class" + }, + { + "text": "Foo", + "kind": "interface" + }, + { + "text": "\"Multiline\\r\\nMadness\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "\"Multiline\\\nMadness\"", + "kind": "module", + "kindModifiers": "declare" + }, + { + "text": "\"MultilineMadness\"", + "kind": "module", + "kindModifiers": "declare" + } + ], + "indent": 0 + }, + { + "text": "Bar", + "kind": "class", + "childItems": [ + { + "text": "'a1\\\\\\r\\nb'", + "kind": "property" + }, + { + "text": "'a2\\\n \\\n b'", + "kind": "method" + } + ], + "indent": 1 + }, + { + "text": "Foo", + "kind": "interface", + "childItems": [ + { + "text": "\"a1\\\\\\r\\nb\"", + "kind": "property" + }, + { + "text": "\"a2\\\n \\\n b\"", + "kind": "method" + } + ], + "indent": 1 + }, + { + "text": "\"Multiline\\r\\nMadness\"", + "kind": "module", + "kindModifiers": "declare", + "childItems": [], + "indent": 1 + }, + { + "text": "\"Multiline\\\nMadness\"", + "kind": "module", + "kindModifiers": "declare", + "childItems": [], + "indent": 1 + }, + { + "text": "\"MultilineMadness\"", + "kind": "module", + "kindModifiers": "declare", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts b/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts index 8e1981f610..d99d3bce9e 100644 --- a/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts +++ b/tests/cases/fourslash/navigationBarItemsPropertiesDefinedInConstructors.ts @@ -6,10 +6,37 @@ //// } ////} -verify.navigationBarContains("List", "class"); -verify.navigationBarContains("constructor", "constructor"); -verify.navigationBarContains("a", "property"); -verify.navigationBarContains("b", "property"); - -// no other items -verify.navigationBarCount(6); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "List", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "List", + "kind": "class", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "a", + "kind": "property", + "kindModifiers": "public" + }, + { + "text": "b", + "kind": "property", + "kindModifiers": "public" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsSymbols1.ts b/tests/cases/fourslash/navigationBarItemsSymbols1.ts index 6d55812fa0..8c565447c1 100644 --- a/tests/cases/fourslash/navigationBarItemsSymbols1.ts +++ b/tests/cases/fourslash/navigationBarItemsSymbols1.ts @@ -1,18 +1,40 @@ /// -////{| "itemName": "C", "kind": "class", "parentName": "" |} ////class C { -//// {| "itemName": "[Symbol.isRegExp]", "kind": "property", "parentName": "C" |} //// [Symbol.isRegExp] = 0; -//// {| "itemName": "[Symbol.iterator]", "kind": "method", "parentName": "C" |} //// [Symbol.iterator]() { } -//// {| "itemName": "[Symbol.isConcatSpreadable]", "kind": "getter", "parentName": "C" |} //// get [Symbol.isConcatSpreadable]() { } ////} -test.markers().forEach(marker => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -// 2 lack markers: and its child -verify.navigationBarCount(2 + test.markers().length); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "C", + "kind": "class" + } + ], + "indent": 0 + }, + { + "text": "C", + "kind": "class", + "childItems": [ + { + "text": "[Symbol.isConcatSpreadable]", + "kind": "getter" + }, + { + "text": "[Symbol.isRegExp]", + "kind": "property" + }, + { + "text": "[Symbol.iterator]", + "kind": "method" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsSymbols2.ts b/tests/cases/fourslash/navigationBarItemsSymbols2.ts index 5c398f77bb..d747b5dada 100644 --- a/tests/cases/fourslash/navigationBarItemsSymbols2.ts +++ b/tests/cases/fourslash/navigationBarItemsSymbols2.ts @@ -1,16 +1,35 @@ /// -////{| "itemName": "I", "kind": "interface", "parentName": "" |} ////interface I { -//// {| "itemName": "[Symbol.isRegExp]", "kind": "property", "parentName": "I" |} //// [Symbol.isRegExp]: string; -//// {| "itemName": "[Symbol.iterator]", "kind": "method", "parentName": "I" |} //// [Symbol.iterator](): string; ////} -test.markers().forEach(marker => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -// 2 are not marked: and its child. -verify.navigationBarCount(2 + test.markers().length); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "I", + "kind": "interface" + } + ], + "indent": 0 + }, + { + "text": "I", + "kind": "interface", + "childItems": [ + { + "text": "[Symbol.isRegExp]", + "kind": "property" + }, + { + "text": "[Symbol.iterator]", + "kind": "method" + } + ], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsSymbols3.ts b/tests/cases/fourslash/navigationBarItemsSymbols3.ts index 23451588ec..29ff9f277a 100644 --- a/tests/cases/fourslash/navigationBarItemsSymbols3.ts +++ b/tests/cases/fourslash/navigationBarItemsSymbols3.ts @@ -1,13 +1,26 @@ /// -////{| "itemName": "E", "kind": "enum", "parentName": "" |} ////enum E { //// // No nav bar entry for this //// [Symbol.isRegExp] = 0 ////} -test.markers().forEach(marker => { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); -}); - -verify.navigationBarCount(3); // and E appearing both toplevel and under \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "E", + "kind": "enum" + } + ], + "indent": 0 + }, + { + "text": "E", + "kind": "enum", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/navigationBarItemsTypeAlias.ts b/tests/cases/fourslash/navigationBarItemsTypeAlias.ts index 5092325653..8a422651bf 100644 --- a/tests/cases/fourslash/navigationBarItemsTypeAlias.ts +++ b/tests/cases/fourslash/navigationBarItemsTypeAlias.ts @@ -2,5 +2,17 @@ ////type T = number | string; -verify.navigationBarCount(1); -verify.navigationBarContains("T", "type"); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [], + "indent": 0 + }, + { + "text": "T", + "kind": "type", + "childItems": [], + "indent": 1 + } +]); diff --git a/tests/cases/fourslash/server/navbar01.ts b/tests/cases/fourslash/server/navbar01.ts index fea424317d..ed8ed2d856 100644 --- a/tests/cases/fourslash/server/navbar01.ts +++ b/tests/cases/fourslash/server/navbar01.ts @@ -1,52 +1,171 @@ /// ////// Interface -////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint { -//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number; -//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint; -//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any; -//// {| "itemName": "[]", "kind": "index", "parentName": "IPoint" |}[x:string]: number; -//// {| "itemName": "prop", "kind": "property", "parentName": "IPoint" |}prop: string; +////interface IPoint { +//// getDist(): number; +//// new(): IPoint; +//// (): any; +//// [x:string]: number; +//// prop: string; ////} //// /////// Module -////{| "itemName": "Shapes", "kind": "module", "parentName": "" |}module Shapes { -//// +////module Shapes { //// // Class -//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint { -//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Point" |}constructor (public x: number, public y: number) { } +//// export class Point implements IPoint { +//// constructor (public x: number, public y: number) { } //// //// // Instance member -//// {| "itemName": "getDist", "kind": "method", "parentName": "Point" |}getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } +//// getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } //// //// // Getter -//// {| "itemName": "value", "kind": "getter", "parentName": "Point" |}get value(): number { return 0; } +//// get value(): number { return 0; } //// //// // Setter -//// {| "itemName": "value", "kind": "setter", "parentName": "Point" |}set value(newValue: number) { return; } +//// set value(newValue: number) { return; } //// //// // Static member -//// {| "itemName": "origin", "kind": "property", "parentName": "Point" |}static origin = new Point(0, 0); +//// static origin = new Point(0, 0); //// //// // Static method -//// {| "itemName": "getOrigin", "kind": "method", "parentName": "Point" |}private static getOrigin() { return Point.origin;} +//// private static getOrigin() { return Point.origin;} //// } //// -//// {| "itemName": "Values", "kind": "enum", "parentName": "Shapes" |}enum Values { -//// value1, -//// {| "itemName": "value2", "kind": "property", "parentName": "Values" |}value2, -//// value3, -//// } +//// enum Values { value1, value2, value3 } ////} //// ////// Local variables -////{| "itemName": "p", "kind": "var", "parentName": "" |}var p: IPoint = new Shapes.Point(3, 4); -////{| "itemName": "dist", "kind": "var", "parentName": "" |}var dist = p.getDist(); +////var p: IPoint = new Shapes.Point(3, 4); +////var dist = p.getDist(); -test.markers().forEach((marker) => { - if (marker.data) { - verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName); +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "dist", + "kind": "var" + }, + { + "text": "IPoint", + "kind": "interface" + }, + { + "text": "p", + "kind": "var" + }, + { + "text": "Shapes", + "kind": "module" + } + ], + "indent": 0 + }, + { + "text": "IPoint", + "kind": "interface", + "childItems": [ + { + "text": "()", + "kind": "call" + }, + { + "text": "new()", + "kind": "construct" + }, + { + "text": "[]", + "kind": "index" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "prop", + "kind": "property" + } + ], + "indent": 0 + }, + { + "text": "Shapes", + "kind": "module", + "childItems": [ + { + "text": "Point", + "kind": "class", + "kindModifiers": "export" + }, + { + "text": "Values", + "kind": "enum" + } + ], + "indent": 0 + }, + { + "text": "Point", + "kind": "class", + "kindModifiers": "export", + "childItems": [ + { + "text": "constructor", + "kind": "constructor" + }, + { + "text": "getDist", + "kind": "method" + }, + { + "text": "getOrigin", + "kind": "method", + "kindModifiers": "private,static" + }, + { + "text": "origin", + "kind": "property", + "kindModifiers": "static" + }, + { + "text": "value", + "kind": "getter" + }, + { + "text": "value", + "kind": "setter" + }, + { + "text": "x", + "kind": "property", + "kindModifiers": "public" + }, + { + "text": "y", + "kind": "property", + "kindModifiers": "public" + } + ], + "indent": 0 + }, + { + "text": "Values", + "kind": "enum", + "childItems": [ + { + "text": "value1", + "kind": "property" + }, + { + "text": "value2", + "kind": "property" + }, + { + "text": "value3", + "kind": "property" + } + ], + "indent": 0 } -}); - -verify.navigationBarCount(27); +]); diff --git a/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts b/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts index a2cdb80bae..fe852e03a2 100644 --- a/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts +++ b/tests/cases/fourslash/shims-pp/getNavigationBarItems.ts @@ -2,12 +2,16 @@ //// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0; -test.markers().forEach(marker => { - verify.navigationBarContains( - marker.data.itemName, - marker.data.kind, - marker.fileName, - marker.data.parentName, - marker.data.isAdditionalRange, - marker.position); -}); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "c", + "kind": "const" + } + ], + "indent": 0 + } +]); diff --git a/tests/cases/fourslash/shims/getNavigationBarItems.ts b/tests/cases/fourslash/shims/getNavigationBarItems.ts index a2cdb80bae..fe852e03a2 100644 --- a/tests/cases/fourslash/shims/getNavigationBarItems.ts +++ b/tests/cases/fourslash/shims/getNavigationBarItems.ts @@ -2,12 +2,16 @@ //// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0; -test.markers().forEach(marker => { - verify.navigationBarContains( - marker.data.itemName, - marker.data.kind, - marker.fileName, - marker.data.parentName, - marker.data.isAdditionalRange, - marker.position); -}); \ No newline at end of file +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "c", + "kind": "const" + } + ], + "indent": 0 + } +]);