MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / Content_SearchFilesAsync

Function Content_SearchFilesAsync

Source/Wasm/WasmRuntime.cpp:774–809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

772}
773
774void Content_SearchFilesAsync(String path, std::vector<std::string>&& exts, Dictionary* extensionLevels, std::vector<std::string>&& excludes, String pattern, bool useRegex, bool caseSensitive, bool includeContent, int contentWindow, std::function<bool(Dictionary* result)> callback) {
775 std::unordered_map<std::string, int> extLevels;
776 auto keys = extensionLevels->getKeys();
777 extLevels.reserve(keys.size());
778 for (const auto& key : keys) {
779 const auto& value = extensionLevels->get(key);
780 if (!value) continue;
781 if (auto intVal = value->asVal<int64_t>()) {
782 extLevels[key.toString()] = s_cast<int>(*intVal);
783 } else if (auto floatVal = value->asVal<double>()) {
784 extLevels[key.toString()] = s_cast<int>(*floatVal);
785 }
786 }
787 SharedContent.searchFilesAsync(
788 path,
789 std::move(exts),
790 std::move(extLevels),
791 std::move(excludes),
792 pattern,
793 useRegex,
794 caseSensitive,
795 includeContent,
796 contentWindow,
797 [callback](Content::SearchResult&& res) {
798 if (res.file.empty()) {
799 return callback(Dictionary::create());
800 }
801 auto result = Dictionary::create();
802 result->set("file"sv, Value::alloc(res.file));
803 result->set("pos"sv, Value::alloc(s_cast<int64_t>(res.pos)));
804 result->set("line"sv, Value::alloc(res.line));
805 result->set("column"sv, Value::alloc(res.column));
806 result->set("content"sv, Value::alloc(res.content));
807 return callback(result);
808 });
809}
810
811/* Rect */
812

Callers 1

Calls 11

moveFunction · 0.85
getKeysMethod · 0.80
searchFilesAsyncMethod · 0.80
getMethod · 0.65
toStringMethod · 0.65
setMethod · 0.65
createFunction · 0.50
allocFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected