ycmd's JSON interface now uses 1-based indices
This makes far more sense because editors manipulate user-level errors/warnings on a 1-based system, not a 0-based one.
This commit is contained in:
parent
81029d9f4e
commit
d56ec1ea7a
@ -137,13 +137,15 @@ class BaseRequest( object ):
|
||||
def BuildRequestData( start_column = None,
|
||||
query = None,
|
||||
include_buffer_data = True ):
|
||||
if start_column is None:
|
||||
start_column = 0
|
||||
line, column = vimsupport.CurrentLineAndColumn()
|
||||
filepath = vimsupport.GetCurrentBufferFilepath()
|
||||
request_data = {
|
||||
'filetypes': vimsupport.CurrentFiletypes(),
|
||||
'line_num': line,
|
||||
'column_num': column,
|
||||
'start_column': start_column,
|
||||
'line_num': line + 1,
|
||||
'column_num': column + 1,
|
||||
'start_column': start_column + 1,
|
||||
'line_value': vim.current.line,
|
||||
'filepath': filepath
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ class CommandRequest( BaseRequest ):
|
||||
vim.eval( 'youcompleteme#OpenGoToList()' )
|
||||
else:
|
||||
vimsupport.JumpToLocation( self._response[ 'filepath' ],
|
||||
self._response[ 'line_num' ] + 1,
|
||||
self._response[ 'column_num' ] + 1)
|
||||
self._response[ 'line_num' ],
|
||||
self._response[ 'column_num' ] )
|
||||
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ def _BuildQfListItem( goto_data_item ):
|
||||
if 'description' in goto_data_item:
|
||||
qf_item[ 'text' ] = ToUtf8IfNeeded( goto_data_item[ 'description' ] )
|
||||
if 'line_num' in goto_data_item:
|
||||
qf_item[ 'lnum' ] = goto_data_item[ 'line_num' ] + 1
|
||||
qf_item[ 'lnum' ] = goto_data_item[ 'line_num' ]
|
||||
if 'column_num' in goto_data_item:
|
||||
qf_item[ 'col' ] = goto_data_item[ 'column_num' ]
|
||||
qf_item[ 'col' ] = goto_data_item[ 'column_num' ] - 1
|
||||
return qf_item
|
||||
|
@ -160,8 +160,8 @@ class IdentifierCompleter( GeneralCompleter ):
|
||||
|
||||
|
||||
def _PreviousIdentifier( min_num_completion_start_chars, request_data ):
|
||||
line_num = request_data[ 'line_num' ]
|
||||
column_num = request_data[ 'column_num' ]
|
||||
line_num = request_data[ 'line_num' ] - 1
|
||||
column_num = request_data[ 'column_num' ] - 1
|
||||
filepath = request_data[ 'filepath' ]
|
||||
contents_per_line = (
|
||||
request_data[ 'file_data' ][ filepath ][ 'contents' ].split( '\n' ) )
|
||||
@ -226,7 +226,7 @@ def _GetCursorIdentifier( request_data ):
|
||||
identifier_end += 1
|
||||
return identifier_end + 1
|
||||
|
||||
column_num = request_data[ 'column_num' ]
|
||||
column_num = request_data[ 'column_num' ] - 1
|
||||
line = request_data[ 'line_value' ]
|
||||
|
||||
try:
|
||||
|
@ -25,14 +25,14 @@ def GetCursorIdentifier_StartOfLine_test():
|
||||
eq_( 'foo',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 0,
|
||||
'column_num': 1,
|
||||
'line_value': 'foo'
|
||||
} ) )
|
||||
|
||||
eq_( 'fooBar',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 0,
|
||||
'column_num': 1,
|
||||
'line_value': 'fooBar'
|
||||
} ) )
|
||||
|
||||
@ -41,7 +41,7 @@ def GetCursorIdentifier_EndOfLine_test():
|
||||
eq_( 'foo',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 2,
|
||||
'column_num': 3,
|
||||
'line_value': 'foo'
|
||||
} ) )
|
||||
|
||||
@ -50,7 +50,7 @@ def GetCursorIdentifier_PastEndOfLine_test():
|
||||
eq_( '',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 10,
|
||||
'column_num': 11,
|
||||
'line_value': 'foo'
|
||||
} ) )
|
||||
|
||||
@ -68,7 +68,7 @@ def GetCursorIdentifier_StartOfLine_StopsAtNonIdentifierChar_test():
|
||||
eq_( 'foo',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 0,
|
||||
'column_num': 1,
|
||||
'line_value': 'foo(goo)'
|
||||
} ) )
|
||||
|
||||
@ -77,7 +77,7 @@ def GetCursorIdentifier_AtNonIdentifier_test():
|
||||
eq_( 'goo',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 3,
|
||||
'column_num': 4,
|
||||
'line_value': 'foo(goo)'
|
||||
} ) )
|
||||
|
||||
@ -86,7 +86,7 @@ def GetCursorIdentifier_WalksForwardForIdentifier_test():
|
||||
eq_( 'foo',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 0,
|
||||
'column_num': 1,
|
||||
'line_value': ' foo'
|
||||
} ) )
|
||||
|
||||
@ -95,7 +95,7 @@ def GetCursorIdentifier_FindsNothingForward_test():
|
||||
eq_( '',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 4,
|
||||
'column_num': 5,
|
||||
'line_value': 'foo ()***()'
|
||||
} ) )
|
||||
|
||||
@ -104,7 +104,7 @@ def GetCursorIdentifier_SingleCharIdentifier_test():
|
||||
eq_( 'f',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 0,
|
||||
'column_num': 1,
|
||||
'line_value': ' f '
|
||||
} ) )
|
||||
|
||||
@ -113,7 +113,7 @@ def GetCursorIdentifier_StartsInMiddleOfIdentifier_test():
|
||||
eq_( 'foobar',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 3,
|
||||
'column_num': 4,
|
||||
'line_value': 'foobar'
|
||||
} ) )
|
||||
|
||||
@ -122,6 +122,6 @@ def GetCursorIdentifier_LineEmpty_test():
|
||||
eq_( '',
|
||||
identifier_completer._GetCursorIdentifier(
|
||||
{
|
||||
'column_num': 11,
|
||||
'column_num': 12,
|
||||
'line_value': ''
|
||||
} ) )
|
||||
|
@ -133,7 +133,7 @@ class Completer( object ):
|
||||
|
||||
def ShouldUseNowInner( self, request_data ):
|
||||
current_line = request_data[ 'line_value' ]
|
||||
start_column = request_data[ 'start_column' ]
|
||||
start_column = request_data[ 'start_column' ] - 1
|
||||
line_length = len( current_line )
|
||||
if not line_length or start_column - 1 >= line_length:
|
||||
return False
|
||||
|
@ -85,8 +85,8 @@ class ClangCompleter( Completer ):
|
||||
raise RuntimeError( NO_COMPILE_FLAGS_MESSAGE )
|
||||
|
||||
files = self.GetUnsavedFilesVector( request_data )
|
||||
line = request_data[ 'line_num' ] + 1
|
||||
column = request_data[ 'start_column' ] + 1
|
||||
line = request_data[ 'line_num' ]
|
||||
column = request_data[ 'start_column' ]
|
||||
results = self._completer.CandidatesForLocationInFile(
|
||||
ToUtf8IfNeeded( filename ),
|
||||
line,
|
||||
@ -136,8 +136,8 @@ class ClangCompleter( Completer ):
|
||||
raise ValueError( NO_COMPILE_FLAGS_MESSAGE )
|
||||
|
||||
files = self.GetUnsavedFilesVector( request_data )
|
||||
line = request_data[ 'line_num' ] + 1
|
||||
column = request_data[ 'column_num' ] + 1
|
||||
line = request_data[ 'line_num' ]
|
||||
column = request_data[ 'column_num' ]
|
||||
return getattr( self._completer, goto_function )(
|
||||
ToUtf8IfNeeded( filename ),
|
||||
line,
|
||||
@ -217,8 +217,8 @@ class ClangCompleter( Completer ):
|
||||
|
||||
|
||||
def GetDetailedDiagnostic( self, request_data ):
|
||||
current_line = request_data[ 'line_num' ] + 1
|
||||
current_column = request_data[ 'column_num' ] + 1
|
||||
current_line = request_data[ 'line_num' ]
|
||||
current_column = request_data[ 'column_num' ]
|
||||
current_file = request_data[ 'filepath' ]
|
||||
|
||||
if not self._diagnostic_store:
|
||||
@ -304,7 +304,7 @@ def _FilterDiagnostics( diagnostics ):
|
||||
|
||||
def _ResponseForLocation( location ):
|
||||
return responses.BuildGoToResponse( location.filename_,
|
||||
location.line_number_ - 1,
|
||||
location.column_number_ - 1)
|
||||
location.line_number_,
|
||||
location.column_number_ )
|
||||
|
||||
|
||||
|
@ -157,8 +157,8 @@ class CsharpCompleter( Completer ):
|
||||
|
||||
|
||||
def GetDetailedDiagnostic( self, request_data ):
|
||||
current_line = request_data[ 'line_num' ] + 1
|
||||
current_column = request_data[ 'column_num' ] + 1
|
||||
current_line = request_data[ 'line_num' ]
|
||||
current_column = request_data[ 'column_num' ]
|
||||
current_file = request_data[ 'filepath' ]
|
||||
|
||||
if not self._diagnostic_store:
|
||||
@ -301,8 +301,8 @@ class CsharpCompleter( Completer ):
|
||||
self._DefaultParameters( request_data ) )
|
||||
if definition[ 'FileName' ] != None:
|
||||
return responses.BuildGoToResponse( definition[ 'FileName' ],
|
||||
definition[ 'Line' ] - 1,
|
||||
definition[ 'Column' ] - 1 )
|
||||
definition[ 'Line' ],
|
||||
definition[ 'Column' ] )
|
||||
else:
|
||||
raise RuntimeError( 'Can\'t jump to definition' )
|
||||
|
||||
@ -310,11 +310,11 @@ class CsharpCompleter( Completer ):
|
||||
def _DefaultParameters( self, request_data ):
|
||||
""" Some very common request parameters """
|
||||
parameters = {}
|
||||
parameters[ 'line' ] = request_data[ 'line_num' ] + 1
|
||||
parameters[ 'column' ] = request_data[ 'column_num' ] + 1
|
||||
parameters[ 'line' ] = request_data[ 'line_num' ]
|
||||
parameters[ 'column' ] = request_data[ 'column_num' ]
|
||||
filepath = request_data[ 'filepath' ]
|
||||
parameters[ 'buffer' ] = request_data[ 'file_data' ][ filepath ][
|
||||
'contents' ]
|
||||
parameters[ 'buffer' ] = (
|
||||
request_data[ 'file_data' ][ filepath ][ 'contents' ] )
|
||||
parameters[ 'filename' ] = filepath
|
||||
return parameters
|
||||
|
||||
|
@ -57,7 +57,7 @@ class FilenameCompleter( Completer ):
|
||||
|
||||
|
||||
def AtIncludeStatementStart( self, request_data ):
|
||||
start_column = request_data[ 'start_column' ]
|
||||
start_column = request_data[ 'start_column' ] - 1
|
||||
current_line = request_data[ 'line_value' ]
|
||||
filepath = ToUtf8IfNeeded( request_data[ 'filepath' ] )
|
||||
filetypes = request_data[ 'file_data' ][ filepath ][ 'filetypes' ]
|
||||
@ -67,7 +67,7 @@ class FilenameCompleter( Completer ):
|
||||
|
||||
|
||||
def ShouldUseNowInner( self, request_data ):
|
||||
start_column = request_data[ 'start_column' ]
|
||||
start_column = request_data[ 'start_column' ] - 1
|
||||
current_line = request_data[ 'line_value' ]
|
||||
return ( start_column and ( current_line[ start_column - 1 ] == '/' or
|
||||
self.AtIncludeStatementStart( request_data ) ) )
|
||||
@ -79,7 +79,7 @@ class FilenameCompleter( Completer ):
|
||||
|
||||
def ComputeCandidatesInner( self, request_data ):
|
||||
current_line = request_data[ 'line_value' ]
|
||||
start_column = request_data[ 'start_column' ]
|
||||
start_column = request_data[ 'start_column' ] - 1
|
||||
filepath = ToUtf8IfNeeded( request_data[ 'filepath' ] )
|
||||
filetypes = request_data[ 'file_data' ][ filepath ][ 'filetypes' ]
|
||||
line = current_line[ :start_column ]
|
||||
|
@ -40,7 +40,7 @@ request_data = {
|
||||
}
|
||||
|
||||
def GetCompletionData( request_data ):
|
||||
request_data[ 'start_column' ] = len( request_data[ 'line_value' ] )
|
||||
request_data[ 'start_column' ] = len( request_data[ 'line_value' ] ) + 1
|
||||
candidates = fnc.ComputeCandidatesInner( request_data )
|
||||
return [ ( c[ 'insertion_text' ], c[ 'extra_menu_info' ] ) for c in candidates ]
|
||||
|
||||
|
@ -48,9 +48,9 @@ class JediCompleter( Completer ):
|
||||
def _GetJediScript( self, request_data ):
|
||||
filename = request_data[ 'filepath' ]
|
||||
contents = request_data[ 'file_data' ][ filename ][ 'contents' ]
|
||||
# Jedi expects lines to start at 1, not 0
|
||||
line = request_data[ 'line_num' ] + 1
|
||||
column = request_data[ 'column_num' ]
|
||||
line = request_data[ 'line_num' ]
|
||||
# Jedi expects columns to start at 0, not 1
|
||||
column = request_data[ 'column_num' ] - 1
|
||||
|
||||
return jedi.Script( contents, line, column, filename )
|
||||
|
||||
@ -134,8 +134,8 @@ class JediCompleter( Completer ):
|
||||
raise RuntimeError( 'Builtin modules cannot be displayed.' )
|
||||
else:
|
||||
return responses.BuildGoToResponse( definition.module_path,
|
||||
definition.line - 1,
|
||||
definition.column )
|
||||
definition.line,
|
||||
definition.column + 1 )
|
||||
else:
|
||||
# multiple definitions
|
||||
defs = []
|
||||
@ -146,8 +146,8 @@ class JediCompleter( Completer ):
|
||||
else:
|
||||
defs.append(
|
||||
responses.BuildGoToResponse( definition.module_path,
|
||||
definition.line - 1,
|
||||
definition.column,
|
||||
definition.line,
|
||||
definition.column + 1,
|
||||
definition.description ) )
|
||||
return defs
|
||||
|
||||
|
@ -83,22 +83,22 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ):
|
||||
if location_extent[ 'start' ][ 'line_num' ] < 0:
|
||||
location = diag[ 'location' ]
|
||||
vimsupport.AddDiagnosticSyntaxMatch(
|
||||
location[ 'line_num' ] + 1,
|
||||
location[ 'column_num' ] + 1 )
|
||||
location[ 'line_num' ],
|
||||
location[ 'column_num' ] )
|
||||
else:
|
||||
vimsupport.AddDiagnosticSyntaxMatch(
|
||||
location_extent[ 'start' ][ 'line_num' ] + 1,
|
||||
location_extent[ 'start' ][ 'column_num' ] + 1,
|
||||
location_extent[ 'end' ][ 'line_num' ] + 1,
|
||||
location_extent[ 'end' ][ 'column_num' ] + 1,
|
||||
location_extent[ 'start' ][ 'line_num' ],
|
||||
location_extent[ 'start' ][ 'column_num' ],
|
||||
location_extent[ 'end' ][ 'line_num' ],
|
||||
location_extent[ 'end' ][ 'column_num' ],
|
||||
is_error = is_error )
|
||||
|
||||
for diag_range in diag[ 'ranges' ]:
|
||||
vimsupport.AddDiagnosticSyntaxMatch(
|
||||
diag_range[ 'start' ][ 'line_num' ] + 1,
|
||||
diag_range[ 'start' ][ 'column_num' ] + 1,
|
||||
diag_range[ 'end' ][ 'line_num' ] + 1,
|
||||
diag_range[ 'end' ][ 'column_num' ] + 1,
|
||||
diag_range[ 'start' ][ 'line_num' ],
|
||||
diag_range[ 'start' ][ 'column_num' ],
|
||||
diag_range[ 'end' ][ 'line_num' ],
|
||||
diag_range[ 'end' ][ 'column_num' ],
|
||||
is_error = is_error )
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ def _ConvertDiagListToDict( diag_list ):
|
||||
location = diag[ 'location' ]
|
||||
buffer_number = vimsupport.GetBufferNumberForFilename(
|
||||
location[ 'filepath' ] )
|
||||
line_number = location[ 'line_num' ] + 1
|
||||
line_number = location[ 'line_num' ]
|
||||
buffer_to_line_to_diags[ buffer_number ][ line_number ].append( diag )
|
||||
|
||||
for line_to_diags in buffer_to_line_to_diags.itervalues():
|
||||
|
@ -110,8 +110,8 @@ def BuildDiagnosticData( diagnostic ):
|
||||
|
||||
def BuildLocationData( location ):
|
||||
return {
|
||||
'line_num': location.line_number_ - 1,
|
||||
'column_num': location.column_number_ - 1,
|
||||
'line_num': location.line_number_,
|
||||
'column_num': location.column_number_,
|
||||
'filepath': location.filename_,
|
||||
}
|
||||
|
||||
|
@ -55,26 +55,26 @@ void foo() {
|
||||
'text': contains_string( 'cannot initialize' ),
|
||||
'ranges': contains( has_entries( {
|
||||
'start': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 15,
|
||||
'line_num': 3,
|
||||
'column_num': 16,
|
||||
} ),
|
||||
'end': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 20,
|
||||
'line_num': 3,
|
||||
'column_num': 21,
|
||||
} ),
|
||||
} ) ),
|
||||
'location': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 9
|
||||
'line_num': 3,
|
||||
'column_num': 10
|
||||
} ),
|
||||
'location_extent': has_entries( {
|
||||
'start': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 9,
|
||||
'line_num': 3,
|
||||
'column_num': 10,
|
||||
} ),
|
||||
'end': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 12,
|
||||
'line_num': 3,
|
||||
'column_num': 13,
|
||||
} ),
|
||||
} )
|
||||
} ) ) )
|
||||
@ -102,12 +102,12 @@ void foo() {
|
||||
has_entries( {
|
||||
'location_extent': has_entries( {
|
||||
'start': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 2,
|
||||
'line_num': 3,
|
||||
'column_num': 3,
|
||||
} ),
|
||||
'end': has_entries( {
|
||||
'line_num': 2,
|
||||
'column_num': 5,
|
||||
'line_num': 3,
|
||||
'column_num': 6,
|
||||
} ),
|
||||
} )
|
||||
} ) ) )
|
||||
@ -163,17 +163,17 @@ def Diagnostics_CsCompleter_ZeroBasedLineAndColumn_test():
|
||||
'text': contains_string(
|
||||
"Unexpected symbol `}'', expecting identifier" ),
|
||||
'location': has_entries( {
|
||||
'line_num': 9,
|
||||
'column_num': 1
|
||||
'line_num': 10,
|
||||
'column_num': 2
|
||||
} ),
|
||||
'location_extent': has_entries( {
|
||||
'start': has_entries( {
|
||||
'line_num': 9,
|
||||
'column_num': 1,
|
||||
'line_num': 10,
|
||||
'column_num': 2,
|
||||
} ),
|
||||
'end': has_entries( {
|
||||
'line_num': 9,
|
||||
'column_num': 1,
|
||||
'line_num': 10,
|
||||
'column_num': 2,
|
||||
} ),
|
||||
} )
|
||||
} ) ) )
|
||||
@ -194,7 +194,7 @@ struct Foo {
|
||||
"""
|
||||
|
||||
diag_data = BuildRequest( compilation_flags = ['-x', 'c++'],
|
||||
line_num = 2,
|
||||
line_num = 3,
|
||||
contents = contents,
|
||||
filetype = 'cpp' )
|
||||
|
||||
@ -226,9 +226,9 @@ def GetDetailedDiagnostic_CsCompleter_Works_test():
|
||||
diag_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cs',
|
||||
contents = contents,
|
||||
line_num = 9,
|
||||
column_num = 1,
|
||||
start_column = 1 )
|
||||
line_num = 10,
|
||||
column_num = 2,
|
||||
start_column = 2 )
|
||||
|
||||
results = app.post_json( '/detailed_diagnostic', diag_data ).json
|
||||
assert_that( results,
|
||||
@ -244,7 +244,7 @@ def GetDetailedDiagnostic_CsCompleter_Works_test():
|
||||
def GetDetailedDiagnostic_JediCompleter_DoesntWork_test():
|
||||
app = TestApp( handlers.app )
|
||||
diag_data = BuildRequest( contents = "foo = 5",
|
||||
line_num = 1,
|
||||
line_num = 2,
|
||||
filetype = 'python' )
|
||||
response = app.post_json( '/detailed_diagnostic',
|
||||
diag_data,
|
||||
|
@ -50,7 +50,7 @@ def GetCompletions_IdentifierCompleter_Works_test():
|
||||
|
||||
completion_data = BuildRequest( contents = 'oo foo foogoo ba',
|
||||
query = 'oo',
|
||||
column_num = 2 )
|
||||
column_num = 3 )
|
||||
|
||||
eq_( [ BuildCompletionData( 'foo' ),
|
||||
BuildCompletionData( 'foogoo' ) ],
|
||||
@ -73,9 +73,9 @@ def GetCompletions_CsCompleter_Works_test():
|
||||
completion_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cs',
|
||||
contents = contents,
|
||||
line_num = 8,
|
||||
column_num = 11,
|
||||
start_column = 11 )
|
||||
line_num = 9,
|
||||
column_num = 12,
|
||||
start_column = 12 )
|
||||
|
||||
results = app.post_json( '/completions', completion_data ).json
|
||||
assert_that( results, has_items( CompletionEntryMatcher( 'CursorLeft' ),
|
||||
@ -172,9 +172,9 @@ int main()
|
||||
completion_data = BuildRequest( filepath = '/foo.cpp',
|
||||
filetype = 'cpp',
|
||||
contents = contents,
|
||||
line_num = 10,
|
||||
column_num = 6,
|
||||
start_column = 6,
|
||||
line_num = 11,
|
||||
column_num = 7,
|
||||
start_column = 7,
|
||||
compilation_flags = ['-x', 'c++'] )
|
||||
|
||||
results = app.post_json( '/completions', completion_data ).json
|
||||
@ -204,9 +204,9 @@ int main()
|
||||
completion_data = BuildRequest( filepath = '/foo.cpp',
|
||||
filetype = 'cpp',
|
||||
contents = contents,
|
||||
line_num = 10,
|
||||
column_num = 6,
|
||||
start_column = 6,
|
||||
line_num = 11,
|
||||
column_num = 7,
|
||||
start_column = 7,
|
||||
compilation_flags = ['-x', 'c++'] )
|
||||
|
||||
results = app.post_json( '/completions', completion_data ).json
|
||||
@ -220,9 +220,9 @@ def GetCompletions_ClangCompleter_UnknownExtraConfException_test():
|
||||
completion_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cpp',
|
||||
contents = open( filepath ).read(),
|
||||
line_num = 10,
|
||||
column_num = 6,
|
||||
start_column = 6,
|
||||
line_num = 11,
|
||||
column_num = 7,
|
||||
start_column = 7,
|
||||
force_semantic = True )
|
||||
|
||||
response = app.post_json( '/completions',
|
||||
@ -257,9 +257,9 @@ def GetCompletions_ClangCompleter_WorksWhenExtraConfExplicitlyAllowed_test():
|
||||
completion_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cpp',
|
||||
contents = open( filepath ).read(),
|
||||
line_num = 10,
|
||||
column_num = 6,
|
||||
start_column = 6 )
|
||||
line_num = 11,
|
||||
column_num = 7,
|
||||
start_column = 7 )
|
||||
|
||||
results = app.post_json( '/completions', completion_data ).json
|
||||
assert_that( results, has_items( CompletionEntryMatcher( 'c' ),
|
||||
@ -278,9 +278,9 @@ def GetCompletions_ClangCompleter_ExceptionWhenNoFlagsFromExtraConf_test():
|
||||
completion_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cpp',
|
||||
contents = open( filepath ).read(),
|
||||
line_num = 10,
|
||||
column_num = 6,
|
||||
start_column = 6 )
|
||||
line_num = 11,
|
||||
column_num = 7,
|
||||
start_column = 7 )
|
||||
|
||||
response = app.post_json( '/completions',
|
||||
completion_data,
|
||||
@ -311,9 +311,9 @@ int main()
|
||||
filetype = 'cpp',
|
||||
force_semantic = True,
|
||||
contents = contents,
|
||||
line_num = 8,
|
||||
column_num = 7,
|
||||
start_column = 7,
|
||||
line_num = 9,
|
||||
column_num = 8,
|
||||
start_column = 8,
|
||||
query = 'fooar',
|
||||
compilation_flags = ['-x', 'c++'] )
|
||||
|
||||
@ -347,9 +347,9 @@ def GetCompletions_ClangCompleter_ClientDataGivenToExtraConf_test():
|
||||
completion_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cpp',
|
||||
contents = open( filepath ).read(),
|
||||
line_num = 8,
|
||||
column_num = 6,
|
||||
start_column = 6,
|
||||
line_num = 9,
|
||||
column_num = 7,
|
||||
start_column = 7,
|
||||
extra_conf_data = {
|
||||
'flags': ['-x', 'c++']
|
||||
})
|
||||
@ -368,7 +368,7 @@ def GetCompletions_IdentifierCompleter_SyntaxKeywordsAdded_test():
|
||||
|
||||
completion_data = BuildRequest( contents = 'oo ',
|
||||
query = 'oo',
|
||||
column_num = 2 )
|
||||
column_num = 3 )
|
||||
|
||||
eq_( [ BuildCompletionData( 'foo' ),
|
||||
BuildCompletionData( 'zoo' ) ],
|
||||
@ -389,7 +389,7 @@ def GetCompletions_UltiSnipsCompleter_Works_test():
|
||||
|
||||
completion_data = BuildRequest( contents = 'oo ',
|
||||
query = 'oo',
|
||||
column_num = 2 )
|
||||
column_num = 3 )
|
||||
|
||||
eq_( [ BuildCompletionData( 'foo', '<snip> bar' ),
|
||||
BuildCompletionData( 'zoo', '<snip> goo' ) ],
|
||||
@ -412,7 +412,7 @@ def GetCompletions_UltiSnipsCompleter_UnusedWhenOffWithOption_test():
|
||||
|
||||
completion_data = BuildRequest( contents = 'oo ',
|
||||
query = 'oo',
|
||||
column_num = 2 )
|
||||
column_num = 3 )
|
||||
|
||||
eq_( [], app.post_json( '/completions', completion_data ).json )
|
||||
|
||||
|
@ -40,16 +40,15 @@ foo()
|
||||
|
||||
goto_data = BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['GoToDefinition'],
|
||||
line_num = 4,
|
||||
line_num = 5,
|
||||
contents = contents,
|
||||
filetype = 'python',
|
||||
filepath = '/foo.py' )
|
||||
|
||||
# 0-based line and column!
|
||||
eq_( {
|
||||
'filepath': '/foo.py',
|
||||
'line_num': 1,
|
||||
'column_num': 4
|
||||
'line_num': 2,
|
||||
'column_num': 5
|
||||
},
|
||||
app.post_json( '/run_completer_command', goto_data ).json )
|
||||
|
||||
@ -74,16 +73,15 @@ int main()
|
||||
goto_data = BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['GoToDefinition'],
|
||||
compilation_flags = ['-x', 'c++'],
|
||||
line_num = 9,
|
||||
column_num = 2,
|
||||
line_num = 10,
|
||||
column_num = 3,
|
||||
contents = contents,
|
||||
filetype = 'cpp' )
|
||||
|
||||
# 0-based line and column!
|
||||
eq_( {
|
||||
'filepath': '/foo',
|
||||
'line_num': 1,
|
||||
'column_num': 7
|
||||
'line_num': 2,
|
||||
'column_num': 8
|
||||
},
|
||||
app.post_json( '/run_completer_command', goto_data ).json )
|
||||
|
||||
|
@ -29,9 +29,9 @@ def BuildRequest( **kwargs ):
|
||||
|
||||
request = {
|
||||
'query': '',
|
||||
'line_num': 0,
|
||||
'column_num': 0,
|
||||
'start_column': 0,
|
||||
'line_num': 1,
|
||||
'column_num': 1,
|
||||
'start_column': 1,
|
||||
'filetypes': [ filetype ],
|
||||
'filepath': filepath,
|
||||
'line_value': contents,
|
||||
@ -51,8 +51,8 @@ def BuildRequest( **kwargs ):
|
||||
if key == 'line_num':
|
||||
lines = contents.splitlines()
|
||||
if len( lines ) > 1:
|
||||
# NOTE: assumes 0-based line_num
|
||||
request[ 'line_value' ] = lines[ value ]
|
||||
# NOTE: assumes 1-based line_num
|
||||
request[ 'line_value' ] = lines[ value - 1 ]
|
||||
|
||||
return request
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user