@@ -350,23 +350,26 @@ def Exit():
350
350
return Exit ()
351
351
except Linter .Cancel as e :
352
352
scriptName = None
353
- if stat :
354
- if stat .type == self .sem .STAT_EXPRESSION :
355
- scriptName = self .sem .NodeVisitor (stat .data .expression )
356
- elif stat .type == self .sem .STAT_ASSIGNMENT :
357
- scriptName = self .sem .NodeVisitor (stat .data .rightExpression )
358
- elif stat .type == self .sem .STAT_VARIABLEDEF :
359
- scriptName = self .sem .NodeVisitor (stat .data .value )
360
- elif stat .type == self .sem .STAT_IF :
361
- scriptName = self .sem .NodeVisitor (stat .data .expression )
362
- elif stat .type == self .sem .STAT_ELSEIF :
363
- scriptName = self .sem .NodeVisitor (stat .data .expression )
364
- elif stat .type == self .sem .STAT_WHILE :
365
- scriptName = self .sem .NodeVisitor (stat .data .expression )
366
- elif stat .type == self .sem .STAT_RETURN :
367
- scriptName = self .sem .NodeVisitor (stat .data .expression )
368
- elif expr :
369
- scriptName = self .sem .NodeVisitor (expr )
353
+ try :
354
+ if stat :
355
+ if stat .type == self .sem .STAT_EXPRESSION :
356
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
357
+ elif stat .type == self .sem .STAT_ASSIGNMENT :
358
+ scriptName = self .sem .NodeVisitor (stat .data .rightExpression )
359
+ elif stat .type == self .sem .STAT_VARIABLEDEF :
360
+ scriptName = self .sem .NodeVisitor (stat .data .value )
361
+ elif stat .type == self .sem .STAT_IF :
362
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
363
+ elif stat .type == self .sem .STAT_ELSEIF :
364
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
365
+ elif stat .type == self .sem .STAT_WHILE :
366
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
367
+ elif stat .type == self .sem .STAT_RETURN :
368
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
369
+ elif expr :
370
+ scriptName = self .sem .NodeVisitor (expr )
371
+ except Linter .SemanticError as e :
372
+ return Exit ()
370
373
if scriptName :
371
374
if scriptName == self .sem .KW_SELF :
372
375
for scope in e .functions :
@@ -375,6 +378,10 @@ def Exit():
375
378
completions .append (SublimePapyrus .MakeFunctionCompletion (obj , self .sem ))
376
379
elif obj .type == self .sem .STAT_EVENTDEF :
377
380
completions .append (SublimePapyrus .MakeEventCompletion (obj , self .sem ))
381
+ elif "[]" in scriptName :
382
+ typ = scriptName [:- 2 ].capitalize ()
383
+ completions .append (("find\t int func." , "Find(${1:%s akElement}, ${2:Int aiStartIndex = 0})" % typ ,))
384
+ completions .append (("rfind\t int func." , "RFind(${1:%s akElement}, ${2:Int aiStartIndex = -1})" % typ ,))
378
385
else :
379
386
properties = self .GetPropertyCompletions (scriptName )
380
387
functions = self .GetFunctionCompletions (scriptName )
@@ -512,7 +519,7 @@ def GetBaseFunctionBlockCompletions(self):
512
519
("return\t stat." , "Return ${1:$SELECTION}" ,),
513
520
("while\t while-loop" , "While(${1:$SELECTION})\n \t ${0}\n EndWhile" ,),
514
521
("for\t pseudo for-loop" , "Int ${1:iCount} = 0\n While(${1:iCount} < ${2:maxSize})\n \t ${0}\n \t ${1:iCount} += 1\n EndWhile" ,),
515
- ("getstate\t func ." , "GetState()" ,),
522
+ ("getstate\t string func ." , "GetState()" ,),
516
523
("gotostate\t func." , "GoToState(${1:String asState})" ,),
517
524
("onbeginstate\t event" , "OnBeginState()" ,),
518
525
("onendstate\t event" , "OnEndState()" ,),
0 commit comments