MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / SetBufferSyntax

Method SetBufferSyntax

external/zep/src/editor.cpp:702–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700 }
701
702 void ZepEditor::SetBufferSyntax(ZepBuffer& buffer) const {
703 std::string ext;
704 std::string fileName;
705 if (buffer.GetFilePath().has_filename() && buffer.GetFilePath().filename().has_extension()) {
706 ext = string_tolower(buffer.GetFilePath().filename().extension().string());
707 fileName = string_tolower(buffer.GetFilePath().filename().string());
708 } else {
709 auto str = buffer.GetName();
710 size_t dot_pos = str.find_last_of(".");
711 if (dot_pos != std::string::npos) {
712 ext = string_tolower(str.substr(dot_pos, str.length() - dot_pos));
713 }
714 }
715
716 // first check file name
717 if (!fileName.empty()) {
718 auto itr = m_mapSyntax.find(fileName);
719 if (itr != m_mapSyntax.end()) {
720 buffer.SetSyntaxProvider(itr->second);
721 return;
722 }
723 }
724
725 auto itr = m_mapSyntax.find(ext);
726 if (itr != m_mapSyntax.end()) {
727 buffer.SetSyntaxProvider(itr->second);
728 } else {
729 itr = m_mapSyntax.find(string_tolower(buffer.GetName()));
730 if (itr != m_mapSyntax.end()) {
731 buffer.SetSyntaxProvider(itr->second);
732 } else {
733 buffer.SetSyntaxProvider(SyntaxProvider{});
734 }
735 }
736 }
737
738 void ZepEditor::RegisterSyntaxFactory(const std::vector<std::string>& mappings, SyntaxProvider provider) {
739 for (auto& m : mappings) {

Callers 2

LoadMethod · 0.80
SetFilePathMethod · 0.80

Calls 9

string_tolowerFunction · 0.85
GetFilePathMethod · 0.80
stringMethod · 0.80
GetNameMethod · 0.80
lengthMethod · 0.80
SetSyntaxProviderMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected