mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Merge pull request #9220 from Microsoft/navbar_refactor_3000
Refactor navigation bar
This commit is contained in:
commit
4d5d152788
@ -138,6 +138,17 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function filterMutate<T>(array: T[], f: (x: T) => boolean): void {
|
||||
let outIndex = 0;
|
||||
for (const item of array) {
|
||||
if (f(item)) {
|
||||
array[outIndex] = item;
|
||||
outIndex++;
|
||||
}
|
||||
}
|
||||
array.length = outIndex;
|
||||
}
|
||||
|
||||
export function map<T, U>(array: T[], f: (x: T) => U): U[] {
|
||||
let result: U[];
|
||||
if (array) {
|
||||
|
||||
@ -45,8 +45,9 @@ namespace ts.server {
|
||||
return lineMap;
|
||||
}
|
||||
|
||||
private lineOffsetToPosition(fileName: string, lineOffset: protocol.Location): number {
|
||||
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineOffset.line - 1, lineOffset.offset - 1);
|
||||
private lineOffsetToPosition(fileName: string, lineOffset: protocol.Location, lineMap?: number[]): number {
|
||||
lineMap = lineMap || this.getLineMap(fileName);
|
||||
return ts.computePositionOfLineAndCharacter(lineMap, lineOffset.line - 1, lineOffset.offset - 1);
|
||||
}
|
||||
|
||||
private positionToOneBasedLineOffset(fileName: string, position: number): protocol.Location {
|
||||
@ -449,7 +450,7 @@ namespace ts.server {
|
||||
return this.lastRenameEntry.locations;
|
||||
}
|
||||
|
||||
decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string): NavigationBarItem[] {
|
||||
decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] {
|
||||
if (!items) {
|
||||
return [];
|
||||
}
|
||||
@ -458,8 +459,11 @@ namespace ts.server {
|
||||
text: item.text,
|
||||
kind: item.kind,
|
||||
kindModifiers: item.kindModifiers || "",
|
||||
spans: item.spans.map(span => createTextSpanFromBounds(this.lineOffsetToPosition(fileName, span.start), this.lineOffsetToPosition(fileName, span.end))),
|
||||
childItems: this.decodeNavigationBarItems(item.childItems, fileName),
|
||||
spans: item.spans.map(span =>
|
||||
createTextSpanFromBounds(
|
||||
this.lineOffsetToPosition(fileName, span.start, lineMap),
|
||||
this.lineOffsetToPosition(fileName, span.end, lineMap))),
|
||||
childItems: this.decodeNavigationBarItems(item.childItems, fileName, lineMap),
|
||||
indent: item.indent,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
@ -474,7 +478,8 @@ namespace ts.server {
|
||||
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
|
||||
const response = this.processResponse<protocol.NavBarResponse>(request);
|
||||
|
||||
return this.decodeNavigationBarItems(response.body, fileName);
|
||||
const lineMap = this.getLineMap(fileName);
|
||||
return this.decodeNavigationBarItems(response.body, fileName, lineMap);
|
||||
}
|
||||
|
||||
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
|
||||
|
||||
@ -359,12 +359,16 @@ namespace ts.server {
|
||||
* @param line 1-based index
|
||||
* @param offset 1-based index
|
||||
*/
|
||||
positionToLineOffset(filename: string, position: number): ILineInfo {
|
||||
positionToLineOffset(filename: string, position: number, lineIndex?: LineIndex): ILineInfo {
|
||||
lineIndex = lineIndex || this.getLineIndex(filename);
|
||||
const lineOffset = lineIndex.charOffsetToLineNumberAndPos(position);
|
||||
return { line: lineOffset.line, offset: lineOffset.offset + 1 };
|
||||
}
|
||||
|
||||
getLineIndex(filename: string): LineIndex {
|
||||
const path = toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName);
|
||||
const script: ScriptInfo = this.filenameToScript.get(path);
|
||||
const index = script.snap().index;
|
||||
const lineOffset = index.charOffsetToLineNumberAndPos(position);
|
||||
return { line: lineOffset.line, offset: lineOffset.offset + 1 };
|
||||
return script.snap().index;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1452,7 +1456,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
// if the project is too large, the root files might not have been all loaded if the total
|
||||
// program size reached the upper limit. In that case project.projectOptions.files should
|
||||
// program size reached the upper limit. In that case project.projectOptions.files should
|
||||
// be more precise. However this would only happen for configured project.
|
||||
const oldFileNames = project.projectOptions ? project.projectOptions.files : project.compilerService.host.roots.map(info => info.fileName);
|
||||
const newFileNames = ts.filter(projectOptions.files, f => this.host.fileExists(f));
|
||||
|
||||
@ -863,7 +863,7 @@ namespace ts.server {
|
||||
this.projectService.closeClientFile(file);
|
||||
}
|
||||
|
||||
private decorateNavigationBarItem(project: Project, fileName: string, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] {
|
||||
private decorateNavigationBarItem(project: Project, fileName: string, items: ts.NavigationBarItem[], lineIndex: LineIndex): protocol.NavigationBarItem[] {
|
||||
if (!items) {
|
||||
return undefined;
|
||||
}
|
||||
@ -875,10 +875,10 @@ namespace ts.server {
|
||||
kind: item.kind,
|
||||
kindModifiers: item.kindModifiers,
|
||||
spans: item.spans.map(span => ({
|
||||
start: compilerService.host.positionToLineOffset(fileName, span.start),
|
||||
end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span))
|
||||
start: compilerService.host.positionToLineOffset(fileName, span.start, lineIndex),
|
||||
end: compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(span), lineIndex)
|
||||
})),
|
||||
childItems: this.decorateNavigationBarItem(project, fileName, item.childItems),
|
||||
childItems: this.decorateNavigationBarItem(project, fileName, item.childItems, lineIndex),
|
||||
indent: item.indent
|
||||
}));
|
||||
}
|
||||
@ -896,7 +896,7 @@ namespace ts.server {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return this.decorateNavigationBarItem(project, fileName, items);
|
||||
return this.decorateNavigationBarItem(project, fileName, items, compilerService.host.getLineIndex(fileName));
|
||||
}
|
||||
|
||||
private getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -7047,7 +7047,7 @@ namespace ts {
|
||||
function getNavigationBarItems(fileName: string): NavigationBarItem[] {
|
||||
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
|
||||
return NavigationBar.getNavigationBarItems(sourceFile, host.getCompilationSettings());
|
||||
return NavigationBar.getNavigationBarItems(sourceFile);
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// declare module Windows {
|
||||
//// export module Foundation {
|
||||
//// export var B;
|
||||
@ -16,13 +16,13 @@
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// class ABC {
|
||||
//// public foo() {
|
||||
//// return 3;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// module ABC {
|
||||
//// export var x = 3;
|
||||
//// }
|
||||
@ -95,13 +95,13 @@ verify.navigationBar([
|
||||
"kindModifiers": "export,declare"
|
||||
},
|
||||
{
|
||||
"text": "Test",
|
||||
"kind": "class",
|
||||
"text": "B",
|
||||
"kind": "var",
|
||||
"kindModifiers": "export,declare"
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "var",
|
||||
"text": "Test",
|
||||
"kind": "class",
|
||||
"kindModifiers": "export,declare"
|
||||
},
|
||||
{
|
||||
|
||||
@ -16,7 +16,14 @@ goTo.file("a.ts");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "\"a\"",
|
||||
"kind": "module"
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "default",
|
||||
"kind": "class",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "default",
|
||||
@ -52,6 +59,13 @@ verify.navigationBar([
|
||||
{
|
||||
"text": "\"c\"",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "default",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "default",
|
||||
|
||||
@ -0,0 +1,147 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////global.cls = class { };
|
||||
////(function() {
|
||||
//// const x = () => {
|
||||
//// // Presence of inner function causes x to be a top-level function.
|
||||
//// function xx() {}
|
||||
//// };
|
||||
//// const y = {
|
||||
//// // This is not a top-level function (contains nothing, but shows up in childItems of its parent.)
|
||||
//// foo: function() {}
|
||||
//// };
|
||||
//// (function nest() {
|
||||
//// function moreNest() {}
|
||||
//// })();
|
||||
////})();
|
||||
////(function() { // Different anonymous functions are not merged
|
||||
//// // These will only show up as childItems.
|
||||
//// function z() {}
|
||||
//// console.log(function() {})
|
||||
////})
|
||||
////(function classes() {
|
||||
//// // Classes show up in top-level regardless of whether they have names or inner declarations.
|
||||
//// const cls2 = class { };
|
||||
//// console.log(class cls3 {});
|
||||
//// (class { });
|
||||
////})
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "classes",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "global.cls",
|
||||
"kind": "class"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "nest",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "y",
|
||||
"kind": "const"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "nest",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "moreNest",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "xx",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "z",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "classes",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<class>",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "cls2",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "cls3",
|
||||
"kind": "class"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "<class>",
|
||||
"kind": "class",
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "cls2",
|
||||
"kind": "class",
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "cls3",
|
||||
"kind": "class",
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"text": "global.cls",
|
||||
"kind": "class",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
@ -0,0 +1,64 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////console.log(console.log(class Y {}, class X {}), console.log(class B {}, class A {}));
|
||||
////console.log(class Cls { meth() {} });
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "Cls",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "X",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "Y",
|
||||
"kind": "class"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "class",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "class",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "Cls",
|
||||
"kind": "class",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "meth",
|
||||
"kind": "method"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "X",
|
||||
"kind": "class",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "Y",
|
||||
"kind": "class",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
48
tests/cases/fourslash/navigationBarGetterAndSetter.ts
Normal file
48
tests/cases/fourslash/navigationBarGetterAndSetter.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////class X {
|
||||
//// get x() {}
|
||||
//// set x(value) {
|
||||
//// // Inner declaration should make the setter top-level.
|
||||
//// function f() {}
|
||||
//// }
|
||||
////}
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "X",
|
||||
"kind": "class"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "X",
|
||||
"kind": "class",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "getter"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "setter"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "setter",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
}
|
||||
]);
|
||||
30
tests/cases/fourslash/navigationBarImports.ts
Normal file
30
tests/cases/fourslash/navigationBarImports.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////import a, {b} from "m";
|
||||
////import c = require("m");
|
||||
////import * as d from "m";
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "\"navigationBarImports\"",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "alias"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "alias"
|
||||
},
|
||||
{
|
||||
"text": "c",
|
||||
"kind": "alias"
|
||||
},
|
||||
{
|
||||
"text": "d",
|
||||
"kind": "alias"
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
@ -32,6 +32,12 @@ verify.navigationBar([
|
||||
{
|
||||
"text": "baz",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "v",
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
@ -41,6 +47,10 @@ verify.navigationBar([
|
||||
{
|
||||
"text": "bar",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
@ -52,6 +62,10 @@ verify.navigationBar([
|
||||
{
|
||||
"text": "biz",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "y",
|
||||
"kind": "var"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
|
||||
@ -18,6 +18,12 @@ verify.navigationBar([
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
@ -10,6 +10,10 @@ verify.navigationBar([
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "function"
|
||||
@ -19,6 +23,12 @@ verify.navigationBar([
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "function",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
@ -76,17 +76,17 @@ verify.navigationBar([
|
||||
"kind": "property"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
"indent": 3
|
||||
},
|
||||
{
|
||||
"text": "LocalFunctionInConstructor",
|
||||
"kind": "function",
|
||||
"indent": 2
|
||||
"indent": 3
|
||||
},
|
||||
{
|
||||
"text": "LocalInterfaceInConstrcutor",
|
||||
"kind": "interface",
|
||||
"indent": 2
|
||||
"indent": 3
|
||||
},
|
||||
{
|
||||
"text": "method",
|
||||
@ -116,7 +116,7 @@ verify.navigationBar([
|
||||
"kind": "property"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
"indent": 3
|
||||
},
|
||||
{
|
||||
"text": "LocalFunctionInMethod",
|
||||
@ -127,11 +127,11 @@ verify.navigationBar([
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
"indent": 3
|
||||
},
|
||||
{
|
||||
"text": "LocalInterfaceInMethod",
|
||||
"kind": "interface",
|
||||
"indent": 2
|
||||
"indent": 3
|
||||
}
|
||||
]);
|
||||
|
||||
@ -12,6 +12,11 @@ verify.navigationBar([
|
||||
"text": "\"navigationBarItemsItems2\"",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<class>",
|
||||
"kind": "class",
|
||||
"kindModifiers": "export"
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "module"
|
||||
@ -19,7 +24,7 @@ verify.navigationBar([
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "default",
|
||||
"text": "<class>",
|
||||
"kind": "class",
|
||||
"kindModifiers": "export",
|
||||
"indent": 1
|
||||
|
||||
@ -1,80 +0,0 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_0.ts
|
||||
/////*file1*/
|
||||
////(function() {
|
||||
//// // this should not be included
|
||||
//// var x = 0;
|
||||
////
|
||||
//// // this should not be included either
|
||||
//// function foo() {
|
||||
////
|
||||
//// }
|
||||
////})();
|
||||
////
|
||||
// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_1.ts
|
||||
/////*file2*/
|
||||
////var x = function() {
|
||||
//// // this should not be included
|
||||
//// var x = 0;
|
||||
////
|
||||
//// // this should not be included either
|
||||
//// function foo() {
|
||||
////};
|
||||
////
|
||||
// @Filename: scriptLexicalStructureItemsContainsNoAnonymouseFunctions_2.ts
|
||||
////// Named functions should still show up
|
||||
/////*file3*/
|
||||
////function foo() {
|
||||
////}
|
||||
////function bar() {
|
||||
////}
|
||||
|
||||
goTo.marker("file1");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module"
|
||||
}
|
||||
]);
|
||||
|
||||
goTo.marker("file2");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "var"
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
goTo.marker("file3");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "bar",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "function"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "bar",
|
||||
"kind": "function",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "function",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
@ -8,6 +8,11 @@ verify.navigationBar([
|
||||
"text": "\"navigationBarItemsMissingName1\"",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<function>",
|
||||
"kind": "function",
|
||||
"kindModifiers": "export"
|
||||
},
|
||||
{
|
||||
"text": "C",
|
||||
"kind": "class"
|
||||
|
||||
@ -9,10 +9,16 @@
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module"
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "<class>",
|
||||
"kind": "class"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "default",
|
||||
"text": "<class>",
|
||||
"kind": "class",
|
||||
"childItems": [
|
||||
{
|
||||
|
||||
@ -28,107 +28,107 @@
|
||||
//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": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "A.B.C",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "A.B",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "\"X.Y.Z\"",
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
},
|
||||
{
|
||||
"childItems": [
|
||||
{
|
||||
"text": "'X2.Y2.Z2'",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
},
|
||||
{
|
||||
"text": "\"X.Y.Z\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "A.B",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "A.B.C",
|
||||
"kind": "module"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "'X2.Y2.Z2'",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "\"X.Y.Z\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "z",
|
||||
"kind": "var",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "module"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "B",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "C",
|
||||
"kind": "module"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "'X2.Y2.Z2'",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
}
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "var",
|
||||
"kindModifiers": "declare"
|
||||
}
|
||||
],
|
||||
"indent": 3
|
||||
},
|
||||
{
|
||||
"text": "A.B",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "y",
|
||||
"kind": "var",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "A.B.C",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "var",
|
||||
"kindModifiers": "export"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
@ -30,12 +30,9 @@ verify.navigationBar([
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "Bar",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "Foo",
|
||||
"kind": "interface"
|
||||
"text": "\"Multiline\\\nMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
},
|
||||
{
|
||||
"text": "\"Multiline\\r\\nMadness\"",
|
||||
@ -43,17 +40,38 @@ verify.navigationBar([
|
||||
"kindModifiers": "declare"
|
||||
},
|
||||
{
|
||||
"text": "\"Multiline\\\nMadness\"",
|
||||
"text": "\"MultilineMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
},
|
||||
{
|
||||
"text": "\"MultilineMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare"
|
||||
"text": "Bar",
|
||||
"kind": "class"
|
||||
},
|
||||
{
|
||||
"text": "Foo",
|
||||
"kind": "interface"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "\"Multiline\\\nMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "\"Multiline\\r\\nMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "\"MultilineMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "Bar",
|
||||
"kind": "class",
|
||||
@ -83,23 +101,5 @@ verify.navigationBar([
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "\"Multiline\\r\\nMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "\"Multiline\\\nMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "\"MultilineMadness\"",
|
||||
"kind": "module",
|
||||
"kindModifiers": "declare",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
@ -6,16 +6,32 @@
|
||||
////const x = 0;
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "NumberLike",
|
||||
"kind": "type"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "const"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "type"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "NumberLike",
|
||||
"kind": "type"
|
||||
"kind": "type",
|
||||
"indent": 1,
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "type"
|
||||
},
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "var"
|
||||
"kind": "type",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
189
tests/cases/fourslash/navigationBarMerging.ts
Normal file
189
tests/cases/fourslash/navigationBarMerging.ts
Normal file
@ -0,0 +1,189 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
////module a {
|
||||
//// function foo() {}
|
||||
////}
|
||||
////module b {
|
||||
//// function foo() {}
|
||||
////}
|
||||
////module a {
|
||||
//// function bar() {}
|
||||
////}
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "module"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "bar",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "function"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
// Does not merge unlike declarations.
|
||||
// @Filename: file2.ts
|
||||
////module a {}
|
||||
////function a() {}
|
||||
|
||||
goTo.file("file2.ts");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "module"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "function",
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "module",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
|
||||
// Merges recursively
|
||||
// @Filename: file3.ts
|
||||
////module a {
|
||||
//// interface A {
|
||||
//// foo: number;
|
||||
//// }
|
||||
////}
|
||||
////module a {
|
||||
//// interface A {
|
||||
//// bar: number;
|
||||
//// }
|
||||
////}
|
||||
|
||||
goTo.file("file3.ts");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "module"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "interface"
|
||||
}
|
||||
],
|
||||
"indent": 1
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "interface",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "bar",
|
||||
"kind": "property"
|
||||
},
|
||||
{
|
||||
"text": "foo",
|
||||
"kind": "property"
|
||||
}
|
||||
],
|
||||
"indent": 2
|
||||
}
|
||||
]);
|
||||
|
||||
// Does not merge 'module A' with 'module A.B'
|
||||
|
||||
// @Filename: file4.ts
|
||||
////module A { export var x; }
|
||||
////module A.B { export var y; }
|
||||
|
||||
goTo.file("file4.ts");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "A",
|
||||
"kind": "module"
|
||||
},
|
||||
{
|
||||
"text": "A.B",
|
||||
"kind": "module"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "A",
|
||||
"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
|
||||
}
|
||||
]);
|
||||
53
tests/cases/fourslash/navigationBarVariables.ts
Normal file
53
tests/cases/fourslash/navigationBarVariables.ts
Normal file
@ -0,0 +1,53 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////var x = 0;
|
||||
////let y = 1;
|
||||
////const z = 2;
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "x",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "y",
|
||||
"kind": "let"
|
||||
},
|
||||
{
|
||||
"text": "z",
|
||||
"kind": "const"
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
||||
// @Filename: file2.ts
|
||||
////var {a} = 0;
|
||||
////let {a: b} = 0;
|
||||
////const [c] = 0;
|
||||
|
||||
goTo.file("file2.ts");
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "let"
|
||||
},
|
||||
{
|
||||
"text": "c",
|
||||
"kind": "const"
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
@ -11,20 +11,36 @@
|
||||
//// var numberLike;
|
||||
|
||||
verify.navigationBar([
|
||||
{
|
||||
"text": "NumberLike",
|
||||
"kind": "type"
|
||||
},
|
||||
{
|
||||
"text": "NumberLike2",
|
||||
"kind": "type"
|
||||
},
|
||||
{
|
||||
"text": "NumberLike2",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "numberLike",
|
||||
"kind": "var"
|
||||
}
|
||||
{
|
||||
"text": "<global>",
|
||||
"kind": "module",
|
||||
"childItems": [
|
||||
{
|
||||
"text": "numberLike",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "NumberLike",
|
||||
"kind": "type"
|
||||
},
|
||||
{
|
||||
"text": "NumberLike2",
|
||||
"kind": "var"
|
||||
},
|
||||
{
|
||||
"text": "NumberLike2",
|
||||
"kind": "type"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"text": "NumberLike",
|
||||
"kind": "type",
|
||||
"indent": 1,
|
||||
},
|
||||
{
|
||||
"text": "NumberLike2",
|
||||
"kind": "type",
|
||||
"indent": 1
|
||||
}
|
||||
]);
|
||||
Loading…
x
Reference in New Issue
Block a user