@@ -287,55 +287,45 @@ func getPossibleTypeArgumentsInfo(tokenIn *ast.Node, sourceFile *ast.SourceFile)
287287 }
288288 }
289289 remainingLessThanTokens --
290- break
291290 case ast .KindGreaterThanGreaterThanGreaterThanToken :
292291 remainingLessThanTokens = + 3
293- break
294292 case ast .KindGreaterThanGreaterThanToken :
295293 remainingLessThanTokens = + 2
296- break
297294 case ast .KindGreaterThanToken :
298295 remainingLessThanTokens ++
299- break
300296 case ast .KindCloseBraceToken :
301297 // This can be object type, skip until we find the matching open brace token
302298 // Skip until the matching open brace token
303299 token = findPrecedingMatchingToken (token , ast .KindOpenBraceToken , sourceFile )
304300 if token == nil {
305301 return nil
306302 }
307- break
308303 case ast .KindCloseParenToken :
309304 // This can be object type, skip until we find the matching open brace token
310305 // Skip until the matching open brace token
311306 token = findPrecedingMatchingToken (token , ast .KindOpenParenToken , sourceFile )
312307 if token == nil {
313308 return nil
314309 }
315- break
316310 case ast .KindCloseBracketToken :
317311 // This can be object type, skip until we find the matching open brace token
318312 // Skip until the matching open brace token
319313 token = findPrecedingMatchingToken (token , ast .KindOpenBracketToken , sourceFile )
320314 if token == nil {
321315 return nil
322316 }
323- break
324-
325- // Valid tokens in a type name. Skip.
326317 case ast .KindCommaToken :
318+ // Valid tokens in a type name. Skip.
327319 nTypeArguments ++
328- break
329320 case ast .KindEqualsGreaterThanToken , ast .KindIdentifier , ast .KindStringLiteral , ast .KindNumericLiteral ,
330321 ast .KindBigIntLiteral , ast .KindTrueKeyword , ast .KindFalseKeyword , ast .KindTypeOfKeyword , ast .KindExtendsKeyword ,
331322 ast .KindKeyOfKeyword , ast .KindDotToken , ast .KindBarToken , ast .KindQuestionToken , ast .KindColonToken :
332- break
323+ // do nothing
333324 default :
334- if ast .IsTypeNode (token ) {
335- break
325+ if ! ast .IsTypeNode (token ) {
326+ // Invalid token in type
327+ return nil
336328 }
337- // Invalid token in type
338- return nil
339329 }
340330 token = astnav .FindPrecedingToken (sourceFile , token .Pos ())
341331 }
@@ -1215,15 +1205,18 @@ func getAdjustedLocationForImportDeclaration(node *ast.ImportDeclaration, forRen
12151205 // import /**/type { propertyName as [|name|] } from ...;
12161206 // import /**/type * as [|name|] from ...;
12171207 if namedBindings := node .ImportClause .AsImportClause ().NamedBindings ; namedBindings != nil {
1218- if namedBindings .Kind == ast .KindNamedImports {
1208+ switch namedBindings .Kind {
1209+ case ast .KindNamedImports :
12191210 // do nothing if there is more than one binding
12201211 elements := namedBindings .AsNamedImports ().Elements
12211212 if len (elements .Nodes ) != 1 {
12221213 return nil
12231214 }
12241215 return elements .Nodes [0 ].Name ()
1225- } else if namedBindings .Kind == ast .KindNamespaceImport {
1216+
1217+ case ast .KindNamespaceImport :
12261218 return namedBindings .Name ()
1219+
12271220 }
12281221 }
12291222 }
@@ -1244,14 +1237,15 @@ func getAdjustedLocationForExportDeclaration(node *ast.ExportDeclaration, forRen
12441237 // export /**/type { [|name|] } from ...
12451238 // export /**/type { propertyName as [|name|] } from ...
12461239 // export /**/type * as [|name|] ...
1247- if node .ExportClause .Kind == ast .KindNamedExports {
1240+ switch node .ExportClause .Kind {
1241+ case ast .KindNamedExports :
12481242 // do nothing if there is more than one binding
12491243 elements := node .ExportClause .AsNamedExports ().Elements
12501244 if len (elements .Nodes ) != 1 {
12511245 return nil
12521246 }
12531247 return elements .Nodes [0 ].Name ()
1254- } else if node . ExportClause . Kind == ast .KindNamespaceExport {
1248+ case ast .KindNamespaceExport :
12551249 return node .ExportClause .Name ()
12561250 }
12571251 }
@@ -1641,12 +1635,13 @@ func findPrecedingMatchingToken(token *ast.Node, matchingTokenKind ast.Kind, sou
16411635 return nil
16421636 }
16431637 token = preceding
1644- if token .Kind == matchingTokenKind {
1638+ switch token .Kind {
1639+ case matchingTokenKind :
16451640 if remainingMatchingTokens == 0 {
16461641 return token
16471642 }
16481643 remainingMatchingTokens --
1649- } else if token . Kind == tokenKind {
1644+ case tokenKind :
16501645 remainingMatchingTokens ++
16511646 }
16521647 }
0 commit comments