Only showing the first overloaded func signature

This commit is contained in:
Strahinja Val Markovic 2012-07-26 21:43:20 -07:00
parent e9cf3c14b2
commit 0d9d697b50
2 changed files with 33 additions and 5 deletions

View File

@ -39,6 +39,7 @@ using boost::bind;
using boost::thread; using boost::thread;
using boost::lock_guard; using boost::lock_guard;
using boost::mutex; using boost::mutex;
using boost::unordered_map;
namespace YouCompleteMe namespace YouCompleteMe
{ {
@ -206,6 +207,8 @@ std::vector< CompletionData > ToCompletionDataVector(
std::vector< CompletionData > completions; std::vector< CompletionData > completions;
completions.reserve( results->NumResults ); completions.reserve( results->NumResults );
unordered_map< std::string, uint > seen_data;
for ( uint i = 0; i < results->NumResults; ++i ) for ( uint i = 0; i < results->NumResults; ++i )
{ {
CXCompletionResult completion_result = results->Results[ i ]; CXCompletionResult completion_result = results->Results[ i ];
@ -213,8 +216,22 @@ std::vector< CompletionData > ToCompletionDataVector(
if ( !CompletionStringAvailable( completion_result.CompletionString ) ) if ( !CompletionStringAvailable( completion_result.CompletionString ) )
continue; continue;
completions.push_back( CompletionData data = CompletionResultToCompletionData( completion_result );
CompletionResultToCompletionData( completion_result ) ); uint index = GetValueElseInsert( seen_data,
data.original_string_,
completions.size() );
if ( index == completions.size() )
{
completions.push_back( data );
}
else
{
completions[ index ].detailed_info_
.append( "\n" )
.append( data.extra_menu_info_ );
}
} }
return completions; return completions;

View File

@ -39,8 +39,8 @@ void WriteUtf8File( const fs::path &filepath, const std::string &contents );
template <class Container, class Key> template <class Container, class Key>
typename Container::mapped_type & typename Container::mapped_type &
GetValueElseInsert( Container &container, GetValueElseInsert( Container &container,
Key const& key, const Key &key,
typename Container::mapped_type const& value ) const typename Container::mapped_type &value )
{ {
return container.insert( typename Container::value_type( key, value ) ) return container.insert( typename Container::value_type( key, value ) )
.first->second; .first->second;
@ -48,11 +48,22 @@ GetValueElseInsert( Container &container,
template <class Container, class Key> template <class Container, class Key>
bool ContainsKey( Container &container, Key const& key) bool ContainsKey( Container &container, const Key &key )
{ {
return container.find( key ) != container.end(); return container.find( key ) != container.end();
} }
template <class Container, class Key>
const typename Container::mapped_type &
FindWithDefault( Container &container,
const Key &key,
const typename Container::mapped_type &value )
{
auto it = container.find( key );
return it != container.end() ? *it : value;
}
} // namespace YouCompleteMe } // namespace YouCompleteMe
#endif /* end of include guard: UTILS_H_KEPMRPBH */ #endif /* end of include guard: UTILS_H_KEPMRPBH */