Exemplo n.º 1
0
    def __init__(self, user_options):
        self.user_options = user_options
        self.min_num_chars = user_options['min_num_of_chars_for_completion']
        self.max_diagnostics_to_display = user_options[
            'max_diagnostics_to_display']
        self.completion_triggers = (completer_utils.PreparedTriggers(
            user_trigger_map=user_options['semantic_triggers'],
            filetype_set=set(self.SupportedFiletypes()))
                                    if user_options['auto_trigger'] else None)

        self._signature_triggers = (
            completer_utils.PreparedTriggers(
                user_trigger_map=
                {},  # user triggers not supported for signature help
                filetype_set=set(self.SupportedFiletypes()),
                default_triggers={})
            if not user_options['disable_signature_help'] else None)

        self._completions_cache = CompletionsCache()
        self._max_candidates = user_options['max_num_candidates']
        self._max_candidates_to_detail = user_options[
            'max_num_candidates_to_detail']

        LOGGER.info(f"Completion config: { self._max_candidates }, detailing "
                    f"{ self._max_candidates_to_detail } candiates")
Exemplo n.º 2
0
def PreparedTriggers_ObjectiveC_test():
    triggers = cu.PreparedTriggers()

    # Bracketed calls
    ok_(triggers.MatchesForFiletype('[foo ', 5, 6, 'objc'))
    ok_(not triggers.MatchesForFiletype('[foo', 4, 5, 'objc'))
    ok_(not triggers.MatchesForFiletype('[3foo ', 6, 6, 'objc'))
    ok_(triggers.MatchesForFiletype('[f3oo ', 6, 6, 'objc'))
    ok_(triggers.MatchesForFiletype('[[foo ', 6, 6, 'objc'))

    # Bracketless calls
    ok_(not triggers.MatchesForFiletype('3foo ', 5, 5, 'objc'))
    ok_(triggers.MatchesForFiletype('foo3 ', 5, 5, 'objc'))
    ok_(triggers.MatchesForFiletype('foo ', 4, 4, 'objc'))

    # Method composition
    ok_(
        triggers.MatchesForFiletype(
            '[NSString stringWithFormat:@"Test %@", stuff] ', 46, 46, 'objc'))
    ok_(
        triggers.MatchesForFiletype('   [NSString stringWithFormat:@"Test"] ',
                                    39, 39, 'objc'))
    ok_(
        triggers.MatchesForFiletype(
            '   [[NSString stringWithFormat:@"Test"] stringByAppendingString:%@] ',
            68, 68, 'objc'))

    ok_(not triggers.MatchesForFiletype('// foo ', 8, 8, 'objc'))
Exemplo n.º 3
0
def PreparedTriggers_UserTriggers_test():
    triggers = cu.PreparedTriggers(user_trigger_map={'c': ['->']})

    assert_that(triggers.MatchesForFiletype('foo->bar', 5, 8, 'c'))
    assert_that(
        triggers.MatchingTriggerForFiletype('foo->bar', 5, 8, 'c').pattern,
        equal_to(re.escape('->')))
Exemplo n.º 4
0
def PreparedTriggers_UserTriggers_test():
    triggers = cu.PreparedTriggers(user_trigger_map={'c': ['->']})

    ok_(triggers.MatchesForFiletype('foo->bar', 5, 8, 'c'))
    eq_(
        triggers.MatchingTriggerForFiletype('foo->bar', 5, 8, 'c').pattern,
        re.escape('->'))
Exemplo n.º 5
0
 def __init__(self, user_options):
     self.user_options = user_options
     self.min_num_chars = user_options['min_num_of_chars_for_completion']
     self.prepared_triggers = (completer_utils.PreparedTriggers(
         user_trigger_map=user_options['semantic_triggers'],
         filetype_set=set(self.SupportedFiletypes()))
                               if user_options['auto_trigger'] else None)
     self._completions_cache = CompletionsCache()
Exemplo n.º 6
0
def PreparedTriggers_OnlySomeFiletypesSelected_test():
    triggers = cu.PreparedTriggers(filetype_set=set('c'))
    ok_(triggers.MatchesForFiletype('foo.bar', 4, 'c'))
    eq_(
        triggers.MatchingTriggerForFiletype('foo.bar', 4, 'c').pattern,
        re.escape('.'))
    ok_(not triggers.MatchesForFiletype('foo->bar', 5, 'cpp'))
    eq_(triggers.MatchingTriggerForFiletype('foo->bar', 5, 'cpp'), None)
Exemplo n.º 7
0
def PreparedTriggers_Basic_test():
  triggers = cu.PreparedTriggers()

  ok_( triggers.MatchesForFiletype( 'foo.bar', 4, 8, 'c' ) )
  eq_( triggers.MatchingTriggerForFiletype( 'foo.bar', 4, 8, 'c' ).pattern,
       re.escape( '.' ) )
  ok_( triggers.MatchesForFiletype( 'foo->bar', 5, 9, 'cpp' ) )
  eq_( triggers.MatchingTriggerForFiletype( 'foo->bar', 5, 9, 'cpp' ).pattern,
       re.escape( '->' ) )
Exemplo n.º 8
0
def PreparedTriggers_OnlySomeFiletypesSelected_test():
    triggers = cu.PreparedTriggers(filetype_set=set('c'))

    assert_that(triggers.MatchesForFiletype('foo.bar', 4, 7, 'c'))
    assert_that(
        triggers.MatchingTriggerForFiletype('foo.bar', 4, 7, 'c').pattern,
        equal_to(re.escape('.')))
    assert_that(not triggers.MatchesForFiletype('foo->bar', 5, 8, 'cpp'))
    assert_that(triggers.MatchingTriggerForFiletype('foo->bar', 5, 8, 'cpp'),
                none())
Exemplo n.º 9
0
def PreparedTriggers_Basic_test():
    triggers = cu.PreparedTriggers()

    assert_that(triggers.MatchesForFiletype('foo.bar', 4, 8, 'c'))
    assert_that(
        triggers.MatchingTriggerForFiletype('foo.bar', 4, 8, 'c').pattern,
        equal_to(re.escape('.')))
    assert_that(triggers.MatchesForFiletype('foo->bar', 5, 9, 'cpp'))
    assert_that(
        triggers.MatchingTriggerForFiletype('foo->bar', 5, 9, 'cpp').pattern,
        equal_to(re.escape('->')))
Exemplo n.º 10
0
def PreparedTriggers_ObjectiveC_test():
  triggers = cu.PreparedTriggers()
  ok_( triggers.MatchesForFiletype( '[foo ', 5, 'objc' ) )
  ok_( not triggers.MatchesForFiletype( '[foo', 4, 'objc' ) )
  ok_( not triggers.MatchesForFiletype( '[3foo ', 6, 'objc' ) )
Exemplo n.º 11
0
def PreparedTriggers_VimTriggerIgnoresConcatOperator_test():
  triggers = cu.PreparedTriggers()
  ok_( triggers.MatchesForFiletype( 'foo.bar', 4, 'vim' ) )
  ok_( not triggers.MatchesForFiletype( 'foo . bar', 4, 'vim' ) )
  ok_( not triggers.MatchesForFiletype( 'foo . bar', 5, 'vim' ) )
  ok_( not triggers.MatchesForFiletype( 'foo . bar', 6, 'vim' ) )
Exemplo n.º 12
0
def PreparedTriggers_UserTriggers_test():
  triggers = cu.PreparedTriggers( user_trigger_map = { 'c': ['->'] } )
  ok_( triggers.MatchesForFiletype( 'foo->bar', 5, 'c' ) )
Exemplo n.º 13
0
def PreparedTriggers_OnlySomeFiletypesSelected_test():
  triggers = cu.PreparedTriggers( filetype_set = set( 'c' ) )
  ok_( triggers.MatchesForFiletype( 'foo.bar', 4, 'c' ) )
  ok_( not triggers.MatchesForFiletype( 'foo->bar', 5, 'cpp' ) )
Exemplo n.º 14
0
def PreparedTriggers_Basic_test():
  triggers = cu.PreparedTriggers()
  ok_( triggers.MatchesForFiletype( 'foo.bar', 4, 'c' ) )
  ok_( triggers.MatchesForFiletype( 'foo->bar', 5, 'cpp' ) )