#include "config.h"
#include "ContentSearchUtilities.h"
-#if ENABLE(INSPECTOR)
-
-#include "InspectorJSTypeBuilders.h"
#include "InspectorValues.h"
#include "RegularExpression.h"
#include "Yarr.h"
return result;
}
-static PassRefPtr<Inspector::TypeBuilder::GenericTypes::SearchMatch> buildObjectForSearchMatch(size_t lineNumber, const String& lineContent)
+static Ref<Inspector::Protocol::GenericTypes::SearchMatch> buildObjectForSearchMatch(size_t lineNumber, const String& lineContent)
{
- return Inspector::TypeBuilder::GenericTypes::SearchMatch::create()
+ return Inspector::Protocol::GenericTypes::SearchMatch::create()
.setLineNumber(lineNumber)
.setLineContent(lineContent)
.release();
return result;
}
-PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex)
+Ref<Inspector::Protocol::Array<Inspector::Protocol::GenericTypes::SearchMatch>> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex)
{
- RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>> result = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>::create();
+ Ref<Inspector::Protocol::Array<Inspector::Protocol::GenericTypes::SearchMatch>> result = Inspector::Protocol::Array<Inspector::Protocol::GenericTypes::SearchMatch>::create();
JSC::Yarr::RegularExpression regex = ContentSearchUtilities::createSearchRegex(query, caseSensitive, isRegex);
Vector<std::pair<size_t, String>> matches = getRegularExpressionMatchesByLines(regex, text);
- for (const auto& match : matches)
- result->addItem(buildObjectForSearchMatch(match.first, match.second));
+ for (const auto& match : matches) {
+ Ref<Inspector::Protocol::GenericTypes::SearchMatch> matchObject = buildObjectForSearchMatch(match.first, match.second);
+ result->addItem(WTF::move(matchObject));
+ }
return result;
}
static String findMagicComment(const String& content, const String& patternString)
{
+ ASSERT(!content.isNull());
const char* error = nullptr;
JSC::Yarr::YarrPattern pattern(patternString, false, true, &error);
ASSERT(!error);
BumpPointerAllocator regexAllocator;
- OwnPtr<JSC::Yarr::BytecodePattern> bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator);
+ auto bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator);
ASSERT(bytecodePattern);
ASSERT(pattern.m_numSubpatterns == 1);
} // namespace ContentSearchUtilities
} // namespace Inspector
-
-#endif // ENABLE(INSPECTOR)