@@ -166,17 +166,17 @@ def QueueLinter(self, view):
166
166
delay = settings .get ("linter_delay" , 500 )/ 1000.0
167
167
if delay < 0.050 :
168
168
delay = 0.050
169
- if PYTHON_VERSION [ 0 ] == 2 :
170
- self .fileName = view . file_name ()
171
- if self . fileName :
169
+ self . fileName = view . file_name ()
170
+ if self .fileName :
171
+ if PYTHON_VERSION [ 0 ] == 2 :
172
172
self .scriptContents = view .substr (sublime .Region (0 , view .size ()))
173
173
self .sourcePaths = SublimePapyrus .GetSourcePaths (view )
174
174
SublimePapyrus .ClearLinterHighlights (view )
175
175
t = threading .Timer (delay , self .Linter , kwargs = {"view" : None })
176
176
t .start ()
177
- elif PYTHON_VERSION [0 ] >= 3 :
178
- t = threading .Timer (delay , self .Linter , kwargs = {"view" : view })
179
- t .start ()
177
+ elif PYTHON_VERSION [0 ] >= 3 :
178
+ t = threading .Timer (delay , self .Linter , kwargs = {"view" : view })
179
+ t .start ()
180
180
181
181
def Linter (self , view ):
182
182
self .linterQueue -= 1 # Remove from queue
@@ -190,13 +190,14 @@ def Linter(self, view):
190
190
#start = time.time()
191
191
error = False
192
192
def Exit ():
193
+ #print("Linter: Finished in %f milliseconds and releasing lock..." % ((time.time()-start)*1000.0))
193
194
self .linterRunning = False
194
195
return False
195
196
with self .cacheLock :
197
+ #start = time.time()
196
198
settings = None
197
199
if view :
198
200
settings = SublimePapyrus .GetSettings ()
199
- #start = time.time()
200
201
if int (sublime .version ()) >= 3103 and view .is_auto_complete_visible (): # If a list of completions is visible, then cancel
201
202
return Exit ()
202
203
if view :
@@ -226,8 +227,6 @@ def Exit():
226
227
SublimePapyrus .ShowMessage ("Lexical error on line %d, column %d: %s" % (e .line , e .column , e .message ))
227
228
if settings .get ("linter_panel_error_messages" , False ):
228
229
view .window ().show_quick_panel ([[e .message , "Line %d, column %d" % (e .line , e .column )]], None )
229
- #else:
230
- # print("Lexical error on line %d, column %d: %s" % (e.line, e.column, e.message))
231
230
error = True
232
231
return Exit ()
233
232
if self .syn :
@@ -243,14 +242,9 @@ def Exit():
243
242
SublimePapyrus .ShowMessage ("Syntactic error on line %d: %s" % (e .line , e .message ))
244
243
if settings .get ("linter_panel_error_messages" , False ):
245
244
view .window ().show_quick_panel ([[e .message , "Line %d" % e .line ]], None )
246
- #else:
247
- # print("Syntactic error on line %d: %s" % (e.line, e.message))
248
245
error = True
249
246
if statements :
250
- if view :
251
- self .SetStatements (view .file_name (), statements [:]) # Cache a copy of the statements
252
- else :
253
- self .SetStatements (self .fileName , statements [:]) # Cache a copy of the statements
247
+ self .SetStatements (self .fileName , statements [:]) # Cache a copy of the statements
254
248
else :
255
249
return Exit ()
256
250
if error :
@@ -267,18 +261,13 @@ def Exit():
267
261
SublimePapyrus .ShowMessage ("Semantic error on line %d: %s" % (e .line , e .message ))
268
262
if settings .get ("linter_panel_error_messages" , False ):
269
263
view .window ().show_quick_panel ([[e .message , "Line %d" % e .line ]], None )
270
- #else:
271
- # print("Semantic error on line %d: %s" % (e.line, e.message))
272
264
error = True
273
265
return Exit ()
274
266
except Linter .Cancel as e :
275
267
pass
276
- #print("Linter: Finished in %f milliseconds and releasing lock..." % ((time.time()-start)*1000.0))
277
268
if not error :
278
269
if view :
279
270
SublimePapyrus .ShowMessage ("Linter found no issues..." )
280
- #else:
281
- # print("Linter found no issues...")
282
271
return Exit ()
283
272
284
273
def Completions (self , view , prefix , locations ):
@@ -349,63 +338,64 @@ def Exit():
349
338
except Linter .SemanticError as e :
350
339
return Exit ()
351
340
except Linter .Cancel as e :
352
- scriptName = None
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 ()
373
- if scriptName :
374
- if scriptName == self .sem .KW_SELF :
375
- for scope in e .functions :
376
- for name , obj in scope .items ():
377
- if obj .type == self .sem .STAT_FUNCTIONDEF :
378
- completions .append (SublimePapyrus .MakeFunctionCompletion (obj , self .sem ))
379
- elif obj .type == self .sem .STAT_EVENTDEF :
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 ,))
385
- else :
386
- properties = self .GetPropertyCompletions (scriptName )
387
- functions = self .GetFunctionCompletions (scriptName )
388
- if properties and functions :
389
- completions .extend (properties )
390
- completions .extend (functions )
341
+ if len (e .variables ) > 2 :
342
+ scriptName = None
343
+ try :
344
+ if stat :
345
+ if stat .type == self .sem .STAT_EXPRESSION :
346
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
347
+ elif stat .type == self .sem .STAT_ASSIGNMENT :
348
+ scriptName = self .sem .NodeVisitor (stat .data .rightExpression )
349
+ elif stat .type == self .sem .STAT_VARIABLEDEF :
350
+ scriptName = self .sem .NodeVisitor (stat .data .value )
351
+ elif stat .type == self .sem .STAT_IF :
352
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
353
+ elif stat .type == self .sem .STAT_ELSEIF :
354
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
355
+ elif stat .type == self .sem .STAT_WHILE :
356
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
357
+ elif stat .type == self .sem .STAT_RETURN :
358
+ scriptName = self .sem .NodeVisitor (stat .data .expression )
359
+ elif expr :
360
+ scriptName = self .sem .NodeVisitor (expr )
361
+ except Linter .SemanticError as e :
362
+ return Exit ()
363
+ if scriptName :
364
+ if scriptName == self .sem .KW_SELF :
365
+ for scope in e .functions :
366
+ for name , obj in scope .items ():
367
+ if obj .type == self .sem .STAT_FUNCTIONDEF :
368
+ completions .append (SublimePapyrus .MakeFunctionCompletion (obj , self .sem ))
369
+ elif obj .type == self .sem .STAT_EVENTDEF :
370
+ completions .append (SublimePapyrus .MakeEventCompletion (obj , self .sem ))
371
+ elif "[]" in scriptName :
372
+ typ = scriptName [:- 2 ].capitalize ()
373
+ completions .append (("find\t int func." , "Find(${1:%s akElement}, ${2:Int aiStartIndex = 0})" % typ ,))
374
+ completions .append (("rfind\t int func." , "RFind(${1:%s akElement}, ${2:Int aiStartIndex = -1})" % typ ,))
391
375
else :
392
- try :
393
- script = self .sem .GetCachedScript (scriptName )
394
- except :
395
- return Exit ()
396
- if script :
397
- if not properties :
398
- properties = []
399
- for name , obj in script .properties .items ():
400
- properties .append (SublimePapyrus .MakePropertyCompletion (obj ))
401
- self .SetPropertyCompletions (scriptName , properties )
376
+ properties = self .GetPropertyCompletions (scriptName )
377
+ functions = self .GetFunctionCompletions (scriptName )
378
+ if properties and functions :
402
379
completions .extend (properties )
403
- if not functions :
404
- functions = []
405
- for name , obj in script .functions .items ():
406
- functions .append (SublimePapyrus .MakeFunctionCompletion (obj , self .sem ))
407
- self .SetFunctionCompletions (scriptName , functions )
408
380
completions .extend (functions )
381
+ else :
382
+ try :
383
+ script = self .sem .GetCachedScript (scriptName )
384
+ except :
385
+ return Exit ()
386
+ if script :
387
+ if not properties :
388
+ properties = []
389
+ for name , obj in script .properties .items ():
390
+ properties .append (SublimePapyrus .MakePropertyCompletion (obj ))
391
+ self .SetPropertyCompletions (scriptName , properties )
392
+ completions .extend (properties )
393
+ if not functions :
394
+ functions = []
395
+ for name , obj in script .functions .items ():
396
+ functions .append (SublimePapyrus .MakeFunctionCompletion (obj , self .sem ))
397
+ self .SetFunctionCompletions (scriptName , functions )
398
+ completions .extend (functions )
409
399
else : # Objects from the script that is being edited
410
400
try :
411
401
self .sem .Process (statements , SublimePapyrus .GetSourcePaths (view ), line )
0 commit comments