diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index cd54e320..f739ccaa 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -74,7 +74,8 @@ else() "Your C++ compiler does NOT support C++11, compiling in C++03 mode." ) endif() -if ( NOT EXTERNAL_LIBCLANG_PATH AND NOT USE_SYSTEM_LIBCLANG ) +if ( NOT NO_CLANG_COMPLETER AND + ( NOT EXTERNAL_LIBCLANG_PATH AND NOT USE_SYSTEM_LIBCLANG ) ) add_subdirectory( llvm ) endif() diff --git a/cpp/ycm/CMakeLists.txt b/cpp/ycm/CMakeLists.txt index cf54856e..65f7cb5e 100644 --- a/cpp/ycm/CMakeLists.txt +++ b/cpp/ycm/CMakeLists.txt @@ -39,6 +39,7 @@ include_directories( "${CMAKE_SOURCE_DIR}/llvm/tools/clang/include" ) + file( GLOB_RECURSE SOURCES *.h *.cpp ) # The test sources are a part of a different target, so we remove them @@ -50,6 +51,18 @@ if( to_remove ) list( REMOVE_ITEM SOURCES ${to_remove} ) endif() +if ( NO_CLANG_COMPLETER ) + file( GLOB_RECURSE to_remove_clang ClangCompleter/*.h ClangCompleter/*.cpp ) + + if( to_remove_clang ) + list( REMOVE_ITEM SOURCES ${to_remove_clang} ) + endif() + + add_definitions( -DNO_CLANG_COMPLETER ) +else() + include_directories( "${CURRENT_SOURCE_DIR}/ClangCompleter" ) +endif() + ############################################################################# # One can use the system libclang.[so|dylib] like so: @@ -74,8 +87,10 @@ if ( EXTERNAL_LIBCLANG_PATH OR USE_SYSTEM_LIBCLANG ) set( LIBCLANG_TARGET ${EXTERNAL_LIBCLANG_PATH} ) message( "Using external libclang: ${EXTERNAL_LIBCLANG_PATH}" ) -else() +elseif( NOT NO_CLANG_COMPLETER ) set( LIBCLANG_TARGET libclang_static ) +else() + set( LIBCLANG_TARGET ) endif() if ( EXTRA_RPATH ) diff --git a/cpp/ycm/CandidateRepository.cpp b/cpp/ycm/CandidateRepository.cpp index 4f629b9a..53fa24a2 100644 --- a/cpp/ycm/CandidateRepository.cpp +++ b/cpp/ycm/CandidateRepository.cpp @@ -17,12 +17,15 @@ #include "CandidateRepository.h" #include "Candidate.h" -#include "CompletionData.h" #include "standard.h" #include "Utils.h" #include +#ifndef NO_CLANG_COMPLETER +# include "CompletionData.h" +#endif // NO_CLANG_COMPLETER + namespace YouCompleteMe { @@ -74,6 +77,7 @@ std::vector< const Candidate* > CandidateRepository::GetCandidatesForStrings( return candidates; } +#ifndef NO_CLANG_COMPLETER std::vector< const Candidate* > CandidateRepository::GetCandidatesForStrings( const std::vector< CompletionData > &datas ) @@ -99,6 +103,7 @@ std::vector< const Candidate* > CandidateRepository::GetCandidatesForStrings( return candidates; } +#endif // NO_CLANG_COMPLETER CandidateRepository::~CandidateRepository() { diff --git a/cpp/ycm/CandidateRepository.h b/cpp/ycm/CandidateRepository.h index b1ac8e9f..93b99dfa 100644 --- a/cpp/ycm/CandidateRepository.h +++ b/cpp/ycm/CandidateRepository.h @@ -44,8 +44,10 @@ public: std::vector< const Candidate* > GetCandidatesForStrings( const std::vector< std::string > &strings ); +#ifndef NO_CLANG_COMPLETER std::vector< const Candidate* > GetCandidatesForStrings( const std::vector< CompletionData > &datas ); +#endif // NO_CLANG_COMPLETER private: CandidateRepository() {}; @@ -63,4 +65,3 @@ private: } // namespace YouCompleteMe #endif /* end of include guard: CANDIDATEREPOSITORY_H_K9OVCMHG */ - diff --git a/cpp/ycm/ClangCompleter.cpp b/cpp/ycm/ClangCompleter/ClangCompleter.cpp similarity index 100% rename from cpp/ycm/ClangCompleter.cpp rename to cpp/ycm/ClangCompleter/ClangCompleter.cpp diff --git a/cpp/ycm/ClangCompleter.h b/cpp/ycm/ClangCompleter/ClangCompleter.h similarity index 100% rename from cpp/ycm/ClangCompleter.h rename to cpp/ycm/ClangCompleter/ClangCompleter.h diff --git a/cpp/ycm/ClangResultsCache.cpp b/cpp/ycm/ClangCompleter/ClangResultsCache.cpp similarity index 100% rename from cpp/ycm/ClangResultsCache.cpp rename to cpp/ycm/ClangCompleter/ClangResultsCache.cpp diff --git a/cpp/ycm/ClangResultsCache.h b/cpp/ycm/ClangCompleter/ClangResultsCache.h similarity index 100% rename from cpp/ycm/ClangResultsCache.h rename to cpp/ycm/ClangCompleter/ClangResultsCache.h diff --git a/cpp/ycm/ClangUtils.cpp b/cpp/ycm/ClangCompleter/ClangUtils.cpp similarity index 100% rename from cpp/ycm/ClangUtils.cpp rename to cpp/ycm/ClangCompleter/ClangUtils.cpp diff --git a/cpp/ycm/ClangUtils.h b/cpp/ycm/ClangCompleter/ClangUtils.h similarity index 100% rename from cpp/ycm/ClangUtils.h rename to cpp/ycm/ClangCompleter/ClangUtils.h diff --git a/cpp/ycm/CompletionData.cpp b/cpp/ycm/ClangCompleter/CompletionData.cpp similarity index 100% rename from cpp/ycm/CompletionData.cpp rename to cpp/ycm/ClangCompleter/CompletionData.cpp diff --git a/cpp/ycm/CompletionData.h b/cpp/ycm/ClangCompleter/CompletionData.h similarity index 100% rename from cpp/ycm/CompletionData.h rename to cpp/ycm/ClangCompleter/CompletionData.h diff --git a/cpp/ycm/Diagnostic.h b/cpp/ycm/ClangCompleter/Diagnostic.h similarity index 100% rename from cpp/ycm/Diagnostic.h rename to cpp/ycm/ClangCompleter/Diagnostic.h diff --git a/cpp/ycm/TranslationUnit.cpp b/cpp/ycm/ClangCompleter/TranslationUnit.cpp similarity index 100% rename from cpp/ycm/TranslationUnit.cpp rename to cpp/ycm/ClangCompleter/TranslationUnit.cpp diff --git a/cpp/ycm/TranslationUnit.h b/cpp/ycm/ClangCompleter/TranslationUnit.h similarity index 100% rename from cpp/ycm/TranslationUnit.h rename to cpp/ycm/ClangCompleter/TranslationUnit.h diff --git a/cpp/ycm/UnsavedFile.h b/cpp/ycm/ClangCompleter/UnsavedFile.h similarity index 100% rename from cpp/ycm/UnsavedFile.h rename to cpp/ycm/ClangCompleter/UnsavedFile.h diff --git a/cpp/ycm/IdentifierCompleter.h b/cpp/ycm/IdentifierCompleter.h index 41e07d6b..dd41b41d 100644 --- a/cpp/ycm/IdentifierCompleter.h +++ b/cpp/ycm/IdentifierCompleter.h @@ -92,15 +92,15 @@ public: std::string filepath ); // Only provided for tests! - std::vector< std::string > CandidatesForQuery( - const std::string &query ) const; + std::vector< std::string > CandidatesForQuery( + const std::string &query ) const; std::vector< std::string > CandidatesForQueryAndType( const std::string &query, const std::string &filetype ) const; - Future< AsyncResults > CandidatesForQueryAndTypeAsync( - const std::string &query, + Future< AsyncResults > CandidatesForQueryAndTypeAsync( + const std::string &query, const std::string &filetype ) const; private: diff --git a/cpp/ycm/ycm_core.cpp b/cpp/ycm/ycm_core.cpp index 41731162..2424fea4 100644 --- a/cpp/ycm/ycm_core.cpp +++ b/cpp/ycm/ycm_core.cpp @@ -16,11 +16,14 @@ // along with YouCompleteMe. If not, see . #include "IdentifierCompleter.h" -#include "ClangCompleter.h" #include "Future.h" -#include "CompletionData.h" -#include "Diagnostic.h" -#include "UnsavedFile.h" + +#ifndef NO_CLANG_COMPLETER +# include "ClangCompleter.h" +# include "CompletionData.h" +# include "Diagnostic.h" +# include "UnsavedFile.h" +#endif // NO_CLANG_COMPLETER #include #include @@ -31,47 +34,6 @@ BOOST_PYTHON_MODULE(ycm_core) using namespace boost::python; using namespace YouCompleteMe; - // TODO: rename these *Vec classes to *Vector; don't forget the python file - class_< std::vector< std::string >, - boost::shared_ptr< std::vector< std::string > > >( "StringVec" ) - .def( vector_indexing_suite< std::vector< std::string > >() ); - - class_< CompletionData >( "CompletionData" ) - .def( "TextToInsertInBuffer", &CompletionData::TextToInsertInBuffer ) - .def( "MainCompletionText", &CompletionData::MainCompletionText ) - .def( "ExtraMenuInfo", &CompletionData::ExtraMenuInfo ) - .def( "DetailedInfoForPreviewWindow", - &CompletionData::DetailedInfoForPreviewWindow ) - .def_readonly( "kind_", &CompletionData::kind_ ); - - class_< std::vector< CompletionData >, - boost::shared_ptr< std::vector< CompletionData > > >( - "CompletionVec" ) - .def( vector_indexing_suite< std::vector< CompletionData > >() ); - - class_< Diagnostic >( "Diagnostic" ) - .def_readonly( "line_number_", &Diagnostic::line_number_ ) - .def_readonly( "column_number_", &Diagnostic::column_number_ ) - .def_readonly( "kind_", &Diagnostic::kind_ ) - .def_readonly( "filename_", &Diagnostic::filename_ ) - .def_readonly( "text_", &Diagnostic::text_ ) - .def_readonly( "long_formatted_text_", &Diagnostic::long_formatted_text_ ); - - class_< std::vector< Diagnostic > >( "DiagnosticVec" ) - .def( vector_indexing_suite< std::vector< Diagnostic > >() ); - - class_< Future< AsyncResults > >( "FutureResults" ) - .def( "ResultsReady", &Future< AsyncResults >::ResultsReady ) - .def( "GetResults", &Future< AsyncResults >::GetResults ); - - class_< Future< AsyncCompletions > >( "FutureCompletions" ) - .def( "ResultsReady", &Future< AsyncCompletions >::ResultsReady ) - .def( "GetResults", &Future< AsyncCompletions >::GetResults ); - - class_< Future< void > >( "FutureVoid" ) - .def( "ResultsReady", &Future< void >::ResultsReady ) - .def( "GetResults", &Future< void >::GetResults ); - class_< IdentifierCompleter, boost::noncopyable >( "IdentifierCompleter" ) .def( "EnableThreading", &IdentifierCompleter::EnableThreading ) .def( "AddCandidatesToDatabase", @@ -81,11 +43,29 @@ BOOST_PYTHON_MODULE(ycm_core) .def( "CandidatesForQueryAndTypeAsync", &IdentifierCompleter::CandidatesForQueryAndTypeAsync ); + // TODO: rename these *Vec classes to *Vector; don't forget the python file + class_< std::vector< std::string >, + boost::shared_ptr< std::vector< std::string > > >( "StringVec" ) + .def( vector_indexing_suite< std::vector< std::string > >() ); + + class_< Future< AsyncResults > >( "FutureResults" ) + .def( "ResultsReady", &Future< AsyncResults >::ResultsReady ) + .def( "GetResults", &Future< AsyncResults >::GetResults ); + + class_< Future< void > >( "FutureVoid" ) + .def( "ResultsReady", &Future< void >::ResultsReady ) + .def( "GetResults", &Future< void >::GetResults ); + +#ifndef NO_CLANG_COMPLETER + class_< Future< AsyncCompletions > >( "FutureCompletions" ) + .def( "ResultsReady", &Future< AsyncCompletions >::ResultsReady ) + .def( "GetResults", &Future< AsyncCompletions >::GetResults ); + // CAREFUL HERE! For filename and contents we are referring directly to // Python-allocated and -managed memory since we are accepting pointers to // data members of python objects. We need to ensure that those objects // outlive our UnsavedFile objects. - class_< UnsavedFile >( "UnsavedFile" ) + class_< UnsavedFile >( "UnsavedFile" ) .add_property( "filename_", make_getter( &UnsavedFile::filename_ ), make_setter( &UnsavedFile::filename_, @@ -96,8 +76,8 @@ BOOST_PYTHON_MODULE(ycm_core) return_value_policy< reference_existing_object >() ) ) .def_readwrite( "length_", &UnsavedFile::length_ ); - class_< std::vector< UnsavedFile > >( "UnsavedFileVec" ) - .def( vector_indexing_suite< std::vector< UnsavedFile > >() ); + class_< std::vector< UnsavedFile > >( "UnsavedFileVec" ) + .def( vector_indexing_suite< std::vector< UnsavedFile > >() ); class_< ClangCompleter, boost::noncopyable >( "ClangCompleter" ) .def( "EnableThreading", &ClangCompleter::EnableThreading ) @@ -107,4 +87,30 @@ BOOST_PYTHON_MODULE(ycm_core) &ClangCompleter::UpdateTranslationUnitAsync ) .def( "CandidatesForQueryAndLocationInFileAsync", &ClangCompleter::CandidatesForQueryAndLocationInFileAsync ); + + class_< CompletionData >( "CompletionData" ) + .def( "TextToInsertInBuffer", &CompletionData::TextToInsertInBuffer ) + .def( "MainCompletionText", &CompletionData::MainCompletionText ) + .def( "ExtraMenuInfo", &CompletionData::ExtraMenuInfo ) + .def( "DetailedInfoForPreviewWindow", + &CompletionData::DetailedInfoForPreviewWindow ) + .def_readonly( "kind_", &CompletionData::kind_ ); + + class_< std::vector< CompletionData >, + boost::shared_ptr< std::vector< CompletionData > > >( + "CompletionVec" ) + .def( vector_indexing_suite< std::vector< CompletionData > >() ); + + class_< Diagnostic >( "Diagnostic" ) + .def_readonly( "line_number_", &Diagnostic::line_number_ ) + .def_readonly( "column_number_", &Diagnostic::column_number_ ) + .def_readonly( "kind_", &Diagnostic::kind_ ) + .def_readonly( "filename_", &Diagnostic::filename_ ) + .def_readonly( "text_", &Diagnostic::text_ ) + .def_readonly( "long_formatted_text_", &Diagnostic::long_formatted_text_ ); + + class_< std::vector< Diagnostic > >( "DiagnosticVec" ) + .def( vector_indexing_suite< std::vector< Diagnostic > >() ); + +#endif // NO_CLANG_COMPLETER }