MCPcopy Create free account
hub / github.com/SpartanJ/eepp / exportLanguages

Function exportLanguages

src/tools/ecode/ecode.cpp:5096–5131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5094}
5095
5096static void exportLanguages( const std::string& path, const std::string& langs,
5097 const std::string& langsPath ) {
5098 Language::LanguagesSyntaxHighlighting::load();
5099 SyntaxDefinitionManager* sdm = SyntaxDefinitionManager::instance();
5100 SyntaxDefinitionManager::instance()->loadFromFolder( langsPath );
5101 std::vector<SyntaxDefinition> defs;
5102
5103 sdm->forEachPreDefinition( []( auto preDef ) { preDef.load(); } );
5104
5105 if ( !langs.empty() ) {
5106 if ( langs == "all" ) {
5107 sdm->forEachDefinition( [&defs]( auto def ) { defs.push_back( *def.get() ); } );
5108 } else {
5109 auto langss = String::split( langs, ',' );
5110 for ( const auto& l : langss ) {
5111 const auto& sd = sdm->getByLSPName( l );
5112
5113 if ( !sd.getPatterns().empty() ) {
5114 defs.push_back( sd );
5115 continue;
5116 }
5117
5118 const auto& sd2 = sdm->getByLanguageNameInsensitive( l );
5119
5120 if ( !sd2.getPatterns().empty() )
5121 defs.push_back( sd2 );
5122 }
5123 }
5124 }
5125
5126 if ( sdm->save( path, defs ) ) {
5127 std::cout << "Language definitions exported!\n";
5128 } else {
5129 std::cout << "Could not write the file\n";
5130 }
5131}
5132
5133} // namespace ecode
5134

Callers 1

mainFunction · 0.85

Calls 6

loadFromFolderMethod · 0.80
push_backMethod · 0.80
loadMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected