Running style_format.sh on codebase

This commit is contained in:
Strahinja Val Markovic 2013-10-29 19:13:52 -07:00
parent bff2584ec1
commit 227cceae8a
8 changed files with 75 additions and 72 deletions

View File

@ -80,10 +80,10 @@ std::vector< Diagnostic > ClangCompleter::UpdateTranslationUnit(
ReleaseGil unlock; ReleaseGil unlock;
bool translation_unit_created; bool translation_unit_created;
shared_ptr< TranslationUnit > unit = translation_unit_store_.GetOrCreate( shared_ptr< TranslationUnit > unit = translation_unit_store_.GetOrCreate(
filename, filename,
unsaved_files, unsaved_files,
flags, flags,
translation_unit_created ); translation_unit_created );
if ( !unit ) if ( !unit )
return std::vector< Diagnostic >(); return std::vector< Diagnostic >();
@ -93,6 +93,7 @@ std::vector< Diagnostic > ClangCompleter::UpdateTranslationUnit(
// parsed in the TU constructor // parsed in the TU constructor
if ( !translation_unit_created ) if ( !translation_unit_created )
return unit->Reparse( unsaved_files ); return unit->Reparse( unsaved_files );
return unit->LatestDiagnostics(); return unit->LatestDiagnostics();
} }
@ -116,7 +117,7 @@ ClangCompleter::CandidatesForLocationInFile(
const std::vector< std::string > &flags ) { const std::vector< std::string > &flags ) {
ReleaseGil unlock; ReleaseGil unlock;
shared_ptr< TranslationUnit > unit = shared_ptr< TranslationUnit > unit =
translation_unit_store_.GetOrCreate( filename, unsaved_files, flags ); translation_unit_store_.GetOrCreate( filename, unsaved_files, flags );
if ( !unit ) if ( !unit )
return std::vector< CompletionData >(); return std::vector< CompletionData >();
@ -135,7 +136,7 @@ Location ClangCompleter::GetDeclarationLocation(
const std::vector< std::string > &flags ) { const std::vector< std::string > &flags ) {
ReleaseGil unlock; ReleaseGil unlock;
shared_ptr< TranslationUnit > unit = shared_ptr< TranslationUnit > unit =
translation_unit_store_.GetOrCreate( filename, unsaved_files, flags ); translation_unit_store_.GetOrCreate( filename, unsaved_files, flags );
if ( !unit ) { if ( !unit ) {
return Location(); return Location();
@ -153,7 +154,7 @@ Location ClangCompleter::GetDefinitionLocation(
const std::vector< std::string > &flags ) { const std::vector< std::string > &flags ) {
ReleaseGil unlock; ReleaseGil unlock;
shared_ptr< TranslationUnit > unit = shared_ptr< TranslationUnit > unit =
translation_unit_store_.GetOrCreate( filename, unsaved_files, flags ); translation_unit_store_.GetOrCreate( filename, unsaved_files, flags );
if ( !unit ) { if ( !unit ) {
return Location(); return Location();

View File

@ -57,14 +57,14 @@ TranslationUnit::TranslationUnit(
std::vector< CXUnsavedFile > cxunsaved_files = std::vector< CXUnsavedFile > cxunsaved_files =
ToCXUnsavedFiles( unsaved_files ); ToCXUnsavedFiles( unsaved_files );
const CXUnsavedFile *unsaved = cxunsaved_files.size() > 0 const CXUnsavedFile *unsaved = cxunsaved_files.size() > 0
? &cxunsaved_files[ 0 ] : NULL; ? &cxunsaved_files[ 0 ] : NULL;
clang_translation_unit_ = clang_parseTranslationUnit( clang_translation_unit_ = clang_parseTranslationUnit(
clang_index, clang_index,
filename.c_str(), filename.c_str(),
&pointer_flags[ 0 ], &pointer_flags[ 0 ],
pointer_flags.size(), pointer_flags.size(),
const_cast<CXUnsavedFile *>(unsaved), const_cast<CXUnsavedFile *>( unsaved ),
cxunsaved_files.size(), cxunsaved_files.size(),
clang_defaultEditingTranslationUnitOptions() ); clang_defaultEditingTranslationUnitOptions() );
@ -146,7 +146,7 @@ std::vector< CompletionData > TranslationUnit::CandidatesForLocation(
std::vector< CXUnsavedFile > cxunsaved_files = std::vector< CXUnsavedFile > cxunsaved_files =
ToCXUnsavedFiles( unsaved_files ); ToCXUnsavedFiles( unsaved_files );
const CXUnsavedFile *unsaved = cxunsaved_files.size() > 0 const CXUnsavedFile *unsaved = cxunsaved_files.size() > 0
? &cxunsaved_files[ 0 ] : NULL; ? &cxunsaved_files[ 0 ] : NULL;
// codeCompleteAt reparses the TU if the underlying source file has changed on // codeCompleteAt reparses the TU if the underlying source file has changed on
// disk since the last time the TU was updated and there are no unsaved files. // disk since the last time the TU was updated and there are no unsaved files.
@ -163,7 +163,7 @@ std::vector< CompletionData > TranslationUnit::CandidatesForLocation(
filename_.c_str(), filename_.c_str(),
line, line,
column, column,
const_cast<CXUnsavedFile *>(unsaved), const_cast<CXUnsavedFile *>( unsaved ),
cxunsaved_files.size(), cxunsaved_files.size(),
clang_defaultCodeCompleteOptions() ), clang_defaultCodeCompleteOptions() ),
clang_disposeCodeCompleteResults ); clang_disposeCodeCompleteResults );
@ -242,8 +242,9 @@ void TranslationUnit::Reparse( std::vector< CXUnsavedFile > &unsaved_files,
if ( !clang_translation_unit_ ) if ( !clang_translation_unit_ )
return; return;
CXUnsavedFile *unsaved = unsaved_files.size() > 0 CXUnsavedFile *unsaved = unsaved_files.size() > 0
? &unsaved_files[ 0 ] : NULL; ? &unsaved_files[ 0 ] : NULL;
failure = clang_reparseTranslationUnit( clang_translation_unit_, failure = clang_reparseTranslationUnit( clang_translation_unit_,
unsaved_files.size(), unsaved_files.size(),

View File

@ -57,7 +57,7 @@ public:
bool IsCurrentlyUpdating() const; bool IsCurrentlyUpdating() const;
std::vector< Diagnostic > Reparse( std::vector< Diagnostic > Reparse(
const std::vector< UnsavedFile > &unsaved_files ); const std::vector< UnsavedFile > &unsaved_files );
void ReparseForIndexing( const std::vector< UnsavedFile > &unsaved_files ); void ReparseForIndexing( const std::vector< UnsavedFile > &unsaved_files );

View File

@ -79,7 +79,7 @@ shared_ptr< TranslationUnit > TranslationUnitStore::GetOrCreate(
// TU object. When we are done creating the TU, we will overwrite this value // TU object. When we are done creating the TU, we will overwrite this value
// with the valid object. // with the valid object.
filename_to_translation_unit_[ filename ] = filename_to_translation_unit_[ filename ] =
make_shared< TranslationUnit >(); make_shared< TranslationUnit >();
// We need to store the flags for the sentinel TU so that other threads end // We need to store the flags for the sentinel TU so that other threads end
// up returning the sentinel TU while the real one is being created. // up returning the sentinel TU while the real one is being created.
@ -110,7 +110,7 @@ shared_ptr< TranslationUnit > TranslationUnitStore::GetOrCreate(
shared_ptr< TranslationUnit > TranslationUnitStore::Get( shared_ptr< TranslationUnit > TranslationUnitStore::Get(
const std::string &filename ) { const std::string &filename ) {
lock_guard< mutex > lock( filename_to_translation_unit_and_flags_mutex_ ); lock_guard< mutex > lock( filename_to_translation_unit_and_flags_mutex_ );
return GetNoLock( filename ); return GetNoLock( filename );
} }
@ -131,7 +131,7 @@ void TranslationUnitStore::RemoveAll() {
shared_ptr< TranslationUnit > TranslationUnitStore::GetNoLock( shared_ptr< TranslationUnit > TranslationUnitStore::GetNoLock(
const std::string &filename ) { const std::string &filename ) {
return FindWithDefault( filename_to_translation_unit_, return FindWithDefault( filename_to_translation_unit_,
filename, filename,
shared_ptr< TranslationUnit >() ); shared_ptr< TranslationUnit >() );

View File

@ -67,10 +67,10 @@ private:
boost::shared_ptr< TranslationUnit > GetNoLock( const std::string &filename ); boost::shared_ptr< TranslationUnit > GetNoLock( const std::string &filename );
typedef boost::unordered_map< std::string, typedef boost::unordered_map < std::string,
boost::shared_ptr< TranslationUnit > > TranslationUnitForFilename; boost::shared_ptr< TranslationUnit > > TranslationUnitForFilename;
typedef boost::unordered_map< std::string, typedef boost::unordered_map < std::string,
std::size_t > FlagsHashForFilename; std::size_t > FlagsHashForFilename;
CXIndex clang_index_; CXIndex clang_index_;

View File

@ -30,7 +30,7 @@ namespace fs = boost::filesystem;
namespace { namespace {
const char * const COMMENT_AND_STRING_REGEX = const char *const COMMENT_AND_STRING_REGEX =
"//.*?$" // Anything following '//' "//.*?$" // Anything following '//'
"|" "|"
"#.*?$" // Anything following '#' "#.*?$" // Anything following '#'
@ -50,12 +50,12 @@ const char * const COMMENT_AND_STRING_REGEX =
// 3. the escaped double quote inside the string // 3. the escaped double quote inside the string
"(?<!\\\\)\"(?:\\\\\\\\|\\\\\"|.)*?\""; "(?<!\\\\)\"(?:\\\\\\\\|\\\\\"|.)*?\"";
const char * const IDENTIFIER_REGEX = "[_a-zA-Z]\\w*"; const char *const IDENTIFIER_REGEX = "[_a-zA-Z]\\w*";
// For details on the tag format supported, see here for details: // For details on the tag format supported, see here for details:
// http://ctags.sourceforge.net/FORMAT // http://ctags.sourceforge.net/FORMAT
// TL;DR: The only supported format is the one Exuberant Ctags emits. // TL;DR: The only supported format is the one Exuberant Ctags emits.
const char * const TAG_REGEX = const char *const TAG_REGEX =
"^([^\\t\\n\\r]+)" // The first field is the identifier "^([^\\t\\n\\r]+)" // The first field is the identifier
"\\t" // A TAB char is the field separator "\\t" // A TAB char is the field separator
// The second field is the path to the file that has the identifier; either // The second field is the path to the file that has the identifier; either
@ -71,11 +71,10 @@ const char * const TAG_REGEX =
// When passed a const char* this will create a temporary std::string for // When passed a const char* this will create a temporary std::string for
// comparison, but it's fast enough for our use case. // comparison, but it's fast enough for our use case.
struct StringEqualityComparer : struct StringEqualityComparer :
std::binary_function< std::string, std::string, bool > std::binary_function< std::string, std::string, bool > {
{ bool operator()( const std::string &a, const std::string &b ) const {
bool operator()( const std::string &a, const std::string &b ) const { return a == b;
return a == b; }
}
}; };
// List of languages Exuberant Ctags supports: // List of languages Exuberant Ctags supports:
@ -84,51 +83,51 @@ struct StringEqualityComparer :
// :e $VIMRUNTIME/filetype.vim // :e $VIMRUNTIME/filetype.vim
// This is a map of const char* and not std::string to prevent issues with // This is a map of const char* and not std::string to prevent issues with
// static initialization. // static initialization.
const boost::unordered_map< const char*, const boost::unordered_map < const char *,
const char*, const char *,
boost::hash< std::string >, boost::hash< std::string >,
StringEqualityComparer > LANG_TO_FILETYPE = StringEqualityComparer > LANG_TO_FILETYPE =
boost::assign::map_list_of boost::assign::map_list_of
( "Ant" , "ant" ) ( "Ant" , "ant" )
( "Asm" , "asm" ) ( "Asm" , "asm" )
( "Awk" , "awk" ) ( "Awk" , "awk" )
( "Basic" , "basic" ) ( "Basic" , "basic" )
( "C++" , "cpp" ) ( "C++" , "cpp" )
( "C#" , "cs" ) ( "C#" , "cs" )
( "C" , "c" ) ( "C" , "c" )
( "COBOL" , "cobol" ) ( "COBOL" , "cobol" )
( "DosBatch" , "dosbatch" ) ( "DosBatch" , "dosbatch" )
( "Eiffel" , "eiffel" ) ( "Eiffel" , "eiffel" )
( "Erlang" , "erlang" ) ( "Erlang" , "erlang" )
( "Fortran" , "fortran" ) ( "Fortran" , "fortran" )
( "HTML" , "html" ) ( "HTML" , "html" )
( "Java" , "java" ) ( "Java" , "java" )
( "JavaScript" , "javascript" ) ( "JavaScript" , "javascript" )
( "Lisp" , "lisp" ) ( "Lisp" , "lisp" )
( "Lua" , "lua" ) ( "Lua" , "lua" )
( "Make" , "make" ) ( "Make" , "make" )
( "MatLab" , "matlab" ) ( "MatLab" , "matlab" )
( "OCaml" , "ocaml" ) ( "OCaml" , "ocaml" )
( "Pascal" , "pascal" ) ( "Pascal" , "pascal" )
( "Perl" , "perl" ) ( "Perl" , "perl" )
( "PHP" , "php" ) ( "PHP" , "php" )
( "Python" , "python" ) ( "Python" , "python" )
( "REXX" , "rexx" ) ( "REXX" , "rexx" )
( "Ruby" , "ruby" ) ( "Ruby" , "ruby" )
( "Scheme" , "scheme" ) ( "Scheme" , "scheme" )
( "Sh" , "sh" ) ( "Sh" , "sh" )
( "SLang" , "slang" ) ( "SLang" , "slang" )
( "SML" , "sml" ) ( "SML" , "sml" )
( "SQL" , "sql" ) ( "SQL" , "sql" )
( "Tcl" , "tcl" ) ( "Tcl" , "tcl" )
( "Tex" , "tex" ) ( "Tex" , "tex" )
( "Vera" , "vera" ) ( "Vera" , "vera" )
( "Verilog" , "verilog" ) ( "Verilog" , "verilog" )
( "VHDL" , "vhdl" ) ( "VHDL" , "vhdl" )
( "Vim" , "vim" ) ( "Vim" , "vim" )
( "YACC" , "yacc" ); ( "YACC" , "yacc" );
const char * const NOT_FOUND = "YCMFOOBAR_NOT_FOUND"; const char *const NOT_FOUND = "YCMFOOBAR_NOT_FOUND";
} // unnamed namespace } // unnamed namespace

View File

@ -40,8 +40,10 @@ namespace {
std::string GetUtf8String( const boost::python::object &string_or_unicode ) { std::string GetUtf8String( const boost::python::object &string_or_unicode ) {
extract< std::string > to_string( string_or_unicode ); extract< std::string > to_string( string_or_unicode );
if ( to_string.check() ) if ( to_string.check() )
return to_string(); return to_string();
return extract< std::string >( str( string_or_unicode ).encode( "utf8" ) ); return extract< std::string >( str( string_or_unicode ).encode( "utf8" ) );
} }
@ -95,7 +97,7 @@ boost::python::list FilterAndSortCandidates(
continue; continue;
Result result = candidate->QueryMatchResult( query, Result result = candidate->QueryMatchResult( query,
query_has_uppercase_letters ); query_has_uppercase_letters );
if ( result.IsSubsequence() ) { if ( result.IsSubsequence() ) {
ResultAnd< int > object_and_result( i, result ); ResultAnd< int > object_and_result( i, result );

View File

@ -7,7 +7,7 @@ int main( int argc, char **argv ) {
// Necessary because of usage of the ReleaseGil class // Necessary because of usage of the ReleaseGil class
PyEval_InitThreads(); PyEval_InitThreads();
testing::InitGoogleMock(&argc, argv); testing::InitGoogleMock( &argc, argv );
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
} }