@@ -2902,23 +2902,30 @@ namespace ts {
29022902 let jsx = options . jsx !== JsxEmit . None ;
29032903 let target = options . target ;
29042904
2905- // Find the node where completion is requested on, in the case of a completion after
2906- // a dot, it is the member access expression other wise, it is a request for all
2907- // visible symbols in the scope, and the node is the current location .
2905+ // Find the node where completion is requested on.
2906+ // Also determine whether we are trying to complete with members of that node
2907+ // or attributes of a JSX tag .
29082908 let node = currentToken ;
29092909 let isRightOfDot = false ;
29102910 let isRightOfOpenTag = false ;
29112911
29122912 let location = getTouchingPropertyName ( sourceFile , position ) ;
2913- if ( contextToken ) {
2914- let kind = contextToken . kind ;
2915- if ( kind === SyntaxKind . DotToken && contextToken . parent . kind === SyntaxKind . PropertyAccessExpression ) {
2916- node = ( < PropertyAccessExpression > contextToken . parent ) . expression ;
2917- isRightOfDot = true ;
2918- }
2919- else if ( kind === SyntaxKind . DotToken && contextToken . parent . kind === SyntaxKind . QualifiedName ) {
2920- node = ( < QualifiedName > contextToken . parent ) . left ;
2921- isRightOfDot = true ;
2913+ if ( contextToken ) {
2914+ let { parent, kind } = contextToken ;
2915+ if ( kind === SyntaxKind . DotToken ) {
2916+ if ( parent . kind === SyntaxKind . PropertyAccessExpression ) {
2917+ node = ( < PropertyAccessExpression > contextToken . parent ) . expression ;
2918+ isRightOfDot = true ;
2919+ }
2920+ else if ( parent . kind === SyntaxKind . QualifiedName ) {
2921+ node = ( < QualifiedName > contextToken . parent ) . left ;
2922+ isRightOfDot = true ;
2923+ }
2924+ else {
2925+ // There is nothing that precedes the dot, so this likely just a stray character
2926+ // or leading into a '...' token. Just bail out instead.
2927+ return undefined ;
2928+ }
29222929 }
29232930 else if ( kind === SyntaxKind . LessThanToken && sourceFile . languageVariant === LanguageVariant . JSX ) {
29242931 isRightOfOpenTag = true ;
0 commit comments