Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -30518,7 +30518,7 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy
}
return nil
case ast.KindDefaultKeyword, ast.KindFunctionKeyword, ast.KindEqualsGreaterThanToken, ast.KindClassKeyword:
return c.getSymbolOfNode(node)
return c.getSymbolOfNode(node.Parent)
case ast.KindImportType:
if ast.IsLiteralImportTypeNode(node) {
return c.getSymbolAtLocation(node.AsImportTypeNode().Argument.AsLiteralTypeNode().Literal, ignoreErrors)
Expand Down
3 changes: 3 additions & 0 deletions internal/checker/nodebuilderimpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ func (b *NodeBuilderImpl) getNameOfSymbolAsWritten(symbol *ast.Symbol) string {
if len(name) > 0 {
return name
}
if symbol.Name == ast.InternalSymbolNameMissing {
return "__missing"
}
return symbol.Name
}

Expand Down
17 changes: 17 additions & 0 deletions internal/fourslash/tests/quickInfoFunction_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/typescript-go/internal/fourslash"
"github.com/microsoft/typescript-go/internal/testutil"
)

func TestQuickInfoFunction(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `/**/function foo() { return "hi"; }`

f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
f.VerifyQuickInfoAt(t, "", "function foo(): string", "")
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// === documentHighlights ===
// === /documentHighlights_40082.ts ===
// export = (state, messages) => {
// export /*HIGHLIGHTS*/default {
// export /*HIGHLIGHTS*/[|default|] {
// }
// }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// === findAllReferences ===
// === /findAllRefsExportDefaultClassConstructor.ts ===
// export default class {
// /*FIND ALL REFS*/constructor() {}
// /*FIND ALL REFS*/[|constructor|]() {}
// }
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,30 @@
// === findAllReferences ===
// === /a.ts ===
// const a = 0;
// export /*FIND ALL REFS*/default a;
// export /*FIND ALL REFS*/[|default|] a;

// === /b.ts ===
// import [|a|] from "./a";
// [|a|];



// === findAllReferences ===
// === /a.ts ===
// const a = 0;
// export [|default|] a;

// === /b.ts ===
// import /*FIND ALL REFS*/[|a|] from "./a";
// [|a|];



// === findAllReferences ===
// === /a.ts ===
// const a = 0;
// export [|default|] a;

// === /b.ts ===
// import [|a|] from "./a";
// /*FIND ALL REFS*/[|a|];
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// === findAllReferences ===
// === /a.ts ===
// export /*FIND ALL REFS*/default 1;
// export /*FIND ALL REFS*/[|default|] 1;

// === /b.ts ===
// import [|a|] from "./a";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /file1.ts ===
// var foo = /*FIND ALL REFS*/function foo(a = foo(), b = () => foo) {
// foo(foo, foo);
// var foo = /*FIND ALL REFS*/function [|foo|](a = [|foo|](), b = () => [|foo|]) {
// [|foo|]([|foo|], [|foo|]);
// }


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /findAllRefsWithLeadingUnderscoreNames8.ts ===
// (/*FIND ALL REFS*/function __foo() {
// __foo();
// [|__foo|]();
// })


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// === findAllReferences ===
// === /findAllRefsWithLeadingUnderscoreNames9.ts ===
// (/*FIND ALL REFS*/function ___foo() {
// ___foo();
// [|___foo|]();
// })


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@
// const enum E {
// }
// async function fn() {}
// export /*FIND ALL REFS*/default class C2 {}
// export /*FIND ALL REFS*/[|default|] class C2 {}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// === goToDefinition ===
// === /goToDefinitionSwitchCase5.ts ===
// export /*GOTO DEF*/default {}
// [|export /*GOTO DEF*/default {}|]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// === /goToDefinitionSwitchCase7.ts ===
// switch (null) {
// case null:
// export /*GOTO DEF*/default 123;
// [|export /*GOTO DEF*/default 123;|]
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
// * @type {number}
// */
// export default 10;
// ^
// ^^^^^^^
// | ----------------------------------------------------------------------
// | No quickinfo at /*1*/.
// | ```tsx
// | (property) default: 10
// | ```
// | Comment
// | ----------------------------------------------------------------------
=== /test.ts ===
// export { default as test } from "./jsDocAliasQuickInfo";
Expand All @@ -32,7 +35,22 @@
"Name": "1",
"Data": {}
},
"item": null
"item": {
"contents": {
"kind": "markdown",
"value": "```tsx\n(property) default: 10\n```\nComment"
},
"range": {
"start": {
"line": 4,
"character": 7
},
"end": {
"line": 4,
"character": 14
}
}
}
},
{
"marker": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
// | ----------------------------------------------------------------------
// | No quickinfo at /*1*/.
// | ----------------------------------------------------------------------
// ^
// ^^^^^^^
// | ----------------------------------------------------------------------
// | No quickinfo at /*2*/.
// | ```tsx
// | class default
// | ```
// |
// | ----------------------------------------------------------------------
// ^
// ^^^^^
// | ----------------------------------------------------------------------
// | No quickinfo at /*3*/.
// | ```tsx
// | class default
// | ```
// |
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
Expand Down Expand Up @@ -41,7 +47,22 @@
"Name": "2",
"Data": {}
},
"item": null
"item": {
"contents": {
"kind": "markdown",
"value": "```tsx\nclass default\n```\n"
},
"range": {
"start": {
"line": 0,
"character": 7
},
"end": {
"line": 0,
"character": 14
}
}
}
},
{
"marker": {
Expand All @@ -53,7 +74,22 @@
"Name": "3",
"Data": {}
},
"item": null
"item": {
"contents": {
"kind": "markdown",
"value": "```tsx\nclass default\n```\n"
},
"range": {
"start": {
"line": 0,
"character": 15
},
"end": {
"line": 0,
"character": 20
}
}
}
},
{
"marker": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@
// | ----------------------------------------------------------------------
// | No quickinfo at /*1*/.
// | ----------------------------------------------------------------------
// ^
// ^^^^^^^
// | ----------------------------------------------------------------------
// | No quickinfo at /*2*/.
// | ```tsx
// | class C
// | ```
// |
// | ----------------------------------------------------------------------
// ^
// ^^^^^
// | ----------------------------------------------------------------------
// | No quickinfo at /*3*/.
// | ```tsx
// | class C
// | ```
// |
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
Expand Down Expand Up @@ -48,7 +54,22 @@
"Name": "2",
"Data": {}
},
"item": null
"item": {
"contents": {
"kind": "markdown",
"value": "```tsx\nclass C\n```\n"
},
"range": {
"start": {
"line": 0,
"character": 7
},
"end": {
"line": 0,
"character": 14
}
}
}
},
{
"marker": {
Expand All @@ -60,7 +81,22 @@
"Name": "3",
"Data": {}
},
"item": null
"item": {
"contents": {
"kind": "markdown",
"value": "```tsx\nclass C\n```\n"
},
"range": {
"start": {
"line": 0,
"character": 15
},
"end": {
"line": 0,
"character": 20
}
}
}
},
{
"marker": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// === QuickInfo ===
=== /quickInfoDisplayPartsClassIncomplete.ts ===
// class {
// ^
// ^^^^^
// | ----------------------------------------------------------------------
// | No quickinfo at /*1*/.
// | ```tsx
// | class __missing
// | ```
// |
// | ----------------------------------------------------------------------
// ^
// | ----------------------------------------------------------------------
Expand All @@ -21,7 +24,22 @@
"Name": "1",
"Data": {}
},
"item": null
"item": {
"contents": {
"kind": "markdown",
"value": "```tsx\nclass __missing\n```\n"
},
"range": {
"start": {
"line": 0,
"character": 0
},
"end": {
"line": 0,
"character": 5
}
}
}
},
{
"marker": {
Expand Down
Loading