@@ -661,6 +661,11 @@ module ts {
661
661
return callback ( globals ) ;
662
662
}
663
663
664
+ function getQualifiedLeftMeaning ( rightMeaning : SymbolFlags ) {
665
+ // If we are looking in value space, the parent meaning is value, other wise it is namespace
666
+ return rightMeaning === SymbolFlags . Value ? SymbolFlags . Value : SymbolFlags . Namespace ;
667
+ }
668
+
664
669
function getAccessibleSymbolChain ( symbol : Symbol , enclosingDeclaration : Node , meaning : SymbolFlags ) : Symbol [ ] {
665
670
function getAccessibleSymbolChainFromSymbolTable ( symbols : SymbolTable ) : Symbol [ ] {
666
671
function canQualifySymbol ( symbolFromSymbolTable : Symbol , meaning : SymbolFlags ) {
@@ -670,7 +675,7 @@ module ts {
670
675
}
671
676
672
677
// If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too
673
- var accessibleParent = getAccessibleSymbolChain ( symbolFromSymbolTable . parent , enclosingDeclaration , SymbolFlags . Namespace ) ;
678
+ var accessibleParent = getAccessibleSymbolChain ( symbolFromSymbolTable . parent , enclosingDeclaration , getQualifiedLeftMeaning ( meaning ) ) ;
674
679
return ! ! accessibleParent ;
675
680
}
676
681
@@ -698,7 +703,7 @@ module ts {
698
703
// Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain
699
704
// but only if the symbolFromSymbolTable can be qualified
700
705
var accessibleSymbolsFromExports = resolvedImportedSymbol . exports ? getAccessibleSymbolChainFromSymbolTable ( resolvedImportedSymbol . exports ) : undefined ;
701
- if ( accessibleSymbolsFromExports && canQualifySymbol ( symbolFromSymbolTable , SymbolFlags . Namespace ) ) {
706
+ if ( accessibleSymbolsFromExports && canQualifySymbol ( symbolFromSymbolTable , getQualifiedLeftMeaning ( meaning ) ) ) {
702
707
return [ symbolFromSymbolTable ] . concat ( accessibleSymbolsFromExports ) ;
703
708
}
704
709
}
@@ -758,8 +763,6 @@ module ts {
758
763
return { accessibility : SymbolAccessibility . Accessible , aliasesToMakeVisible : hasAccessibleDeclarations . aliasesToMakeVisible } ;
759
764
}
760
765
761
- // TODO(shkamat): Handle static method of class
762
-
763
766
// If we havent got the accessible symbol doesnt mean the symbol is actually inaccessible.
764
767
// It could be qualified symbol and hence verify the path
765
768
// eg:
@@ -772,7 +775,7 @@ module ts {
772
775
// we are going to see if c can be accessed in scope directly.
773
776
// But it cant, hence the accessible is going to be undefined, but that doesnt mean m.c is accessible
774
777
// It is accessible if the parent m is accessible because then m.c can be accessed through qualification
775
- meaningToLook = SymbolFlags . Namespace ;
778
+ meaningToLook = getQualifiedLeftMeaning ( meaning ) ;
776
779
symbol = symbol . parent ;
777
780
}
778
781
@@ -851,14 +854,14 @@ module ts {
851
854
var symbolName : string ;
852
855
while ( symbol ) {
853
856
var isFirstName = ! symbolName ;
854
- var meaningToLook = isFirstName ? meaning : SymbolFlags . Namespace ;
855
- var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaningToLook ) ;
857
+ var accessibleSymbolChain = getAccessibleSymbolChain ( symbol , enclosingDeclaration , meaning ) ;
856
858
var currentSymbolName = accessibleSymbolChain ? ts . map ( accessibleSymbolChain , accessibleSymbol => getSymbolName ( accessibleSymbol ) ) . join ( "." ) : getSymbolName ( symbol ) ;
857
859
symbolName = currentSymbolName + ( isFirstName ? "" : ( "." + symbolName ) ) ;
858
- if ( accessibleSymbolChain && ! needsQualification ( accessibleSymbolChain [ 0 ] , enclosingDeclaration , accessibleSymbolChain . length === 1 ? meaningToLook : SymbolFlags . Namespace ) ) {
860
+ if ( accessibleSymbolChain && ! needsQualification ( accessibleSymbolChain [ 0 ] , enclosingDeclaration , accessibleSymbolChain . length === 1 ? meaning : getQualifiedLeftMeaning ( meaning ) ) ) {
859
861
break ;
860
862
}
861
863
symbol = accessibleSymbolChain ? accessibleSymbolChain [ 0 ] . parent : symbol . parent ;
864
+ meaning = getQualifiedLeftMeaning ( meaning ) ;
862
865
}
863
866
864
867
return symbolName ;
0 commit comments