@@ -89,45 +89,37 @@ namespace ts.NavigateTo {
89
89
}
90
90
91
91
function tryAddSingleDeclarationName ( declaration : Declaration , containers : string [ ] ) : boolean {
92
- if ( declaration ) {
93
- const name = getNameOfDeclaration ( declaration ) ;
94
- if ( name ) {
95
- const text = getTextOfIdentifierOrLiteral ( name as ( Identifier | LiteralExpression ) ) ;
96
- if ( text !== undefined ) {
97
- containers . unshift ( text ) ;
98
- }
99
- else if ( name . kind === SyntaxKind . ComputedPropertyName ) {
100
- return tryAddComputedPropertyName ( name . expression , containers , /*includeLastPortion*/ true ) ;
101
- }
102
- else {
103
- // Don't know how to add this.
104
- return false ;
105
- }
106
- }
92
+ const name = getNameOfDeclaration ( declaration ) ;
93
+ if ( name && isPropertyNameLiteral ( name ) ) {
94
+ containers . unshift ( getTextOfIdentifierOrLiteral ( name ) ) ;
95
+ return true ;
96
+ }
97
+ else if ( name && name . kind === SyntaxKind . ComputedPropertyName ) {
98
+ return tryAddComputedPropertyName ( name . expression , containers , /*includeLastPortion*/ true ) ;
99
+ }
100
+ else {
101
+ // Don't know how to add this.
102
+ return false ;
107
103
}
108
-
109
- return true ;
110
104
}
111
105
112
106
// Only added the names of computed properties if they're simple dotted expressions, like:
113
107
//
114
108
// [X.Y.Z]() { }
115
109
function tryAddComputedPropertyName ( expression : Expression , containers : string [ ] , includeLastPortion : boolean ) : boolean {
116
- const text = getTextOfIdentifierOrLiteral ( expression as LiteralExpression ) ;
117
- if ( text !== undefined ) {
110
+ if ( isPropertyNameLiteral ( expression ) ) {
111
+ const text = getTextOfIdentifierOrLiteral ( expression ) ;
118
112
if ( includeLastPortion ) {
119
113
containers . unshift ( text ) ;
120
114
}
121
115
return true ;
122
116
}
123
-
124
- if ( expression . kind === SyntaxKind . PropertyAccessExpression ) {
125
- const propertyAccess = < PropertyAccessExpression > expression ;
117
+ if ( isPropertyAccessExpression ( expression ) ) {
126
118
if ( includeLastPortion ) {
127
- containers . unshift ( propertyAccess . name . text ) ;
119
+ containers . unshift ( expression . name . text ) ;
128
120
}
129
121
130
- return tryAddComputedPropertyName ( propertyAccess . expression , containers , /*includeLastPortion*/ true ) ;
122
+ return tryAddComputedPropertyName ( expression . expression , containers , /*includeLastPortion*/ true ) ;
131
123
}
132
124
133
125
return false ;
0 commit comments