parent
98ef568359
commit
8ce07f508c
@ -153,13 +153,18 @@ class Completer( object ):
|
|||||||
not self.ShouldUseNow( request_data ) ):
|
not self.ShouldUseNow( request_data ) ):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if ( request_data[ 'query' ] and
|
candidates = self._GetCandidatesFromSubclass( request_data )
|
||||||
self._completions_cache and
|
if request_data[ 'query' ]:
|
||||||
|
candidates = self.FilterAndSortCandidates( candidates,
|
||||||
|
request_data[ 'query' ] )
|
||||||
|
return candidates
|
||||||
|
|
||||||
|
|
||||||
|
def _GetCandidatesFromSubclass( self, request_data ):
|
||||||
|
if ( self._completions_cache and
|
||||||
self._completions_cache.CacheValid( request_data[ 'line_num' ],
|
self._completions_cache.CacheValid( request_data[ 'line_num' ],
|
||||||
request_data[ 'start_column' ] ) ):
|
request_data[ 'start_column' ] ) ):
|
||||||
return self.FilterAndSortCandidates(
|
return self._completions_cache.raw_completions
|
||||||
self._completions_cache.raw_completions,
|
|
||||||
request_data[ 'query' ] )
|
|
||||||
else:
|
else:
|
||||||
self._completions_cache = CompletionsCache()
|
self._completions_cache = CompletionsCache()
|
||||||
self._completions_cache.raw_completions = self.ComputeCandidatesInner(
|
self._completions_cache.raw_completions = self.ComputeCandidatesInner(
|
||||||
|
@ -25,7 +25,7 @@ from .. import ycmd
|
|||||||
from ..responses import BuildCompletionData, UnknownExtraConf
|
from ..responses import BuildCompletionData, UnknownExtraConf
|
||||||
from nose.tools import ok_, eq_, with_setup
|
from nose.tools import ok_, eq_, with_setup
|
||||||
from hamcrest import ( assert_that, has_items, has_entry, contains,
|
from hamcrest import ( assert_that, has_items, has_entry, contains,
|
||||||
contains_string, has_entries )
|
contains_string, has_entries, contains_inanyorder )
|
||||||
import bottle
|
import bottle
|
||||||
|
|
||||||
bottle.debug( True )
|
bottle.debug( True )
|
||||||
@ -207,6 +207,38 @@ def GetCompletions_ClangCompleter_WorksWhenExtraConfExplicitlyAllowed_test():
|
|||||||
CompletionEntryMatcher( 'y' ) ) )
|
CompletionEntryMatcher( 'y' ) ) )
|
||||||
|
|
||||||
|
|
||||||
|
@with_setup( Setup )
|
||||||
|
def GetCompletions_ClangCompleter_ForceSemantic_OnlyFileteredCompletions_test():
|
||||||
|
app = TestApp( ycmd.app )
|
||||||
|
contents = """
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int foobar;
|
||||||
|
int floozar;
|
||||||
|
int gooboo;
|
||||||
|
int bleble;
|
||||||
|
|
||||||
|
fooar
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
# 0-based line and column!
|
||||||
|
completion_data = BuildRequest( filepath = '/foo.cpp',
|
||||||
|
filetype = 'cpp',
|
||||||
|
force_semantic = True,
|
||||||
|
contents = contents,
|
||||||
|
line_num = 8,
|
||||||
|
column_num = 7,
|
||||||
|
start_column = 7,
|
||||||
|
query = 'fooar',
|
||||||
|
compilation_flags = ['-x', 'c++'] )
|
||||||
|
|
||||||
|
results = app.post_json( '/completions', completion_data ).json
|
||||||
|
assert_that( results,
|
||||||
|
contains_inanyorder( CompletionEntryMatcher( 'foobar' ),
|
||||||
|
CompletionEntryMatcher( 'floozar' ) ) )
|
||||||
|
|
||||||
|
|
||||||
@with_setup( Setup )
|
@with_setup( Setup )
|
||||||
def GetCompletions_ForceSemantic_Works_test():
|
def GetCompletions_ForceSemantic_Works_test():
|
||||||
app = TestApp( ycmd.app )
|
app = TestApp( ycmd.app )
|
||||||
|
Loading…
Reference in New Issue
Block a user