Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fourslash_test

import (
"testing"

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

func TestFindAllReferencesJSDocPrivateIdentifier(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `
class C {
/*1*/#field;
/**
* @see C./*2*/#field
*/
method() {}
}
`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()

f.VerifyBaselineFindAllReferences(t, "1", "2")
}
20 changes: 16 additions & 4 deletions internal/ls/findallreferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,9 @@ func getRangeOfNode(node *ast.Node, sourceFile *ast.SourceFile, endNode *ast.Nod
func isValidReferencePosition(node *ast.Node, searchSymbolName string) bool {
switch node.Kind {
case ast.KindPrivateIdentifier:
// !!!
// if (isJSDocMemberName(node.Parent)) {
// return true;
// }
if isJSDocMemberName(node.Parent) {
return true
}
Comment on lines 350 to +353
return len(node.Text()) == len(searchSymbolName)
Comment on lines 348 to 354
case ast.KindIdentifier:
return len(node.Text()) == len(searchSymbolName)
Expand Down Expand Up @@ -2652,3 +2651,16 @@ func (state *refState) explicitlyInheritsFrom(symbol *ast.Symbol, parent *ast.Sy
state.inheritsFromCache[key] = inherits
return inherits
}

func isJSDocMemberName(node *ast.Node) bool {
if node == nil {
return false
}
if node.Kind == ast.KindIdentifier || node.Kind == ast.KindPrivateIdentifier {
return true
}
if node.Kind == ast.KindPropertyAccessExpression {
return isJSDocMemberName(node.AsPropertyAccessExpression().Name())
}
return false
}
Comment on lines +2655 to +2666
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// === findAllReferences ===
// === /findAllReferencesJSDocPrivateIdentifier.ts ===
//
// class C {
// /*FIND ALL REFS*/[|#field|];
// /**
// * @see C.#field
// */
// --- (line: 7) skipped ---



// === findAllReferences ===
// === /findAllReferencesJSDocPrivateIdentifier.ts ===
//
// class C {
// #field;
// /**
// * @see C./*FIND ALL REFS*/#field
// */
// method() {}
// }
//
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- old.findAllReferencesJSDocPrivateIdentifier.baseline.jsonc
+++ new.findAllReferencesJSDocPrivateIdentifier.baseline.jsonc
@@= skipped --1, +0 lines =@@
+// === findAllReferences ===
+// === /findAllReferencesJSDocPrivateIdentifier.ts ===
+//
+// class C {
+// /*FIND ALL REFS*/[|#field|];
+// /**
+// * @see C.#field
+// */
+// --- (line: 7) skipped ---
+
+
+
+// === findAllReferences ===
+// === /findAllReferencesJSDocPrivateIdentifier.ts ===
+//
+// class C {
+// #field;
+// /**
+// * @see C./*FIND ALL REFS*/#field
+// */
+// method() {}
+// }
+//
1 change: 1 addition & 0 deletions testdata/submoduleAccepted.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1412,3 +1412,4 @@ conformance/callbackTagVariadicType.js.diff
# definiteAssignment shorthand in object literal loses optional modifier
## https://github.com/microsoft/typescript-go/issues/3563
conformance/definiteAssignmentAssertionsWithObjectShortHand.js.diff
fourslash/findAllReferences/findAllReferencesJSDocPrivateIdentifier.baseline.jsonc.diff