def Diagnostics_ZeroBasedLineAndColumn_test(app):
    filepath = PathToTestFile('testy', 'Program.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        results = {}
        for _ in (0, 1):  # First call always returns blank for some reason
            event_data = BuildRequest(filepath=filepath,
                                      event_name='FileReadyToParse',
                                      filetype='cs',
                                      contents=contents)

            results = app.post_json('/event_notification', event_data).json

        assert_that(
            results,
            contains(
                has_entries({
                    'kind':
                    equal_to('ERROR'),
                    'text':
                    contains_string(
                        "Unexpected symbol `}'', expecting identifier"),
                    'location':
                    has_entries({
                        'line_num': 11,
                        'column_num': 2
                    }),
                    'location_extent':
                    has_entries({
                        'start':
                        has_entries({
                            'line_num': 11,
                            'column_num': 2,
                        }),
                        'end':
                        has_entries({
                            'line_num': 11,
                            'column_num': 2,
                        }),
                    })
                })))
Пример #2
0
def Subcommands_FixIt_Range_test(app):
    fixit_test = PathToTestFile('testy', 'FixItTestCase.cs')
    with WrapOmniSharpServer(app, fixit_test):
        contents = ReadFile(fixit_test)

        request = BuildRequest(completer_target='filetype_default',
                               command_arguments=['FixIt'],
                               line_num=5,
                               column_num=23,
                               contents=contents,
                               filetype='cs',
                               filepath=fixit_test)
        request.update({
            'range': {
                'start': {
                    'line_num': 5,
                    'column_num': 23
                },
                'end': {
                    'line_num': 5,
                    'column_num': 27
                }
            }
        })
        response = app.post_json('/run_completer_command', request).json
        assert_that(
            response,
            has_entries({
                'fixits':
                contains_exactly(
                    has_entries({
                        'text': 'Extract method',
                        'command': has_entries({'index': 0}),
                        'resolve': True
                    }),
                    has_entries({
                        'text': 'Extract local function',
                        'command': has_entries({'index': 1}),
                        'resolve': True
                    }),
                )
            }))
def Subcommands_Format_Works_test(app):
    filepath = PathToTestFile('testy', 'Program.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        request = BuildRequest(command_arguments=['Format'],
                               line_num=1,
                               column_num=1,
                               contents=contents,
                               filetype='cs',
                               filepath=filepath)

        response = app.post_json('/run_completer_command', request).json
        print('completer response = ', response)
        assert_that(
            response,
            has_entries({
                'fixits':
                contains_exactly(
                    has_entries({
                        'location':
                        LocationMatcher(filepath, 1, 1),
                        'chunks':
                        contains_exactly(
                            ChunkMatcher('\n        }\n    ',
                                         LocationMatcher(filepath, 11, 1),
                                         LocationMatcher(filepath, 12, 2)),
                            ChunkMatcher('            ',
                                         LocationMatcher(filepath, 10, 1),
                                         LocationMatcher(filepath, 10, 4)),
                            ChunkMatcher('        {\n            ',
                                         LocationMatcher(filepath, 8, 1),
                                         LocationMatcher(filepath, 9, 4)),
                            ChunkMatcher('', LocationMatcher(filepath, 7, 26),
                                         LocationMatcher(filepath, 7, 27)),
                            ChunkMatcher(
                                '    class MainClass\n    {\n        ',
                                LocationMatcher(filepath, 5, 1),
                                LocationMatcher(filepath, 7, 3)),
                        )
                    }))
            }))
def Subcommands_GetDoc_Variable_test(app):
    filepath = PathToTestFile('testy', 'GetDocTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        getdoc_data = BuildRequest(completer_target='filetype_default',
                                   command_arguments=['GetDoc'],
                                   line_num=13,
                                   column_num=28,
                                   contents=contents,
                                   filetype='cs',
                                   filepath=filepath)

        eq_(
            {
                'detailed_info':
                'int GetDocTestCase.an_int;\n'
                'an integer, or something',
            },
            app.post_json('/run_completer_command', getdoc_data).json)
def SignatureHelp_NotAFunction_NoError_test( app ):
  filepath = PathToTestFile( 'testy', 'ContinuousTest.cs' )
  contents = ReadFile( filepath )
  request = BuildRequest(
    line_num = 19,
    column_num = 7,
    filetypes = [ 'cs' ],
    filepath = filepath,
    contents = contents )
  with WrapOmniSharpServer( app, filepath ):
    response = app.post_json( '/signature_help', request ).json
    LOGGER.debug( 'response = %s', response )
    assert_that( response, has_entries( {
      'errors': empty(),
      'signature_help': has_entries( {
        'activeSignature': 0,
        'activeParameter': 0,
        'signatures': empty()
      } )
    } ) )
Пример #6
0
def Diagnostics_ZeroBasedLineAndColumn_test( app ):
  filepath = PathToTestFile( 'testy', 'Program.cs' )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )

    event_data = BuildRequest( filepath = filepath,
                               event_name = 'FileReadyToParse',
                               filetype = 'cs',
                               contents = contents )

    results = app.post_json( '/event_notification', event_data ).json

    assert_that( results, has_items(
      has_entries( {
        'kind': equal_to( 'ERROR' ),
        'text': contains_string( "Identifier expected" ),
        'location': LocationMatcher( filepath, 10, 12 ),
        'location_extent': RangeMatcher( filepath, ( 10, 12 ), ( 10, 12 ) ),
      } )
    ) )
def GetCompletions_Unicode_test( app ):
  filepath = PathToTestFile( 'testy', 'Unicode.cs' )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )

    completion_data = BuildRequest( filepath = filepath,
                                    filetype = 'cs',
                                    contents = contents,
                                    line_num = 43,
                                    column_num = 26 )
    response_data = app.post_json( '/completions', completion_data ).json

    assert_that( response_data[ 'completions' ],
                 has_items(
                   CompletionEntryMatcher( 'DoATest' ),
                   CompletionEntryMatcher( 'an_int' ),
                   CompletionEntryMatcher( 'a_unicøde' ),
                   CompletionEntryMatcher( 'øøø' ) ) )

    eq_( 26, response_data[ 'completion_start_column' ] )
Пример #8
0
def Subcommands_GoToImplementation_Basic_test( app ):
  filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )

    goto_data = BuildRequest(
      completer_target = 'filetype_default',
      command_arguments = [ 'GoToImplementation' ],
      line_num = 13,
      column_num = 13,
      contents = contents,
      filetype = 'cs',
      filepath = filepath
    )

    eq_( {
      'filepath': PathToTestFile( 'testy', 'GotoTestCase.cs' ),
      'line_num': 30,
      'column_num': 3
    }, app.post_json( '/run_completer_command', goto_data ).json )
Пример #9
0
def Subcommands_RefactorRename_MissingNewName_test(app):
    continuous_test = PathToTestFile('testy', 'ContinuousTest.cs')
    with WrapOmniSharpServer(app, continuous_test):
        contents = ReadFile(continuous_test)

        request = BuildRequest(completer_target='filetype_default',
                               command_arguments=['RefactorRename'],
                               line_num=5,
                               column_num=15,
                               contents=contents,
                               filetype='cs',
                               filepath=continuous_test)
        response = app.post_json('/run_completer_command',
                                 request,
                                 expect_errors=True).json
        assert_that(
            response,
            ErrorMatcher(
                ValueError, 'Please specify a new name to rename it to.\n'
                'Usage: RefactorRename <new name>'))
Пример #10
0
def Subcommands_GoToImplementationElseDeclaration_MultipleImplementations_test(
        app):
    filepath = PathToTestFile('testy', 'GotoTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        goto_data = BuildRequest(
            completer_target='filetype_default',
            command_arguments=['GoToImplementationElseDeclaration'],
            line_num=22,
            column_num=13,
            contents=contents,
            filetype='cs',
            filepath=filepath)

        response = app.post_json('/run_completer_command', goto_data).json
        assert_that(
            response,
            contains(LocationMatcher(filepath, 44, 15),
                     LocationMatcher(filepath, 49, 15)))
Пример #11
0
def Subcommands_GetDoc_Function_test(app):
    filepath = PathToTestFile('testy', 'GetDocTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        getdoc_data = BuildRequest(completer_target='filetype_default',
                                   command_arguments=['GetDoc'],
                                   line_num=33,
                                   column_num=27,
                                   contents=contents,
                                   filetype='cs',
                                   filepath=filepath)

        response = app.post_json('/run_completer_command', getdoc_data).json
        assert_that(
            response,
            has_entry(
                'detailed_info', 'int GetDocTestCase.DoATest()\n'
                'Very important method.\n\nWith multiple lines of '
                'commentary\nAnd Format-\n-ting'))
Пример #12
0
def Subcommands_CsCompleter_InvalidLocation_test( app ):
  filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )

    goto_data = BuildRequest(
      completer_target = 'filetype_default',
      command_arguments = [ 'GoToImplementation' ],
      line_num = 3,
      column_num = 1,
      contents = contents,
      filetype = 'cs',
      filepath = filepath
    )

    response =  app.post_json( '/run_completer_command',
                               goto_data,
                               expect_errors = True ).json
    assert_that( response, ErrorMatcher( RuntimeError,
                                         "Can't jump to implementation" ) )
Пример #13
0
    def test_Subcommands_GetDoc_Variable(self, app):
        filepath = PathToTestFile('testy', 'GetDocTestCase.cs')
        with WrapOmniSharpServer(app, filepath):
            contents = ReadFile(filepath)

            getdoc_data = BuildRequest(completer_target='filetype_default',
                                       command_arguments=['GetDoc'],
                                       line_num=13,
                                       column_num=28,
                                       contents=contents,
                                       filetype='cs',
                                       filepath=filepath)

            response = app.post_json('/run_completer_command',
                                     getdoc_data).json
            assert_that(
                response,
                has_entry(
                    'detailed_info', 'int GetDocTestCase.an_int\n'
                    'an integer, or something'))
Пример #14
0
    def test_Diagnostics_MaximumDiagnosticsNumberExceeded(self, app):
        filepath = PathToTestFile('testy', 'MaxDiagnostics.cs')
        with WrapOmniSharpServer(app, filepath):
            contents = ReadFile(filepath)

            event_data = BuildRequest(filepath=filepath,
                                      event_name='FileReadyToParse',
                                      filetype='cs',
                                      contents=contents)

            results = app.post_json('/event_notification', event_data).json

            assert_that(
                results,
                contains_exactly(
                    has_entries({
                        'kind':
                        equal_to('ERROR'),
                        'text':
                        contains_string(
                            "The type 'MaxDiagnostics' already contains "
                            "a definition for 'test'"),
                        'location':
                        LocationMatcher(filepath, 4, 16),
                        'location_extent':
                        RangeMatcher(filepath, (4, 16), (4, 20))
                    }),
                    has_entries({
                        'kind':
                        equal_to('ERROR'),
                        'text':
                        contains_string(
                            'Maximum number of diagnostics exceeded.'),
                        'location':
                        LocationMatcher(filepath, 1, 1),
                        'location_extent':
                        RangeMatcher(filepath, (1, 1), (1, 1)),
                        'ranges':
                        contains_exactly(RangeMatcher(filepath, (1, 1),
                                                      (1, 1)))
                    })))
Пример #15
0
def GetCompletions_ForcedDividesCache_test( app ):
  filepath = PathToTestFile( 'testy', 'ContinuousTest.cs' )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )
    event_data = BuildRequest( filepath = filepath,
                               filetype = 'cs',
                               contents = contents,
                               event_name = 'FileReadyToParse' )

    app.post_json( '/event_notification', event_data )

    completion_data = BuildRequest( filepath = filepath,
                                    filetype = 'cs',
                                    contents = contents,
                                    line_num = 9,
                                    column_num = 21,
                                    force_semantic = True,
                                    query = 'Date' )
    results = app.post_json( '/completions', completion_data ).json

    assert_that( results[ 'completions' ], not( empty() ) )
    assert_that( results[ 'errors' ], empty() )

    completion_data = BuildRequest( filepath = filepath,
                                    filetype = 'cs',
                                    contents = contents,
                                    line_num = 9,
                                    column_num = 21,
                                    force_semantic = False,
                                    query = 'Date' )
    results = app.post_json( '/completions', completion_data ).json

    # There are no semantic completions. However, we fall back to identifier
    # completer in this case.
    assert_that( results, has_entries( {
      'completions': has_item( has_entries( {
        'insertion_text' : 'String',
        'extra_menu_info': '[ID]',
      } ) ),
      'errors': empty(),
    } ) )
Пример #16
0
def Diagnostics_WithRange_test(app):
    filepath = PathToTestFile('testy', 'DiagnosticRange.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        results = {}
        for _ in (0, 1):  # First call always returns blank for some reason
            event_data = BuildRequest(filepath=filepath,
                                      event_name='FileReadyToParse',
                                      filetype='cs',
                                      contents=contents)

            results = app.post_json('/event_notification', event_data).json

        assert_that(
            results,
            contains(
                has_entries({
                    'kind':
                    equal_to('WARNING'),
                    'text':
                    contains_string("Name should have prefix '_'"),
                    'location':
                    has_entries({
                        'line_num': 3,
                        'column_num': 16
                    }),
                    'location_extent':
                    has_entries({
                        'start':
                        has_entries({
                            'line_num': 3,
                            'column_num': 16,
                        }),
                        'end':
                        has_entries({
                            'line_num': 3,
                            'column_num': 25,
                        }),
                    })
                })))
Пример #17
0
def Subcommands_RefactorRename_Unicode_test( app ):
  unicode_test = PathToTestFile( 'testy', 'Unicode.cs' )
  with WrapOmniSharpServer( app, unicode_test ):
    contents = ReadFile( unicode_test )

    request = BuildRequest( completer_target = 'filetype_default',
                            command_arguments = [ 'RefactorRename', 'x' ],
                            line_num = 30,
                            column_num = 31,
                            contents = contents,
                            filetype = 'cs',
                            filepath = unicode_test )
    response = app.post_json( '/run_completer_command', request ).json
    assert_that( response, has_entries( {
      'fixits': contains_exactly( has_entries( {
        'location': LocationMatcher( unicode_test, 30, 31 ),
        'chunks': contains_exactly(
          has_entries( {
            'replacement_text': 'x',
            'range': RangeMatcher( unicode_test, ( 30, 29 ), ( 30, 35 ) ) } )
        ) } ) ) } ) )
Пример #18
0
def Diagnostics_WithRange_test( app ):
  filepath = PathToTestFile( 'testy', 'DiagnosticRange.cs' )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )

    event_data = BuildRequest( filepath = filepath,
                               event_name = 'FileReadyToParse',
                               filetype = 'cs',
                               contents = contents )

    results = app.post_json( '/event_notification', event_data ).json

    assert_that( results, contains_exactly(
      has_entries( {
        'kind': equal_to( 'WARNING' ),
        'text': contains_string(
          "The variable '\u4e5d' is assigned but its value is never used" ),
        'location': LocationMatcher( filepath, 6, 13 ),
        'location_extent': RangeMatcher( filepath, ( 6, 13 ), ( 6, 16 ) )
      } )
    ) )
Пример #19
0
def Diagnostics_Basic_test(app):
    filepath = PathToTestFile('testy', 'Program.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        event_data = BuildRequest(filepath=filepath,
                                  event_name='FileReadyToParse',
                                  filetype='cs',
                                  contents=contents)
        app.post_json('/event_notification', event_data)

        diag_data = BuildRequest(filepath=filepath,
                                 filetype='cs',
                                 contents=contents,
                                 line_num=10,
                                 column_num=2)

        results = app.post_json('/detailed_diagnostic', diag_data).json
        assert_that(
            results,
            has_entry('message', contains_string("Identifier expected")))
Пример #20
0
def Subcommands_RestartServer_PidChanges_test(app):
    filepath = PathToTestFile('testy', 'GotoTestCase.cs')
    with WrapOmniSharpServer(app, filepath):

        def GetPid():
            request_data = BuildRequest(filetype='cs', filepath=filepath)
            debug_info = app.post_json('/debug_info', request_data).json
            return debug_info["completer"]["servers"][0]["pid"]

        old_pid = GetPid()

        app.post_json(
            '/run_completer_command',
            BuildRequest(filetype='cs',
                         filepath=filepath,
                         command_arguments=['RestartServer']))
        WaitUntilCompleterServerReady(app, 'cs')

        new_pid = GetPid()

        assert old_pid != new_pid, '%r == %r' % (old_pid, new_pid)
Пример #21
0
def Subcommands_GoToImplementation_NoImplementation_test(app):
    filepath = PathToTestFile('testy', 'GotoTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        goto_data = BuildRequest(completer_target='filetype_default',
                                 command_arguments=['GoToImplementation'],
                                 line_num=17,
                                 column_num=13,
                                 contents=contents,
                                 filetype='cs',
                                 filepath=filepath)

        try:
            app.post_json('/run_completer_command', goto_data).json
            raise Exception("Expected a 'No implementations found' error")
        except AppError as e:
            if 'No implementations found' in str(e):
                pass
            else:
                raise
Пример #22
0
def Subcommands_RefactorRename_Basic_test( app ):
  continuous_test = PathToTestFile( 'testy', 'ContinuousTest.cs' )
  with WrapOmniSharpServer( app, continuous_test ):
    contents = ReadFile( continuous_test )

    request = BuildRequest( completer_target = 'filetype_default',
                            command_arguments = [ 'RefactorRename', 'x' ],
                            line_num = 5,
                            column_num = 15,
                            contents = contents,
                            filetype = 'cs',
                            filepath = continuous_test )
    response = app.post_json( '/run_completer_command', request ).json
    assert_that( response, has_entries( { 'fixits': contains( has_entries( {
      'location': LocationMatcher( continuous_test, 5, 15 ),
      'chunks': contains(
        has_entries( {
          'replacement_text': 'x',
          'range': RangeMatcher( continuous_test, ( 5, 15 ), ( 5, 29 ) ) } )
      )
    } ) ) } ) )
Пример #23
0
def GetCompletions_MultipleSolution_test(app):
    filepaths = [
        PathToTestFile('testy', 'Program.cs'),
        PathToTestFile('testy-multiple-solutions',
                       'solution-named-like-folder', 'testy', 'Program.cs')
    ]
    lines = [10, 9]
    for filepath, line in zip(filepaths, lines):
        with WrapOmniSharpServer(app, filepath):
            contents = ReadFile(filepath)

            completion_data = BuildRequest(filepath=filepath,
                                           filetype='cs',
                                           contents=contents,
                                           line_num=line,
                                           column_num=12)
            response_data = app.post_json('/completions', completion_data).json
            assert_that(
                response_data['completions'],
                has_items(CompletionEntryMatcher('CursorLeft'),
                          CompletionEntryMatcher('CursorSize')))
            eq_(12, response_data['completion_start_column'])
Пример #24
0
def GetCompletions_DefaultToIdentifier_test(app):
    filepath = PathToTestFile('testy', 'Program.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        completion_data = BuildRequest(filepath=filepath,
                                       filetype='cs',
                                       contents=contents,
                                       line_num=10,
                                       column_num=7)
        response_data = app.post_json('/completions', completion_data).json
        print('Response: ', response_data)
        assert_that(
            response_data,
            has_entries({
                'completion_start_column':
                4,
                'completions':
                has_items(CompletionEntryMatcher('Console', '[ID]'), ),
                'errors':
                empty(),
            }))
Пример #25
0
def RunFixItTest( app,
                  line,
                  column,
                  result_matcher,
                  filepath = [ 'testy', 'FixItTestCase.cs' ] ):
  filepath = PathToTestFile( *filepath )
  with WrapOmniSharpServer( app, filepath ):
    contents = ReadFile( filepath )

    fixit_data = BuildRequest( completer_target = 'filetype_default',
                               command_arguments = [ 'FixIt' ],
                               line_num = line,
                               column_num = column,
                               contents = contents,
                               filetype = 'cs',
                               filepath = filepath )

    response = app.post_json( '/run_completer_command', fixit_data ).json

    pprint.pprint( response )

    assert_that( response, result_matcher )
Пример #26
0
def Subcommands_GetDoc_Function_test(app):
    filepath = PathToTestFile('testy', 'GetDocTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        getdoc_data = BuildRequest(completer_target='filetype_default',
                                   command_arguments=['GetDoc'],
                                   line_num=33,
                                   column_num=27,
                                   contents=contents,
                                   filetype='cs',
                                   filepath=filepath)

        # It seems that Omnisharp server eats newlines
        eq_(
            {
                'detailed_info':
                'int GetDocTestCase.DoATest();\n'
                ' Very important method. With multiple lines of '
                'commentary And Format- -ting',
            },
            app.post_json('/run_completer_command', getdoc_data).json)
Пример #27
0
def Subcommands_CsCompleter_InvalidLocation_test(app):
    filepath = PathToTestFile('testy', 'GotoTestCase.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        goto_data = BuildRequest(completer_target='filetype_default',
                                 command_arguments=['GoToImplementation'],
                                 line_num=2,
                                 column_num=1,
                                 contents=contents,
                                 filetype='cs',
                                 filepath=filepath)

        try:
            app.post_json('/run_completer_command', goto_data).json
            raise Exception(
                'Expected a "Can\\\'t jump to implementation" error')
        except AppError as e:
            if 'Can\\\'t jump to implementation' in str(e):
                pass
            else:
                raise
Пример #28
0
def Subcommands_FixIt_Multi_test( app ):
  fixit_test = PathToTestFile( 'testy', 'FixItTestCase.cs' )
  with WrapOmniSharpServer( app, fixit_test ):
    contents = ReadFile( fixit_test )

    request = BuildRequest( completer_target = 'filetype_default',
                            command_arguments = [ 'FixIt' ],
                            line_num = 4,
                            column_num = 27,
                            contents = contents,
                            filetype = 'cs',
                            filepath = fixit_test )
    response = app.post_json( '/run_completer_command', request ).json
    assert_that( response, has_entries( {
      'fixits': contains_exactly(
        has_entries( {
          'text': 'Introduce constant',
          'command': has_entries( { 'index': 0 } ),
          'resolve': True } ),
        has_entries( {
          'text': 'Convert to binary',
          'command': has_entries( { 'index': 1 } ),
          'resolve': True } ),
        has_entries( {
          'text': 'Convert to hex',
          'command': has_entries( { 'index': 2 } ),
          'resolve': True } ),
      ) } ) )
    request.pop( 'command_arguments' )
    request.update( { 'fixit': response[ 'fixits' ][ 1 ] } )
    response = app.post_json( '/resolve_fixit', request ).json
    LOGGER.debug( 'r = %s', response )
    assert_that( response, has_entries( {
      'fixits': contains_exactly( has_entries( {
        'location': LocationMatcher( fixit_test, 4, 27 ),
        'chunks': contains_exactly(
          has_entries( { 'replacement_text': '0b101', } ) )
      } ) ) } ) )
Пример #29
0
def GetCompletions_ImportsOrderedAfter_test(app):
    filepath = PathToTestFile('testy', 'ImportTest.cs')
    with WrapOmniSharpServer(app, filepath):
        contents = ReadFile(filepath)

        completion_data = BuildRequest(filepath=filepath,
                                       filetype='cs',
                                       contents=contents,
                                       line_num=9,
                                       column_num=12,
                                       force_semantic=True,
                                       query='Date')
        response_data = app.post_json('/completions', completion_data).json

        min_import_index = min(
            loc for loc, val in enumerate(response_data['completions'])
            if val['extra_data']['required_namespace_import'])

        max_nonimport_index = max(
            loc for loc, val in enumerate(response_data['completions'])
            if not val['extra_data']['required_namespace_import'])

        assert_that(min_import_index, greater_than(max_nonimport_index)),
Пример #30
0
def SignatureHelp_TriggerParen_test( app ):
  filepath = PathToTestFile( 'testy', 'ContinuousTest.cs' )
  contents = ReadFile( filepath )
  request = BuildRequest(
    line_num = 10,
    column_num = 9,
    filetypes = [ 'cs' ],
    filepath = filepath,
    contents = contents )
  with WrapOmniSharpServer( app, filepath ):
    response = app.post_json( '/signature_help', request ).json
    LOGGER.debug( 'response = %s', response )
    assert_that( response, has_entries( {
      'errors': empty(),
      'signature_help': has_entries( {
        'activeSignature': 0,
        'activeParameter': 0,
        'signatures': contains_exactly(
          SignatureMatcher( 'void ContinuousTest.Main(string[] args)',
                            [ ParameterMatcher( 25, 38 ) ] )
        )
      } )
    } ) )