@@ -1906,13 +1906,28 @@ namespace ts.FindAllReferences {
1906
1906
function populateSearchSymbolSet ( symbol : Symbol , location : Node , checker : TypeChecker , isForRename : boolean , providePrefixAndSuffixText : boolean , implementations : boolean ) : Symbol [ ] {
1907
1907
const result : Symbol [ ] = [ ] ;
1908
1908
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 ) ;
1911
1920
return result ;
1912
1921
}
1913
1922
1923
+ /**
1924
+ * @param allowBaseTypes return true means it would try to find in base class or interface.
1925
+ */
1914
1926
function forEachRelatedSymbol < T > (
1915
1927
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
+ */
1916
1931
cbSymbol : ( symbol : Symbol , rootSymbol ?: Symbol , baseSymbol ?: Symbol , kind ?: NodeEntryKind ) => T | undefined ,
1917
1932
allowBaseTypes : ( rootSymbol : Symbol ) => boolean ,
1918
1933
) : T | undefined {
@@ -2031,16 +2046,33 @@ namespace ts.FindAllReferences {
2031
2046
readonly symbol : Symbol ;
2032
2047
readonly kind : NodeEntryKind | undefined ;
2033
2048
}
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
+
2034
2056
function getRelatedSymbol ( search : Search , referenceSymbol : Symbol , referenceLocation : Node , state : State ) : RelatedSymbol | undefined {
2035
2057
const { checker } = state ;
2036
2058
return forEachRelatedSymbol ( referenceSymbol , referenceLocation , checker , /*isForRenamePopulateSearchSymbolSet*/ false ,
2037
2059
/*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
+ } ,
2042
2073
/*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
+ ) ;
2044
2076
}
2045
2077
2046
2078
/**
0 commit comments