@@ -287,55 +287,45 @@ func getPossibleTypeArgumentsInfo(tokenIn *ast.Node, sourceFile *ast.SourceFile)
287
287
}
288
288
}
289
289
remainingLessThanTokens --
290
- break
291
290
case ast .KindGreaterThanGreaterThanGreaterThanToken :
292
291
remainingLessThanTokens = + 3
293
- break
294
292
case ast .KindGreaterThanGreaterThanToken :
295
293
remainingLessThanTokens = + 2
296
- break
297
294
case ast .KindGreaterThanToken :
298
295
remainingLessThanTokens ++
299
- break
300
296
case ast .KindCloseBraceToken :
301
297
// This can be object type, skip until we find the matching open brace token
302
298
// Skip until the matching open brace token
303
299
token = findPrecedingMatchingToken (token , ast .KindOpenBraceToken , sourceFile )
304
300
if token == nil {
305
301
return nil
306
302
}
307
- break
308
303
case ast .KindCloseParenToken :
309
304
// This can be object type, skip until we find the matching open brace token
310
305
// Skip until the matching open brace token
311
306
token = findPrecedingMatchingToken (token , ast .KindOpenParenToken , sourceFile )
312
307
if token == nil {
313
308
return nil
314
309
}
315
- break
316
310
case ast .KindCloseBracketToken :
317
311
// This can be object type, skip until we find the matching open brace token
318
312
// Skip until the matching open brace token
319
313
token = findPrecedingMatchingToken (token , ast .KindOpenBracketToken , sourceFile )
320
314
if token == nil {
321
315
return nil
322
316
}
323
- break
324
-
325
- // Valid tokens in a type name. Skip.
326
317
case ast .KindCommaToken :
318
+ // Valid tokens in a type name. Skip.
327
319
nTypeArguments ++
328
- break
329
320
case ast .KindEqualsGreaterThanToken , ast .KindIdentifier , ast .KindStringLiteral , ast .KindNumericLiteral ,
330
321
ast .KindBigIntLiteral , ast .KindTrueKeyword , ast .KindFalseKeyword , ast .KindTypeOfKeyword , ast .KindExtendsKeyword ,
331
322
ast .KindKeyOfKeyword , ast .KindDotToken , ast .KindBarToken , ast .KindQuestionToken , ast .KindColonToken :
332
- break
323
+ // do nothing
333
324
default :
334
- if ast .IsTypeNode (token ) {
335
- break
325
+ if ! ast .IsTypeNode (token ) {
326
+ // Invalid token in type
327
+ return nil
336
328
}
337
- // Invalid token in type
338
- return nil
339
329
}
340
330
token = astnav .FindPrecedingToken (sourceFile , token .Pos ())
341
331
}
@@ -1215,15 +1205,18 @@ func getAdjustedLocationForImportDeclaration(node *ast.ImportDeclaration, forRen
1215
1205
// import /**/type { propertyName as [|name|] } from ...;
1216
1206
// import /**/type * as [|name|] from ...;
1217
1207
if namedBindings := node .ImportClause .AsImportClause ().NamedBindings ; namedBindings != nil {
1218
- if namedBindings .Kind == ast .KindNamedImports {
1208
+ switch namedBindings .Kind {
1209
+ case ast .KindNamedImports :
1219
1210
// do nothing if there is more than one binding
1220
1211
elements := namedBindings .AsNamedImports ().Elements
1221
1212
if len (elements .Nodes ) != 1 {
1222
1213
return nil
1223
1214
}
1224
1215
return elements .Nodes [0 ].Name ()
1225
- } else if namedBindings .Kind == ast .KindNamespaceImport {
1216
+
1217
+ case ast .KindNamespaceImport :
1226
1218
return namedBindings .Name ()
1219
+
1227
1220
}
1228
1221
}
1229
1222
}
@@ -1244,14 +1237,15 @@ func getAdjustedLocationForExportDeclaration(node *ast.ExportDeclaration, forRen
1244
1237
// export /**/type { [|name|] } from ...
1245
1238
// export /**/type { propertyName as [|name|] } from ...
1246
1239
// export /**/type * as [|name|] ...
1247
- if node .ExportClause .Kind == ast .KindNamedExports {
1240
+ switch node .ExportClause .Kind {
1241
+ case ast .KindNamedExports :
1248
1242
// do nothing if there is more than one binding
1249
1243
elements := node .ExportClause .AsNamedExports ().Elements
1250
1244
if len (elements .Nodes ) != 1 {
1251
1245
return nil
1252
1246
}
1253
1247
return elements .Nodes [0 ].Name ()
1254
- } else if node . ExportClause . Kind == ast .KindNamespaceExport {
1248
+ case ast .KindNamespaceExport :
1255
1249
return node .ExportClause .Name ()
1256
1250
}
1257
1251
}
@@ -1641,12 +1635,13 @@ func findPrecedingMatchingToken(token *ast.Node, matchingTokenKind ast.Kind, sou
1641
1635
return nil
1642
1636
}
1643
1637
token = preceding
1644
- if token .Kind == matchingTokenKind {
1638
+ switch token .Kind {
1639
+ case matchingTokenKind :
1645
1640
if remainingMatchingTokens == 0 {
1646
1641
return token
1647
1642
}
1648
1643
remainingMatchingTokens --
1649
- } else if token . Kind == tokenKind {
1644
+ case tokenKind :
1650
1645
remainingMatchingTokens ++
1651
1646
}
1652
1647
}
0 commit comments