Skip to content

Commit dedfbd9

Browse files
authored
fix(2074): No quick info on function and other similar tokens (#2078)
1 parent 61246af commit dedfbd9

19 files changed

+238
-39
lines changed

internal/checker/checker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30518,7 +30518,7 @@ func (c *Checker) getSymbolAtLocation(node *ast.Node, ignoreErrors bool) *ast.Sy
3051830518
}
3051930519
return nil
3052030520
case ast.KindDefaultKeyword, ast.KindFunctionKeyword, ast.KindEqualsGreaterThanToken, ast.KindClassKeyword:
30521-
return c.getSymbolOfNode(node)
30521+
return c.getSymbolOfNode(node.Parent)
3052230522
case ast.KindImportType:
3052330523
if ast.IsLiteralImportTypeNode(node) {
3052430524
return c.getSymbolAtLocation(node.AsImportTypeNode().Argument.AsLiteralTypeNode().Literal, ignoreErrors)

internal/checker/nodebuilderimpl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,9 @@ func (b *NodeBuilderImpl) getNameOfSymbolAsWritten(symbol *ast.Symbol) string {
886886
if len(name) > 0 {
887887
return name
888888
}
889+
if symbol.Name == ast.InternalSymbolNameMissing {
890+
return "__missing"
891+
}
889892
return symbol.Name
890893
}
891894

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package fourslash_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/microsoft/typescript-go/internal/fourslash"
7+
"github.com/microsoft/typescript-go/internal/testutil"
8+
)
9+
10+
func TestQuickInfoFunction(t *testing.T) {
11+
t.Parallel()
12+
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
13+
const content = `/**/function foo() { return "hi"; }`
14+
15+
f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
16+
f.VerifyQuickInfoAt(t, "", "function foo(): string", "")
17+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// === documentHighlights ===
22
// === /documentHighlights_40082.ts ===
33
// export = (state, messages) => {
4-
// export /*HIGHLIGHTS*/default {
4+
// export /*HIGHLIGHTS*/[|default|] {
55
// }
66
// }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// === findAllReferences ===
22
// === /findAllRefsExportDefaultClassConstructor.ts ===
33
// export default class {
4-
// /*FIND ALL REFS*/constructor() {}
4+
// /*FIND ALL REFS*/[|constructor|]() {}
55
// }

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForDefaultExport04.baseline.jsonc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,30 @@
2323
// === findAllReferences ===
2424
// === /a.ts ===
2525
// const a = 0;
26-
// export /*FIND ALL REFS*/default a;
26+
// export /*FIND ALL REFS*/[|default|] a;
27+
28+
// === /b.ts ===
29+
// import [|a|] from "./a";
30+
// [|a|];
2731

2832

2933

3034
// === findAllReferences ===
35+
// === /a.ts ===
36+
// const a = 0;
37+
// export [|default|] a;
38+
3139
// === /b.ts ===
3240
// import /*FIND ALL REFS*/[|a|] from "./a";
3341
// [|a|];
3442

3543

3644

3745
// === findAllReferences ===
46+
// === /a.ts ===
47+
// const a = 0;
48+
// export [|default|] a;
49+
3850
// === /b.ts ===
3951
// import [|a|] from "./a";
4052
// /*FIND ALL REFS*/[|a|];
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
// === findAllReferences ===
22
// === /a.ts ===
3-
// export /*FIND ALL REFS*/default 1;
3+
// export /*FIND ALL REFS*/[|default|] 1;
4+
5+
// === /b.ts ===
6+
// import [|a|] from "./a";

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsForFunctionExpression01.baseline.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// === findAllReferences ===
22
// === /file1.ts ===
3-
// var foo = /*FIND ALL REFS*/function foo(a = foo(), b = () => foo) {
4-
// foo(foo, foo);
3+
// var foo = /*FIND ALL REFS*/function [|foo|](a = [|foo|](), b = () => [|foo|]) {
4+
// [|foo|]([|foo|], [|foo|]);
55
// }
66

77

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames8.baseline.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// === findAllReferences ===
22
// === /findAllRefsWithLeadingUnderscoreNames8.ts ===
33
// (/*FIND ALL REFS*/function __foo() {
4-
// __foo();
4+
// [|__foo|]();
55
// })
66

77

testdata/baselines/reference/fourslash/findAllReferences/findAllRefsWithLeadingUnderscoreNames9.baseline.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// === findAllReferences ===
22
// === /findAllRefsWithLeadingUnderscoreNames9.ts ===
33
// (/*FIND ALL REFS*/function ___foo() {
4-
// ___foo();
4+
// [|___foo|]();
55
// })
66

77

0 commit comments

Comments
 (0)