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

View File

@ -57,14 +57,14 @@ TranslationUnit::TranslationUnit(
std::vector< CXUnsavedFile > cxunsaved_files =
ToCXUnsavedFiles( unsaved_files );
const CXUnsavedFile *unsaved = cxunsaved_files.size() > 0
? &cxunsaved_files[ 0 ] : NULL;
? &cxunsaved_files[ 0 ] : NULL;
clang_translation_unit_ = clang_parseTranslationUnit(
clang_index,
filename.c_str(),
&pointer_flags[ 0 ],
pointer_flags.size(),
const_cast<CXUnsavedFile *>(unsaved),
const_cast<CXUnsavedFile *>( unsaved ),
cxunsaved_files.size(),
clang_defaultEditingTranslationUnitOptions() );
@ -146,7 +146,7 @@ std::vector< CompletionData > TranslationUnit::CandidatesForLocation(
std::vector< CXUnsavedFile > cxunsaved_files =
ToCXUnsavedFiles( unsaved_files );
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
// 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(),
line,
column,
const_cast<CXUnsavedFile *>(unsaved),
const_cast<CXUnsavedFile *>( unsaved ),
cxunsaved_files.size(),
clang_defaultCodeCompleteOptions() ),
clang_disposeCodeCompleteResults );
@ -242,8 +242,9 @@ void TranslationUnit::Reparse( std::vector< CXUnsavedFile > &unsaved_files,
if ( !clang_translation_unit_ )
return;
CXUnsavedFile *unsaved = unsaved_files.size() > 0
? &unsaved_files[ 0 ] : NULL;
? &unsaved_files[ 0 ] : NULL;
failure = clang_reparseTranslationUnit( clang_translation_unit_,
unsaved_files.size(),

View File

@ -57,7 +57,7 @@ public:
bool IsCurrentlyUpdating() const;
std::vector< Diagnostic > Reparse(
const std::vector< UnsavedFile > &unsaved_files );
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
// with the valid object.
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
// 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(
const std::string &filename ) {
const std::string &filename ) {
lock_guard< mutex > lock( filename_to_translation_unit_and_flags_mutex_ );
return GetNoLock( filename );
}
@ -131,7 +131,7 @@ void TranslationUnitStore::RemoveAll() {
shared_ptr< TranslationUnit > TranslationUnitStore::GetNoLock(
const std::string &filename ) {
const std::string &filename ) {
return FindWithDefault( filename_to_translation_unit_,
filename,
shared_ptr< TranslationUnit >() );

View File

@ -67,10 +67,10 @@ private:
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;
typedef boost::unordered_map< std::string,
typedef boost::unordered_map < std::string,
std::size_t > FlagsHashForFilename;
CXIndex clang_index_;

View File

@ -30,7 +30,7 @@ namespace fs = boost::filesystem;
namespace {
const char * const COMMENT_AND_STRING_REGEX =
const char *const COMMENT_AND_STRING_REGEX =
"//.*?$" // Anything following '//'
"|"
"#.*?$" // Anything following '#'
@ -50,12 +50,12 @@ const char * const COMMENT_AND_STRING_REGEX =
// 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:
// http://ctags.sourceforge.net/FORMAT
// 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" // A TAB char is the field separator
// 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
// comparison, but it's fast enough for our use case.
struct StringEqualityComparer :
std::binary_function< std::string, std::string, bool >
{
bool operator()( const std::string &a, const std::string &b ) const {
return a == b;
}
std::binary_function< std::string, std::string, bool > {
bool operator()( const std::string &a, const std::string &b ) const {
return a == b;
}
};
// List of languages Exuberant Ctags supports:
@ -84,51 +83,51 @@ struct StringEqualityComparer :
// :e $VIMRUNTIME/filetype.vim
// This is a map of const char* and not std::string to prevent issues with
// static initialization.
const boost::unordered_map< const char*,
const char*,
boost::hash< std::string >,
StringEqualityComparer > LANG_TO_FILETYPE =
boost::assign::map_list_of
( "Ant" , "ant" )
( "Asm" , "asm" )
( "Awk" , "awk" )
( "Basic" , "basic" )
( "C++" , "cpp" )
( "C#" , "cs" )
( "C" , "c" )
( "COBOL" , "cobol" )
( "DosBatch" , "dosbatch" )
( "Eiffel" , "eiffel" )
( "Erlang" , "erlang" )
( "Fortran" , "fortran" )
( "HTML" , "html" )
( "Java" , "java" )
( "JavaScript" , "javascript" )
( "Lisp" , "lisp" )
( "Lua" , "lua" )
( "Make" , "make" )
( "MatLab" , "matlab" )
( "OCaml" , "ocaml" )
( "Pascal" , "pascal" )
( "Perl" , "perl" )
( "PHP" , "php" )
( "Python" , "python" )
( "REXX" , "rexx" )
( "Ruby" , "ruby" )
( "Scheme" , "scheme" )
( "Sh" , "sh" )
( "SLang" , "slang" )
( "SML" , "sml" )
( "SQL" , "sql" )
( "Tcl" , "tcl" )
( "Tex" , "tex" )
( "Vera" , "vera" )
( "Verilog" , "verilog" )
( "VHDL" , "vhdl" )
( "Vim" , "vim" )
( "YACC" , "yacc" );
const boost::unordered_map < const char *,
const char *,
boost::hash< std::string >,
StringEqualityComparer > LANG_TO_FILETYPE =
boost::assign::map_list_of
( "Ant" , "ant" )
( "Asm" , "asm" )
( "Awk" , "awk" )
( "Basic" , "basic" )
( "C++" , "cpp" )
( "C#" , "cs" )
( "C" , "c" )
( "COBOL" , "cobol" )
( "DosBatch" , "dosbatch" )
( "Eiffel" , "eiffel" )
( "Erlang" , "erlang" )
( "Fortran" , "fortran" )
( "HTML" , "html" )
( "Java" , "java" )
( "JavaScript" , "javascript" )
( "Lisp" , "lisp" )
( "Lua" , "lua" )
( "Make" , "make" )
( "MatLab" , "matlab" )
( "OCaml" , "ocaml" )
( "Pascal" , "pascal" )
( "Perl" , "perl" )
( "PHP" , "php" )
( "Python" , "python" )
( "REXX" , "rexx" )
( "Ruby" , "ruby" )
( "Scheme" , "scheme" )
( "Sh" , "sh" )
( "SLang" , "slang" )
( "SML" , "sml" )
( "SQL" , "sql" )
( "Tcl" , "tcl" )
( "Tex" , "tex" )
( "Vera" , "vera" )
( "Verilog" , "verilog" )
( "VHDL" , "vhdl" )
( "Vim" , "vim" )
( "YACC" , "yacc" );
const char * const NOT_FOUND = "YCMFOOBAR_NOT_FOUND";
const char *const NOT_FOUND = "YCMFOOBAR_NOT_FOUND";
} // unnamed namespace

View File

@ -40,8 +40,10 @@ namespace {
std::string GetUtf8String( const boost::python::object &string_or_unicode ) {
extract< std::string > to_string( string_or_unicode );
if ( to_string.check() )
return to_string();
return extract< std::string >( str( string_or_unicode ).encode( "utf8" ) );
}
@ -95,7 +97,7 @@ boost::python::list FilterAndSortCandidates(
continue;
Result result = candidate->QueryMatchResult( query,
query_has_uppercase_letters );
query_has_uppercase_letters );
if ( result.IsSubsequence() ) {
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
PyEval_InitThreads();
testing::InitGoogleMock(&argc, argv);
testing::InitGoogleMock( &argc, argv );
return RUN_ALL_TESTS();
}