def CppBindings_IdentifierCompleter_test(): identifier_completer = ycm_core.IdentifierCompleter() identifiers = ycm_core.StringVector() identifiers.append( ToCppStr( 'foo' ) ) identifiers.append( ToCppStr( 'bar' ) ) identifiers.append( ToCppStr( 'baz' ) ) identifier_completer.AddIdentifiersToDatabase( identifiers, ToCppStr( 'foo' ), ToCppStr( 'file' ) ) del identifiers query_fo_10 = identifier_completer.CandidatesForQueryAndType( ToCppStr( 'fo' ), ToCppStr( 'foo' ), 10 ) query_fo = identifier_completer.CandidatesForQueryAndType( ToCppStr( 'fo' ), ToCppStr( 'foo' ) ) query_a = identifier_completer.CandidatesForQueryAndType( ToCppStr( 'a' ), ToCppStr( 'foo' ) ) assert_that( query_fo_10, contains( 'foo' ) ) assert_that( query_fo, contains( 'foo' ) ) assert_that( query_a, contains( 'bar', 'baz' ) ) identifiers = ycm_core.StringVector() identifiers.append( ToCppStr( 'oof' ) ) identifiers.append( ToCppStr( 'rab' ) ) identifiers.append( ToCppStr( 'zab' ) ) identifier_completer.ClearForFileAndAddIdentifiersToDatabase( identifiers, ToCppStr( 'foo' ), ToCppStr( 'file' ) ) query_a_10 = identifier_completer.CandidatesForQueryAndType( ToCppStr( 'a' ), ToCppStr( 'foo' ) ) assert_that( query_a_10, contains( 'rab', 'zab' ) )
def CppBindings_DefinitionLocation_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 9 column = 17 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc++' ) ) reparse = True clang_completer = ycm_core.ClangCompleter() location = clang_completer.GetDefinitionLocation( translation_unit, filename, line, column, unsaved_file_vector, flags, reparse ) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse assert_that( location, has_properties( { 'line_number_': 2, 'column_number_': 5, 'filename_': PathToTestFile( 'foo.c' ) } ) )
def CppBindings_GetType_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 9 column = 17 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc++' ) ) reparse = True clang_completer = ycm_core.ClangCompleter() type_at_cursor = clang_completer.GetTypeAtLocation( translation_unit, filename, line, column, unsaved_file_vector, flags, reparse ) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse eq_( 'int ()', type_at_cursor )
def CppBindings_GetParent_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 9 column = 17 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc++' ) ) reparse = True clang_completer = ycm_core.ClangCompleter() enclosing_function = ( clang_completer .GetEnclosingFunctionAtLocation( translation_unit, filename, line, column, unsaved_file_vector, flags, reparse ) ) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse eq_( 'bar', enclosing_function )
def PrepareFlagsForClang( flags, filename, add_extra_clang_flags = True, enable_windows_style_flags = False ): flags = _AddLanguageFlagWhenAppropriate( flags, enable_windows_style_flags ) flags = _RemoveXclangFlags( flags ) flags = RemoveUnusedFlags( flags, filename, enable_windows_style_flags ) if add_extra_clang_flags: # This flag tells libclang where to find the builtin includes. flags.append( '-resource-dir=' + CLANG_RESOURCE_DIR ) # On Windows, parsing of templates is delayed until instantiation time. # This makes GetType and GetParent commands fail to return the expected # result when the cursor is in a template. # Using the -fno-delayed-template-parsing flag disables this behavior. See # http://clang.llvm.org/extra/PassByValueTransform.html#note-about-delayed-template-parsing # noqa # for an explanation of the flag and # https://code.google.com/p/include-what-you-use/source/detail?r=566 # for a similar issue. if OnWindows(): flags.append( '-fno-delayed-template-parsing' ) if OnMac(): flags = AddMacIncludePaths( flags ) flags = _EnableTypoCorrection( flags ) vector = ycm_core.StringVector() for flag in flags: vector.append( flag ) return vector
def _AddIdentifiersFromSyntax(self, keyword_list, filetype): keyword_vector = ycm_core.StringVector() for keyword in keyword_list: keyword_vector.append(keyword) filepath = SYNTAX_FILENAME + filetype self._completer.AddIdentifiersToDatabase(keyword_vector, filetype, filepath)
def ToCppStringCompatible_Py3Int_test(): value = utils.ToCppStringCompatible(123) eq_(value, bytes(b'123')) ok_(isinstance(value, bytes)) vector = ycm_core.StringVector() vector.append(value) eq_(vector[0], '123')
def _IdentifiersFromBuffer(text, filetype, collect_from_comments_and_strings): if not collect_from_comments_and_strings: text = identifier_utils.RemoveIdentifierFreeText(text) idents = identifier_utils.ExtractIdentifiersFromText(text, filetype) vector = ycm_core.StringVector() for ident in idents: vector.append(ToCppStringCompatible(ident)) return vector
def ToCppStringCompatible_Py2Unicode_test(): value = utils.ToCppStringCompatible(u'abc') eq_(value, 'abc') eq_(type(value), type('')) vector = ycm_core.StringVector() vector.append(value) eq_(vector[0], 'abc')
def ToCppStringCompatible_Py2Int_test(): value = utils.ToCppStringCompatible(123) eq_(value, '123') eq_(type(value), type('')) vector = ycm_core.StringVector() vector.append(value) eq_(vector[0], '123')
def AddIdentifiersFromSyntax(self, keyword_list, filetypes): keyword_vector = ycm_core.StringVector() for keyword in keyword_list: keyword_vector.append(ToUtf8IfNeeded(keyword)) filepath = SYNTAX_FILENAME + filetypes[0] self._completer.AddIdentifiersToDatabase(keyword_vector, ToUtf8IfNeeded(filetypes[0]), ToUtf8IfNeeded(filepath))
def _AddIdentifiersFromTagFiles(self, tag_files): absolute_paths_to_tag_files = ycm_core.StringVector() for tag_file in self._FilterUnchangedTagFiles(tag_files): absolute_paths_to_tag_files.append(ToCppStringCompatible(tag_file)) if not absolute_paths_to_tag_files: return self._completer.AddIdentifiersToDatabaseFromTagFiles( absolute_paths_to_tag_files)
def CppBindings_FixIt_test(): translation_unit = ToCppStr(PathToTestFile('foo.c')) filename = ToCppStr(PathToTestFile('foo.c')) line = 3 column = 5 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append(ToCppStr('-xc++')) reparse = True clang_completer = ycm_core.ClangCompleter() fixits = clang_completer.GetFixItsForLocationInFile( translation_unit, filename, line, column, unsaved_file_vector, flags, reparse) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse assert_that( fixits, contains( has_properties({ 'text': (PathToTestFile('foo.c') + ':3:16: error: expected \';\' at end of declaration'), 'location': has_properties({ 'line_number_': 3, 'column_number_': 16, 'filename_': PathToTestFile('foo.c') }), 'chunks': contains( has_properties({ 'replacement_text': ';', 'range': has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }) })), })))
def CppBindings_FixItChunkVector_test(): flags = ycm_core.StringVector() flags.append(ToCppStr('-xc++')) clang_completer = ycm_core.ClangCompleter() translation_unit = PathToTestFile('foo.c') filename = PathToTestFile('foo.c') fixits = (clang_completer.GetFixItsForLocationInFile( ToCppStr(translation_unit), ToCppStr(filename), 3, 5, ycm_core.UnsavedFileVector(), flags, True)) fixit_chunks = fixits[0].chunks[0:1] EmplaceBack(fixit_chunks, fixit_chunks[0]) del translation_unit del flags del filename del clang_completer del fixits assert_that( fixit_chunks, contains( has_properties({ 'replacement_text': ';', 'range': has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }), }), has_properties({ 'replacement_text': ';', 'range': has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }), })))
def PrepareFlagsForClang(flags, filename, add_extra_clang_flags=True): flags = _AddLanguageFlagWhenAppropriate(flags) flags = _RemoveXclangFlags(flags) flags = _RemoveUnusedFlags(flags, filename) if add_extra_clang_flags: flags = _EnableTypoCorrection(flags) vector = ycm_core.StringVector() for flag in flags: vector.append(ToCppStringCompatible(flag)) return vector
def _AddIdentifier(self, identifier, request_data): filetype = request_data['first_filetype'] filepath = request_data['filepath'] if not filetype or not filepath or not identifier: return vector = ycm_core.StringVector() vector.append(identifier) LOGGER.info('Adding ONE buffer identifier for file: %s', filepath) self._completer.AddIdentifiersToDatabase(vector, filetype, filepath)
def CppBindings_StringVector_test(): str1 = 'foo' str2 = 'bar' str3 = 'baz' string_vector = ycm_core.StringVector() string_vector.append(ToCppStr(str1)) EmplaceBack(string_vector, ToCppStr(str2)) string_vector.append(ToCppStr(str3)) del str1 del str2 del str3 assert_that(string_vector, contains('foo', 'bar', 'baz'))
def CppBindings_CompletionDataVector_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 11 column = 6 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc' ) ) clang_completer = ycm_core.ClangCompleter() candidates = ( clang_completer .CandidatesForLocationInFile( translation_unit, filename, line, column, unsaved_file_vector, flags ) ) if candidates[ 0 ].TextToInsertInBuffer() == 'a': candidate = candidates[ 0 ] else: candidate = candidates[ 1 ] candidates = ycm_core.CompletionVector() candidates.append( candidate ) EmplaceBack( candidates, candidate ) del translation_unit del filename del candidate del clang_completer del line del column del flags del unsaved_file_vector candidates = [ ConvertCompletionData( x ) for x in candidates ] assert_that( candidates, contains_inanyorder( has_entries( { 'detailed_info': 'int a\n', 'extra_menu_info': 'int', 'insertion_text': 'a', 'kind': 'MEMBER', 'menu_text': 'a' } ), has_entries( { 'detailed_info': 'int a\n', 'extra_menu_info': 'int', 'insertion_text': 'a', 'kind': 'MEMBER', 'menu_text': 'a' } ) ) )
def PrepareFlagsForClang(flags, filename, add_extra_clang_flags=True): flags = _AddLanguageFlagWhenAppropriate(flags) flags = _RemoveXclangFlags(flags) flags = _RemoveUnusedFlags(flags, filename) if add_extra_clang_flags: if OnMac() and not _SysRootSpecifedIn(flags): for path in _MacIncludePaths(): flags.extend(['-isystem', path]) flags = _EnableTypoCorrection(flags) vector = ycm_core.StringVector() for flag in flags: vector.append(ToCppStringCompatible(flag)) return vector
def AddIdentifier(self, identifier, request_data): filetype = request_data['first_filetype'] filepath = request_data['filepath'] if not filetype or not filepath or not identifier: return vector = ycm_core.StringVector() vector.append(ToCppStringCompatible(identifier)) self._logger.info('Adding ONE buffer identifier for file: %s', filepath) self._completer.AddIdentifiersToDatabase( vector, ToCppStringCompatible(filetype), ToCppStringCompatible(filepath))
def CppBindings_Diags_test(): filename = ToCppStr(PathToTestFile('foo.c')) unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append(ToCppStr('-xc++')) reparse = True clang_completer = ycm_core.ClangCompleter() diag_vector = clang_completer.UpdateTranslationUnit( filename, unsaved_file_vector, flags) diags = [BuildDiagnosticData(x) for x in diag_vector] del diag_vector del filename del unsaved_file_vector del flags del clang_completer del reparse assert_that( diags, contains( has_entries({ 'kind': 'ERROR', 'text': contains_string('expected \';\' at end of declaration'), 'ranges': contains(), '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': 16, }), }), })))
def CppBindings_RangeVector_test(): flags = ycm_core.StringVector() flags.append('-xc++') clang_completer = ycm_core.ClangCompleter() translation_unit = PathToTestFile('foo.c') filename = PathToTestFile('foo.c') fixits = (clang_completer.GetFixItsForLocationInFile( translation_unit, filename, 3, 5, ycm_core.UnsavedFileVector(), flags, True)) fixit_range = fixits[0].chunks[0].range ranges = ycm_core.RangeVector() ranges.append(fixit_range) EmplaceBack(ranges, fixit_range) del flags del translation_unit del filename del clang_completer del fixits del fixit_range assert_that( ranges, contains_exactly( has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }), has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }), ))
def AddIdentifier( self, identifier, request_data ): try: filetype = request_data[ 'filetypes' ][ 0 ] except KeyError: filetype = None filepath = request_data[ 'filepath' ] if not filetype or not filepath or not identifier: return vector = ycm_core.StringVector() vector.append( ToUtf8IfNeeded( identifier ) ) self._logger.info( 'Adding ONE buffer identifier for file: %s', filepath ) self._completer.AddIdentifiersToDatabase( vector, ToUtf8IfNeeded( filetype ), ToUtf8IfNeeded( filepath ) )
def CppBindings_Candidates_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 11 column = 6 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc' ) ) reparse = True clang_completer = ycm_core.ClangCompleter() candidates = ( clang_completer .CandidatesForLocationInFile( translation_unit, filename, line, column, unsaved_file_vector, flags ) ) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse candidates = [ ConvertCompletionData( x ) for x in candidates ] assert_that( candidates, contains_inanyorder( has_entries( { 'detailed_info': 'float b\n', 'extra_menu_info': 'float', 'insertion_text': 'b', 'kind': 'MEMBER', 'menu_text': 'b' } ), has_entries( { 'detailed_info': 'int a\n', 'extra_menu_info': 'int', 'insertion_text': 'a', 'kind': 'MEMBER', 'menu_text': 'a' } ) ) )
def CppBindings_Docs_test(): translation_unit = ToCppStr(PathToTestFile('foo.c')) filename = ToCppStr(PathToTestFile('foo.c')) line = 9 column = 16 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append(ToCppStr('-xc++')) reparse = True clang_completer = ycm_core.ClangCompleter() docs = clang_completer.GetDocsForLocationInFile(translation_unit, filename, line, column, unsaved_file_vector, flags, reparse) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse assert_that( docs, has_properties({ 'comment_xml': '<Function file="' + PathToTestFile('foo.c') + '"' ' line="2" column="5"><Name>foooo</Name><USR>c:@F@foooo#' '</USR><Declaration>int foooo()</Declaration><Abstract>' '<Para> Foo</Para></Abstract></Function>', 'brief_comment': 'Foo', 'raw_comment': '/// Foo', 'canonical_type': 'int ()', 'display_name': 'foooo' }))
def AddIdentifiersFromTagFiles(self, tag_files): absolute_paths_to_tag_files = ycm_core.StringVector() for tag_file in tag_files: try: current_mtime = os.path.getmtime(tag_file) except: continue last_mtime = self._tags_file_last_mtime[tag_file] # We don't want to repeatedly process the same file over and over; we only # process if it's changed since the last time we looked at it if current_mtime <= last_mtime: continue self._tags_file_last_mtime[tag_file] = current_mtime absolute_paths_to_tag_files.append(ToCppStringCompatible(tag_file)) if not absolute_paths_to_tag_files: return self._completer.AddIdentifiersToDatabaseFromTagFiles( absolute_paths_to_tag_files)
def _SanitizeFlags( flags ): """Drops unsafe flags. Currently these are only -arch flags; they tend to crash libclang.""" sanitized_flags = [] saw_arch = False for i, flag in enumerate( flags ): if flag == '-arch': saw_arch = True continue elif flag.startswith( '-arch' ): continue elif saw_arch: saw_arch = False continue sanitized_flags.append( flag ) vector = ycm_core.StringVector() for flag in sanitized_flags: vector.append( ToUtf8IfNeeded( flag ) ) return vector
def FlagsForFile(filename, **kwargs): if database: # Bear in mind that compilation_info.compiler_flags_ does NOT return a # python list, but a "list-like" StringVec object compilation_info = GetCompilationInfoForFile(filename) if not compilation_info: retflags = ycm_core.StringVector() retflags.extend(flags) return {'flags': retflags, 'do_cache': True} final_flags = MakeRelativePathsInFlagsAbsolute( compilation_info.compiler_flags_, compilation_info.compiler_working_dir_) removal_list = [] for flag in final_flags: if flag.startswith('-m'): removal_list.append(flag) if flag.startswith('-f'): removal_list.append(flag) for flag in removal_list: final_flags.remove(flag) # NOTE: This is just for YouCompleteMe; it's highly likely that your project # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT. #try: # final_flags.remove( '-stdlib=libc++' ) #except ValueError: # pass else: relative_to = DirectoryOfThisScript() final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to) return {'flags': final_flags, 'do_cache': True}
def CppBindings_FixItVector_test(): flags = ycm_core.StringVector() flags.append(ToCppStr('-xc++')) clang_completer = ycm_core.ClangCompleter() translation_unit = PathToTestFile('foo.c') filename = ToCppStr(PathToTestFile('foo.c')) fixits = (clang_completer.GetFixItsForLocationInFile( ToCppStr(translation_unit), ToCppStr(filename), 3, 5, ycm_core.UnsavedFileVector(), flags, True)) fixits = fixits[0:1] EmplaceBack(fixits, fixits[0]) del translation_unit del flags del filename del clang_completer assert_that( fixits, contains( has_properties({ 'text': (PathToTestFile('foo.c') + ':3:16: error: expected \';\' at end of declaration'), 'location': has_properties({ 'line_number_': 3, 'column_number_': 16, 'filename_': PathToTestFile('foo.c') }), 'chunks': contains( has_properties({ 'replacement_text': ';', 'range': has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }) })), }), has_properties({ 'text': (PathToTestFile('foo.c') + ':3:16: error: expected \';\' at end of declaration'), 'location': has_properties({ 'line_number_': 3, 'column_number_': 16, 'filename_': PathToTestFile('foo.c') }), 'chunks': contains( has_properties({ 'replacement_text': ';', 'range': has_properties({ 'start_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), 'end_': has_properties({ 'line_number_': 3, 'column_number_': 16, }), }) })), })))
def CppBindings_ReadOnly_test(): assert_that( calling(ycm_core.CompletionData().__setattr__).with_args( 'kind_', ycm_core.CompletionData().kind_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Location().__setattr__).with_args('line_number_', 1), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Location().__setattr__).with_args( 'column_number_', 1), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Location().__setattr__).with_args('filename_', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Range().__setattr__).with_args( 'end_', ycm_core.Range().end_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Range().__setattr__).with_args( 'start_', ycm_core.Range().start_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.FixItChunk().__setattr__).with_args( 'range', ycm_core.FixItChunk().range), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.FixItChunk().__setattr__).with_args( 'replacement_text', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.FixIt().__setattr__).with_args( 'chunks', ycm_core.FixIt().chunks), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.FixIt().__setattr__).with_args( 'location', ycm_core.FixIt().location), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.FixIt().__setattr__).with_args('text', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args( 'ranges_', ycm_core.Diagnostic().ranges_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args( 'location_', ycm_core.Diagnostic().location_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args( 'location_extent_', ycm_core.Diagnostic().location_extent_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args( 'fixits_', ycm_core.Diagnostic().fixits_), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args('text_', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args( 'long_formatted_text_', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.Diagnostic().__setattr__).with_args( 'kind_', ycm_core.Diagnostic().kind_.WARNING), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.DocumentationData().__setattr__).with_args( 'raw_comment', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.DocumentationData().__setattr__).with_args( 'brief_comment', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.DocumentationData().__setattr__).with_args( 'canonical_type', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.DocumentationData().__setattr__).with_args( 'display_name', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(ycm_core.DocumentationData().__setattr__).with_args( 'comment_xml', 'foo'), raises(AttributeError, READONLY_MESSAGE)) db = ycm_core.CompilationDatabase('foo') assert_that( calling(db.__setattr__).with_args('database_directory', 'foo'), raises(AttributeError, READONLY_MESSAGE)) compilation_info = db.GetCompilationInfoForFile('foo.c') assert_that( calling(compilation_info.__setattr__).with_args( 'compiler_working_dir_', 'foo'), raises(AttributeError, READONLY_MESSAGE)) assert_that( calling(compilation_info.__setattr__).with_args( 'compiler_flags_', ycm_core.StringVector()), raises(AttributeError, READONLY_MESSAGE))