Whitespace changes

This commit is contained in:
Strahinja Val Markovic 2012-05-07 21:23:38 -07:00
parent 5f5b9bd7b4
commit 6430677f4f

View File

@ -23,6 +23,7 @@ import indexer
min_num_chars = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) ) min_num_chars = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) )
class CompletionSystem( object ): class CompletionSystem( object ):
def __init__( self ): def __init__( self ):
self.completer = indexer.Completer() self.completer = indexer.Completer()
@ -30,15 +31,18 @@ class CompletionSystem( object ):
self.pattern = re.compile( r"[_a-zA-Z]\w*" ) self.pattern = re.compile( r"[_a-zA-Z]\w*" )
self.future = None self.future = None
def CandidatesForQueryAsync( self, query ): def CandidatesForQueryAsync( self, query ):
filetype = vim.eval( "&filetype" ) filetype = vim.eval( "&filetype" )
self.future = self.completer.CandidatesForQueryAndTypeAsync( self.future = self.completer.CandidatesForQueryAndTypeAsync(
SanitizeQuery( query ), SanitizeQuery( query ),
filetype ) filetype )
def AsyncCandidateRequestReady( self ): def AsyncCandidateRequestReady( self ):
return self.future.ResultsReady() return self.future.ResultsReady()
def CandidatesFromStoredRequest( self ): def CandidatesFromStoredRequest( self ):
if not self.future: if not self.future:
return [] return []
@ -47,6 +51,7 @@ class CompletionSystem( object ):
self.future.GetResults( results ) self.future.GetResults( results )
return results return results
def AddBufferIdentifiers( self ): def AddBufferIdentifiers( self ):
text = "\n".join( vim.current.buffer ) text = "\n".join( vim.current.buffer )
text = RemoveIdentFreeText( text ) text = RemoveIdentFreeText( text )
@ -60,10 +65,12 @@ class CompletionSystem( object ):
self.completer.AddCandidatesToDatabase( idents, filetype, filepath ) self.completer.AddCandidatesToDatabase( idents, filetype, filepath )
def CurrentColumn(): def CurrentColumn():
# vim's columns start at 1 while vim.current.line columns start at 0 # vim's columns start at 1 while vim.current.line columns start at 0
return int( vim.eval( "col('.')" ) ) - 1 return int( vim.eval( "col('.')" ) ) - 1
def CompletionStartColumn(): def CompletionStartColumn():
line = vim.current.line line = vim.current.line
current_column = CurrentColumn() current_column = CurrentColumn()
@ -77,9 +84,11 @@ def CompletionStartColumn():
return start_column return start_column
def EscapeForVim( text ): def EscapeForVim( text ):
return text.replace( "'", "''" ) return text.replace( "'", "''" )
def CurrentCursorText(): def CurrentCursorText():
start_column = CompletionStartColumn() start_column = CompletionStartColumn()
current_column = CurrentColumn() current_column = CurrentColumn()
@ -94,6 +103,7 @@ def CurrentCursorText():
def SanitizeQuery( query ): def SanitizeQuery( query ):
return query.strip() return query.strip()
def RemoveIdentFreeText( text ): def RemoveIdentFreeText( text ):
"""Removes commented-out code and code in quotes.""" """Removes commented-out code and code in quotes."""