Style fixes for C++
This commit is contained in:
parent
b294d2531d
commit
1676a3b2a4
@ -263,11 +263,11 @@ ClangCompleter::CandidatesForQueryAndLocationInFileAsync(
|
|||||||
|
|
||||||
|
|
||||||
Location ClangCompleter::GetDeclarationLocation(
|
Location ClangCompleter::GetDeclarationLocation(
|
||||||
const std::string &filename,
|
const std::string &filename,
|
||||||
int line,
|
int line,
|
||||||
int column,
|
int column,
|
||||||
const std::vector< UnsavedFile > &unsaved_files,
|
const std::vector< UnsavedFile > &unsaved_files,
|
||||||
const std::vector< std::string > &flags ) {
|
const std::vector< std::string > &flags ) {
|
||||||
shared_ptr< TranslationUnit > unit = GetTranslationUnitForFile(
|
shared_ptr< TranslationUnit > unit = GetTranslationUnitForFile(
|
||||||
filename,
|
filename,
|
||||||
unsaved_files,
|
unsaved_files,
|
||||||
@ -277,11 +277,11 @@ Location ClangCompleter::GetDeclarationLocation(
|
|||||||
|
|
||||||
|
|
||||||
Location ClangCompleter::GetDefinitionLocation(
|
Location ClangCompleter::GetDefinitionLocation(
|
||||||
const std::string &filename,
|
const std::string &filename,
|
||||||
int line,
|
int line,
|
||||||
int column,
|
int column,
|
||||||
const std::vector< UnsavedFile > &unsaved_files,
|
const std::vector< UnsavedFile > &unsaved_files,
|
||||||
const std::vector< std::string > &flags ) {
|
const std::vector< std::string > &flags ) {
|
||||||
shared_ptr< TranslationUnit > unit = GetTranslationUnitForFile(
|
shared_ptr< TranslationUnit > unit = GetTranslationUnitForFile(
|
||||||
filename,
|
filename,
|
||||||
unsaved_files,
|
unsaved_files,
|
||||||
|
@ -135,7 +135,7 @@ void TranslationUnit::Reparse(
|
|||||||
void TranslationUnit::ReparseForIndexing(
|
void TranslationUnit::ReparseForIndexing(
|
||||||
const std::vector< UnsavedFile > &unsaved_files ) {
|
const std::vector< UnsavedFile > &unsaved_files ) {
|
||||||
std::vector< CXUnsavedFile > cxunsaved_files =
|
std::vector< CXUnsavedFile > cxunsaved_files =
|
||||||
ToCXUnsavedFiles( unsaved_files );
|
ToCXUnsavedFiles( unsaved_files );
|
||||||
|
|
||||||
Reparse( cxunsaved_files,
|
Reparse( cxunsaved_files,
|
||||||
CXTranslationUnit_PrecompiledPreamble |
|
CXTranslationUnit_PrecompiledPreamble |
|
||||||
@ -181,9 +181,9 @@ std::vector< CompletionData > TranslationUnit::CandidatesForLocation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location TranslationUnit::GetDeclarationLocation(
|
Location TranslationUnit::GetDeclarationLocation(
|
||||||
int line,
|
int line,
|
||||||
int column,
|
int column,
|
||||||
const std::vector< UnsavedFile > &unsaved_files ) {
|
const std::vector< UnsavedFile > &unsaved_files ) {
|
||||||
ReparseForIndexing( unsaved_files );
|
ReparseForIndexing( unsaved_files );
|
||||||
unique_lock< mutex > lock( clang_access_mutex_ );
|
unique_lock< mutex > lock( clang_access_mutex_ );
|
||||||
|
|
||||||
@ -191,21 +191,23 @@ Location TranslationUnit::GetDeclarationLocation(
|
|||||||
return Location();
|
return Location();
|
||||||
|
|
||||||
CXCursor cursor = GetCursor( line, column );
|
CXCursor cursor = GetCursor( line, column );
|
||||||
|
|
||||||
if ( !CursorIsValid( cursor ) )
|
if ( !CursorIsValid( cursor ) )
|
||||||
return Location();
|
return Location();
|
||||||
|
|
||||||
CXCursor referenced_cursor = clang_getCursorReferenced( cursor );
|
CXCursor referenced_cursor = clang_getCursorReferenced( cursor );
|
||||||
|
|
||||||
if ( !CursorIsValid( referenced_cursor ) )
|
if ( !CursorIsValid( referenced_cursor ) )
|
||||||
return Location();
|
return Location();
|
||||||
|
|
||||||
return LocationFromSourceLocation(
|
return LocationFromSourceLocation(
|
||||||
clang_getCursorLocation( referenced_cursor ) );
|
clang_getCursorLocation( referenced_cursor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Location TranslationUnit::GetDefinitionLocation(
|
Location TranslationUnit::GetDefinitionLocation(
|
||||||
int line,
|
int line,
|
||||||
int column,
|
int column,
|
||||||
const std::vector< UnsavedFile > &unsaved_files ) {
|
const std::vector< UnsavedFile > &unsaved_files ) {
|
||||||
ReparseForIndexing( unsaved_files );
|
ReparseForIndexing( unsaved_files );
|
||||||
unique_lock< mutex > lock( clang_access_mutex_ );
|
unique_lock< mutex > lock( clang_access_mutex_ );
|
||||||
|
|
||||||
@ -213,15 +215,17 @@ Location TranslationUnit::GetDefinitionLocation(
|
|||||||
return Location();
|
return Location();
|
||||||
|
|
||||||
CXCursor cursor = GetCursor( line, column );
|
CXCursor cursor = GetCursor( line, column );
|
||||||
|
|
||||||
if ( !CursorIsValid( cursor ) )
|
if ( !CursorIsValid( cursor ) )
|
||||||
return Location();
|
return Location();
|
||||||
|
|
||||||
CXCursor definition_cursor = clang_getCursorDefinition( cursor );
|
CXCursor definition_cursor = clang_getCursorDefinition( cursor );
|
||||||
|
|
||||||
if ( !CursorIsValid( definition_cursor ) )
|
if ( !CursorIsValid( definition_cursor ) )
|
||||||
return Location();
|
return Location();
|
||||||
|
|
||||||
return LocationFromSourceLocation(
|
return LocationFromSourceLocation(
|
||||||
clang_getCursorLocation( definition_cursor ) );
|
clang_getCursorLocation( definition_cursor ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -284,16 +288,16 @@ CXCursor TranslationUnit::GetCursor( int line, int column ) {
|
|||||||
|
|
||||||
CXFile file = clang_getFile( clang_translation_unit_, filename_.c_str() );
|
CXFile file = clang_getFile( clang_translation_unit_, filename_.c_str() );
|
||||||
CXSourceLocation source_location = clang_getLocation(
|
CXSourceLocation source_location = clang_getLocation(
|
||||||
clang_translation_unit_,
|
clang_translation_unit_,
|
||||||
file,
|
file,
|
||||||
line,
|
line,
|
||||||
column );
|
column );
|
||||||
|
|
||||||
return clang_getCursor( clang_translation_unit_, source_location );
|
return clang_getCursor( clang_translation_unit_, source_location );
|
||||||
}
|
}
|
||||||
|
|
||||||
Location TranslationUnit::LocationFromSourceLocation(
|
Location TranslationUnit::LocationFromSourceLocation(
|
||||||
CXSourceLocation source_location ) {
|
CXSourceLocation source_location ) {
|
||||||
// ASSUMES A LOCK IS ALREADY HELD ON clang_access_mutex_!
|
// ASSUMES A LOCK IS ALREADY HELD ON clang_access_mutex_!
|
||||||
if ( !clang_translation_unit_ )
|
if ( !clang_translation_unit_ )
|
||||||
return Location();
|
return Location();
|
||||||
|
@ -70,9 +70,9 @@ TEST_F( TranslationUnitTest, GoToDefinitionWorks ) {
|
|||||||
clang_index_ );
|
clang_index_ );
|
||||||
|
|
||||||
Location location = unit.GetDefinitionLocation(
|
Location location = unit.GetDefinitionLocation(
|
||||||
15,
|
15,
|
||||||
3,
|
3,
|
||||||
std::vector< UnsavedFile >() );
|
std::vector< UnsavedFile >() );
|
||||||
|
|
||||||
EXPECT_EQ( 1, location.line_number_ );
|
EXPECT_EQ( 1, location.line_number_ );
|
||||||
EXPECT_EQ( 8, location.column_number_ );
|
EXPECT_EQ( 8, location.column_number_ );
|
||||||
@ -89,9 +89,9 @@ TEST_F( TranslationUnitTest, GoToDefinitionFails ) {
|
|||||||
clang_index_ );
|
clang_index_ );
|
||||||
|
|
||||||
Location location = unit.GetDefinitionLocation(
|
Location location = unit.GetDefinitionLocation(
|
||||||
17,
|
17,
|
||||||
3,
|
3,
|
||||||
std::vector< UnsavedFile >() );
|
std::vector< UnsavedFile >() );
|
||||||
|
|
||||||
EXPECT_FALSE( location.IsValid() );
|
EXPECT_FALSE( location.IsValid() );
|
||||||
}
|
}
|
||||||
@ -106,9 +106,9 @@ TEST_F( TranslationUnitTest, GoToDeclarationWorks ) {
|
|||||||
clang_index_ );
|
clang_index_ );
|
||||||
|
|
||||||
Location location = unit.GetDeclarationLocation(
|
Location location = unit.GetDeclarationLocation(
|
||||||
17,
|
17,
|
||||||
3,
|
3,
|
||||||
std::vector< UnsavedFile >() );
|
std::vector< UnsavedFile >() );
|
||||||
|
|
||||||
EXPECT_EQ( 12, location.line_number_ );
|
EXPECT_EQ( 12, location.line_number_ );
|
||||||
EXPECT_EQ( 8, location.column_number_ );
|
EXPECT_EQ( 8, location.column_number_ );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user