diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index c8e1d679bf..ec18c25113 100644 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -94,6 +94,11 @@ function parseFileContent(filename: string, content: string): GoTest | undefined goTest.commands.push(...result); } } + if (goTest.commands.length === 0) { + console.error(`No commands parsed in file: ${filename}`); + unparsedFiles.push(filename); + return undefined; + } return goTest; } @@ -237,6 +242,10 @@ function parseFourslashStatement(statement: ts.Statement): Cmd[] | undefined { case "outliningSpansInCurrentFile": case "outliningHintSpansInCurrentFile": return parseOutliningSpansArgs(callExpression.arguments); + case "navigationTree": + return parseVerifyNavTree(callExpression.arguments); + case "navigationBar": + return []; // Deprecated. } } // `goTo....` @@ -2273,6 +2282,13 @@ function parseVerifyNavigateToArg(arg: ts.Expression): string | undefined { }`; } +function parseVerifyNavTree(args: readonly ts.Expression[]): [VerifyNavTreeCmd] | undefined { + // Ignore arguments and use baseline tests intead. + return [{ + kind: "verifyNavigationTree", + }]; +} + function parseNavToItem(arg: ts.Expression): string | undefined { let item = getNodeOfKind(arg, ts.isObjectLiteralExpression); if (!item) { @@ -2348,11 +2364,15 @@ function getSymbolKind(kind: ts.Expression): string | undefined { console.error(`Expected string literal for symbol kind, got ${kind.getText()}`); return undefined; } - switch (result.text) { + return getSymbolKindWorker(result.text); +} + +function getSymbolKindWorker(kind: string): string { + switch (kind) { case "script": return "SymbolKindFile"; case "module": - return "SymbolKindModule"; + return "SymbolKindNamespace"; case "class": case "local class": return "SymbolKindClass"; @@ -2400,6 +2420,8 @@ function getSymbolKind(kind: ts.Expression): string | undefined { return "SymbolKindModule"; case "string": return "SymbolKindString"; + case "type": + return "SymbolKindClass"; default: return "SymbolKindVariable"; } @@ -2567,6 +2589,10 @@ interface VerifyOutliningSpansCmd { foldingRangeKind?: string; } +interface VerifyNavTreeCmd { + kind: "verifyNavigationTree"; +} + type Cmd = | VerifyCompletionsCmd | VerifyApplyCodeActionFromCompletionCmd @@ -2587,6 +2613,7 @@ type Cmd = | VerifyBaselineRenameCmd | VerifyRenameInfoCmd | VerifyNavToCmd + | VerifyNavTreeCmd | VerifyBaselineInlayHintsCmd | VerifyImportFixAtPositionCmd | VerifyDiagnosticsCmd @@ -2894,6 +2921,8 @@ function generateCmd(cmd: Cmd): string { return generateNoSignatureHelpForTriggerReason(cmd); case "verifyOutliningSpans": return generateVerifyOutliningSpans(cmd); + case "verifyNavigationTree": + return `f.VerifyBaselineDocumentSymbol(t)`; default: let neverCommand: never = cmd; throw new Error(`Unknown command kind: ${neverCommand as Cmd["kind"]}`); diff --git a/internal/fourslash/_scripts/manualTests.txt b/internal/fourslash/_scripts/manualTests.txt index c86bec5d29..5373890ae0 100644 --- a/internal/fourslash/_scripts/manualTests.txt +++ b/internal/fourslash/_scripts/manualTests.txt @@ -2,6 +2,14 @@ completionListInClosedFunction05 completionsAtIncompleteObjectLiteralProperty completionsSelfDeclaring1 completionsWithDeprecatedTag4 +navigationBarFunctionPrototype +navigationBarFunctionPrototype2 +navigationBarFunctionPrototype3 +navigationBarFunctionPrototype4 +navigationBarFunctionPrototypeBroken +navigationBarFunctionPrototypeInterlaced +navigationBarFunctionPrototypeNested +navigationBarJsDoc navigationItemsExactMatch2 navigationItemsSpecialPropertyAssignment navto_excludeLib1 diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index f013bb4752..1e8e488380 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -35,6 +35,7 @@ const ( signatureHelpCmd baselineCommand = "SignatureHelp" smartSelectionCmd baselineCommand = "Smart Selection" codeLensesCmd baselineCommand = "Code Lenses" + documentSymbolsCmd baselineCommand = "Document Symbols" ) type baselineCommand string @@ -71,7 +72,7 @@ func getBaselineFileName(t *testing.T, command baselineCommand) string { func getBaselineExtension(command baselineCommand) string { switch command { - case quickInfoCmd, signatureHelpCmd, smartSelectionCmd, inlayHintsCmd, nonSuggestionDiagnosticsCmd: + case quickInfoCmd, signatureHelpCmd, smartSelectionCmd, inlayHintsCmd, nonSuggestionDiagnosticsCmd, documentSymbolsCmd: return "baseline" case callHierarchyCmd: return "callHierarchy.txt" @@ -472,11 +473,49 @@ func (f *FourslashTest) textOfFile(fileName string) (string, bool) { return f.vfs.ReadFile(fileName) } +type detailKind int + +const ( + detailKindMarker detailKind = iota // /*MARKER*/ + detailKindContextStart // <| + detailKindTextStart // [| + detailKindTextEnd // |] + detailKindContextEnd // |> +) + +func (k detailKind) isEnd() bool { + return k == detailKindContextEnd || k == detailKindTextEnd +} + +func (k detailKind) isStart() bool { + return k == detailKindContextStart || k == detailKindTextStart +} + type baselineDetail struct { pos lsproto.Position positionMarker string span *documentSpan - kind string + kind detailKind +} + +func (d *baselineDetail) getRange() lsproto.Range { + switch d.kind { + case detailKindContextStart: + return *d.span.contextSpan + case detailKindContextEnd: + return *d.span.contextSpan + case detailKindTextStart: + return d.span.textSpan + case detailKindTextEnd: + return d.span.textSpan + case detailKindMarker: + return lsproto.Range{ + Start: d.pos, + End: d.pos, + } + default: + panic("unknown detail kind") + } } func (f *FourslashTest) getBaselineContentForFile( @@ -504,7 +543,7 @@ func (f *FourslashTest) getBaselineContentForFile( pos: span.contextSpan.Start, positionMarker: "<|", span: &span, - kind: "contextStart", + kind: detailKindContextStart, }) // Check if context span starts after text span @@ -519,8 +558,8 @@ func (f *FourslashTest) getBaselineContentForFile( startMarker += options.getLocationData(span) } details = append(details, - &baselineDetail{pos: span.textSpan.Start, positionMarker: startMarker, span: &span, kind: "textStart"}, - &baselineDetail{pos: span.textSpan.End, positionMarker: core.OrElse(options.endMarker, "|]"), span: &span, kind: "textEnd"}, + &baselineDetail{pos: span.textSpan.Start, positionMarker: startMarker, span: &span, kind: detailKindTextStart}, + &baselineDetail{pos: span.textSpan.End, positionMarker: core.OrElse(options.endMarker, "|]"), span: &span, kind: detailKindTextEnd}, ) if span.contextSpan != nil { @@ -528,7 +567,7 @@ func (f *FourslashTest) getBaselineContentForFile( pos: span.contextSpan.End, positionMarker: "|>", span: &span, - kind: "contextEnd", + kind: detailKindContextEnd, }) } @@ -566,37 +605,69 @@ func (f *FourslashTest) getBaselineContentForFile( } } - slices.SortStableFunc(details, func(d1, d2 *baselineDetail) int { - return lsproto.ComparePositions(d1.pos, d2.pos) - }) - // !!! if canDetermineContextIdInline - - textWithContext := newTextWithContext(fileName, content) - - // Our preferred way to write marker is + // Our preferred way to write markers is // /*MARKER*/[| some text |] // [| some /*MARKER*/ text |] // [| some text |]/*MARKER*/ - // Stable sort should handle first two cases but with that marker will be before rangeEnd if locations match - // So we will defer writing marker in this case by checking and finding index of rangeEnd if same - var deferredMarkerIndex *int + slices.SortStableFunc(details, func(d1, d2 *baselineDetail) int { + c := lsproto.ComparePositions(d1.pos, d2.pos) + if c != 0 || d1.kind == detailKindMarker && d2.kind == detailKindMarker { + return c + } - for index, detail := range details { - if detail.span == nil && deferredMarkerIndex == nil { - // If this is marker position and its same as textEnd and/or contextEnd we want to write marker after those - for matchingEndPosIndex := index + 1; matchingEndPosIndex < len(details); matchingEndPosIndex++ { - // Defer after the location if its same as rangeEnd - if details[matchingEndPosIndex].pos == detail.pos && strings.HasSuffix(details[matchingEndPosIndex].kind, "End") { - deferredMarkerIndex = ptrTo(matchingEndPosIndex) - } - // Dont defer further than already determined - break + // /*MARKER*/[| some text |] + if d1.kind == detailKindMarker && d2.kind.isStart() { + return -1 + } + if d2.kind == detailKindMarker && d1.kind.isStart() { + return 1 + } + + // [| some text |]/*MARKER*/ + if d1.kind == detailKindMarker && d2.kind.isEnd() { + return 1 + } + if d2.kind == detailKindMarker && d1.kind.isEnd() { + return -1 + } + + // [||] or <||> + if d1.span == d2.span { + return int(d1.kind - d2.kind) + } + + // ...|><|... + if d1.kind.isStart() && d2.kind.isEnd() { + return 1 + } + if d1.kind.isEnd() && d2.kind.isStart() { + return -1 + } + + // <| ... [| ... |]|> + if d1.kind.isEnd() && d2.kind.isEnd() { + c := lsproto.ComparePositions(d2.getRange().Start, d1.getRange().Start) + if c != 0 { + return c } - // Defer writing marker position to deffered marker index - if deferredMarkerIndex != nil { - continue + return int(d1.kind - d2.kind) + } + + // <|[| ... |] ... |> + if d1.kind.isStart() && d2.kind.isStart() { + c := lsproto.ComparePositions(d2.getRange().End, d2.getRange().End) + if c != 0 { + return c } + return int(d1.kind - d2.kind) } + + return 0 + }) + // !!! if canDetermineContextIdInline + + textWithContext := newTextWithContext(fileName, content) + for index, detail := range details { textWithContext.add(detail) textWithContext.pos = detail.pos // Prefix @@ -607,13 +678,13 @@ func (f *FourslashTest) getBaselineContentForFile( textWithContext.newContent.WriteString(detail.positionMarker) if detail.span != nil { switch detail.kind { - case "textStart": + case detailKindTextStart: var text string if contextId, ok := spanToContextId[*detail.span]; ok { isAfterContextStart := false for textStartIndex := index - 1; textStartIndex >= 0; textStartIndex-- { textStartDetail := details[textStartIndex] - if textStartDetail.kind == "contextStart" && textStartDetail.span == detail.span { + if textStartDetail.kind == detailKindContextStart && textStartDetail.span == detail.span { isAfterContextStart = true break } @@ -634,18 +705,11 @@ func (f *FourslashTest) getBaselineContentForFile( if text != "" { textWithContext.newContent.WriteString(`{ ` + text + ` |}`) } - case "contextStart": + case detailKindContextStart: if canDetermineContextIdInline { spanToContextId[*detail.span] = len(spanToContextId) } } - - if deferredMarkerIndex != nil && *deferredMarkerIndex == index { - // Write the marker - textWithContext.newContent.WriteString(options.markerName) - deferredMarkerIndex = nil - detail = details[0] // Marker detail - } } if suffix, ok := detailSuffixes[detail]; ok { textWithContext.newContent.WriteString(suffix) @@ -714,7 +778,7 @@ func (t *textWithContext) add(detail *baselineDetail) { if t.content == "" && detail == nil { panic("Unsupported") } - if detail == nil || (detail.kind != "textEnd" && detail.kind != "contextEnd") { + if detail == nil || (detail.kind != detailKindTextEnd && detail.kind != detailKindContextEnd) { // Calculate pos to location number of lines posLineIndex := t.lineInfo if t.posInfo == nil || *t.posInfo != t.pos { diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index b9e223b88d..43b388cc55 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -167,6 +167,7 @@ func NewFourslash(t *testing.T, capabilities *lsproto.ClientCapabilities, conten testfs[filePath] = vfstest.Symlink(tspath.GetNormalizedAbsolutePath(target, rootDir)) } + // !!! use default compiler options for inferred project as base compilerOptions := &core.CompilerOptions{ SkipDefaultLibCheck: core.TSTrue, } @@ -479,6 +480,19 @@ var ( defaultHoverCapabilities = &lsproto.HoverClientCapabilities{ ContentFormat: &[]lsproto.MarkupKind{lsproto.MarkupKindMarkdown, lsproto.MarkupKindPlainText}, } + defaultSignatureHelpCapabilities = &lsproto.SignatureHelpClientCapabilities{ + SignatureInformation: &lsproto.ClientSignatureInformationOptions{ + DocumentationFormat: &[]lsproto.MarkupKind{lsproto.MarkupKindMarkdown, lsproto.MarkupKindPlainText}, + ParameterInformation: &lsproto.ClientSignatureParameterInformationOptions{ + LabelOffsetSupport: ptrTrue, + }, + ActiveParameterSupport: ptrTrue, + }, + ContextSupport: ptrTrue, + } + defaultDocumentSymbolCapabilities = &lsproto.DocumentSymbolClientCapabilities{ + HierarchicalDocumentSymbolSupport: ptrTrue, + } ) func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lsproto.ClientCapabilities { @@ -536,16 +550,10 @@ func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lspr capabilitiesWithDefaults.TextDocument.Hover = defaultHoverCapabilities } if capabilitiesWithDefaults.TextDocument.SignatureHelp == nil { - capabilitiesWithDefaults.TextDocument.SignatureHelp = &lsproto.SignatureHelpClientCapabilities{ - SignatureInformation: &lsproto.ClientSignatureInformationOptions{ - DocumentationFormat: &[]lsproto.MarkupKind{lsproto.MarkupKindMarkdown, lsproto.MarkupKindPlainText}, - ParameterInformation: &lsproto.ClientSignatureParameterInformationOptions{ - LabelOffsetSupport: ptrTrue, - }, - ActiveParameterSupport: ptrTrue, - }, - ContextSupport: ptrTrue, - } + capabilitiesWithDefaults.TextDocument.SignatureHelp = defaultSignatureHelpCapabilities + } + if capabilitiesWithDefaults.TextDocument.DocumentSymbol == nil { + capabilitiesWithDefaults.TextDocument.DocumentSymbol = defaultDocumentSymbolCapabilities } return &capabilitiesWithDefaults } @@ -2989,7 +2997,7 @@ func (f *FourslashTest) getCurrentPositionPrefix() string { if f.lastKnownMarkerName != nil { return fmt.Sprintf("At marker '%s': ", *f.lastKnownMarkerName) } - return fmt.Sprintf("At position (Ln %d, Col %d): ", f.currentCaretPosition.Line, f.currentCaretPosition.Character) + return fmt.Sprintf("At position %s(Ln %d, Col %d): ", f.activeFilename, f.currentCaretPosition.Line, f.currentCaretPosition.Character) } func (f *FourslashTest) BaselineAutoImportsCompletions(t *testing.T, markerNames []string) { @@ -3665,3 +3673,62 @@ func verifyIncludesSymbols( assertDeepEqual(t, actualSym, sym, fmt.Sprintf("%s: Symbol '%s' at location '%v' mismatch", prefix, sym.Name, sym.Location)) } } + +func (f *FourslashTest) VerifyBaselineDocumentSymbol(t *testing.T) { + params := &lsproto.DocumentSymbolParams{ + TextDocument: lsproto.TextDocumentIdentifier{ + Uri: lsconv.FileNameToDocumentURI(f.activeFilename), + }, + } + result := sendRequest(t, f, lsproto.TextDocumentDocumentSymbolInfo, params) + uri := lsconv.FileNameToDocumentURI(f.activeFilename) + spansToSymbol := make(map[documentSpan]*lsproto.DocumentSymbol) + if result.DocumentSymbols != nil { + for _, symbol := range *result.DocumentSymbols { + collectDocumentSymbolSpans(uri, symbol, spansToSymbol) + } + } + f.addResultToBaseline( + t, + documentSymbolsCmd, + f.getBaselineForSpansWithFileContents(slices.Collect(maps.Keys(spansToSymbol)), baselineFourslashLocationsOptions{ + getLocationData: func(span documentSpan) string { + symbol := spansToSymbol[span] + return fmt.Sprintf("{| name: %s, kind: %s |}", symbol.Name, symbol.Kind.String()) + }, + }), + ) + + var detailsBuilder strings.Builder + if result.DocumentSymbols != nil { + writeDocumentSymbolDetails(*result.DocumentSymbols, 0, &detailsBuilder) + } + f.writeToBaseline(documentSymbolsCmd, "\n\n// === Details ===\n"+detailsBuilder.String()) +} + +func writeDocumentSymbolDetails(symbols []*lsproto.DocumentSymbol, indent int, builder *strings.Builder) { + for _, symbol := range symbols { + fmt.Fprintf(builder, "%s(%s) %s\n", strings.Repeat(" ", indent), symbol.Kind.String(), symbol.Name) + if symbol.Children != nil { + writeDocumentSymbolDetails(*symbol.Children, indent+1, builder) + } + } +} + +func collectDocumentSymbolSpans( + uri lsproto.DocumentUri, + symbol *lsproto.DocumentSymbol, + spansToSymbol map[documentSpan]*lsproto.DocumentSymbol, +) { + span := documentSpan{ + uri: uri, + textSpan: symbol.SelectionRange, + contextSpan: &symbol.Range, + } + spansToSymbol[span] = symbol + if symbol.Children != nil { + for _, child := range *symbol.Children { + collectDocumentSymbolSpans(uri, child, spansToSymbol) + } + } +} diff --git a/internal/fourslash/tests/documentSymbolPrivateName_test.go b/internal/fourslash/tests/documentSymbolPrivateName_test.go new file mode 100644 index 0000000000..c77e828a6f --- /dev/null +++ b/internal/fourslash/tests/documentSymbolPrivateName_test.go @@ -0,0 +1,40 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestDocumentSymbolPrivateName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: first.ts +class A { + #foo() { + class B { + #bar() { + function baz () { + } + } + } + } +} + +class B { + constructor(private prop: string) {} +} + +// @Filename: second.ts +class Foo { + #privateProp: string; +} +` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "second.ts") + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/getNavigationBarItems_test.go b/internal/fourslash/tests/gen/getNavigationBarItems_test.go new file mode 100644 index 0000000000..476da2b5e9 --- /dev/null +++ b/internal/fourslash/tests/gen/getNavigationBarItems_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestGetNavigationBarItems(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + foo; + ["bar"]: string; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/jsdocTypedefTagNavigateTo_test.go b/internal/fourslash/tests/gen/jsdocTypedefTagNavigateTo_test.go new file mode 100644 index 0000000000..8d188f2067 --- /dev/null +++ b/internal/fourslash/tests/gen/jsdocTypedefTagNavigateTo_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestJsdocTypedefTagNavigateTo(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowNonTsExtensions: true +// @Filename: jsDocTypedef_form2.js + +/** @typedef {(string | number)} NumberLike */ +/** @typedef {(string | number | string[])} */ +var NumberLike2; + +/** @type {/*1*/NumberLike} */ +var numberLike;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.MarkTestAsStradaServer() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navbar01_test.go b/internal/fourslash/tests/gen/navbar01_test.go new file mode 100644 index 0000000000..79c365347a --- /dev/null +++ b/internal/fourslash/tests/gen/navbar01_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavbar01(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Interface +interface IPoint { + getDist(): number; + new(): IPoint; + (): any; + [x:string]: number; + prop: string; +} + +/// Module +module Shapes { + // Class + export class Point implements IPoint { + constructor (public x: number, public y: number) { } + + // Instance member + getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } + + // Getter + get value(): number { return 0; } + + // Setter + set value(newValue: number) { return; } + + // Static member + static origin = new Point(0, 0); + + // Static method + private static getOrigin() { return Point.origin;} + } + + enum Values { value1, value2, value3 } +} + +// Local variables +var p: IPoint = new Shapes.Point(3, 4); +var dist = p.getDist();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.MarkTestAsStradaServer() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navbarNestedCommonJsExports_test.go b/internal/fourslash/tests/gen/navbarNestedCommonJsExports_test.go new file mode 100644 index 0000000000..2f125efc33 --- /dev/null +++ b/internal/fourslash/tests/gen/navbarNestedCommonJsExports_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavbarNestedCommonJsExports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: /a.js +exports.a = exports.b = exports.c = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navbar_const_test.go b/internal/fourslash/tests/gen/navbar_const_test.go new file mode 100644 index 0000000000..1a10265003 --- /dev/null +++ b/internal/fourslash/tests/gen/navbar_const_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavbar_const(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const c = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navbar_contains-no-duplicates_test.go b/internal/fourslash/tests/gen/navbar_contains-no-duplicates_test.go new file mode 100644 index 0000000000..741c0a61b2 --- /dev/null +++ b/internal/fourslash/tests/gen/navbar_contains-no-duplicates_test.go @@ -0,0 +1,44 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavbar_contains_no_duplicates(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module Windows { + export module Foundation { + export var A; + export class Test { + public wow(); + } + } +} + +declare module Windows { + export module Foundation { + export var B; + export module Test { + export function Boom(): number; + } + } +} + +class ABC { + public foo() { + return 3; + } +} + +module ABC { + export var x = 3; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navbar_exportDefault_test.go b/internal/fourslash/tests/gen/navbar_exportDefault_test.go new file mode 100644 index 0000000000..7a84339734 --- /dev/null +++ b/internal/fourslash/tests/gen/navbar_exportDefault_test.go @@ -0,0 +1,32 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavbar_exportDefault(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: a.ts +export default class { } +// @Filename: b.ts +export default class C { } +// @Filename: c.ts +export default function { } +// @Filename: d.ts +export default function Func { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToFile(t, "a.ts") + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "b.ts") + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "c.ts") + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "d.ts") + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navbar_let_test.go b/internal/fourslash/tests/gen/navbar_let_test.go new file mode 100644 index 0000000000..67c8b6c467 --- /dev/null +++ b/internal/fourslash/tests/gen/navbar_let_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavbar_let(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `let c = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions2_test.go b/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions2_test.go new file mode 100644 index 0000000000..9148c39776 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarAnonymousClassAndFunctionExpressions2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `console.log(console.log(class Y {}, class X {}), console.log(class B {}, class A {})); +console.log(class Cls { meth() {} });` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions3_test.go b/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions3_test.go new file mode 100644 index 0000000000..23d5445344 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions3_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarAnonymousClassAndFunctionExpressions3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `describe('foo', () => { + test(` + "`" + `a ${1} b ${2}` + "`" + `, () => {}) +}) + +const a = 1; +const b = 2; +describe('foo', () => { + test(` + "`" + `a ${a} b {b}` + "`" + `, () => {}) +})` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions_test.go b/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions_test.go new file mode 100644 index 0000000000..4efee99b64 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarAnonymousClassAndFunctionExpressions_test.go @@ -0,0 +1,44 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarAnonymousClassAndFunctionExpressions(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `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() {}) + describe("this", 'function', ` + "`" + `is a function` + "`" + `, ` + "`" + `with template literal ${"a"}` + "`" + `, () => {}); + [].map(() => {}); +}) +(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 { }); +})` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarAssignmentTypes_test.go b/internal/fourslash/tests/gen/navigationBarAssignmentTypes_test.go new file mode 100644 index 0000000000..6207737485 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarAssignmentTypes_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarAssignmentTypes(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `'use strict' +const a = { + ...b, + c, + d: 0 +};` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarClassStaticBlock_test.go b/internal/fourslash/tests/gen/navigationBarClassStaticBlock_test.go new file mode 100644 index 0000000000..f45966b6a7 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarClassStaticBlock_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarClassStaticBlock(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + static { + let x; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarComputedPropertyName_test.go b/internal/fourslash/tests/gen/navigationBarComputedPropertyName_test.go new file mode 100644 index 0000000000..036db2380c --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarComputedPropertyName_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarComputedPropertyName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function F(key, value) { + return { + [key]: value, + "prop": true + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarFunctionIndirectlyInVariableDeclaration_test.go b/internal/fourslash/tests/gen/navigationBarFunctionIndirectlyInVariableDeclaration_test.go new file mode 100644 index 0000000000..162009df08 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarFunctionIndirectlyInVariableDeclaration_test.go @@ -0,0 +1,29 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionIndirectlyInVariableDeclaration(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var a = { + propA: function() { + var c; + } +}; +var b; +b = { + propB: function() { + // function must not have an empty body to appear top level + var d; + } +};` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarFunctionLikePropertyAssignments_test.go b/internal/fourslash/tests/gen/navigationBarFunctionLikePropertyAssignments_test.go new file mode 100644 index 0000000000..cbabc984e8 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarFunctionLikePropertyAssignments_test.go @@ -0,0 +1,25 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionLikePropertyAssignments(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var functions = { + a: 0, + b: function () { }, + c: function x() { }, + d: () => { }, + e: y(), + f() { } +};` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarGetterAndSetter_test.go b/internal/fourslash/tests/gen/navigationBarGetterAndSetter_test.go new file mode 100644 index 0000000000..577a99b041 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarGetterAndSetter_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarGetterAndSetter(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class X { + get x() {} + set x(value) { + // Inner declaration should make the setter top-level. + function f() {} + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarImports_test.go b/internal/fourslash/tests/gen/navigationBarImports_test.go new file mode 100644 index 0000000000..60044cfea9 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarImports_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarImports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import a, {b} from "m"; +import c = require("m"); +import * as d from "m";` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarInitializerSpans_test.go b/internal/fourslash/tests/gen/navigationBarInitializerSpans_test.go new file mode 100644 index 0000000000..2e489ec61e --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarInitializerSpans_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarInitializerSpans(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// get the name for the navbar from the variable name rather than the function name +const [|[|x|] = () => { var [|a|]; }|]; +const [|[|f|] = function f() { var [|b|]; }|]; +const [|[|y|] = { [|[|z|]: function z() { var [|c|]; }|] }|];` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsBindingPatternsInConstructor_test.go b/internal/fourslash/tests/gen/navigationBarItemsBindingPatternsInConstructor_test.go new file mode 100644 index 0000000000..b1d15f0ec6 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsBindingPatternsInConstructor_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsBindingPatternsInConstructor(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + x: any + constructor([a]: any) { + } +} +class B { + x: any; + constructor( {a} = { a: 1 }) { + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsBindingPatterns_test.go b/internal/fourslash/tests/gen/navigationBarItemsBindingPatterns_test.go new file mode 100644 index 0000000000..12cf8f4f58 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsBindingPatterns_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsBindingPatterns(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `'use strict' +var foo, {} +var bar, [] +let foo1, {a, b} +const bar1, [c, d] +var {e, x: [f, g]} = {a:1, x:[]}; +var { h: i = function j() {} } = obj;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsClass1_test.go b/internal/fourslash/tests/gen/navigationBarItemsClass1_test.go new file mode 100644 index 0000000000..7b896c4ad3 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsClass1_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsClass1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function Foo() {} +class Foo {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsClass2_test.go b/internal/fourslash/tests/gen/navigationBarItemsClass2_test.go new file mode 100644 index 0000000000..377a64a9f6 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsClass2_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsClass2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo {} +function Foo() {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsClass3_test.go b/internal/fourslash/tests/gen/navigationBarItemsClass3_test.go new file mode 100644 index 0000000000..4ccea8df9a --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsClass3_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsClass3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @filename: /foo.js +function Foo() {} +class Foo {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsClass4_test.go b/internal/fourslash/tests/gen/navigationBarItemsClass4_test.go new file mode 100644 index 0000000000..e3a8670a5d --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsClass4_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsClass4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @filename: /foo.js +class Foo {} +function Foo() {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsClass5_test.go b/internal/fourslash/tests/gen/navigationBarItemsClass5_test.go new file mode 100644 index 0000000000..3f8c73c728 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsClass5_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsClass5(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Foo {} +let Foo = 1;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsClass6_test.go b/internal/fourslash/tests/gen/navigationBarItemsClass6_test.go new file mode 100644 index 0000000000..47cf1c6c54 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsClass6_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsClass6(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function Z() { } + +Z.foo = 42 + +class Z { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsComputedNames_test.go b/internal/fourslash/tests/gen/navigationBarItemsComputedNames_test.go new file mode 100644 index 0000000000..5657250e22 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsComputedNames_test.go @@ -0,0 +1,39 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsComputedNames(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `const enum E { + A = 'A', +} +const a = ''; + +class C { + [a]() { + return 1; + } + + [E.A]() { + return 1; + } + + [1]() { + return 1; + }, + + ["foo"]() { + return 1; + }, +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsEmptyConstructors_test.go b/internal/fourslash/tests/gen/navigationBarItemsEmptyConstructors_test.go new file mode 100644 index 0000000000..0fda289592 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsEmptyConstructors_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsEmptyConstructors(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Test { + constructor() { + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsExports_test.go b/internal/fourslash/tests/gen/navigationBarItemsExports_test.go new file mode 100644 index 0000000000..18cb9c0d30 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsExports_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsExports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export { a } from "a"; + +export { b as B } from "a" + +export import e = require("a"); + +export * from "a"; // no bindings here` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsFunctionProperties_test.go b/internal/fourslash/tests/gen/navigationBarItemsFunctionProperties_test.go new file mode 100644 index 0000000000..1ba2084c52 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsFunctionProperties_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsFunctionProperties(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `(function(){ +var A; +A/*1*/ +.a = function() { }; +})();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsFunctionsBroken2_test.go b/internal/fourslash/tests/gen/navigationBarItemsFunctionsBroken2_test.go new file mode 100644 index 0000000000..60087425b6 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsFunctionsBroken2_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsFunctionsBroken2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function; +function f() { + function; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsFunctionsBroken_test.go b/internal/fourslash/tests/gen/navigationBarItemsFunctionsBroken_test.go new file mode 100644 index 0000000000..b16a7e8367 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsFunctionsBroken_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsFunctionsBroken(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f() { + function; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsFunctions_test.go b/internal/fourslash/tests/gen/navigationBarItemsFunctions_test.go new file mode 100644 index 0000000000..0980f4bf65 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsFunctions_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsFunctions(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function foo() { + var x = 10; + function bar() { + var y = 10; + function biz() { + var z = 10; + } + function qux() { + // A function with an empty body should not be top level + } + } +} + +function baz() { + var v = 10; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsImports_test.go b/internal/fourslash/tests/gen/navigationBarItemsImports_test.go new file mode 100644 index 0000000000..dad31f19cb --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsImports_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsImports(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import d1 from "a"; + +import { a } from "a"; + +import { b as B } from "a" + +import d2, { c, d as D } from "a" + +import e = require("a"); + +import * as ns from "a";` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsInsideMethodsAndConstructors_test.go b/internal/fourslash/tests/gen/navigationBarItemsInsideMethodsAndConstructors_test.go new file mode 100644 index 0000000000..2dca7bdc43 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsInsideMethodsAndConstructors_test.go @@ -0,0 +1,34 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsInsideMethodsAndConstructors(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class Class { + constructor() { + function LocalFunctionInConstructor() {} + interface LocalInterfaceInConstrcutor {} + enum LocalEnumInConstructor { LocalEnumMemberInConstructor } + } + + method() { + function LocalFunctionInMethod() { + function LocalFunctionInLocalFunctionInMethod() {} + } + interface LocalInterfaceInMethod {} + enum LocalEnumInMethod { LocalEnumMemberInMethod } + } + + emptyMethod() { } // Non child functions method should not be duplicated +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsItems2_test.go b/internal/fourslash/tests/gen/navigationBarItemsItems2_test.go new file mode 100644 index 0000000000..e3f1cdb822 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsItems2_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsItems2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/**/` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "") + f.InsertLine(t, "module A") + f.Insert(t, "export class ") + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules2_test.go b/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules2_test.go new file mode 100644 index 0000000000..42b9fa0376 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsItemsExternalModules2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: test/file.ts +export class Bar { + public s: string; +} +export var x: number;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules3_test.go b/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules3_test.go new file mode 100644 index 0000000000..83a9ae0d35 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules3_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsItemsExternalModules3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: test/my fil e.ts +export class Bar { + public s: string; +} +export var x: number;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules_test.go b/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules_test.go new file mode 100644 index 0000000000..fc1d90c605 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsItemsExternalModules_test.go @@ -0,0 +1,20 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsItemsExternalModules(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export class Bar { + public s: string; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsItemsModuleVariables_test.go b/internal/fourslash/tests/gen/navigationBarItemsItemsModuleVariables_test.go new file mode 100644 index 0000000000..d3a11fd5c5 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsItemsModuleVariables_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsItemsModuleVariables(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: navigationItemsModuleVariables_0.ts + /*file1*/ +module Module1 { + export var x = 0; +} +// @Filename: navigationItemsModuleVariables_1.ts + /*file2*/ +module Module1.SubModule { + export var y = 0; +} +// @Filename: navigationItemsModuleVariables_2.ts + /*file3*/ +module Module1 { + export var z = 0; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.GoToMarker(t, "file1") + f.VerifyBaselineDocumentSymbol(t) + f.GoToMarker(t, "file2") + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsItems_test.go b/internal/fourslash/tests/gen/navigationBarItemsItems_test.go new file mode 100644 index 0000000000..232c7317f6 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsItems_test.go @@ -0,0 +1,55 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsItems(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Interface +interface IPoint { + getDist(): number; + new(): IPoint; + (): any; + [x:string]: number; + prop: string; +} + +/// Module +module Shapes { + + // Class + export class Point implements IPoint { + constructor (public x: number, public y: number) { } + + // Instance member + getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } + + // Getter + get value(): number { return 0; } + + // Setter + set value(newValue: number) { return; } + + // Static member + static origin = new Point(0, 0); + + // Static method + private static getOrigin() { return Point.origin; } + } + + enum Values { value1, value2, value3 } +} + +// Local variables +var p: IPoint = new Shapes.Point(3, 4); +var dist = p.getDist();` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsMissingName1_test.go b/internal/fourslash/tests/gen/navigationBarItemsMissingName1_test.go new file mode 100644 index 0000000000..9d47714161 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsMissingName1_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsMissingName1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export function +class C { + foo() {} +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsMissingName2_test.go b/internal/fourslash/tests/gen/navigationBarItemsMissingName2_test.go new file mode 100644 index 0000000000..43ace1f216 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsMissingName2_test.go @@ -0,0 +1,23 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsMissingName2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** + * This is a class. + */ +class /* But it has no name! */ { + foo() {} +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsModules1_test.go b/internal/fourslash/tests/gen/navigationBarItemsModules1_test.go new file mode 100644 index 0000000000..140aeafe12 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsModules1_test.go @@ -0,0 +1,42 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsModules1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module "X.Y.Z" {} + +declare module 'X2.Y2.Z2' {} + +declare module "foo"; + +module A.B.C { + export var x; +} + +module A.B { + export var y; +} + +module A { + export var z; +} + +module A { + module B { + module C { + declare var x; + } + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsModules2_test.go b/internal/fourslash/tests/gen/navigationBarItemsModules2_test.go new file mode 100644 index 0000000000..b0456dfc44 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsModules2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsModules2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `namespace Test.A { } + +namespace Test.B { + class Foo { } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers1_test.go b/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers1_test.go new file mode 100644 index 0000000000..c42df06511 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers1_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsMultilineStringIdentifiers1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module "Multiline\r\nMadness" { +} + +declare module "Multiline\ +Madness" { +} +declare module "MultilineMadness" {} + +declare module "Multiline\ +Madness2" { +} + +interface Foo { + "a1\\\r\nb"; + "a2\ + \ + b"(): Foo; +} + +class Bar implements Foo { + 'a1\\\r\nb': Foo; + + 'a2\ + \ + b'(): Foo { + return this; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers2_test.go b/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers2_test.go new file mode 100644 index 0000000000..5ca46e5d1f --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers2_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsMultilineStringIdentifiers2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f(p1: () => any, p2: string) { } +f(() => { }, ` + "`" + `line1\ +line2\ +line3` + "`" + `); + +class c1 { + const a = ' ''line1\ + line2'; +} + +f(() => { }, ` + "`" + `unterminated backtick 1 +unterminated backtick 2 +unterminated backtick 3` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers3_test.go b/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers3_test.go new file mode 100644 index 0000000000..5f1712d0d1 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsMultilineStringIdentifiers3_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsMultilineStringIdentifiers3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `declare module 'MoreThanOneHundredAndFiftyCharacters\ +MoreThanOneHundredAndFiftyCharacters\ +MoreThanOneHundredAndFiftyCharacters\ +MoreThanOneHundredAndFiftyCharacters\ +MoreThanOneHundredAndFiftyCharacters\ +MoreThanOneHundredAndFiftyCharacters\ +MoreThanOneHundredAndFiftyCharacters' { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsNamedArrowFunctions_test.go b/internal/fourslash/tests/gen/navigationBarItemsNamedArrowFunctions_test.go new file mode 100644 index 0000000000..44039a26bc --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsNamedArrowFunctions_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsNamedArrowFunctions(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export const value = 2; +export const func = () => 2; +export const func2 = function() { }; +export function exportedFunction() { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsPropertiesDefinedInConstructors_test.go b/internal/fourslash/tests/gen/navigationBarItemsPropertiesDefinedInConstructors_test.go new file mode 100644 index 0000000000..9d5017df51 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsPropertiesDefinedInConstructors_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsPropertiesDefinedInConstructors(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class List { + constructor(public a: boolean, private b: T, readonly c: string, d: number) { + var local = 0; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsStaticAndNonStaticNoMerge_test.go b/internal/fourslash/tests/gen/navigationBarItemsStaticAndNonStaticNoMerge_test.go new file mode 100644 index 0000000000..2d8477a848 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsStaticAndNonStaticNoMerge_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsStaticAndNonStaticNoMerge(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + static x; + x; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsSymbols1_test.go b/internal/fourslash/tests/gen/navigationBarItemsSymbols1_test.go new file mode 100644 index 0000000000..552a7bf69a --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsSymbols1_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsSymbols1(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class C { + [Symbol.isRegExp] = 0; + [Symbol.iterator]() { } + get [Symbol.isConcatSpreadable]() { } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsSymbols2_test.go b/internal/fourslash/tests/gen/navigationBarItemsSymbols2_test.go new file mode 100644 index 0000000000..185fbda68d --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsSymbols2_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsSymbols2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `interface I { + [Symbol.isRegExp]: string; + [Symbol.iterator](): string; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsSymbols3_test.go b/internal/fourslash/tests/gen/navigationBarItemsSymbols3_test.go new file mode 100644 index 0000000000..60a5c1a7c4 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsSymbols3_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsSymbols3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `enum E { + // No nav bar entry for this + [Symbol.isRegExp] = 0 +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsSymbols4_test.go b/internal/fourslash/tests/gen/navigationBarItemsSymbols4_test.go new file mode 100644 index 0000000000..a56bd9984b --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsSymbols4_test.go @@ -0,0 +1,35 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsSymbols4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @checkJs: true +// @allowJs: true +// @target: es6 +// @Filename: file.js +const _sym = Symbol("_sym"); +class MyClass { + constructor() { + // Dynamic assignment properties can't show up in navigation, + // as they're not syntactic members + // Additonally, late bound members are always filtered out, besides + this[_sym] = "ok"; + } + + method() { + this[_sym] = "yep"; + const x = this[_sym]; + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarItemsTypeAlias_test.go b/internal/fourslash/tests/gen/navigationBarItemsTypeAlias_test.go new file mode 100644 index 0000000000..0de41debd8 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarItemsTypeAlias_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarItemsTypeAlias(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `type T = number | string;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarJsDocCommentWithNoTags_test.go b/internal/fourslash/tests/gen/navigationBarJsDocCommentWithNoTags_test.go new file mode 100644 index 0000000000..83e45aa646 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarJsDocCommentWithNoTags_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarJsDocCommentWithNoTags(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `/** Test */ +export const Test = {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarMerging_grandchildren_test.go b/internal/fourslash/tests/gen/navigationBarMerging_grandchildren_test.go new file mode 100644 index 0000000000..1988fdf4c0 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarMerging_grandchildren_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarMerging_grandchildren(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// Should not merge grandchildren with property assignments +const o = { + a: { + m() {}, + }, + b: { + m() {}, + }, +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarMerging_test.go b/internal/fourslash/tests/gen/navigationBarMerging_test.go new file mode 100644 index 0000000000..0de54ad83b --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarMerging_test.go @@ -0,0 +1,50 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarMerging(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @Filename: file1.ts +module a { + function foo() {} +} +module b { + function foo() {} +} +module a { + function bar() {} +} +// @Filename: file2.ts +module a {} +function a() {} +// @Filename: file3.ts +module a { + interface A { + foo: number; + } +} +module a { + interface A { + bar: number; + } +} +// @Filename: file4.ts +module A { export var x; } +module A.B { export var y; }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "file2.ts") + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "file3.ts") + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "file4.ts") + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarNamespaceImportWithNoName_test.go b/internal/fourslash/tests/gen/navigationBarNamespaceImportWithNoName_test.go new file mode 100644 index 0000000000..dd4469b62a --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarNamespaceImportWithNoName_test.go @@ -0,0 +1,18 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarNamespaceImportWithNoName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `import *{} from 'foo';` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarNestedObjectLiterals_test.go b/internal/fourslash/tests/gen/navigationBarNestedObjectLiterals_test.go new file mode 100644 index 0000000000..e90ebdb6f3 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarNestedObjectLiterals_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarNestedObjectLiterals(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var a = { + b: 0, + c: {}, + d: { + e: 1, + }, + f: { + g: 2, + h: { + i: 3, + }, + }, +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarPrivateNameMethod_test.go b/internal/fourslash/tests/gen/navigationBarPrivateNameMethod_test.go new file mode 100644 index 0000000000..2147d2038b --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarPrivateNameMethod_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarPrivateNameMethod(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + #foo() { + class B { + #bar() { + function baz () { + } + } + } + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarPrivateName_test.go b/internal/fourslash/tests/gen/navigationBarPrivateName_test.go new file mode 100644 index 0000000000..e7e4525d4e --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarPrivateName_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarPrivateName(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + #foo: () => { + class B { + #bar: () => { + function baz () { + } + } + } + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarPropertyDeclarations_test.go b/internal/fourslash/tests/gen/navigationBarPropertyDeclarations_test.go new file mode 100644 index 0000000000..b10d3b60af --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarPropertyDeclarations_test.go @@ -0,0 +1,49 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarPropertyDeclarations(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `class A { + public A1 = class { + public x = 1; + private y() {} + protected z() {} + } + + public A2 = { + x: 1, + y() {}, + z() {} + } + + public A3 = function () {} + public A4 = () => {} + public A5 = 1; + public A6 = "A6"; + + public ["A7"] = class { + public x = 1; + private y() {} + protected z() {} + } + + public [1] = { + x: 1, + y() {}, + z() {} + } + + public [1 + 1] = 1; +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarVariables_test.go b/internal/fourslash/tests/gen/navigationBarVariables_test.go new file mode 100644 index 0000000000..bfc1b5fdec --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarVariables_test.go @@ -0,0 +1,26 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarVariables(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `var x = 0; +let y = 1; +const z = 2; +// @Filename: file2.ts +var {a} = 0; +let {a: b} = 0; +const [c] = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) + f.GoToFile(t, "file2.ts") + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarWellKnownSymbolExpando_test.go b/internal/fourslash/tests/gen/navigationBarWellKnownSymbolExpando_test.go new file mode 100644 index 0000000000..8bd3c9dfb6 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarWellKnownSymbolExpando_test.go @@ -0,0 +1,19 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarWellKnownSymbolExpando(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function f() {} +f[Symbol.iterator] = function() {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationBarWithLocalVariables_test.go b/internal/fourslash/tests/gen/navigationBarWithLocalVariables_test.go new file mode 100644 index 0000000000..26382e552e --- /dev/null +++ b/internal/fourslash/tests/gen/navigationBarWithLocalVariables_test.go @@ -0,0 +1,21 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarWithLocalVariables(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `function x(){ + const x = Object() + x.foo = "" +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationItemsExportDefaultExpression_test.go b/internal/fourslash/tests/gen/navigationItemsExportDefaultExpression_test.go new file mode 100644 index 0000000000..7eddf52790 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsExportDefaultExpression_test.go @@ -0,0 +1,48 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsExportDefaultExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export default function () {} +export default function () { + return class Foo { + } +} + +export default () => "" +export default () => { + return class Foo { + } +} + +export default function f1() {} +export default function f2() { + return class Foo { + } +} + +const abc = 12; +export default abc; +export default class AB {} +export default { + a: 1, + b: 1, + c: { + d: 1 + } +} + +function foo(props: { x: number; y: number }) {} +export default foo({ x: 1, y: 1 });` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/gen/navigationItemsExportEqualsExpression_test.go b/internal/fourslash/tests/gen/navigationItemsExportEqualsExpression_test.go new file mode 100644 index 0000000000..3883e29769 --- /dev/null +++ b/internal/fourslash/tests/gen/navigationItemsExportEqualsExpression_test.go @@ -0,0 +1,45 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationItemsExportEqualsExpression(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `export = function () {} +export = function () { + return class Foo { + } +} + +export = () => "" +export = () => { + return class Foo { + } +} + +export = function f1() {} +export = function f2() { + return class Foo { + } +} + +const abc = 12; +export = abc; +export = class AB {} +export = { + a: 1, + b: 1, + c: { + d: 1 + } +}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/NavigationBarJsDoc_test.go b/internal/fourslash/tests/manual/NavigationBarJsDoc_test.go new file mode 100644 index 0000000000..079ce17f38 --- /dev/null +++ b/internal/fourslash/tests/manual/NavigationBarJsDoc_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarJsDoc(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +/** @typedef {(number|string)} NumberLike */ +/** @typedef {(string|number)} */ +const x = 0;` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototype2_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototype2_test.go new file mode 100644 index 0000000000..d51117325e --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototype2_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototype2(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +A.prototype.a = function() { }; +A.prototype.b = function() { }; +function A() {}` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototype3_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototype3_test.go new file mode 100644 index 0000000000..88f4c28793 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototype3_test.go @@ -0,0 +1,22 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototype3(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +var A; +A.prototype.a = function() { }; +A.b = function() { };` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototype4_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototype4_test.go new file mode 100644 index 0000000000..0f77296de9 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototype4_test.go @@ -0,0 +1,30 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototype4(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +var A; +A.prototype = { }; +A.prototype = { m() {} }; +A.prototype.a = function() { }; +A.b = function() { }; + +var B; +B["prototype"] = { }; +B["prototype"] = { m() {} }; +B["prototype"]["a"] = function() { }; +B["b"] = function() { };` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototypeBroken_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototypeBroken_test.go new file mode 100644 index 0000000000..68f30c5851 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototypeBroken_test.go @@ -0,0 +1,24 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototypeBroken(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +function A() {} +A. // Started typing something here +A.prototype.a = function() { }; +G. // Started typing something here +A.prototype.a = function() { };` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototypeInterlaced_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototypeInterlaced_test.go new file mode 100644 index 0000000000..73a7f9f378 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototypeInterlaced_test.go @@ -0,0 +1,28 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototypeInterlaced(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +var b = 1; +function A() {}; +A.prototype.a = function() { }; +A.b = function() { }; +b = 2 +/* Comment */ +A.prototype.c = function() { } +var b = 2 +A.prototype.d = function() { }` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototypeNested_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototypeNested_test.go new file mode 100644 index 0000000000..51554685d6 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototypeNested_test.go @@ -0,0 +1,27 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototypeNested(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +function A() {} +A.B = function () { } +A.B.prototype.d = function () { } +Object.defineProperty(A.B.prototype, "x", { + get() {} +}) +A.prototype.D = function () { } +A.prototype.D.prototype.d = function () { } ` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/fourslash/tests/manual/navigationBarFunctionPrototype_test.go b/internal/fourslash/tests/manual/navigationBarFunctionPrototype_test.go new file mode 100644 index 0000000000..7f54da4ef5 --- /dev/null +++ b/internal/fourslash/tests/manual/navigationBarFunctionPrototype_test.go @@ -0,0 +1,33 @@ +package fourslash_test + +import ( + "testing" + + "github.com/microsoft/typescript-go/internal/fourslash" + "github.com/microsoft/typescript-go/internal/testutil" +) + +func TestNavigationBarFunctionPrototype(t *testing.T) { + t.Parallel() + + defer testutil.RecoverAndFail(t, "Panic on fourslash test") + const content = `// @allowJs: true +// @Filename: foo.js +function f() {} +f.prototype.x = 0; +f.y = 0; +f.prototype.method = function () {}; +Object.defineProperty(f, 'staticProp', { + set: function() {}, + get: function(){ + } +}); +Object.defineProperty(f.prototype, 'name', { + set: function() {}, + get: function(){ + } +}); ` + f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) + defer done() + f.VerifyBaselineDocumentSymbol(t) +} diff --git a/internal/ls/symbols.go b/internal/ls/symbols.go index 5ca7d20d5c..61c55730c1 100644 --- a/internal/ls/symbols.go +++ b/internal/ls/symbols.go @@ -9,6 +9,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/astnav" + "github.com/microsoft/typescript-go/internal/collections" "github.com/microsoft/typescript-go/internal/compiler" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/ls/lsconv" @@ -23,7 +24,7 @@ import ( func (l *LanguageService) ProvideDocumentSymbols(ctx context.Context, documentURI lsproto.DocumentUri) (lsproto.DocumentSymbolResponse, error) { _, file := l.getProgramAndFile(documentURI) if lsproto.GetClientCapabilities(ctx).TextDocument.DocumentSymbol.HierarchicalDocumentSymbolSupport { - symbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode()) + symbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode(), file) return lsproto.SymbolInformationsOrDocumentSymbolsOrNull{DocumentSymbols: &symbols}, nil } // Client doesn't support hierarchical document symbols, return flat SymbolInformation array @@ -38,7 +39,7 @@ func (l *LanguageService) ProvideDocumentSymbols(ctx context.Context, documentUR // getDocumentSymbolInformations converts hierarchical DocumentSymbols to a flat SymbolInformation array func (l *LanguageService) getDocumentSymbolInformations(ctx context.Context, file *ast.SourceFile, documentURI lsproto.DocumentUri) []lsproto.SymbolInformation { // First get hierarchical symbols - docSymbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode()) + docSymbols := l.getDocumentSymbolsForChildren(ctx, file.AsNode(), file) // Flatten the hierarchy var result []lsproto.SymbolInformation @@ -68,10 +69,11 @@ func (l *LanguageService) getDocumentSymbolInformations(ctx context.Context, fil return result } -func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, node *ast.Node) []*lsproto.DocumentSymbol { +func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, node *ast.Node, file *ast.SourceFile) []*lsproto.DocumentSymbol { var symbols []*lsproto.DocumentSymbol + expandoTargets := collections.Set[string]{} addSymbolForNode := func(node *ast.Node, children []*lsproto.DocumentSymbol) { - if node.Flags&ast.NodeFlagsReparsed == 0 { + if node.Flags&ast.NodeFlagsReparsed == 0 || node.Kind == ast.KindJSExportAssignment { symbol := l.newDocumentSymbol(node, children) if symbol != nil { symbols = append(symbols, symbol) @@ -82,11 +84,40 @@ func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, nod getSymbolsForChildren := func(node *ast.Node) []*lsproto.DocumentSymbol { var result []*lsproto.DocumentSymbol if node != nil { + saveExpandoTargets := expandoTargets + expandoTargets = collections.Set[string]{} saveSymbols := symbols symbols = nil node.ForEachChild(visit) result = symbols symbols = saveSymbols + expandoTargets = saveExpandoTargets + } + return result + } + startNode := func(node *ast.Node) func() { + if node == nil { + return func() {} + } + saveExpandoTargets := expandoTargets + expandoTargets = collections.Set[string]{} + saveSymbols := symbols + symbols = nil + return func() { + result := symbols + symbols = saveSymbols + expandoTargets = saveExpandoTargets + addSymbolForNode(node, result) + } + } + getSymbolsForNode := func(node *ast.Node) []*lsproto.DocumentSymbol { + var result []*lsproto.DocumentSymbol + if node != nil { + saveSymbols := symbols + symbols = nil + visit(node) + result = symbols + symbols = saveSymbols } return result } @@ -94,13 +125,38 @@ func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, nod if ctx.Err() != nil { return true } + if jsdocs := node.JSDoc(file); len(jsdocs) > 0 { + for _, jsdoc := range jsdocs { + if tagList := jsdoc.AsJSDoc().Tags; tagList != nil { + for _, tag := range tagList.Nodes { + if ast.IsJSDocTypedefTag(tag) || ast.IsJSDocCallbackTag(tag) { + addSymbolForNode(tag, nil /*children*/) + } + } + } + } + } switch node.Kind { case ast.KindClassDeclaration, ast.KindClassExpression, ast.KindInterfaceDeclaration, ast.KindEnumDeclaration: + if ast.IsClassLike(node) && ast.GetDeclarationName(node) != "" { + expandoTargets.Add(ast.GetDeclarationName(node)) + } addSymbolForNode(node, getSymbolsForChildren(node)) case ast.KindModuleDeclaration: addSymbolForNode(node, getSymbolsForChildren(getInteriorModule(node))) + case ast.KindConstructor: + addSymbolForNode(node, getSymbolsForChildren(node.Body())) + for _, param := range node.Parameters() { + if ast.IsParameterPropertyDeclaration(param, node) { + addSymbolForNode(param, nil /*children*/) + } + } case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction, ast.KindMethodDeclaration, ast.KindGetAccessor, - ast.KindSetAccessor, ast.KindConstructor: + ast.KindSetAccessor: + name := ast.GetDeclarationName(node) + if name != "" { + expandoTargets.Add(name) + } addSymbolForNode(node, getSymbolsForChildren(node.Body())) case ast.KindVariableDeclaration, ast.KindBindingElement, ast.KindPropertyAssignment, ast.KindPropertyDeclaration: name := node.Name() @@ -111,29 +167,125 @@ func (l *LanguageService) getDocumentSymbolsForChildren(ctx context.Context, nod addSymbolForNode(node, getSymbolsForChildren(node.Initializer())) } } + case ast.KindSpreadAssignment: + addSymbolForNode(node, nil /*children*/) case ast.KindMethodSignature, ast.KindPropertySignature, ast.KindCallSignature, ast.KindConstructSignature, ast.KindIndexSignature, - ast.KindEnumMember, ast.KindShorthandPropertyAssignment, ast.KindTypeAliasDeclaration: + ast.KindEnumMember, ast.KindShorthandPropertyAssignment, ast.KindTypeAliasDeclaration, ast.KindImportEqualsDeclaration, ast.KindExportSpecifier: addSymbolForNode(node, nil) + case ast.KindImportClause: + // Handle default import case e.g.: + // import d from "mod"; + if node.Name() != nil { + addSymbolForNode(node.Name(), nil /*children*/) + } + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + if namedBindings := node.AsImportClause().NamedBindings; namedBindings != nil { + if namedBindings.Kind == ast.KindNamespaceImport { + addSymbolForNode(namedBindings, nil /*children*/) + } else { + for _, element := range namedBindings.Elements() { + addSymbolForNode(element, nil /*children*/) + } + } + } + case ast.KindBinaryExpression: + binaryExpr := node.AsBinaryExpression() + assignmentKind := ast.GetAssignmentDeclarationKind(binaryExpr) + switch assignmentKind { + // `module.exports = ...`` should be reparsed into a JSExportAssignment, + // and `exports.a = ...`` into a CommonJSExport. + case ast.JSDeclarationKindNone, ast.JSDeclarationKindThisProperty, + ast.JSDeclarationKindModuleExports, ast.JSDeclarationKindExportsProperty: + node.ForEachChild(visit) + case ast.JSDeclarationKindProperty: + // `A.b = ... ` or `A.prototype.b = ...` + target := binaryExpr.Left + targetFunction := target.Expression() + if isPrototypeExpando(binaryExpr) { + targetFunction = targetFunction.Expression() + // If we see a prototype assignment, start tracking the target as an expando target. + if ast.IsIdentifier(targetFunction) { + expandoTargets.Add(targetFunction.Text()) + } + } + if ast.IsIdentifier(targetFunction) && + expandoTargets.Has(targetFunction.Text()) { + endNode := startNode(node) + addSymbolForNode(target, getSymbolsForNode(binaryExpr.Right)) + endNode() + } else { + node.ForEachChild(visit) + } + } + case ast.KindExportAssignment, ast.KindJSExportAssignment: + if node.AsExportAssignment().IsExportEquals { + addSymbolForNode(node, getSymbolsForNode(node.Expression())) + } else { + node.ForEachChild(visit) + } default: node.ForEachChild(visit) } return false } node.ForEachChild(visit) - return symbols + return mergeExpandos(symbols) } +// Binary expression is `f.prototype.prop`. +func isPrototypeExpando(binaryExpr *ast.BinaryExpression) bool { + target := binaryExpr.Left.Expression() + if ast.IsAccessExpression(target) { + accessName := ast.GetElementOrPropertyAccessName(target) + return accessName != nil && accessName.Text() == "prototype" + } + return false +} + +const maxLength = 150 + func (l *LanguageService) newDocumentSymbol(node *ast.Node, children []*lsproto.DocumentSymbol) *lsproto.DocumentSymbol { result := new(lsproto.DocumentSymbol) file := ast.GetSourceFileOfNode(node) nodeStartPos := scanner.SkipTrivia(file.Text(), node.Pos()) - name := ast.GetNameOfDeclaration(node) + var name *ast.Node + // Expando properties + if ast.IsBinaryExpression(node) { + if isPrototypeExpando(node.AsBinaryExpression()) { // `f.prototype.prop = ...` + name = node.AsBinaryExpression().Left.Expression().Expression() + } else { // `f[prop] = ...` + name = node.AsBinaryExpression().Left.Expression() + } + } else if ast.IsAccessExpression(node) { + if ast.IsPropertyAccessExpression(node) { + name = node.AsPropertyAccessExpression().Name() + } else if ast.IsElementAccessExpression(node) { + name = node.AsElementAccessExpression().ArgumentExpression + } + } else if ast.IsIdentifier(node) || ast.IsPrivateIdentifier(node) { + name = node + } else if ast.IsSpreadAssignment(node) && ast.IsIdentifier(node.Expression()) { + name = node.Expression() + } else { + name = ast.GetNameOfDeclaration(node) + } var text string var nameStartPos, nameEndPos int if ast.IsModuleDeclaration(node) && !ast.IsAmbientModule(node) { text = getModuleName(node) nameStartPos = scanner.SkipTrivia(file.Text(), name.Pos()) nameEndPos = getInteriorModule(node).Name().End() + } else if ast.IsAnyExportAssignment(node) && node.AsExportAssignment().IsExportEquals { + text = "export=" + if name != nil { + nameStartPos = scanner.SkipTrivia(file.Text(), name.Pos()) + nameEndPos = name.End() + } else { + nameStartPos = nodeStartPos + nameEndPos = node.End() + } } else if name != nil { text = getTextOfName(name) nameStartPos = max(scanner.SkipTrivia(file.Text(), name.Pos()), nodeStartPos) @@ -146,6 +298,10 @@ func (l *LanguageService) newDocumentSymbol(node *ast.Node, children []*lsproto. if text == "" { return nil } + truncatedText := stringutil.TruncateByRunes(text, maxLength) + if len(truncatedText) < len(text) { + text = truncatedText + "..." + } result.Name = text result.Kind = getSymbolKindFromNode(node) result.Range = lsproto.Range{ @@ -163,6 +319,86 @@ func (l *LanguageService) newDocumentSymbol(node *ast.Node, children []*lsproto. return result } +// Merges expando symbols into their target symbols, and namespaces of same name. +// Modifies the input slice. +func mergeExpandos(symbols []*lsproto.DocumentSymbol) []*lsproto.DocumentSymbol { + mergedSymbols := make([]*lsproto.DocumentSymbol, 0, len(symbols)) + // Collect symbols that can be an expando target. + nameToExpandoTargetIndex := collections.MultiMap[string, int]{} + // Collect namespaces. + nameToNamespaceIndex := map[string]int{} + for i, symbol := range symbols { + if isAnonymousName(symbol.Name) { + continue + } + if symbol.Kind == lsproto.SymbolKindClass || symbol.Kind == lsproto.SymbolKindFunction || symbol.Kind == lsproto.SymbolKindVariable { + nameToExpandoTargetIndex.Add(symbol.Name, i) + } + if symbol.Kind == lsproto.SymbolKindNamespace { + if _, ok := nameToNamespaceIndex[symbol.Name]; !ok { + nameToNamespaceIndex[symbol.Name] = i + } + } + } + for i, symbol := range symbols { + if symbol.Children != nil { + children := mergeExpandos(*symbol.Children) + symbol.Children = &children + } + + // Anonymous symbols never merge. + if isAnonymousName(symbol.Name) { + continue + } + + // Merge expandos. + if symbol.Kind == lsproto.SymbolKindProperty { + symbolsWithSameName := nameToExpandoTargetIndex.Get(symbol.Name) + for j := len(symbolsWithSameName) - 1; j >= 0; j-- { + targetIndex := symbolsWithSameName[j] + targetSymbol := symbols[targetIndex] + mergeChildren(targetSymbol, symbol) + // Mark this symbol as merged. + symbols[i] = nil + } + } + // Merge namespaces. + if symbol.Kind == lsproto.SymbolKindNamespace { + if targetIndex, ok := nameToNamespaceIndex[symbol.Name]; ok && targetIndex != i { + targetSymbol := symbols[targetIndex] + mergeChildren(targetSymbol, symbol) + // Mark this symbol as merged. + symbols[i] = nil + } + } + } + for _, symbol := range symbols { + if symbol != nil { + mergedSymbols = append(mergedSymbols, symbol) + } + } + return mergedSymbols +} + +func mergeChildren(target *lsproto.DocumentSymbol, source *lsproto.DocumentSymbol) { + if source.Children != nil { + if target.Children == nil { + target.Children = source.Children + } else { + *target.Children = mergeExpandos(append(*target.Children, *source.Children...)) + slices.SortFunc(*target.Children, func(a, b *lsproto.DocumentSymbol) int { + return lsproto.CompareRanges(&a.Range, &b.Range) + }) + } + } +} + +// See `getUnnamedNodeLabel`. +func isAnonymousName(name string) bool { + return name == "" || name == "" || name == "export=" || name == "default" || + name == "constructor" || name == "()" || name == "new()" || name == "[]" || strings.HasSuffix(name, "() callback") +} + func getTextOfName(node *ast.Node) string { switch node.Kind { case ast.KindIdentifier, ast.KindPrivateIdentifier, ast.KindNumericLiteral: @@ -180,8 +416,17 @@ func getTextOfName(node *ast.Node) string { } func getUnnamedNodeLabel(node *ast.Node) string { + if parent := ast.WalkUpParenthesizedExpressions(node.Parent); parent != nil && ast.IsExportAssignment(parent) { + if parent.AsExportAssignment().IsExportEquals { + return "export=" + } + return "default" + } switch node.Kind { - case ast.KindFunctionExpression, ast.KindArrowFunction: + case ast.KindFunctionDeclaration, ast.KindFunctionExpression, ast.KindArrowFunction: + if node.ModifierFlags()&ast.ModifierFlagsDefault != 0 { + return "default" + } if ast.IsCallExpression(node.Parent) { name := getCallExpressionName(node.Parent.Expression()) if name != "" { @@ -189,7 +434,10 @@ func getUnnamedNodeLabel(node *ast.Node) string { } } return "" - case ast.KindClassExpression: + case ast.KindClassDeclaration, ast.KindClassExpression: + if node.ModifierFlags()&ast.ModifierFlagsDefault != 0 { + return "default" + } return "" case ast.KindConstructor: return "constructor" @@ -360,12 +608,12 @@ func getSymbolKindFromNode(node *ast.Node) lsproto.SymbolKind { } return lsproto.SymbolKindFile case ast.KindModuleDeclaration: - return lsproto.SymbolKindModule + return lsproto.SymbolKindNamespace case ast.KindClassDeclaration, ast.KindClassExpression: return lsproto.SymbolKindClass case ast.KindInterfaceDeclaration: return lsproto.SymbolKindInterface - case ast.KindTypeAliasDeclaration: + case ast.KindTypeAliasDeclaration, ast.KindJSDocTypedefTag, ast.KindJSDocCallbackTag: return lsproto.SymbolKindClass case ast.KindEnumDeclaration: return lsproto.SymbolKindEnum @@ -377,9 +625,10 @@ func getSymbolKindFromNode(node *ast.Node) lsproto.SymbolKind { return lsproto.SymbolKindProperty case ast.KindMethodDeclaration, ast.KindMethodSignature: return lsproto.SymbolKindMethod - case ast.KindPropertyDeclaration, ast.KindPropertySignature: + case ast.KindPropertyDeclaration, ast.KindPropertySignature, ast.KindPropertyAssignment, + ast.KindShorthandPropertyAssignment, ast.KindSpreadAssignment, ast.KindIndexSignature: return lsproto.SymbolKindProperty - case ast.KindIndexSignature, ast.KindCallSignature: + case ast.KindCallSignature: return lsproto.SymbolKindMethod case ast.KindConstructSignature: return lsproto.SymbolKindConstructor diff --git a/internal/stringutil/util.go b/internal/stringutil/util.go index 629846abae..4b4ba7e9d6 100644 --- a/internal/stringutil/util.go +++ b/internal/stringutil/util.go @@ -238,3 +238,20 @@ func LowerFirstChar(str string) string { } return str } + +func TruncateByRunes(str string, maxLength int) string { + if len(str) < maxLength { + return str + } + if maxLength <= 0 { + return "" + } + var runeCount int + for i := range str { + runeCount++ + if runeCount >= maxLength { + return str[:i] + } + } + return str +} diff --git a/testdata/baselines/reference/fourslash/documentSymbols/documentSymbolPrivateName.baseline b/testdata/baselines/reference/fourslash/documentSymbols/documentSymbolPrivateName.baseline new file mode 100644 index 0000000000..bed5091507 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/documentSymbolPrivateName.baseline @@ -0,0 +1,41 @@ +// === Document Symbols === +// === /first.ts === +// <|class [|{| name: A, kind: Class |}A|] { +// <|[|{| name: #foo, kind: Method |}#foo|]() { +// <|class [|{| name: B, kind: Class |}B|] { +// <|[|{| name: #bar, kind: Method |}#bar|]() { +// <|function [|{| name: baz, kind: Function |}baz|] () { +// }|> +// }|> +// }|> +// }|> +// }|> +// +// <|class [|{| name: B, kind: Class |}B|] { +// <|[|{| name: constructor, kind: Constructor |}|]constructor(<|private [|{| name: prop, kind: Property |}prop|]: string|>) {}|> +// }|> +// + +// === Details === +(Class) A + (Method) #foo + (Class) B + (Method) #bar + (Function) baz +(Class) B + (Constructor) constructor + (Property) prop + + + + +// === Document Symbols === +// === /second.ts === +// <|class [|{| name: Foo, kind: Class |}Foo|] { +// <|[|{| name: #privateProp, kind: Property |}#privateProp|]: string;|> +// }|> +// + +// === Details === +(Class) Foo + (Property) #privateProp diff --git a/testdata/baselines/reference/fourslash/documentSymbols/getNavigationBarItems.baseline b/testdata/baselines/reference/fourslash/documentSymbols/getNavigationBarItems.baseline new file mode 100644 index 0000000000..985d1229c7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/getNavigationBarItems.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /getNavigationBarItems.ts === +// <|class [|{| name: C, kind: Class |}C|] { +// <|[|{| name: foo, kind: Property |}foo|];|> +// <|[|{| name: "bar", kind: Property |}["bar"]|]: string;|> +// }|> + +// === Details === +(Class) C + (Property) foo + (Property) "bar" diff --git a/testdata/baselines/reference/fourslash/documentSymbols/jsdocTypedefTagNavigateTo.baseline b/testdata/baselines/reference/fourslash/documentSymbols/jsdocTypedefTagNavigateTo.baseline new file mode 100644 index 0000000000..9d9df97ac3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/jsdocTypedefTagNavigateTo.baseline @@ -0,0 +1,13 @@ +// === Document Symbols === +// === /jsDocTypedef_form2.js === +// /** <|@typedef {(string | number)} [|{| name: NumberLike, kind: Class |}NumberLike|]|> */ +// /** @typedef {(string | number | string[])} */ +// var <|[|{| name: NumberLike2, kind: Variable |}NumberLike2|]|>; +// +// /** @type {NumberLike} */ +// var <|[|{| name: numberLike, kind: Variable |}numberLike|]|>; + +// === Details === +(Class) NumberLike +(Variable) NumberLike2 +(Variable) numberLike diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navbar01.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navbar01.baseline new file mode 100644 index 0000000000..2fefdd8428 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navbar01.baseline @@ -0,0 +1,63 @@ +// === Document Symbols === +// === /navbar01.ts === +// // Interface +// <|interface [|{| name: IPoint, kind: Interface |}IPoint|] { +// <|[|{| name: getDist, kind: Method |}getDist|](): number;|> +// <|[|{| name: new(), kind: Constructor |}|]new(): IPoint;|> +// <|[|{| name: (), kind: Method |}|](): any;|> +// <|[|{| name: [], kind: Property |}|][x:string]: number;|> +// <|[|{| name: prop, kind: Property |}prop|]: string;|> +// }|> +// +// /// Module +// <|module [|{| name: Shapes, kind: Namespace |}Shapes|] { +// // Class +// <|export class [|{| name: Point, kind: Class |}Point|] implements IPoint { +// <|[|{| name: constructor, kind: Constructor |}|]constructor (<|public [|{| name: x, kind: Property |}x|]: number|>, <|public [|{| name: y, kind: Property |}y|]: number|>) { }|> +// +// // Instance member +// <|[|{| name: getDist, kind: Method |}getDist|]() { return Math.sqrt(this.x * this.x + this.y * this.y); }|> +// +// // Getter +// <|get [|{| name: value, kind: Property |}value|](): number { return 0; }|> +// +// // Setter +// <|set [|{| name: value, kind: Property |}value|](newValue: number) { return; }|> +// +// // Static member +// <|static [|{| name: origin, kind: Property |}origin|] = new Point(0, 0);|> +// +// // Static method +// <|private static [|{| name: getOrigin, kind: Method |}getOrigin|]() { return Point.origin;}|> +// }|> +// +// <|enum [|{| name: Values, kind: Enum |}Values|] { <|[|{| name: value1, kind: EnumMember |}value1|]|>, <|[|{| name: value2, kind: EnumMember |}value2|]|>, <|[|{| name: value3, kind: EnumMember |}value3|]|> }|> +// }|> +// +// // Local variables +// var <|[|{| name: p, kind: Variable |}p|]: IPoint = new Shapes.Point(3, 4)|>; +// var <|[|{| name: dist, kind: Variable |}dist|] = p.getDist()|>; + +// === Details === +(Interface) IPoint + (Method) getDist + (Constructor) new() + (Method) () + (Property) [] + (Property) prop +(Namespace) Shapes + (Class) Point + (Constructor) constructor + (Property) x + (Property) y + (Method) getDist + (Property) value + (Property) value + (Property) origin + (Method) getOrigin + (Enum) Values + (EnumMember) value1 + (EnumMember) value2 + (EnumMember) value3 +(Variable) p +(Variable) dist diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navbarNestedCommonJsExports.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navbarNestedCommonJsExports.baseline new file mode 100644 index 0000000000..7e6f2febaf --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navbarNestedCommonJsExports.baseline @@ -0,0 +1,4 @@ +// === Document Symbols === + + +// === Details === diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navbar_const.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navbar_const.baseline new file mode 100644 index 0000000000..b46f520493 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navbar_const.baseline @@ -0,0 +1,6 @@ +// === Document Symbols === +// === /navbar_const.ts === +// const <|[|{| name: c, kind: Variable |}c|] = 0|>; + +// === Details === +(Variable) c diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navbar_contains_no_duplicates.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navbar_contains_no_duplicates.baseline new file mode 100644 index 0000000000..929a495325 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navbar_contains_no_duplicates.baseline @@ -0,0 +1,43 @@ +// === Document Symbols === +// === /navbar_contains_no_duplicates.ts === +// <|declare module [|{| name: Windows, kind: Namespace |}Windows|] { +// <|export module [|{| name: Foundation, kind: Namespace |}Foundation|] { +// export var <|[|{| name: A, kind: Variable |}A|]|>; +// <|export class [|{| name: Test, kind: Class |}Test|] { +// <|public [|{| name: wow, kind: Method |}wow|]();|> +// }|> +// }|> +// }|> +// +// declare module Windows { +// export module Foundation { +// export var <|[|{| name: B, kind: Variable |}B|]|>; +// <|export module [|{| name: Test, kind: Namespace |}Test|] { +// <|export function [|{| name: Boom, kind: Function |}Boom|](): number;|> +// }|> +// } +// } +// +// <|class [|{| name: ABC, kind: Class |}ABC|] { +// <|public [|{| name: foo, kind: Method |}foo|]() { +// return 3; +// }|> +// }|> +// +// <|module [|{| name: ABC, kind: Namespace |}ABC|] { +// export var <|[|{| name: x, kind: Variable |}x|] = 3|>; +// }|> + +// === Details === +(Namespace) Windows + (Namespace) Foundation + (Variable) A + (Class) Test + (Method) wow + (Variable) B + (Namespace) Test + (Function) Boom +(Class) ABC + (Method) foo +(Namespace) ABC + (Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navbar_exportDefault.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navbar_exportDefault.baseline new file mode 100644 index 0000000000..1b1e3cdc50 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navbar_exportDefault.baseline @@ -0,0 +1,36 @@ +// === Document Symbols === +// === /a.ts === +// <|[|{| name: default, kind: Class |}|]export default class { }|> + +// === Details === +(Class) default + + + + +// === Document Symbols === +// === /b.ts === +// <|export default class [|{| name: C, kind: Class |}C|] { }|> + +// === Details === +(Class) C + + + + +// === Document Symbols === +// === /c.ts === +// <|[|{| name: default, kind: Function |}|]export default function { }|> + +// === Details === +(Function) default + + + + +// === Document Symbols === +// === /d.ts === +// <|export default function [|{| name: Func, kind: Function |}Func|] { }|> + +// === Details === +(Function) Func diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navbar_let.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navbar_let.baseline new file mode 100644 index 0000000000..3e54bfc24d --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navbar_let.baseline @@ -0,0 +1,6 @@ +// === Document Symbols === +// === /navbar_let.ts === +// let <|[|{| name: c, kind: Variable |}c|] = 0|>; + +// === Details === +(Variable) c diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions.baseline new file mode 100644 index 0000000000..b5edd20291 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions.baseline @@ -0,0 +1,48 @@ +// === Document Symbols === +// === /navigationBarAnonymousClassAndFunctionExpressions.ts === +// global.cls = <|[|{| name: cls, kind: Class |}|]class { }|>; +// (<|[|{| name: , kind: Function |}|]function() { +// const <|[|{| name: x, kind: Variable |}x|] = () => { +// // Presence of inner function causes x to be a top-level function. +// <|function [|{| name: xx, kind: Function |}xx|]() {}|> +// }|>; +// const <|[|{| name: y, kind: Variable |}y|] = { +// // This is not a top-level function (contains nothing, but shows up in childItems of its parent.) +// <|[|{| name: foo, kind: Property |}foo|]: function() {}|> +// }|>; +// (<|function [|{| name: nest, kind: Function |}nest|]() { +// <|function [|{| name: moreNest, kind: Function |}moreNest|]() {}|> +// }|>)(); +// }|>)(); +// (<|[|{| name: , kind: Function |}|]function() { // Different anonymous functions are not merged +// // These will only show up as childItems. +// <|function [|{| name: z, kind: Function |}z|]() {}|> +// console.log(<|[|{| name: console.log() callback, kind: Function |}|]function() {}|>) +// describe("this", 'function', `is a function`, `with template literal ${"a"}`, <|[|{| name: describe() callback, kind: Function |}|]() => {}|>); +// [].map(<|[|{| name: map() callback, kind: Function |}|]() => {}|>); +// }|>) +// (<|function [|{| name: classes, kind: Function |}classes|]() { +// // Classes show up in top-level regardless of whether they have names or inner declarations. +// const <|[|{| name: cls2, kind: Variable |}cls2|] = class { }|>; +// console.log(<|class [|{| name: cls3, kind: Class |}cls3|] {}|>); +// (<|[|{| name: , kind: Class |}|]class { }|>); +// }|>) + +// === Details === +(Class) cls +(Function) + (Variable) x + (Function) xx + (Variable) y + (Property) foo + (Function) nest + (Function) moreNest +(Function) + (Function) z + (Function) console.log() callback + (Function) describe() callback + (Function) map() callback +(Function) classes + (Variable) cls2 + (Class) cls3 + (Class) diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions2.baseline new file mode 100644 index 0000000000..1bdac1f0cf --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions2.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /navigationBarAnonymousClassAndFunctionExpressions2.ts === +// console.log(console.log(<|class [|{| name: Y, kind: Class |}Y|] {}|>, <|class [|{| name: X, kind: Class |}X|] {}|>), console.log(<|class [|{| name: B, kind: Class |}B|] {}|>, <|class [|{| name: A, kind: Class |}A|] {}|>)); +// console.log(<|class [|{| name: Cls, kind: Class |}Cls|] { <|[|{| name: meth, kind: Method |}meth|]() {}|> }|>); + +// === Details === +(Class) Y +(Class) X +(Class) B +(Class) A +(Class) Cls + (Method) meth diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions3.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions3.baseline new file mode 100644 index 0000000000..9c4d60e29c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAnonymousClassAndFunctionExpressions3.baseline @@ -0,0 +1,19 @@ +// === Document Symbols === +// === /navigationBarAnonymousClassAndFunctionExpressions3.ts === +// describe('foo', <|[|{| name: describe() callback, kind: Function |}|]() => { +// test(`a ${1} b ${2}`, <|[|{| name: test() callback, kind: Function |}|]() => {}|>) +// }|>) +// +// const <|[|{| name: a, kind: Variable |}a|] = 1|>; +// const <|[|{| name: b, kind: Variable |}b|] = 2|>; +// describe('foo', <|[|{| name: describe() callback, kind: Function |}|]() => { +// test(`a ${a} b {b}`, <|[|{| name: test() callback, kind: Function |}|]() => {}|>) +// }|>) + +// === Details === +(Function) describe() callback + (Function) test() callback +(Variable) a +(Variable) b +(Function) describe() callback + (Function) test() callback diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAssignmentTypes.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAssignmentTypes.baseline new file mode 100644 index 0000000000..a6beab67ea --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarAssignmentTypes.baseline @@ -0,0 +1,14 @@ +// === Document Symbols === +// === /navigationBarAssignmentTypes.ts === +// 'use strict' +// const <|[|{| name: a, kind: Variable |}a|] = { +// <|...[|{| name: b, kind: Property |}b|]|>, +// <|[|{| name: c, kind: Property |}c|]|>, +// <|[|{| name: d, kind: Property |}d|]: 0|> +// }|>; + +// === Details === +(Variable) a + (Property) b + (Property) c + (Property) d diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarClassStaticBlock.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarClassStaticBlock.baseline new file mode 100644 index 0000000000..2ccb58c610 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarClassStaticBlock.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /navigationBarClassStaticBlock.ts === +// <|class [|{| name: C, kind: Class |}C|] { +// static { +// let <|[|{| name: x, kind: Variable |}x|]|>; +// } +// }|> + +// === Details === +(Class) C + (Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarComputedPropertyName.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarComputedPropertyName.baseline new file mode 100644 index 0000000000..78bba5bfc1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarComputedPropertyName.baseline @@ -0,0 +1,13 @@ +// === Document Symbols === +// === /navigationBarComputedPropertyName.ts === +// <|function [|{| name: F, kind: Function |}F|](key, value) { +// return { +// <|[|{| name: [key], kind: Property |}[key]|]: value|>, +// <|[|{| name: "prop", kind: Property |}"prop"|]: true|> +// } +// }|> + +// === Details === +(Function) F + (Property) [key] + (Property) "prop" diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionIndirectlyInVariableDeclaration.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionIndirectlyInVariableDeclaration.baseline new file mode 100644 index 0000000000..25cc805303 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionIndirectlyInVariableDeclaration.baseline @@ -0,0 +1,22 @@ +// === Document Symbols === +// === /navigationBarFunctionIndirectlyInVariableDeclaration.ts === +// var <|[|{| name: a, kind: Variable |}a|] = { +// <|[|{| name: propA, kind: Property |}propA|]: function() { +// var <|[|{| name: c, kind: Variable |}c|]|>; +// }|> +// }|>; +// var <|[|{| name: b, kind: Variable |}b|]|>; +// b = { +// <|[|{| name: propB, kind: Property |}propB|]: function() { +// // function must not have an empty body to appear top level +// var <|[|{| name: d, kind: Variable |}d|]|>; +// }|> +// }; + +// === Details === +(Variable) a + (Property) propA + (Variable) c +(Variable) b +(Property) propB + (Variable) d diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionLikePropertyAssignments.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionLikePropertyAssignments.baseline new file mode 100644 index 0000000000..d89e23c91f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionLikePropertyAssignments.baseline @@ -0,0 +1,19 @@ +// === Document Symbols === +// === /navigationBarFunctionLikePropertyAssignments.ts === +// var <|[|{| name: functions, kind: Variable |}functions|] = { +// <|[|{| name: a, kind: Property |}a|]: 0|>, +// <|[|{| name: b, kind: Property |}b|]: function () { }|>, +// <|[|{| name: c, kind: Property |}c|]: function x() { }|>, +// <|[|{| name: d, kind: Property |}d|]: () => { }|>, +// <|[|{| name: e, kind: Property |}e|]: y()|>, +// <|[|{| name: f, kind: Method |}f|]() { }|> +// }|>; + +// === Details === +(Variable) functions + (Property) a + (Property) b + (Property) c + (Property) d + (Property) e + (Method) f diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype.baseline new file mode 100644 index 0000000000..00341aea9d --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype.baseline @@ -0,0 +1,27 @@ +// === Document Symbols === +// === /foo.js === +// <|function [|{| name: f, kind: Function |}f|]() {}|> +// <|f.prototype.[|{| name: x, kind: Variable |}x|]|> = 0; +// <|f.[|{| name: y, kind: Variable |}y|]|> = 0; +// <|f.prototype.[|{| name: method, kind: Variable |}method|]|> = <|[|{| name: method, kind: Function |}|]function () {}|>; +// Object.defineProperty(f, 'staticProp', { +// <|[|{| name: set, kind: Property |}set|]: function() {}|>, +// <|[|{| name: get, kind: Property |}get|]: function(){ +// }|> +// }); +// Object.defineProperty(f.prototype, 'name', { +// <|[|{| name: set, kind: Property |}set|]: function() {}|>, +// <|[|{| name: get, kind: Property |}get|]: function(){ +// }|> +// }); + +// === Details === +(Function) f + (Variable) x + (Variable) y + (Variable) method + (Function) method +(Property) set +(Property) get +(Property) set +(Property) get diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype2.baseline new file mode 100644 index 0000000000..7a1dd74179 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype2.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /foo.js === +// <|A.prototype.[|{| name: a, kind: Variable |}a|]|> = <|[|{| name: a, kind: Function |}|]function() { }|>; +// <|A.prototype.[|{| name: b, kind: Variable |}b|]|> = <|[|{| name: b, kind: Function |}|]function() { }|>; +// <|function [|{| name: A, kind: Function |}A|]() {}|> + +// === Details === +(Function) A + (Variable) a + (Function) a + (Variable) b + (Function) b diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype3.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype3.baseline new file mode 100644 index 0000000000..193ef039da --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype3.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /foo.js === +// var <|[|{| name: A, kind: Variable |}A|]|>; +// <|A.prototype.[|{| name: a, kind: Variable |}a|]|> = <|[|{| name: a, kind: Function |}|]function() { }|>; +// <|A.[|{| name: b, kind: Variable |}b|]|> = <|[|{| name: b, kind: Function |}|]function() { }|>; + +// === Details === +(Variable) A + (Variable) a + (Function) a + (Variable) b + (Function) b diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype4.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype4.baseline new file mode 100644 index 0000000000..8326a90b0a --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototype4.baseline @@ -0,0 +1,27 @@ +// === Document Symbols === +// === /foo.js === +// var <|[|{| name: A, kind: Variable |}A|]|>; +// A.prototype = { }; +// A.prototype = { <|[|{| name: m, kind: Method |}m|]() {}|> }; +// <|A.prototype.[|{| name: a, kind: Variable |}a|]|> = <|[|{| name: a, kind: Function |}|]function() { }|>; +// <|A.[|{| name: b, kind: Variable |}b|]|> = <|[|{| name: b, kind: Function |}|]function() { }|>; +// +// var <|[|{| name: B, kind: Variable |}B|]|>; +// B["prototype"] = { }; +// B["prototype"] = { <|[|{| name: m, kind: Method |}m|]() {}|> }; +// <|B["prototype"][[|{| name: "a", kind: Variable |}"a"|]]|> = <|[|{| name: "a", kind: Function |}|]function() { }|>; +// <|B[[|{| name: "b", kind: Variable |}"b"|]]|> = <|[|{| name: "b", kind: Function |}|]function() { }|>; + +// === Details === +(Variable) A + (Variable) a + (Function) a + (Variable) b + (Function) b +(Method) m +(Variable) B + (Variable) "a" + (Function) "a" + (Variable) "b" + (Function) "b" +(Method) m diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeBroken.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeBroken.baseline new file mode 100644 index 0000000000..e0dead311f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeBroken.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /foo.js === +// <|function [|{| name: A, kind: Function |}A|]() {}|> +// A. // Started typing something here +// A.prototype.a = <|[|{| name: a, kind: Function |}|]function() { }|>; +// G. // Started typing something here +// A.prototype.a = <|[|{| name: a, kind: Function |}|]function() { }|>; + +// === Details === +(Function) A +(Function) a +(Function) a diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeInterlaced.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeInterlaced.baseline new file mode 100644 index 0000000000..bb4baea8a9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeInterlaced.baseline @@ -0,0 +1,24 @@ +// === Document Symbols === +// === /foo.js === +// var <|[|{| name: b, kind: Variable |}b|] = 1|>; +// <|function [|{| name: A, kind: Function |}A|]() {}|>; +// <|A.prototype.[|{| name: a, kind: Variable |}a|]|> = <|[|{| name: a, kind: Function |}|]function() { }|>; +// <|A.[|{| name: b, kind: Variable |}b|]|> = <|[|{| name: b, kind: Function |}|]function() { }|>; +// b = 2 +// /* Comment */ +// <|A.prototype.[|{| name: c, kind: Variable |}c|]|> = <|[|{| name: c, kind: Function |}|]function() { }|> +// var <|[|{| name: b, kind: Variable |}b|] = 2|> +// <|A.prototype.[|{| name: d, kind: Variable |}d|]|> = <|[|{| name: d, kind: Function |}|]function() { }|> + +// === Details === +(Variable) b +(Function) A + (Variable) a + (Function) a + (Variable) b + (Function) b + (Variable) c + (Function) c + (Variable) d + (Function) d +(Variable) b diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeNested.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeNested.baseline new file mode 100644 index 0000000000..5de1065441 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarFunctionPrototypeNested.baseline @@ -0,0 +1,20 @@ +// === Document Symbols === +// === /foo.js === +// <|function [|{| name: A, kind: Function |}A|]() {}|> +// <|A.[|{| name: B, kind: Variable |}B|]|> = <|[|{| name: B, kind: Function |}|]function () { }|> +// A.B.prototype.d = <|[|{| name: d, kind: Function |}|]function () { }|> +// Object.defineProperty(A.B.prototype, "x", { +// <|[|{| name: get, kind: Method |}get|]() {}|> +// }) +// <|A.prototype.[|{| name: D, kind: Variable |}D|]|> = <|[|{| name: D, kind: Function |}|]function () { }|> +// A.prototype.D.prototype.d = <|[|{| name: d, kind: Function |}|]function () { }|> + +// === Details === +(Function) A + (Variable) B + (Function) B + (Variable) D + (Function) D +(Function) d +(Method) get +(Function) d diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarGetterAndSetter.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarGetterAndSetter.baseline new file mode 100644 index 0000000000..0cb13770ad --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarGetterAndSetter.baseline @@ -0,0 +1,15 @@ +// === Document Symbols === +// === /navigationBarGetterAndSetter.ts === +// <|class [|{| name: X, kind: Class |}X|] { +// <|get [|{| name: x, kind: Property |}x|]() {}|> +// <|set [|{| name: x, kind: Property |}x|](value) { +// // Inner declaration should make the setter top-level. +// <|function [|{| name: f, kind: Function |}f|]() {}|> +// }|> +// }|> + +// === Details === +(Class) X + (Property) x + (Property) x + (Function) f diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarImports.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarImports.baseline new file mode 100644 index 0000000000..3c9221113f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarImports.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /navigationBarImports.ts === +// import <|[|{| name: a, kind: Variable |}a|]|>, {<|[|{| name: b, kind: Variable |}b|]|>} from "m"; +// <|import [|{| name: c, kind: Variable |}c|] = require("m");|> +// import <|* as [|{| name: d, kind: Variable |}d|]|> from "m"; + +// === Details === +(Variable) a +(Variable) b +(Variable) c +(Variable) d diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarInitializerSpans.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarInitializerSpans.baseline new file mode 100644 index 0000000000..fcabe53f38 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarInitializerSpans.baseline @@ -0,0 +1,15 @@ +// === Document Symbols === +// === /navigationBarInitializerSpans.ts === +// // get the name for the navbar from the variable name rather than the function name +// const <|[|{| name: x, kind: Variable |}x|] = () => { var <|[|{| name: a, kind: Variable |}a|]|>; }|>; +// const <|[|{| name: f, kind: Variable |}f|] = function f() { var <|[|{| name: b, kind: Variable |}b|]|>; }|>; +// const <|[|{| name: y, kind: Variable |}y|] = { <|[|{| name: z, kind: Property |}z|]: function z() { var <|[|{| name: c, kind: Variable |}c|]|>; }|> }|>; + +// === Details === +(Variable) x + (Variable) a +(Variable) f + (Variable) b +(Variable) y + (Property) z + (Variable) c diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsBindingPatterns.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsBindingPatterns.baseline new file mode 100644 index 0000000000..461be18311 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsBindingPatterns.baseline @@ -0,0 +1,23 @@ +// === Document Symbols === +// === /navigationBarItemsBindingPatterns.ts === +// 'use strict' +// var <|[|{| name: foo, kind: Variable |}foo|]|>, {} +// var <|[|{| name: bar, kind: Variable |}bar|]|>, [] +// let <|[|{| name: foo1, kind: Variable |}foo1|]|>, {<|[|{| name: a, kind: Variable |}a|]|>, <|[|{| name: b, kind: Variable |}b|]|>} +// const <|[|{| name: bar1, kind: Variable |}bar1|]|>, [<|[|{| name: c, kind: Variable |}c|]|>, <|[|{| name: d, kind: Variable |}d|]|>] +// var {<|[|{| name: e, kind: Variable |}e|]|>, x: [<|[|{| name: f, kind: Variable |}f|]|>, <|[|{| name: g, kind: Variable |}g|]|>]} = {a:1, x:[]}; +// var { <|h: [|{| name: i, kind: Variable |}i|] = function j() {}|> } = obj; + +// === Details === +(Variable) foo +(Variable) bar +(Variable) foo1 +(Variable) a +(Variable) b +(Variable) bar1 +(Variable) c +(Variable) d +(Variable) e +(Variable) f +(Variable) g +(Variable) i diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsBindingPatternsInConstructor.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsBindingPatternsInConstructor.baseline new file mode 100644 index 0000000000..7b1ef9fa52 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsBindingPatternsInConstructor.baseline @@ -0,0 +1,20 @@ +// === Document Symbols === +// === /navigationBarItemsBindingPatternsInConstructor.ts === +// <|class [|{| name: A, kind: Class |}A|] { +// <|[|{| name: x, kind: Property |}x|]: any|> +// <|[|{| name: constructor, kind: Constructor |}|]constructor([a]: any) { +// }|> +// }|> +// <|class [|{| name: B, kind: Class |}B|] { +// <|[|{| name: x, kind: Property |}x|]: any;|> +// <|[|{| name: constructor, kind: Constructor |}|]constructor( {a} = { a: 1 }) { +// }|> +// }|> + +// === Details === +(Class) A + (Property) x + (Constructor) constructor +(Class) B + (Property) x + (Constructor) constructor diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass1.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass1.baseline new file mode 100644 index 0000000000..0cd7f3c7ba --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass1.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /navigationBarItemsClass1.ts === +// <|function [|{| name: Foo, kind: Function |}Foo|]() {}|> +// <|class [|{| name: Foo, kind: Class |}Foo|] {}|> + +// === Details === +(Function) Foo +(Class) Foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass2.baseline new file mode 100644 index 0000000000..ab2a2ba530 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass2.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /navigationBarItemsClass2.ts === +// <|class [|{| name: Foo, kind: Class |}Foo|] {}|> +// <|function [|{| name: Foo, kind: Function |}Foo|]() {}|> + +// === Details === +(Class) Foo +(Function) Foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass3.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass3.baseline new file mode 100644 index 0000000000..8dabbeec6e --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass3.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /foo.js === +// <|function [|{| name: Foo, kind: Function |}Foo|]() {}|> +// <|class [|{| name: Foo, kind: Class |}Foo|] {}|> + +// === Details === +(Function) Foo +(Class) Foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass4.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass4.baseline new file mode 100644 index 0000000000..2839a7c4b8 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass4.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /foo.js === +// <|class [|{| name: Foo, kind: Class |}Foo|] {}|> +// <|function [|{| name: Foo, kind: Function |}Foo|]() {}|> + +// === Details === +(Class) Foo +(Function) Foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass5.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass5.baseline new file mode 100644 index 0000000000..6eeca8c93d --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass5.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /navigationBarItemsClass5.ts === +// <|class [|{| name: Foo, kind: Class |}Foo|] {}|> +// let <|[|{| name: Foo, kind: Variable |}Foo|] = 1|>; + +// === Details === +(Class) Foo +(Variable) Foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass6.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass6.baseline new file mode 100644 index 0000000000..a48334f8cb --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsClass6.baseline @@ -0,0 +1,13 @@ +// === Document Symbols === +// === /navigationBarItemsClass6.ts === +// <|function [|{| name: Z, kind: Function |}Z|]() { }|> +// +// <|Z.[|{| name: foo, kind: Variable |}foo|]|> = 42 +// +// <|class [|{| name: Z, kind: Class |}Z|] { }|> + +// === Details === +(Function) Z + (Variable) foo +(Class) Z + (Variable) foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsComputedNames.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsComputedNames.baseline new file mode 100644 index 0000000000..ddb7ac1c08 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsComputedNames.baseline @@ -0,0 +1,34 @@ +// === Document Symbols === +// === /navigationBarItemsComputedNames.ts === +// <|const enum [|{| name: E, kind: Enum |}E|] { +// <|[|{| name: A, kind: EnumMember |}A|] = 'A'|>, +// }|> +// const <|[|{| name: a, kind: Variable |}a|] = ''|>; +// +// <|class [|{| name: C, kind: Class |}C|] { +// <|[|{| name: [a], kind: Method |}[a]|]() { +// return 1; +// }|> +// +// <|[|{| name: [E.A], kind: Method |}[E.A]|]() { +// return 1; +// }|> +// +// <|[|{| name: 1, kind: Method |}[1]|]() { +// return 1; +// }|>, +// +// <|[|{| name: "foo", kind: Method |}["foo"]|]() { +// return 1; +// }|>, +// }|> + +// === Details === +(Enum) E + (EnumMember) A +(Variable) a +(Class) C + (Method) [a] + (Method) [E.A] + (Method) 1 + (Method) "foo" diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsEmptyConstructors.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsEmptyConstructors.baseline new file mode 100644 index 0000000000..415c9b9f53 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsEmptyConstructors.baseline @@ -0,0 +1,10 @@ +// === Document Symbols === +// === /navigationBarItemsEmptyConstructors.ts === +// <|class [|{| name: Test, kind: Class |}Test|] { +// <|[|{| name: constructor, kind: Constructor |}|]constructor() { +// }|> +// }|> + +// === Details === +(Class) Test + (Constructor) constructor diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsExports.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsExports.baseline new file mode 100644 index 0000000000..fab8b1a03e --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsExports.baseline @@ -0,0 +1,14 @@ +// === Document Symbols === +// === /navigationBarItemsExports.ts === +// export { <|[|{| name: a, kind: Variable |}a|]|> } from "a"; +// +// export { <|b as [|{| name: B, kind: Variable |}B|]|> } from "a" +// +// <|export import [|{| name: e, kind: Variable |}e|] = require("a");|> +// +// export * from "a"; // no bindings here + +// === Details === +(Variable) a +(Variable) B +(Variable) e diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionProperties.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionProperties.baseline new file mode 100644 index 0000000000..f931ccfa51 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionProperties.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /navigationBarItemsFunctionProperties.ts === +// (<|[|{| name: , kind: Function |}|]function(){ +// var <|[|{| name: A, kind: Variable |}A|]|>; +// A +// .a = <|[|{| name: a, kind: Function |}|]function() { }|>; +// }|>)(); + +// === Details === +(Function) + (Variable) A + (Function) a diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctions.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctions.baseline new file mode 100644 index 0000000000..9d44e2b057 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctions.baseline @@ -0,0 +1,29 @@ +// === Document Symbols === +// === /navigationBarItemsFunctions.ts === +// <|function [|{| name: foo, kind: Function |}foo|]() { +// var <|[|{| name: x, kind: Variable |}x|] = 10|>; +// <|function [|{| name: bar, kind: Function |}bar|]() { +// var <|[|{| name: y, kind: Variable |}y|] = 10|>; +// <|function [|{| name: biz, kind: Function |}biz|]() { +// var <|[|{| name: z, kind: Variable |}z|] = 10|>; +// }|> +// <|function [|{| name: qux, kind: Function |}qux|]() { +// // A function with an empty body should not be top level +// }|> +// }|> +// }|> +// +// <|function [|{| name: baz, kind: Function |}baz|]() { +// var <|[|{| name: v, kind: Variable |}v|] = 10|>; +// }|> + +// === Details === +(Function) foo + (Variable) x + (Function) bar + (Variable) y + (Function) biz + (Variable) z + (Function) qux +(Function) baz + (Variable) v diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionsBroken.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionsBroken.baseline new file mode 100644 index 0000000000..37c9537f11 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionsBroken.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /navigationBarItemsFunctionsBroken.ts === +// <|function [|{| name: f, kind: Function |}f|]() { +// function; +// }|> + +// === Details === +(Function) f diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionsBroken2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionsBroken2.baseline new file mode 100644 index 0000000000..a80c8ff5c7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsFunctionsBroken2.baseline @@ -0,0 +1,9 @@ +// === Document Symbols === +// === /navigationBarItemsFunctionsBroken2.ts === +// function; +// <|function [|{| name: f, kind: Function |}f|]() { +// function; +// }|> + +// === Details === +(Function) f diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsImports.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsImports.baseline new file mode 100644 index 0000000000..5d2b303fd6 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsImports.baseline @@ -0,0 +1,23 @@ +// === Document Symbols === +// === /navigationBarItemsImports.ts === +// import <|[|{| name: d1, kind: Variable |}d1|]|> from "a"; +// +// import { <|[|{| name: a, kind: Variable |}a|]|> } from "a"; +// +// import { <|b as [|{| name: B, kind: Variable |}B|]|> } from "a" +// +// import <|[|{| name: d2, kind: Variable |}d2|]|>, { <|[|{| name: c, kind: Variable |}c|]|>, <|d as [|{| name: D, kind: Variable |}D|]|> } from "a" +// +// <|import [|{| name: e, kind: Variable |}e|] = require("a");|> +// +// import <|* as [|{| name: ns, kind: Variable |}ns|]|> from "a"; + +// === Details === +(Variable) d1 +(Variable) a +(Variable) B +(Variable) d2 +(Variable) c +(Variable) D +(Variable) e +(Variable) ns diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsInsideMethodsAndConstructors.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsInsideMethodsAndConstructors.baseline new file mode 100644 index 0000000000..e2c88a1ba8 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsInsideMethodsAndConstructors.baseline @@ -0,0 +1,34 @@ +// === Document Symbols === +// === /navigationBarItemsInsideMethodsAndConstructors.ts === +// <|class [|{| name: Class, kind: Class |}Class|] { +// <|[|{| name: constructor, kind: Constructor |}|]constructor() { +// <|function [|{| name: LocalFunctionInConstructor, kind: Function |}LocalFunctionInConstructor|]() {}|> +// <|interface [|{| name: LocalInterfaceInConstrcutor, kind: Interface |}LocalInterfaceInConstrcutor|] {}|> +// <|enum [|{| name: LocalEnumInConstructor, kind: Enum |}LocalEnumInConstructor|] { <|[|{| name: LocalEnumMemberInConstructor, kind: EnumMember |}LocalEnumMemberInConstructor|]|> }|> +// }|> +// +// <|[|{| name: method, kind: Method |}method|]() { +// <|function [|{| name: LocalFunctionInMethod, kind: Function |}LocalFunctionInMethod|]() { +// <|function [|{| name: LocalFunctionInLocalFunctionInMethod, kind: Function |}LocalFunctionInLocalFunctionInMethod|]() {}|> +// }|> +// <|interface [|{| name: LocalInterfaceInMethod, kind: Interface |}LocalInterfaceInMethod|] {}|> +// <|enum [|{| name: LocalEnumInMethod, kind: Enum |}LocalEnumInMethod|] { <|[|{| name: LocalEnumMemberInMethod, kind: EnumMember |}LocalEnumMemberInMethod|]|> }|> +// }|> +// +// <|[|{| name: emptyMethod, kind: Method |}emptyMethod|]() { }|> // Non child functions method should not be duplicated +// }|> + +// === Details === +(Class) Class + (Constructor) constructor + (Function) LocalFunctionInConstructor + (Interface) LocalInterfaceInConstrcutor + (Enum) LocalEnumInConstructor + (EnumMember) LocalEnumMemberInConstructor + (Method) method + (Function) LocalFunctionInMethod + (Function) LocalFunctionInLocalFunctionInMethod + (Interface) LocalInterfaceInMethod + (Enum) LocalEnumInMethod + (EnumMember) LocalEnumMemberInMethod + (Method) emptyMethod diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItems.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItems.baseline new file mode 100644 index 0000000000..d92d017076 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItems.baseline @@ -0,0 +1,64 @@ +// === Document Symbols === +// === /navigationBarItemsItems.ts === +// // Interface +// <|interface [|{| name: IPoint, kind: Interface |}IPoint|] { +// <|[|{| name: getDist, kind: Method |}getDist|](): number;|> +// <|[|{| name: new(), kind: Constructor |}|]new(): IPoint;|> +// <|[|{| name: (), kind: Method |}|](): any;|> +// <|[|{| name: [], kind: Property |}|][x:string]: number;|> +// <|[|{| name: prop, kind: Property |}prop|]: string;|> +// }|> +// +// /// Module +// <|module [|{| name: Shapes, kind: Namespace |}Shapes|] { +// +// // Class +// <|export class [|{| name: Point, kind: Class |}Point|] implements IPoint { +// <|[|{| name: constructor, kind: Constructor |}|]constructor (<|public [|{| name: x, kind: Property |}x|]: number|>, <|public [|{| name: y, kind: Property |}y|]: number|>) { }|> +// +// // Instance member +// <|[|{| name: getDist, kind: Method |}getDist|]() { return Math.sqrt(this.x * this.x + this.y * this.y); }|> +// +// // Getter +// <|get [|{| name: value, kind: Property |}value|](): number { return 0; }|> +// +// // Setter +// <|set [|{| name: value, kind: Property |}value|](newValue: number) { return; }|> +// +// // Static member +// <|static [|{| name: origin, kind: Property |}origin|] = new Point(0, 0);|> +// +// // Static method +// <|private static [|{| name: getOrigin, kind: Method |}getOrigin|]() { return Point.origin; }|> +// }|> +// +// <|enum [|{| name: Values, kind: Enum |}Values|] { <|[|{| name: value1, kind: EnumMember |}value1|]|>, <|[|{| name: value2, kind: EnumMember |}value2|]|>, <|[|{| name: value3, kind: EnumMember |}value3|]|> }|> +// }|> +// +// // Local variables +// var <|[|{| name: p, kind: Variable |}p|]: IPoint = new Shapes.Point(3, 4)|>; +// var <|[|{| name: dist, kind: Variable |}dist|] = p.getDist()|>; + +// === Details === +(Interface) IPoint + (Method) getDist + (Constructor) new() + (Method) () + (Property) [] + (Property) prop +(Namespace) Shapes + (Class) Point + (Constructor) constructor + (Property) x + (Property) y + (Method) getDist + (Property) value + (Property) value + (Property) origin + (Method) getOrigin + (Enum) Values + (EnumMember) value1 + (EnumMember) value2 + (EnumMember) value3 +(Variable) p +(Variable) dist diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItems2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItems2.baseline new file mode 100644 index 0000000000..e470a764cb --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItems2.baseline @@ -0,0 +1,8 @@ +// === Document Symbols === +// === /navigationBarItemsItems2.ts === +// <|module [|{| name: A, kind: Namespace |}A|]|> +// <|[|{| name: , kind: Class |}|]export class|> + +// === Details === +(Namespace) A +(Class) diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules.baseline new file mode 100644 index 0000000000..16ed4a2898 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules.baseline @@ -0,0 +1,9 @@ +// === Document Symbols === +// === /navigationBarItemsItemsExternalModules.ts === +// <|export class [|{| name: Bar, kind: Class |}Bar|] { +// <|public [|{| name: s, kind: Property |}s|]: string;|> +// }|> + +// === Details === +(Class) Bar + (Property) s diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules2.baseline new file mode 100644 index 0000000000..3ae45e23d9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules2.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /test/file.ts === +// <|export class [|{| name: Bar, kind: Class |}Bar|] { +// <|public [|{| name: s, kind: Property |}s|]: string;|> +// }|> +// export var <|[|{| name: x, kind: Variable |}x|]: number|>; + +// === Details === +(Class) Bar + (Property) s +(Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules3.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules3.baseline new file mode 100644 index 0000000000..17191dfda2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsExternalModules3.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /test/my fil e.ts === +// <|export class [|{| name: Bar, kind: Class |}Bar|] { +// <|public [|{| name: s, kind: Property |}s|]: string;|> +// }|> +// export var <|[|{| name: x, kind: Variable |}x|]: number|>; + +// === Details === +(Class) Bar + (Property) s +(Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsModuleVariables.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsModuleVariables.baseline new file mode 100644 index 0000000000..6c06151eb3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsItemsModuleVariables.baseline @@ -0,0 +1,24 @@ +// === Document Symbols === +// === /navigationItemsModuleVariables_0.ts === +// +// <|module [|{| name: Module1, kind: Namespace |}Module1|] { +// export var <|[|{| name: x, kind: Variable |}x|] = 0|>; +// }|> + +// === Details === +(Namespace) Module1 + (Variable) x + + + + +// === Document Symbols === +// === /navigationItemsModuleVariables_1.ts === +// +// <|module [|{| name: Module1.SubModule, kind: Namespace |}Module1.SubModule|] { +// export var <|[|{| name: y, kind: Variable |}y|] = 0|>; +// }|> + +// === Details === +(Namespace) Module1.SubModule + (Variable) y diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMissingName1.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMissingName1.baseline new file mode 100644 index 0000000000..506bda0e9c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMissingName1.baseline @@ -0,0 +1,10 @@ +// === Document Symbols === +// === /navigationBarItemsMissingName1.ts === +// export function +// <|class [|{| name: C, kind: Class |}C|] { +// <|[|{| name: foo, kind: Method |}foo|]() {}|> +// }|> + +// === Details === +(Class) C + (Method) foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMissingName2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMissingName2.baseline new file mode 100644 index 0000000000..c7fac970c6 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMissingName2.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /navigationBarItemsMissingName2.ts === +// /** +// * This is a class. +// */ +// <|[|{| name: , kind: Class |}|]class /* But it has no name! */ { +// <|[|{| name: foo, kind: Method |}foo|]() {}|> +// }|> + +// === Details === +(Class) + (Method) foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsModules1.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsModules1.baseline new file mode 100644 index 0000000000..8630be766d --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsModules1.baseline @@ -0,0 +1,41 @@ +// === Document Symbols === +// === /navigationBarItemsModules1.ts === +// <|declare module [|{| name: "X.Y.Z", kind: Namespace |}"X.Y.Z"|] {}|> +// +// <|declare module [|{| name: "X2.Y2.Z2", kind: Namespace |}'X2.Y2.Z2'|] {}|> +// +// <|declare module [|{| name: "foo", kind: Namespace |}"foo"|];|> +// +// <|module [|{| name: A.B.C, kind: Namespace |}A.B.C|] { +// export var <|[|{| name: x, kind: Variable |}x|]|>; +// }|> +// +// <|module [|{| name: A.B, kind: Namespace |}A.B|] { +// export var <|[|{| name: y, kind: Variable |}y|]|>; +// }|> +// +// <|module [|{| name: A, kind: Namespace |}A|] { +// export var <|[|{| name: z, kind: Variable |}z|]|>; +// }|> +// +// module A { +// <|module [|{| name: B, kind: Namespace |}B|] { +// <|module [|{| name: C, kind: Namespace |}C|] { +// declare var <|[|{| name: x, kind: Variable |}x|]|>; +// }|> +// }|> +// } + +// === Details === +(Namespace) "X.Y.Z" +(Namespace) "X2.Y2.Z2" +(Namespace) "foo" +(Namespace) A.B.C + (Variable) x +(Namespace) A.B + (Variable) y +(Namespace) A + (Variable) z + (Namespace) B + (Namespace) C + (Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsModules2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsModules2.baseline new file mode 100644 index 0000000000..b27d76a4c1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsModules2.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /navigationBarItemsModules2.ts === +// <|namespace [|{| name: Test.A, kind: Namespace |}Test.A|] { }|> +// +// <|namespace [|{| name: Test.B, kind: Namespace |}Test.B|] { +// <|class [|{| name: Foo, kind: Class |}Foo|] { }|> +// }|> + +// === Details === +(Namespace) Test.A +(Namespace) Test.B + (Class) Foo diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers1.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers1.baseline new file mode 100644 index 0000000000..0b0ab30bd9 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers1.baseline @@ -0,0 +1,41 @@ +// === Document Symbols === +// === /navigationBarItemsMultilineStringIdentifiers1.ts === +// <|declare module [|{| name: "Multiline\r\nMadness", kind: Namespace |}"Multiline\r\nMadness"|] { +// }|> +// +// <|declare module [|{| name: "MultilineMadness", kind: Namespace |}"Multiline\ +// Madness"|] { +// }|> +// declare module "MultilineMadness" {} +// +// <|declare module [|{| name: "MultilineMadness2", kind: Namespace |}"Multiline\ +// Madness2"|] { +// }|> +// +// <|interface [|{| name: Foo, kind: Interface |}Foo|] { +// <|[|{| name: "a1\\\r\nb", kind: Property |}"a1\\\r\nb"|];|> +// <|[|{| name: "a2 b", kind: Method |}"a2\ +// \ +// b"|](): Foo;|> +// }|> +// +// <|class [|{| name: Bar, kind: Class |}Bar|] implements Foo { +// <|[|{| name: "a1\\\r\nb", kind: Property |}'a1\\\r\nb'|]: Foo;|> +// +// <|[|{| name: "a2 b", kind: Method |}'a2\ +// \ +// b'|](): Foo { +// return this; +// }|> +// }|> + +// === Details === +(Namespace) "Multiline\r\nMadness" +(Namespace) "MultilineMadness" +(Namespace) "MultilineMadness2" +(Interface) Foo + (Property) "a1\\\r\nb" + (Method) "a2 b" +(Class) Bar + (Property) "a1\\\r\nb" + (Method) "a2 b" diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers2.baseline new file mode 100644 index 0000000000..48c86c4eba --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers2.baseline @@ -0,0 +1,23 @@ +// === Document Symbols === +// === /navigationBarItemsMultilineStringIdentifiers2.ts === +// <|function [|{| name: f, kind: Function |}f|](p1: () => any, p2: string) { }|> +// f(<|[|{| name: f() callback, kind: Function |}|]() => { }|>, `line1\ +// line2\ +// line3`); +// +// <|class [|{| name: c1, kind: Class |}c1|] { +// <|const [|{| name: a, kind: Property |}a|] = ' '|><|[|{| name: "line1 line2", kind: Property |}'line1\ +// line2'|];|> +// }|> +// +// f(<|[|{| name: f() callback, kind: Function |}|]() => { }|>, `unterminated backtick 1 +// unterminated backtick 2 +// unterminated backtick 3 + +// === Details === +(Function) f +(Function) f() callback +(Class) c1 + (Property) a + (Property) "line1 line2" +(Function) f() callback diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers3.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers3.baseline new file mode 100644 index 0000000000..a62da0e6aa --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsMultilineStringIdentifiers3.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /navigationBarItemsMultilineStringIdentifiers3.ts === +// <|declare module [|{| name: "MoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMore..., kind: Namespace |}'MoreThanOneHundredAndFiftyCharacters\ +// MoreThanOneHundredAndFiftyCharacters\ +// MoreThanOneHundredAndFiftyCharacters\ +// MoreThanOneHundredAndFiftyCharacters\ +// MoreThanOneHundredAndFiftyCharacters\ +// MoreThanOneHundredAndFiftyCharacters\ +// MoreThanOneHundredAndFiftyCharacters'|] { }|> + +// === Details === +(Namespace) "MoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMoreThanOneHundredAndFiftyCharactersMore... diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsNamedArrowFunctions.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsNamedArrowFunctions.baseline new file mode 100644 index 0000000000..e84ff8c5e3 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsNamedArrowFunctions.baseline @@ -0,0 +1,12 @@ +// === Document Symbols === +// === /navigationBarItemsNamedArrowFunctions.ts === +// export const <|[|{| name: value, kind: Variable |}value|] = 2|>; +// export const <|[|{| name: func, kind: Variable |}func|] = () => 2|>; +// export const <|[|{| name: func2, kind: Variable |}func2|] = function() { }|>; +// <|export function [|{| name: exportedFunction, kind: Function |}exportedFunction|]() { }|> + +// === Details === +(Variable) value +(Variable) func +(Variable) func2 +(Function) exportedFunction diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsPropertiesDefinedInConstructors.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsPropertiesDefinedInConstructors.baseline new file mode 100644 index 0000000000..74ca121aba --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsPropertiesDefinedInConstructors.baseline @@ -0,0 +1,15 @@ +// === Document Symbols === +// === /navigationBarItemsPropertiesDefinedInConstructors.ts === +// <|class [|{| name: List, kind: Class |}List|] { +// <|[|{| name: constructor, kind: Constructor |}|]constructor(<|public [|{| name: a, kind: Property |}a|]: boolean|>, <|private [|{| name: b, kind: Property |}b|]: T|>, <|readonly [|{| name: c, kind: Property |}c|]: string|>, d: number) { +// var <|[|{| name: local, kind: Variable |}local|] = 0|>; +// }|> +// }|> + +// === Details === +(Class) List + (Constructor) constructor + (Variable) local + (Property) a + (Property) b + (Property) c diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsStaticAndNonStaticNoMerge.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsStaticAndNonStaticNoMerge.baseline new file mode 100644 index 0000000000..7bb5d9cb92 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsStaticAndNonStaticNoMerge.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /navigationBarItemsStaticAndNonStaticNoMerge.ts === +// <|class [|{| name: C, kind: Class |}C|] { +// <|static [|{| name: x, kind: Property |}x|];|> +// <|[|{| name: x, kind: Property |}x|];|> +// }|> + +// === Details === +(Class) C + (Property) x + (Property) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols1.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols1.baseline new file mode 100644 index 0000000000..4bdc6799db --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols1.baseline @@ -0,0 +1,13 @@ +// === Document Symbols === +// === /navigationBarItemsSymbols1.ts === +// <|class [|{| name: C, kind: Class |}C|] { +// <|[|{| name: [Symbol.isRegExp], kind: Property |}[Symbol.isRegExp]|] = 0;|> +// <|[|{| name: [Symbol.iterator], kind: Method |}[Symbol.iterator]|]() { }|> +// <|get [|{| name: [Symbol.isConcatSpreadable], kind: Property |}[Symbol.isConcatSpreadable]|]() { }|> +// }|> + +// === Details === +(Class) C + (Property) [Symbol.isRegExp] + (Method) [Symbol.iterator] + (Property) [Symbol.isConcatSpreadable] diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols2.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols2.baseline new file mode 100644 index 0000000000..aa1023457f --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols2.baseline @@ -0,0 +1,11 @@ +// === Document Symbols === +// === /navigationBarItemsSymbols2.ts === +// <|interface [|{| name: I, kind: Interface |}I|] { +// <|[|{| name: [Symbol.isRegExp], kind: Property |}[Symbol.isRegExp]|]: string;|> +// <|[|{| name: [Symbol.iterator], kind: Method |}[Symbol.iterator]|](): string;|> +// }|> + +// === Details === +(Interface) I + (Property) [Symbol.isRegExp] + (Method) [Symbol.iterator] diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols3.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols3.baseline new file mode 100644 index 0000000000..1b9866ed8d --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols3.baseline @@ -0,0 +1,10 @@ +// === Document Symbols === +// === /navigationBarItemsSymbols3.ts === +// <|enum [|{| name: E, kind: Enum |}E|] { +// // No nav bar entry for this +// <|[|{| name: [Symbol.isRegExp], kind: EnumMember |}[Symbol.isRegExp]|] = 0|> +// }|> + +// === Details === +(Enum) E + (EnumMember) [Symbol.isRegExp] diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols4.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols4.baseline new file mode 100644 index 0000000000..3de61ec63c --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsSymbols4.baseline @@ -0,0 +1,23 @@ +// === Document Symbols === +// === /file.js === +// const <|[|{| name: _sym, kind: Variable |}_sym|] = Symbol("_sym")|>; +// <|class [|{| name: MyClass, kind: Class |}MyClass|] { +// <|[|{| name: constructor, kind: Constructor |}|]constructor() { +// // Dynamic assignment properties can't show up in navigation, +// // as they're not syntactic members +// // Additonally, late bound members are always filtered out, besides +// this[_sym] = "ok"; +// }|> +// +// <|[|{| name: method, kind: Method |}method|]() { +// this[_sym] = "yep"; +// const <|[|{| name: x, kind: Variable |}x|] = this[_sym]|>; +// }|> +// }|> + +// === Details === +(Variable) _sym +(Class) MyClass + (Constructor) constructor + (Method) method + (Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsTypeAlias.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsTypeAlias.baseline new file mode 100644 index 0000000000..42e076d5c2 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarItemsTypeAlias.baseline @@ -0,0 +1,6 @@ +// === Document Symbols === +// === /navigationBarItemsTypeAlias.ts === +// <|type [|{| name: T, kind: Class |}T|] = number | string;|> + +// === Details === +(Class) T diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarJsDoc.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarJsDoc.baseline new file mode 100644 index 0000000000..a71590e3cb --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarJsDoc.baseline @@ -0,0 +1,9 @@ +// === Document Symbols === +// === /foo.js === +// /** <|@typedef {(number|string)} [|{| name: NumberLike, kind: Class |}NumberLike|]|> */ +// /** @typedef {(string|number)} */ +// const <|[|{| name: x, kind: Variable |}x|] = 0|>; + +// === Details === +(Class) NumberLike +(Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarJsDocCommentWithNoTags.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarJsDocCommentWithNoTags.baseline new file mode 100644 index 0000000000..f2aa982d03 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarJsDocCommentWithNoTags.baseline @@ -0,0 +1,7 @@ +// === Document Symbols === +// === /navigationBarJsDocCommentWithNoTags.ts === +// /** Test */ +// export const <|[|{| name: Test, kind: Variable |}Test|] = {}|> + +// === Details === +(Variable) Test diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarMerging.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarMerging.baseline new file mode 100644 index 0000000000..e22b81da37 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarMerging.baseline @@ -0,0 +1,67 @@ +// === Document Symbols === +// === /file1.ts === +// <|module [|{| name: a, kind: Namespace |}a|] { +// <|function [|{| name: foo, kind: Function |}foo|]() {}|> +// }|> +// <|module [|{| name: b, kind: Namespace |}b|] { +// <|function [|{| name: foo, kind: Function |}foo|]() {}|> +// }|> +// module a { +// <|function [|{| name: bar, kind: Function |}bar|]() {}|> +// } + +// === Details === +(Namespace) a + (Function) foo + (Function) bar +(Namespace) b + (Function) foo + + + + +// === Document Symbols === +// === /file2.ts === +// <|module [|{| name: a, kind: Namespace |}a|] {}|> +// <|function [|{| name: a, kind: Function |}a|]() {}|> + +// === Details === +(Namespace) a +(Function) a + + + + +// === Document Symbols === +// === /file3.ts === +// <|module [|{| name: a, kind: Namespace |}a|] { +// <|interface [|{| name: A, kind: Interface |}A|] { +// <|[|{| name: foo, kind: Property |}foo|]: number;|> +// }|> +// }|> +// module a { +// <|interface [|{| name: A, kind: Interface |}A|] { +// <|[|{| name: bar, kind: Property |}bar|]: number;|> +// }|> +// } + +// === Details === +(Namespace) a + (Interface) A + (Property) foo + (Interface) A + (Property) bar + + + + +// === Document Symbols === +// === /file4.ts === +// <|module [|{| name: A, kind: Namespace |}A|] { export var <|[|{| name: x, kind: Variable |}x|]|>; }|> +// <|module [|{| name: A.B, kind: Namespace |}A.B|] { export var <|[|{| name: y, kind: Variable |}y|]|>; }|> + +// === Details === +(Namespace) A + (Variable) x +(Namespace) A.B + (Variable) y diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarMerging_grandchildren.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarMerging_grandchildren.baseline new file mode 100644 index 0000000000..ebf749dba1 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarMerging_grandchildren.baseline @@ -0,0 +1,18 @@ +// === Document Symbols === +// === /navigationBarMerging_grandchildren.ts === +// // Should not merge grandchildren with property assignments +// const <|[|{| name: o, kind: Variable |}o|] = { +// <|[|{| name: a, kind: Property |}a|]: { +// <|[|{| name: m, kind: Method |}m|]() {}|>, +// }|>, +// <|[|{| name: b, kind: Property |}b|]: { +// <|[|{| name: m, kind: Method |}m|]() {}|>, +// }|>, +// }|> + +// === Details === +(Variable) o + (Property) a + (Method) m + (Property) b + (Method) m diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarNamespaceImportWithNoName.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarNamespaceImportWithNoName.baseline new file mode 100644 index 0000000000..7e6f2febaf --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarNamespaceImportWithNoName.baseline @@ -0,0 +1,4 @@ +// === Document Symbols === + + +// === Details === diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarNestedObjectLiterals.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarNestedObjectLiterals.baseline new file mode 100644 index 0000000000..1877f8d900 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarNestedObjectLiterals.baseline @@ -0,0 +1,26 @@ +// === Document Symbols === +// === /navigationBarNestedObjectLiterals.ts === +// var <|[|{| name: a, kind: Variable |}a|] = { +// <|[|{| name: b, kind: Property |}b|]: 0|>, +// <|[|{| name: c, kind: Property |}c|]: {}|>, +// <|[|{| name: d, kind: Property |}d|]: { +// <|[|{| name: e, kind: Property |}e|]: 1|>, +// }|>, +// <|[|{| name: f, kind: Property |}f|]: { +// <|[|{| name: g, kind: Property |}g|]: 2|>, +// <|[|{| name: h, kind: Property |}h|]: { +// <|[|{| name: i, kind: Property |}i|]: 3|>, +// }|>, +// }|>, +// }|> + +// === Details === +(Variable) a + (Property) b + (Property) c + (Property) d + (Property) e + (Property) f + (Property) g + (Property) h + (Property) i diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPrivateName.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPrivateName.baseline new file mode 100644 index 0000000000..ffe6f113c7 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPrivateName.baseline @@ -0,0 +1,19 @@ +// === Document Symbols === +// === /navigationBarPrivateName.ts === +// <|class [|{| name: A, kind: Class |}A|] { +// <|[|{| name: #foo, kind: Property |}#foo|]: () => {|>|> +// <|class [|{| name: B, kind: Class |}B|] { +// <|[|{| name: #bar, kind: Property |}#bar|]: () => {|>|> +// <|function [|{| name: baz, kind: Function |}baz|] () { +// }|> +// } +// } +// } +// } + +// === Details === +(Class) A + (Property) #foo +(Class) B + (Property) #bar +(Function) baz diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPrivateNameMethod.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPrivateNameMethod.baseline new file mode 100644 index 0000000000..0f883cf7d0 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPrivateNameMethod.baseline @@ -0,0 +1,19 @@ +// === Document Symbols === +// === /navigationBarPrivateNameMethod.ts === +// <|class [|{| name: A, kind: Class |}A|] { +// <|[|{| name: #foo, kind: Method |}#foo|]() { +// <|class [|{| name: B, kind: Class |}B|] { +// <|[|{| name: #bar, kind: Method |}#bar|]() { +// <|function [|{| name: baz, kind: Function |}baz|] () { +// }|> +// }|> +// }|> +// }|> +// }|> + +// === Details === +(Class) A + (Method) #foo + (Class) B + (Method) #bar + (Function) baz diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPropertyDeclarations.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPropertyDeclarations.baseline new file mode 100644 index 0000000000..65f06685c4 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarPropertyDeclarations.baseline @@ -0,0 +1,58 @@ +// === Document Symbols === +// === /navigationBarPropertyDeclarations.ts === +// <|class [|{| name: A, kind: Class |}A|] { +// <|public [|{| name: A1, kind: Property |}A1|] = class { +// <|public [|{| name: x, kind: Property |}x|] = 1;|> +// <|private [|{| name: y, kind: Method |}y|]() {}|> +// <|protected [|{| name: z, kind: Method |}z|]() {}|> +// }|> +// +// <|public [|{| name: A2, kind: Property |}A2|] = { +// <|[|{| name: x, kind: Property |}x|]: 1|>, +// <|[|{| name: y, kind: Method |}y|]() {}|>, +// <|[|{| name: z, kind: Method |}z|]() {}|> +// }|> +// +// <|public [|{| name: A3, kind: Property |}A3|] = function () {}|> +// <|public [|{| name: A4, kind: Property |}A4|] = () => {}|> +// <|public [|{| name: A5, kind: Property |}A5|] = 1;|> +// <|public [|{| name: A6, kind: Property |}A6|] = "A6";|> +// +// <|public [|{| name: "A7", kind: Property |}["A7"]|] = class { +// <|public [|{| name: x, kind: Property |}x|] = 1;|> +// <|private [|{| name: y, kind: Method |}y|]() {}|> +// <|protected [|{| name: z, kind: Method |}z|]() {}|> +// }|> +// +// <|public [|{| name: 1, kind: Property |}[1]|] = { +// <|[|{| name: x, kind: Property |}x|]: 1|>, +// <|[|{| name: y, kind: Method |}y|]() {}|>, +// <|[|{| name: z, kind: Method |}z|]() {}|> +// }|> +// +// <|public [|{| name: [1 + 1], kind: Property |}[1 + 1]|] = 1;|> +// }|> + +// === Details === +(Class) A + (Property) A1 + (Property) x + (Method) y + (Method) z + (Property) A2 + (Property) x + (Method) y + (Method) z + (Property) A3 + (Property) A4 + (Property) A5 + (Property) A6 + (Property) "A7" + (Property) x + (Method) y + (Method) z + (Property) 1 + (Property) x + (Method) y + (Method) z + (Property) [1 + 1] diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarVariables.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarVariables.baseline new file mode 100644 index 0000000000..87dbbdfe75 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarVariables.baseline @@ -0,0 +1,24 @@ +// === Document Symbols === +// === /navigationBarVariables.ts === +// var <|[|{| name: x, kind: Variable |}x|] = 0|>; +// let <|[|{| name: y, kind: Variable |}y|] = 1|>; +// const <|[|{| name: z, kind: Variable |}z|] = 2|>; + +// === Details === +(Variable) x +(Variable) y +(Variable) z + + + + +// === Document Symbols === +// === /file2.ts === +// var {<|[|{| name: a, kind: Variable |}a|]|>} = 0; +// let {<|a: [|{| name: b, kind: Variable |}b|]|>} = 0; +// const [<|[|{| name: c, kind: Variable |}c|]|>] = 0; + +// === Details === +(Variable) a +(Variable) b +(Variable) c diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarWellKnownSymbolExpando.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarWellKnownSymbolExpando.baseline new file mode 100644 index 0000000000..5072f6d825 --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarWellKnownSymbolExpando.baseline @@ -0,0 +1,9 @@ +// === Document Symbols === +// === /navigationBarWellKnownSymbolExpando.ts === +// <|function [|{| name: f, kind: Function |}f|]() {}|> +// <|f[[|{| name: Symbol.iterator, kind: Variable |}Symbol.iterator|]]|> = <|[|{| name: , kind: Function |}|]function() {}|> + +// === Details === +(Function) f + (Variable) Symbol.iterator + (Function) diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationBarWithLocalVariables.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarWithLocalVariables.baseline new file mode 100644 index 0000000000..ce7541548e --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationBarWithLocalVariables.baseline @@ -0,0 +1,10 @@ +// === Document Symbols === +// === /navigationBarWithLocalVariables.ts === +// <|function [|{| name: x, kind: Function |}x|](){ +// const <|[|{| name: x, kind: Variable |}x|] = Object()|> +// x.foo = "" +// }|> + +// === Details === +(Function) x + (Variable) x diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationItemsExportDefaultExpression.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationItemsExportDefaultExpression.baseline new file mode 100644 index 0000000000..39a657278e --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationItemsExportDefaultExpression.baseline @@ -0,0 +1,53 @@ +// === Document Symbols === +// === /navigationItemsExportDefaultExpression.ts === +// <|[|{| name: default, kind: Function |}|]export default function () {}|> +// <|[|{| name: default, kind: Function |}|]export default function () { +// return <|class [|{| name: Foo, kind: Class |}Foo|] { +// }|> +// }|> +// +// export default <|[|{| name: default, kind: Function |}|]() => ""|> +// export default <|[|{| name: default, kind: Function |}|]() => { +// return <|class [|{| name: Foo, kind: Class |}Foo|] { +// }|> +// }|> +// +// <|export default function [|{| name: f1, kind: Function |}f1|]() {}|> +// <|export default function [|{| name: f2, kind: Function |}f2|]() { +// return <|class [|{| name: Foo, kind: Class |}Foo|] { +// }|> +// }|> +// +// const <|[|{| name: abc, kind: Variable |}abc|] = 12|>; +// export default abc; +// <|export default class [|{| name: AB, kind: Class |}AB|] {}|> +// export default { +// <|[|{| name: a, kind: Property |}a|]: 1|>, +// <|[|{| name: b, kind: Property |}b|]: 1|>, +// <|[|{| name: c, kind: Property |}c|]: { +// <|[|{| name: d, kind: Property |}d|]: 1|> +// }|> +// } +// +// <|function [|{| name: foo, kind: Function |}foo|](props: { x: number; y: number }) {}|> +// export default foo({ <|[|{| name: x, kind: Property |}x|]: 1|>, <|[|{| name: y, kind: Property |}y|]: 1|> }); + +// === Details === +(Function) default +(Function) default + (Class) Foo +(Function) default +(Function) default + (Class) Foo +(Function) f1 +(Function) f2 + (Class) Foo +(Variable) abc +(Class) AB +(Property) a +(Property) b +(Property) c + (Property) d +(Function) foo +(Property) x +(Property) y diff --git a/testdata/baselines/reference/fourslash/documentSymbols/navigationItemsExportEqualsExpression.baseline b/testdata/baselines/reference/fourslash/documentSymbols/navigationItemsExportEqualsExpression.baseline new file mode 100644 index 0000000000..1055eab22b --- /dev/null +++ b/testdata/baselines/reference/fourslash/documentSymbols/navigationItemsExportEqualsExpression.baseline @@ -0,0 +1,56 @@ +// === Document Symbols === +// === /navigationItemsExportEqualsExpression.ts === +// <|[|{| name: export=, kind: Variable |}export = <|[|{| name: export=, kind: Function |}|]function () {}|>|]|> +// <|[|{| name: export=, kind: Variable |}export = <|[|{| name: export=, kind: Function |}|]function () { +// return <|class [|{| name: Foo, kind: Class |}Foo|] { +// }|> +// }|>|]|> +// +// <|[|{| name: export=, kind: Variable |}export = <|[|{| name: export=, kind: Function |}|]() => ""|>|]|> +// <|[|{| name: export=, kind: Variable |}export = <|[|{| name: export=, kind: Function |}|]() => { +// return <|class [|{| name: Foo, kind: Class |}Foo|] { +// }|> +// }|>|]|> +// +// <|[|{| name: export=, kind: Variable |}export = <|function [|{| name: f1, kind: Function |}f1|]() {}|>|]|> +// <|[|{| name: export=, kind: Variable |}export = <|function [|{| name: f2, kind: Function |}f2|]() { +// return <|class [|{| name: Foo, kind: Class |}Foo|] { +// }|> +// }|>|]|> +// +// const <|[|{| name: abc, kind: Variable |}abc|] = 12|>; +// <|export = [|{| name: export=, kind: Variable |}abc|];|> +// <|[|{| name: export=, kind: Variable |}export = <|class [|{| name: AB, kind: Class |}AB|] {}|>|]|> +// <|[|{| name: export=, kind: Variable |}export = { +// <|[|{| name: a, kind: Property |}a|]: 1|>, +// <|[|{| name: b, kind: Property |}b|]: 1|>, +// <|[|{| name: c, kind: Property |}c|]: { +// <|[|{| name: d, kind: Property |}d|]: 1|> +// }|> +// }|]|> + +// === Details === +(Variable) export= + (Function) export= +(Variable) export= + (Function) export= + (Class) Foo +(Variable) export= + (Function) export= +(Variable) export= + (Function) export= + (Class) Foo +(Variable) export= + (Function) f1 +(Variable) export= + (Function) f2 + (Class) Foo +(Variable) abc +(Variable) export= +(Variable) export= + (Class) AB +(Variable) export= + (Property) a + (Property) b + (Property) c + (Property) d diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc index 44fa8c0917..556862928d 100644 --- a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc @@ -1,6 +1,6 @@ // === goToDefinition === // === /a.js === -// [|module.exports = <|function [|f|]() {}|]|> +// [|module.exports = <|function [|f|]() {}|>|] // === /b.js === // const f = require("./a"); @@ -10,7 +10,7 @@ // === goToDefinition === // === /a.js === -// [|module.exports = <|function [|f|]() {}|]|> +// [|module.exports = <|function [|f|]() {}|>|] // === /bar.ts === // import f = require("./a"); diff --git a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc.diff b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc.diff index a66791c13b..e544b7cc1c 100644 --- a/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc.diff +++ b/testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionSignatureAlias_require.baseline.jsonc.diff @@ -4,7 +4,7 @@ // === goToDefinition === // === /a.js === -// module.exports = <|function [|f|]() {}|> -+// [|module.exports = <|function [|f|]() {}|]|> ++// [|module.exports = <|function [|f|]() {}|>|] // === /b.js === // const f = require("./a"); @@ -13,7 +13,7 @@ // === goToDefinition === // === /a.js === -// module.exports = <|function [|f|]() {}|> -+// [|module.exports = <|function [|f|]() {}|]|> ++// [|module.exports = <|function [|f|]() {}|>|] // === /bar.ts === // import f = require("./a"); \ No newline at end of file