def FixIt_Check_AutoExpand_Resolved( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( has_entries( { 'text': "Expand auto type", 'chunks': contains_exactly( ChunkMatcher( 'const char *', LineColMatcher( 80, 1 ), LineColMatcher( 80, 6 ) ), ) } ) ) } ) )
def FixIt_Check_RawStringReplace_Resolved( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( has_entries( { 'text': 'Convert to raw string', 'chunks': contains_exactly( ChunkMatcher( 'R"(\\\\r\\asd\n\\v)"', LineColMatcher( 80, 19 ), LineColMatcher( 80, 36 ) ), ) } ) ) } ) )
def FixIt_Check_MacroExpand_Resolved( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( has_entries( { 'text': "Expand macro 'DECLARE_INT'", 'chunks': contains_exactly( ChunkMatcher( 'int i', LineColMatcher( 83, 3 ), LineColMatcher( 83, 17 ) ), ) } ) ) } ) )
def FixIt_Check_cpp11_Note(results): assert_that( results, has_entries({ 'fixits': contains( # First note: put parens around it has_entries({ 'text': contains_string('parentheses around the assignment'), 'chunks': contains( ChunkMatcher('(', LineColMatcher(59, 8), LineColMatcher(59, 8)), ChunkMatcher(')', LineColMatcher(61, 12), LineColMatcher(61, 12))), 'location': LineColMatcher(60, 1), }), # Second note: change to == has_entries({ 'text': contains_string('=='), 'chunks': contains( ChunkMatcher('==', LineColMatcher(60, 8), LineColMatcher(60, 9))), 'location': LineColMatcher(60, 1), })) }))
def FixIt_Check_cuda( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( has_entries( { 'text': contains_string( "change 'int' to 'void'" ), 'chunks': contains_exactly( ChunkMatcher( 'void', LineColMatcher( 3, 12 ), LineColMatcher( 3, 15 ) ) ), 'location': LineColMatcher( 3, 12 ), } ) ) } ) )
def FixIt_Check_SubexprExtract_Resolved( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( has_entries( { 'text': 'Extract subexpression to variable', 'chunks': contains_exactly( ChunkMatcher( 'auto dummy = i + 3;\n ', LineColMatcher( 84, 3 ), LineColMatcher( 84, 3 ) ), ChunkMatcher( 'dummy', LineColMatcher( 84, 14 ), LineColMatcher( 84, 21 ) ), ) } ) ) } ) )
def FixIt_Check_cpp11_SpellCheck( results ): assert_that( results, has_entries( { 'fixits': contains( # Change to SpellingIsNotMyStrongPoint has_entries( { 'text': contains_string( "did you mean 'SpellingIsNotMyStrongPoint'" ), 'chunks': contains( ChunkMatcher( 'SpellingIsNotMyStrongPoint', LineColMatcher( 72, 9 ), LineColMatcher( 72, 35 ) ) ), 'location': LineColMatcher( 72, 9 ), } ) ) } ) )
def FixIt_Check_cpp11_Note( results ): assert_that( results, has_entries( { 'fixits': contains( # First note: put parens around it has_entries( { 'text': contains_string( 'parentheses around the assignment' ), 'chunks': contains( ChunkMatcher( '(', LineColMatcher( 59, 8 ), LineColMatcher( 59, 8 ) ), ChunkMatcher( ')', LineColMatcher( 61, 12 ), LineColMatcher( 61, 12 ) ) ), 'location': LineColMatcher( 60, 1 ), } ), # Second note: change to == has_entries( { 'text': contains_string( '==' ), 'chunks': contains( ChunkMatcher( '==', LineColMatcher( 60, 8 ), LineColMatcher( 60, 9 ) ) ), 'location': LineColMatcher( 60, 1 ), } ), # Unresolved, requires /resolve_fixit request has_entries( { 'text': 'Extract subexpression to variable', 'resolve': True, 'command': has_entries( { 'command': 'clangd.applyTweak' } ) } ) ) } ) )
def Subcommands_RefactorRename_test( app ): test = { 'request': { 'filetype': 'cpp', 'completer_target': 'filetype_default', 'contents': ReadFile( PathToTestFile( 'basic.cpp' ) ), 'filepath': PathToTestFile( 'basic.cpp' ), 'command_arguments': [ 'RefactorRename', 'Bar' ], 'line_num': 17, 'column_num': 4, }, 'expect': { 'response': requests.codes.ok, 'data': has_entries( { 'fixits': contains_exactly( has_entries( { 'chunks': contains_exactly( ChunkMatcher( 'Bar', LineColMatcher( 1, 8 ), LineColMatcher( 1, 11 ) ), ChunkMatcher( 'Bar', LineColMatcher( 9, 3 ), LineColMatcher( 9, 6 ) ), ChunkMatcher( 'Bar', LineColMatcher( 15, 8 ), LineColMatcher( 15, 11 ) ), ChunkMatcher( 'Bar', LineColMatcher( 17, 3 ), LineColMatcher( 17, 6 ) ), ) } ) ) } ) }, 'route': '/run_completer_command' } RunAfterInitialized( app, test )
def FixIt_Check_cuda( results ): assert_that( results, has_entries( { 'fixits': contains( has_entries( { 'text': contains_string( "error: kernel function type 'int ()' must have void " ), 'chunks': contains( ChunkMatcher( 'void', LineColMatcher( 3, 12 ), LineColMatcher( 3, 15 ) ) ), 'location': LineColMatcher( 3, 12 ), } ) ) } ) )
def FixIt_Check_cpp11_SpellCheck( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( # Change to SpellingIsNotMyStrongPoint has_entries( { 'kind': 'quickfix', 'text': contains_string( "change 'SpellingIsNotMyStringPiont' to " "'SpellingIsNotMyStrongPoint'" ), 'chunks': contains_exactly( ChunkMatcher( 'SpellingIsNotMyStrongPoint', LineColMatcher( 72, 9 ), LineColMatcher( 72, 35 ) ) ), 'location': LineColMatcher( 72, 9 ), } ) ) } ) )
def Subcommands_RefactorRename_test( app ): test = { 'request': { 'filetype': 'cpp', 'completer_target': 'filetype_default', 'contents': ReadFile( PathToTestFile( 'basic.cpp' ) ), 'filepath': PathToTestFile( 'basic.cpp' ), 'command_arguments': [ 'RefactorRename', 'Bar' ], 'line_num': 17, 'column_num': 4, }, 'expect': { 'response': requests.codes.ok, 'data': has_entries( { 'fixits': contains( has_entries( { 'chunks': contains( ChunkMatcher( 'Bar', LineColMatcher( 1, 8 ), LineColMatcher( 1, 11 ) ), ChunkMatcher( 'Bar', LineColMatcher( 9, 3 ), LineColMatcher( 9, 6 ) ), # NOTE: Bug in clangd. It returns the same chunk twice which is a # strict protocol violation. ChunkMatcher( 'Bar', LineColMatcher( 15, 8 ), LineColMatcher( 15, 11 ) ), ChunkMatcher( 'Bar', LineColMatcher( 15, 8 ), LineColMatcher( 15, 11 ) ), ChunkMatcher( 'Bar', LineColMatcher( 17, 3 ), LineColMatcher( 17, 6 ) ) ) } ) ) } ) }, 'route': '/run_completer_command' } RunAfterInitialized( app, test )
def FixIt_Check_cpp11_SpellCheck( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( # Change to SpellingIsNotMyStrongPoint has_entries( { 'kind': 'quickfix', 'text': contains_string( "change 'SpellingIsNotMyStringPiont' to " "'SpellingIsNotMyStrongPoint'" ), 'chunks': contains_exactly( ChunkMatcher( 'SpellingIsNotMyStrongPoint', LineColMatcher( 72, 9 ), LineColMatcher( 72, 35 ) ) ), 'location': LineColMatcher( 72, 9 ), } ), has_entries( { 'kind': 'refactor', 'text': contains_string( "Add using-declaration for " "SpellingIsNotMyStrongPoint and " "remove qualifier." ), 'resolve': True } ) ) } ) )