Renaming Completer to IdentifierCompleter
This commit is contained in:
parent
39ceebbb1e
commit
545792c055
@ -58,7 +58,6 @@ class ClangComplete : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
ClangComplete();
|
||||
|
||||
~ClangComplete();
|
||||
|
||||
void SetGlobalCompileFlags( const std::vector< std::string > &flags );
|
||||
|
@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "Completer.h"
|
||||
#include "IdentifierCompleter.h"
|
||||
#include "standard.h"
|
||||
#include "Utils.h"
|
||||
|
||||
@ -53,23 +53,25 @@ void ThreadMain( LatestTask &latest_task )
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
Completer::Completer( const std::vector< std::string > &candidates )
|
||||
IdentifierCompleter::IdentifierCompleter(
|
||||
const std::vector< std::string > &candidates )
|
||||
: threading_enabled_( false )
|
||||
{
|
||||
AddCandidatesToDatabase( candidates, "", "", true );
|
||||
}
|
||||
|
||||
|
||||
Completer::Completer( const std::vector< std::string > &candidates,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath )
|
||||
IdentifierCompleter::IdentifierCompleter(
|
||||
const std::vector< std::string > &candidates,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath )
|
||||
: threading_enabled_( false )
|
||||
{
|
||||
AddCandidatesToDatabase( candidates, filetype, filepath, true );
|
||||
}
|
||||
|
||||
|
||||
Completer::~Completer()
|
||||
IdentifierCompleter::~IdentifierCompleter()
|
||||
{
|
||||
foreach ( const CandidateRepository::value_type &pair,
|
||||
candidate_repository_ )
|
||||
@ -81,14 +83,14 @@ Completer::~Completer()
|
||||
|
||||
// We need this mostly so that we can not use it in tests. Apparently the
|
||||
// GoogleTest framework goes apeshit on us if we enable threads by default.
|
||||
void Completer::EnableThreading()
|
||||
void IdentifierCompleter::EnableThreading()
|
||||
{
|
||||
threading_enabled_ = true;
|
||||
InitThreads();
|
||||
}
|
||||
|
||||
|
||||
void Completer::AddCandidatesToDatabase(
|
||||
void IdentifierCompleter::AddCandidatesToDatabase(
|
||||
const std::vector< std::string > &new_candidates,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath,
|
||||
@ -112,14 +114,14 @@ void Completer::AddCandidatesToDatabase(
|
||||
}
|
||||
|
||||
|
||||
std::vector< std::string > Completer::CandidatesForQuery(
|
||||
std::vector< std::string > IdentifierCompleter::CandidatesForQuery(
|
||||
const std::string &query ) const
|
||||
{
|
||||
return CandidatesForQueryAndType( query, "" );
|
||||
}
|
||||
|
||||
|
||||
std::vector< std::string > Completer::CandidatesForQueryAndType(
|
||||
std::vector< std::string > IdentifierCompleter::CandidatesForQueryAndType(
|
||||
const std::string &query,
|
||||
const std::string &filetype ) const
|
||||
{
|
||||
@ -135,7 +137,7 @@ std::vector< std::string > Completer::CandidatesForQueryAndType(
|
||||
}
|
||||
|
||||
|
||||
Future Completer::CandidatesForQueryAndTypeAsync(
|
||||
Future IdentifierCompleter::CandidatesForQueryAndTypeAsync(
|
||||
const std::string &query,
|
||||
const std::string &filetype ) const
|
||||
{
|
||||
@ -146,7 +148,7 @@ Future Completer::CandidatesForQueryAndTypeAsync(
|
||||
// Try not to look at this too hard, it may burn your eyes.
|
||||
shared_ptr< packaged_task< AsyncResults > > task =
|
||||
make_shared< packaged_task< AsyncResults > >(
|
||||
bind( &Completer::ResultsForQueryAndType,
|
||||
bind( &IdentifierCompleter::ResultsForQueryAndType,
|
||||
boost::cref( *this ),
|
||||
query,
|
||||
filetype ) );
|
||||
@ -158,7 +160,7 @@ Future Completer::CandidatesForQueryAndTypeAsync(
|
||||
}
|
||||
|
||||
|
||||
AsyncResults Completer::ResultsForQueryAndType(
|
||||
AsyncResults IdentifierCompleter::ResultsForQueryAndType(
|
||||
const std::string &query,
|
||||
const std::string &filetype ) const
|
||||
{
|
||||
@ -168,9 +170,10 @@ AsyncResults Completer::ResultsForQueryAndType(
|
||||
}
|
||||
|
||||
|
||||
void Completer::ResultsForQueryAndType( const std::string &query,
|
||||
const std::string &filetype,
|
||||
std::vector< Result > &results ) const
|
||||
void IdentifierCompleter::ResultsForQueryAndType(
|
||||
const std::string &query,
|
||||
const std::string &filetype,
|
||||
std::vector< Result > &results ) const
|
||||
{
|
||||
FiletypeMap::const_iterator it = filetype_map_.find( filetype );
|
||||
if ( it == filetype_map_.end() )
|
||||
@ -196,7 +199,7 @@ void Completer::ResultsForQueryAndType( const std::string &query,
|
||||
}
|
||||
|
||||
|
||||
std::list< const Candidate* >& Completer::GetCandidateList(
|
||||
std::list< const Candidate* >& IdentifierCompleter::GetCandidateList(
|
||||
const std::string &filetype,
|
||||
const std::string &filepath )
|
||||
{
|
||||
@ -216,7 +219,7 @@ std::list< const Candidate* >& Completer::GetCandidateList(
|
||||
}
|
||||
|
||||
|
||||
void Completer::InitThreads()
|
||||
void IdentifierCompleter::InitThreads()
|
||||
{
|
||||
int threads_to_create =
|
||||
std::max( MIN_ASYNC_THREADS,
|
@ -54,15 +54,15 @@ typedef ConcurrentLatestValue<
|
||||
boost::packaged_task< AsyncResults > > > LatestTask;
|
||||
|
||||
|
||||
class Completer : boost::noncopyable
|
||||
class IdentifierCompleter : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
Completer() {}
|
||||
Completer( const std::vector< std::string > &candidates );
|
||||
Completer( const std::vector< std::string > &candidates,
|
||||
IdentifierCompleter() {}
|
||||
IdentifierCompleter( const std::vector< std::string > &candidates );
|
||||
IdentifierCompleter( const std::vector< std::string > &candidates,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath );
|
||||
~Completer();
|
||||
~IdentifierCompleter();
|
||||
|
||||
void EnableThreading();
|
||||
|
@ -15,7 +15,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "Completer.h"
|
||||
#include "IdentifierCompleter.h"
|
||||
#include "ClangComplete.h"
|
||||
#include "Future.h"
|
||||
|
||||
@ -35,11 +35,12 @@ BOOST_PYTHON_MODULE(indexer)
|
||||
.def( "ResultsReady", &Future::ResultsReady )
|
||||
.def( "GetResults", &Future::GetResults );
|
||||
|
||||
class_< Completer, boost::noncopyable >( "Completer" )
|
||||
.def( "EnableThreading", &Completer::EnableThreading )
|
||||
.def( "AddCandidatesToDatabase", &Completer::AddCandidatesToDatabase )
|
||||
class_< IdentifierCompleter, boost::noncopyable >( "IdentifierCompleter" )
|
||||
.def( "EnableThreading", &IdentifierCompleter::EnableThreading )
|
||||
.def( "AddCandidatesToDatabase",
|
||||
&IdentifierCompleter::AddCandidatesToDatabase )
|
||||
.def( "CandidatesForQueryAndTypeAsync",
|
||||
&Completer::CandidatesForQueryAndTypeAsync );
|
||||
&IdentifierCompleter::CandidatesForQueryAndTypeAsync );
|
||||
|
||||
// CAREFUL HERE! For filename and contents we are referring directly to
|
||||
// Python-allocated and -managed memory since we are accepting pointers to
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include "Completer.h"
|
||||
#include "IdentifierCompleter.h"
|
||||
#include "Utils.h"
|
||||
|
||||
using ::testing::ElementsAre;
|
||||
@ -64,16 +64,16 @@ std::vector< std::string > Candidates( const std::string &a,
|
||||
} // unnamed namespace
|
||||
|
||||
|
||||
TEST( CompleterTest, OneCandidate )
|
||||
TEST( IdentifierCompleterTest, OneCandidate )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"foobar" ) ).CandidatesForQuery( "fbr" ),
|
||||
ElementsAre( "foobar" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, ManyCandidateSimple )
|
||||
TEST( IdentifierCompleterTest, ManyCandidateSimple )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"foobar",
|
||||
"foobartest",
|
||||
"Foobartest" ) ).CandidatesForQuery( "fbr" ),
|
||||
@ -82,131 +82,131 @@ TEST( CompleterTest, ManyCandidateSimple )
|
||||
"foobartest" ) ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, FirstCharSameAsQueryWins )
|
||||
TEST( IdentifierCompleterTest, FirstCharSameAsQueryWins )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"foobar",
|
||||
"afoobar" ) ).CandidatesForQuery( "fbr" ),
|
||||
ElementsAre( "foobar",
|
||||
"afoobar" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, CompleteMatchForWordBoundaryCharsWins )
|
||||
TEST( IdentifierCompleterTest, CompleteMatchForWordBoundaryCharsWins )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"FooBarQux",
|
||||
"FBaqux" ) ).CandidatesForQuery( "fbq" ),
|
||||
ElementsAre( "FooBarQux",
|
||||
"FBaqux" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"CompleterTest",
|
||||
"CompleteMatchForWordBoundaryCharsWins" ) )
|
||||
.CandidatesForQuery( "ct" ),
|
||||
ElementsAre( "CompleterTest",
|
||||
"CompleteMatchForWordBoundaryCharsWins" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"FooBar",
|
||||
"FooBarRux" ) ).CandidatesForQuery( "fbr" ),
|
||||
ElementsAre( "FooBarRux",
|
||||
"FooBar" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, RatioUtilizationTieBreak )
|
||||
TEST( IdentifierCompleterTest, RatioUtilizationTieBreak )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"aGaaFooBarQux",
|
||||
"aBaafbq" ) ).CandidatesForQuery( "fbq" ),
|
||||
ElementsAre( "aGaaFooBarQux",
|
||||
"aBaafbq" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"aFooBarQux",
|
||||
"afbq" ) ).CandidatesForQuery( "fbq" ),
|
||||
ElementsAre( "aFooBarQux",
|
||||
"afbq" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"acaaCaaFooGxx",
|
||||
"aCaafoog" ) ).CandidatesForQuery( "caafoo" ),
|
||||
ElementsAre( "acaaCaaFooGxx",
|
||||
"aCaafoog" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"acaaCaaFooGxx",
|
||||
"aCaafoog" ) ).CandidatesForQuery( "caaFoo" ),
|
||||
ElementsAre( "acaaCaaFooGxx",
|
||||
"aCaafoog" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"FooBarQux",
|
||||
"FooBarQuxZaa" ) ).CandidatesForQuery( "fbq" ),
|
||||
ElementsAre( "FooBarQux",
|
||||
"FooBarQuxZaa" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"FooBar",
|
||||
"FooBarRux" ) ).CandidatesForQuery( "fba" ),
|
||||
ElementsAre( "FooBar",
|
||||
"FooBarRux" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, QueryPrefixOfCandidateWins )
|
||||
TEST( IdentifierCompleterTest, QueryPrefixOfCandidateWins )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"foobar",
|
||||
"fbaroo" ) ).CandidatesForQuery( "foo" ),
|
||||
ElementsAre( "foobar",
|
||||
"fbaroo" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, LowerMatchCharIndexSumWins )
|
||||
TEST( IdentifierCompleterTest, LowerMatchCharIndexSumWins )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"ratio_of_word_boundary_chars_in_query_",
|
||||
"first_char_same_in_query_and_text_") )
|
||||
.CandidatesForQuery( "charinq" ),
|
||||
ElementsAre( "first_char_same_in_query_and_text_",
|
||||
"ratio_of_word_boundary_chars_in_query_") );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"barfooq",
|
||||
"barquxfoo" ) ).CandidatesForQuery( "foo" ),
|
||||
ElementsAre( "barfooq",
|
||||
"barquxfoo") );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"xxxxxxabc",
|
||||
"xxabcxxxx" ) ).CandidatesForQuery( "abc" ),
|
||||
ElementsAre( "xxabcxxxx",
|
||||
"xxxxxxabc") );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"FooBarQux",
|
||||
"FaBarQux" ) ).CandidatesForQuery( "fbq" ),
|
||||
ElementsAre( "FaBarQux",
|
||||
"FooBarQux" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, ShorterCandidateWins )
|
||||
TEST( IdentifierCompleterTest, ShorterCandidateWins )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"CompleterT",
|
||||
"CompleterTest" ) ).CandidatesForQuery( "co" ),
|
||||
ElementsAre( "CompleterT",
|
||||
"CompleterTest" ) );
|
||||
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"CompleterT",
|
||||
"CompleterTest" ) ).CandidatesForQuery( "plet" ),
|
||||
ElementsAre( "CompleterT",
|
||||
"CompleterTest" ) );
|
||||
}
|
||||
|
||||
TEST( CompleterTest, SameLowercaseCandidateWins )
|
||||
TEST( IdentifierCompleterTest, SameLowercaseCandidateWins )
|
||||
{
|
||||
EXPECT_THAT( Completer( Candidates(
|
||||
EXPECT_THAT( IdentifierCompleter( Candidates(
|
||||
"foobar",
|
||||
"Foobar" ) ).CandidatesForQuery( "foo" ),
|
||||
ElementsAre( "foobar",
|
@ -22,12 +22,12 @@ import vim
|
||||
import indexer
|
||||
|
||||
min_num_chars = int( vim.eval( "g:ycm_min_num_of_chars_for_completion" ) )
|
||||
|
||||
clang_filetypes = set( [ 'c', 'cpp', 'objc', 'objcpp' ] )
|
||||
|
||||
|
||||
class CompletionSystem( object ):
|
||||
def __init__( self ):
|
||||
self.completer = indexer.Completer()
|
||||
self.completer = indexer.IdentifierCompleter()
|
||||
self.completer.EnableThreading()
|
||||
self.pattern = re.compile( r"[_a-zA-Z]\w*" )
|
||||
self.future = None
|
||||
|
Loading…
Reference in New Issue
Block a user