MCPcopy Create free account
hub / github.com/Koihik/LuaFormatter / findBlocksBetweenFormatSwitch

Function findBlocksBetweenFormatSwitch

src/lua-format.cpp:34–54  ·  view source on GitHub ↗

TODO: Collect it while walking AST seems better

Source from the content-addressed store, hash-verified

32
33// TODO: Collect it while walking AST seems better
34std::vector<std::pair<size_t, size_t>> findBlocksBetweenFormatSwitch(const std::string& str) {
35 std::vector<std::pair<size_t, size_t>> blocks;
36 size_t pos = std::string::npos;
37 size_t findAt = 0;
38 std::deque<size_t> startArr;
39 while ((pos = str.find(DISABLE_FORMAT_BEGIN, findAt)) != std::string::npos) {
40 startArr.push_back(pos);
41 findAt = pos + DISABLE_FORMAT_BEGIN.size();
42 }
43 pos = std::string::npos;
44 findAt = 0;
45 while ((pos = str.find(DISABLE_FORMAT_END, findAt)) != std::string::npos) {
46 if (!startArr.empty()) {
47 size_t start = startArr.front();
48 startArr.pop_front();
49 blocks.emplace_back(start, pos);
50 }
51 findAt = pos + DISABLE_FORMAT_END.size();
52 }
53 return blocks;
54}
55
56static std::string getOSLineSeparator() {
57#ifdef _WIN32

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected