@@ -1906,13 +1906,28 @@ namespace ts.FindAllReferences {
19061906 function populateSearchSymbolSet ( symbol : Symbol , location : Node , checker : TypeChecker , isForRename : boolean , providePrefixAndSuffixText : boolean , implementations : boolean ) : Symbol [ ] {
19071907 const result : Symbol [ ] = [ ] ;
19081908 forEachRelatedSymbol < void > ( symbol , location , checker , isForRename , ! ( isForRename && providePrefixAndSuffixText ) ,
1909- ( sym , root , base ) => { result . push ( base || root || sym ) ; } ,
1910- /*allowBaseTypes*/ ( ) => ! implementations ) ;
1909+ ( sym , root , base ) => {
1910+ // static method/property and instance method/property might have the same name. Only include static or only include instance.
1911+ if ( base ) {
1912+ if ( isStatic ( symbol ) !== isStatic ( base ) ) {
1913+ base = undefined ;
1914+ }
1915+ }
1916+ result . push ( base || root || sym ) ;
1917+ } ,
1918+ // when try to find implementation, implementations is true, and not allowed to find base class
1919+ /*allowBaseTypes*/ ( ) => ! implementations ) ;
19111920 return result ;
19121921 }
19131922
1923+ /**
1924+ * @param allowBaseTypes return true means it would try to find in base class or interface.
1925+ */
19141926 function forEachRelatedSymbol < T > (
19151927 symbol : Symbol , location : Node , checker : TypeChecker , isForRenamePopulateSearchSymbolSet : boolean , onlyIncludeBindingElementAtReferenceLocation : boolean ,
1928+ /**
1929+ * @param baseSymbol This symbol means one property/mehtod from base class or interface when it is not null or undefined,
1930+ */
19161931 cbSymbol : ( symbol : Symbol , rootSymbol ?: Symbol , baseSymbol ?: Symbol , kind ?: NodeEntryKind ) => T | undefined ,
19171932 allowBaseTypes : ( rootSymbol : Symbol ) => boolean ,
19181933 ) : T | undefined {
@@ -2031,16 +2046,33 @@ namespace ts.FindAllReferences {
20312046 readonly symbol : Symbol ;
20322047 readonly kind : NodeEntryKind | undefined ;
20332048 }
2049+
2050+ function isStatic ( symbol : Symbol ) : boolean {
2051+ if ( ! symbol . valueDeclaration ) { return false ; }
2052+ const modifierFlags = getEffectiveModifierFlags ( symbol . valueDeclaration ) ;
2053+ return ! ! ( modifierFlags & ModifierFlags . Static ) ;
2054+ }
2055+
20342056 function getRelatedSymbol ( search : Search , referenceSymbol : Symbol , referenceLocation : Node , state : State ) : RelatedSymbol | undefined {
20352057 const { checker } = state ;
20362058 return forEachRelatedSymbol ( referenceSymbol , referenceLocation , checker , /*isForRenamePopulateSearchSymbolSet*/ false ,
20372059 /*onlyIncludeBindingElementAtReferenceLocation*/ state . options . use !== FindReferencesUse . Rename || ! ! state . options . providePrefixAndSuffixTextForRename ,
2038- ( sym , rootSymbol , baseSymbol , kind ) : RelatedSymbol | undefined => search . includes ( baseSymbol || rootSymbol || sym )
2039- // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol.
2040- ? { symbol : rootSymbol && ! ( getCheckFlags ( sym ) & CheckFlags . Synthetic ) ? rootSymbol : sym , kind }
2041- : undefined ,
2060+ ( sym , rootSymbol , baseSymbol , kind ) : RelatedSymbol | undefined => {
2061+ // check whether the symbol used to search itself is just the searched one.
2062+ if ( baseSymbol ) {
2063+ // static method/property and instance method/property might have the same name. Only check static or only check instance.
2064+ if ( isStatic ( referenceSymbol ) !== isStatic ( baseSymbol ) ) {
2065+ baseSymbol = undefined ;
2066+ }
2067+ }
2068+ return search . includes ( baseSymbol || rootSymbol || sym )
2069+ // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol.
2070+ ? { symbol : rootSymbol && ! ( getCheckFlags ( sym ) & CheckFlags . Synthetic ) ? rootSymbol : sym , kind }
2071+ : undefined ;
2072+ } ,
20422073 /*allowBaseTypes*/ rootSymbol =>
2043- ! ( search . parents && ! search . parents . some ( parent => explicitlyInheritsFrom ( rootSymbol . parent ! , parent , state . inheritsFromCache , checker ) ) ) ) ;
2074+ ! ( search . parents && ! search . parents . some ( parent => explicitlyInheritsFrom ( rootSymbol . parent ! , parent , state . inheritsFromCache , checker ) ) )
2075+ ) ;
20442076 }
20452077
20462078 /**
0 commit comments