1- import string
21import re
32from collections import namedtuple
43
@@ -56,14 +55,12 @@ def _matchIdent(self):
5655 return self .ident .partition ('(' )[0 ].lower ()
5756 return self .ident .lower ()
5857
59- """
60- Helper method for string matching
61- When exactly is true:
62- matches search string to target exactly, but empty search string matches anything
63- When exactly is false:
64- if only one char given in search string match this single char with start
65- of target string, otherwise match search string anywhere in target string
66- """
58+ # Helper method for string matching
59+ # When exactly is true:
60+ # matches search string to target exactly, but empty search string matches anything
61+ # When exactly is false:
62+ # if only one char given in search string match this single char with start
63+ # of target string, otherwise match search string anywhere in target string
6764 @staticmethod
6865 def _stringMatched (target , search , exactly ):
6966 if exactly :
@@ -73,16 +70,14 @@ def _stringMatched(target, search, exactly):
7370 return target .startswith (search )
7471 return search in target
7572
76- """
77- Method to match completion item against search string (prefix).
78- Lower score means a better match.
79- If completion item matches prefix with parent identifier, e.g.:
80- table_name.column ~ table_name.co, then score = 1
81- If completion item matches prefix without parent identifier, e.g.:
82- table_name.column ~ co, then score = 2
83- If completion item matches, but prefix has no parent, e.g.:
84- table ~ tab, then score = 3
85- """
73+ # Method to match completion item against search string (prefix).
74+ # Lower score means a better match.
75+ # If completion item matches prefix with parent identifier, e.g.:
76+ # table_name.column ~ table_name.co, then score = 1
77+ # If completion item matches prefix without parent identifier, e.g.:
78+ # table_name.column ~ co, then score = 2
79+ # If completion item matches, but prefix has no parent, e.g.:
80+ # table ~ tab, then score = 3
8681 def prefixMatchScore (self , search , exactly = False ):
8782 target = self ._matchIdent ()
8883 search = search .lower ()
@@ -224,7 +219,6 @@ def getAutoCompleteList(self, prefix, sql, sqlToCursor):
224219 joinAlias = joinCondMatch .group (1 )
225220 except Exception as e :
226221 print (e )
227- pass
228222
229223 autocompleteList = []
230224 inhibit = False
@@ -264,7 +258,7 @@ def _noDotsCompletions(self, prefix, identifiers, joinAlias=None):
264258
265259 for ident in identifiers :
266260 if ident .has_alias ():
267- sqlAliases .add (CompletionItem ('Alias' , ident .alias , 0 ))
261+ sqlAliases .add (CompletionItem ('Alias' , ident .alias , 0 ))
268262
269263 if ident .is_function :
270264 functions = [
@@ -366,7 +360,7 @@ def _singleDotCompletions(self, prefix, identifiers, joinAlias=None):
366360
367361 if ident .is_table_alias :
368362 tables = [
369- ( ident . alias , table )
363+ table
370364 for table in self .allTables
371365 if table .prefixMatchScore (ident .full_name , exactly = True ) > 0
372366 ]
@@ -383,7 +377,7 @@ def _singleDotCompletions(self, prefix, identifiers, joinAlias=None):
383377 # first of all expand table aliases to real table names and try
384378 # to match their columns with prefix of these expanded identifiers
385379 # e.g. select x.co| from tab x // "x.co" will expland to "tab.co"
386- for alias , table_item in sqlTableAliases :
380+ for table_item in sqlTableAliases :
387381 prefix_to_match = table_item .name + '.' + prefixObject
388382 for item in self .allColumns :
389383 score = item .prefixMatchScore (prefix_to_match )
0 commit comments