MCPcopy Create free account
hub / github.com/microsoft/typescript-go / shouldAddSingleReference

Method shouldAddSingleReference

internal/ls/findallreferences.go:2388–2401  ·  view source on GitHub ↗
(singleRef *ast.Node)

Source from the content-addressed store, hash-verified

2386}
2387
2388func (state *refState) shouldAddSingleReference(singleRef *ast.Node) bool {
2389 if !state.hasMatchingMeaning(singleRef) {
2390 return false
2391 }
2392 if state.options.use != referenceUseRename {
2393 return true
2394 }
2395 // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;`
2396 if !ast.IsIdentifier(singleRef) && !ast.IsImportOrExportSpecifier(singleRef.Parent) {
2397 return false
2398 }
2399 // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename.
2400 return !(ast.IsImportOrExportSpecifier(singleRef.Parent) && ast.ModuleExportNameIsDefault(singleRef))
2401}
2402
2403func (state *refState) hasMatchingMeaning(referenceLocation *ast.Node) bool {
2404 return getMeaningFromLocation(referenceLocation)&state.searchMeaning != 0

Callers 1

Calls 4

hasMatchingMeaningMethod · 0.95
IsIdentifierFunction · 0.92

Tested by

no test coverage detected